Jump to content

NEED HELP, how to add a self-defined input device


baileyange

Recommended Posts

Hi everyone,


I am new to Torque3D.

We have developed a input device simillar to Oculus, and we want to add our input's SDK to Torque3D so the game created by Torque3D would work with our device.


I would like to know how to add out SDK.


I check the current version (3.7) which supports Leapmotion, and Oculus. However, I am blocked at some points when reading the codes. I would like to know a general way, or steps, then I can learn it myself. But I dont know where to start.


Hope somebody can help me, and thx in advance.

Link to comment
Share on other sites

I never did finish the Myo implementation (biggest issue was that it was queueing data when game was minimized) but you can find my implementation here.


Alternately I simplified it to show the gist of it here. (Untested code)


I am by no means a guru of input devices, so I'm not much of a help, but that should give you somewhere to begin. What I did was to simply copy and paste the LeapMotion code, and replace the all the Leap stuff (you'll find residue in there though because I never cleaned it properly).


Edit:

That should, btw, bind "orientation" to the "xxx" device, used like this in TorqueScript:

moveMap.bind( xxx, orientation, orientationReceived);

Example:

function printOrientation(%roll, %pitch, %yaw, %angle)
{
   echo(%roll SPC %pitch SPC %yaw SPC %angle);
}
GlobalActionMap.bind(xxx, orientation, printOrientation);
Link to comment
Share on other sites

I never did finish the Myo implementation (biggest issue was that it was queueing data when game was minimized) but you can find my implementation here.


Alternately I simplified it to show the gist of it here. (Untested code)


I am by no means a guru of input devices, so I'm not much of a help, but that should give you somewhere to begin. What I did was to simply copy and paste the LeapMotion code, and replace the all the Leap stuff (you'll find residue in there though because I never cleaned it properly).


Edit:

That should, btw, bind "orientation" to the "xxx" device, used like this in TorqueScript:

moveMap.bind( xxx, orientation, orientationReceived);

Example:

function printOrientation(%roll, %pitch, %yaw, %angle)
{
   echo(%roll SPC %pitch SPC %yaw SPC %angle);
}
GlobalActionMap.bind(xxx, orientation, printOrientation);

 


Thanks, I will chek it.

Link to comment
Share on other sites

I never did finish the Myo implementation (biggest issue was that it was queueing data when game was minimized) but you can find my implementation here.


Alternately I simplified it to show the gist of it here. (Untested code)


I am by no means a guru of input devices, so I'm not much of a help, but that should give you somewhere to begin. What I did was to simply copy and paste the LeapMotion code, and replace the all the Leap stuff (you'll find residue in there though because I never cleaned it properly).


Edit:

That should, btw, bind "orientation" to the "xxx" device, used like this in TorqueScript:

moveMap.bind( xxx, orientation, orientationReceived);

Example:
function printOrientation(%roll, %pitch, %yaw, %angle)
{
echo(%roll SPC %pitch SPC %yaw SPC %angle);
}
GlobalActionMap.bind(xxx, orientation, printOrientation);
[/quote]

I ckecked the code, It helps a lot. But, in fact I am not sure about the whole work flow. I list here what I found, but I don't know if it is correct:

1. First to exctue the new input device Torquescript: in "game\core\scripts\client\core.cs":
   // Input devices
  exec("~/scripts/client/oculusVR.cs");

2. In "game\core\scripts\client\oculusVR.cs" define functions are defined such as:

.....
function enableOculusVRDisplay(%gameConnection, %trueStereoRendering)
{
  setOVRHMDAsGameConnectionDisplayDevice(%gameConnection);
  PlayGui.renderStyle = "stereo side by side";

  if(%trueStereoRendering)
  {
     if($pref::OculusVR::UseChromaticAberrationCorrection)
     {
        OVRBarrelDistortionChromaPostFX.isEnabled = true;
     }
     else
     {
        OVRBarrelDistortionPostFX.isEnabled = true;
     }
  }
  else
  {
     OVRBarrelDistortionMonoPostFX.isEnabled = true;
  }

  // Reset all sensors
  ovrResetAllSensors();
}
........

3. in the code of step 2, some existing functions such as "setOVRHMDAsGameConnectionDisplayDevice", is defined in "Engine\source\platform\input\oculusVR\oculusVRDevice.cs":

DefineEngineFunction(setOVRHMDAsGameConnectionDisplayDevice, bool, (GameConnection* conn),,
  "@brief Sets the first HMD to be a GameConnection's display device\n\n"
  "@param conn The GameConnection to set.\n"
  "@return True if the GameConnection display device was set.\n"
  "@ingroup Game")
{
  if(!ManagedSingleton<OculusVRDevice>::instanceOrNull())
  {
     Con::errorf("setOVRHMDAsGameConnectionDisplayDevice(): No Oculus VR Device present.");
     return false;
  }

  if(!conn)
  {
     Con::errorf("setOVRHMDAsGameConnectionDisplayDevice(): Invalid GameConnection.");
     return false;
  }

  conn->setDisplayDevice(OCULUSVRDEV);
  return true;
}

4. in the code of step 2, the defined functions are used in different torquescripts

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...