USB input from Arduino custom input device
by Andrew · in Torque 3D Beginner · 06/24/2014 (8:26 pm) · 2 replies
Hi All,
I'm very new to Torque3D, but not to programming. I am working on a data glove using an arduino connected to the computer via usb. I'd like to send information to and from the glove(arduino) within Torque. Could anyone point me in the right direction?
Thank you!
I'm very new to Torque3D, but not to programming. I am working on a data glove using an arduino connected to the computer via usb. I'd like to send information to and from the glove(arduino) within Torque. Could anyone point me in the right direction?
Thank you!
#2
Look here for Mouse and/or Keyboard:
arduino.cc/en/Reference/MouseKeyboard
Or even a USB joystick:
www.imaginaryindustries.com/blog/?p=80
To send info to the glove you could use the virtual comm port. The Leonardo is a composite device, it combines a virtual comm port and a HID (keyboard/mouse/-joystick-) in one USB device. You'll have to make a c++ class that lets you write (and also read) to the arduino using serial communication. You could call functions of this class from script, like TurnLedOn(), etc... Maybe you can use this code inside your class;
www.codeguru.com/cpp/i-n/network/serialcommunications/article.php/c2503/CSerial-...
Take a look at Teensy boards too:
www.pjrc.com/teensy/
Hope it helps.
06/24/2014 (11:14 pm)
You can always use an Arduino Leonardo, Micro, or Due board to appear as a native Mouse and/or Keyboard. Look here for Mouse and/or Keyboard:
arduino.cc/en/Reference/MouseKeyboard
Or even a USB joystick:
www.imaginaryindustries.com/blog/?p=80
To send info to the glove you could use the virtual comm port. The Leonardo is a composite device, it combines a virtual comm port and a HID (keyboard/mouse/-joystick-) in one USB device. You'll have to make a c++ class that lets you write (and also read) to the arduino using serial communication. You could call functions of this class from script, like TurnLedOn(), etc... Maybe you can use this code inside your class;
www.codeguru.com/cpp/i-n/network/serialcommunications/article.php/c2503/CSerial-...
Take a look at Teensy boards too:
www.pjrc.com/teensy/
Hope it helps.
Torque Owner Daniel Buckmaster
T3D Steering Committee
You'll probably also want to get an overview of the engine... this thread collects a lot of useful info. The Torque engine source code analysis video tutorial seems useful, though it's sort of slow going as they were designed for personal use :P. I do recommend my own t3d-bones if you want a very minimal example to work with (on the scripting side of things) - in particular, this tutorial goes over using an ActionMap to create a free-flying camera. From there you could probably trace the event flow through the engine when you press keys and so on.