Skip to content

tm-nielsen/CortexPlugin

Repository files navigation

Bonspiel Games Cortex Unity Plugin

This is the plugin used in Curl for integration with the Emotiv Cortex Service, adapted from the official support for simplicity and support for multiple simultaneous headset streams. The contents are formatted as a Unity package and can be added to a unity project via git URL.

Prerequisites

  1. Install Unity. You can get it for free at unity3d.com.

  2. Make an EmotivID on the official website

  3. Create a Cortex application on the account page to get an app client id and secret. MAKE SURE TO NOTE THE CLIENT SECRET AS IT WILL ONLY BE SHOWN ONCE

  4. Download and install the EMOITV Launcher

  5. Add the CortexPlugin package to any Unity project via git URL in the package manager:

https://github.com/cm-nielsen/CortexPlugin.git

How to Use

More detail is available in The Documentation

  1. Import the EmotivUnityPlugin namespace
using CortexPlugin
  1. Call Cortex.Start() with your cortex app's client id and secret. Using Awake() and script execution order in your project settings can ensure that this is called before any other monobehavior functions, letting you freely use Cortex functionality anywhere else without worry.
Cortex.Start(clientId, clientSecret);
  1. Subscribe to the Cortex.HeadsetQueryResult to receive a list of available headsets
Cortex.HeadsetQueryResult += (List<Headset> headsets) =>
{
    Debug.Log($"{headsets.Count} headsets detected!");
}
  1. Connect to a headset, starting data streams
Cortex.StartSession(headsetId);
  1. Subscribe to a headset's data streams from anywhere
Cortex.SubscribeMentalCommands(headsetId, (MentalCommand command) => Debug.Log(command));
Cortex.SubscribeDataStream<MentalCommand>(headsetId, OnMentalCommandReceived);
Cortex.SubscribeDeviceInfo(headsetId, OnDeviceInfoReceived)
  1. Load or create a profile
Cortex.profiles.QueryProfiles();
Cortex.profiles.LoadProfile(profileName, headsetId);
Cortex.profiles.CreateProfile("Jimmy");
  1. Train mental commands for a profile in engine with live feedback from the data stream
Cortex.training.GetTrainedActions(profileName);
Cortex.training.StartTraining(actionName);
Cortex.training.AcceptTraining(actionName);

About

Custom Emotiv Cortex integration package for Unity, built off the official support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages