Jim McKeeth from Embarcadero has released his source code for interfacing with the Emotiv EPOC device with Delphi XE6 Firemonkey. The Emotiv EPOC device is a head mounted brain wave scanner and gyroscope. Jim has a video online where he demonstrates using the device and using Delphi to interface with it. The source code that has been released for the demo and interface is now on Github. Apparently the device will allow you to access the head rotation and movement of the wearer, their facial expressions, their emotional state, and custom training of brain events into action. A custom component called TEmotivEpoc is used to wrap the Emotiv EPOC API functions which are in a DLL. It should probably run on Delphi XE5 and AppMethod as well. There is source code available for the following demos: BasicEmotivTest (VCL), CogEngineTest (FMX), EdkParrot (FMX), EmoEngineTest (FMX), and ExpEngineTest (FMX). If you like playing with gadgets or just want to see an example of accessing a DLL and API with Delphi Firemonkey check out the source code. Here is some sample code from the component which shows the brainwave training event code:
procedure TEmotivEpoc.HandleCogEvent;
var
cogEvent: EE_CognitivEvent_t;
reject: Boolean;
begin
cogEvent := EE_CognitivEventGetType(eEvent);
case cogEvent of
EE_CognitivNoEvent: Log('Cog: NoEvent');
EE_CognitivTrainingStarted:
begin
Log('Cog: TrainingStarted');
if Assigned(fCognitivTrainingStarted) then
fCognitivTrainingStarted(self);
//pbTraining.Visible := True;
//animateTraining.Start;
end;
EE_CognitivTrainingSucceeded:
begin
Log('Cog: TrainingSucceeded');
if Assigned(fCognitivTrainingSucceeded) then
fCognitivTrainingSucceeded(self, reject);
if not reject then
AcceptTraining;
//animateTraining.Stop;
//pbTraining.Visible := False;
end;
EE_CognitivTrainingFailed: Log('Cog: TrainingFailed');
EE_CognitivTrainingCompleted: Log('Cog: TrainingCompleted');
EE_CognitivTrainingDataErased: Log('Cog: TrainingDataErased');
EE_CognitivTrainingRejected: Log('Cog: TrainingRejected');
EE_CognitivTrainingReset: Log('Cog: TrainingReset');
EE_CognitivAutoSamplingNeutralCompleted: Log('Cog: AutoSamplingNeutralCompleted');
EE_CognitivSignatureUpdated: Log('Cog: SignatureUpdated');
end;
end;
Head over and check out the full source code for accessing the Emotiv EPOC API and SDK from Firemonkey.