Code: Select all
&& just for testing, reading a 3Dconnexion mouse into Visual Foxpro.
&& This is not finished code,
&& Cleanup needs to be done,
&& should not be public variables. Just for testing.
PUBLIC omouse,oevents,osensor
oevents = NEWOBJECT("MouseHandler") && Create an instance of the event handler
omouse = CREATEOBJECTEX("TDxInput.Device",[]) && Create the object from the 3dConnection library
omouse.CONNECT && connect the mouse (Maybe not neccessary?)
=EVENTHANDLER(omouse.sensor, oevents) && Set up the event binding
=EVENTHANDLER(omouse.keyboard, oevents) && for both sensor as well as keyboard events
RETURN && Done
DEFINE CLASS MouseHandler AS SESSION
IMPLEMENTS _ISensorEvents IN TDxInput.DEVICE && Sensor events
IMPLEMENTS _IKeyboardEvents IN TDxInput.DEVICE && Keyboard events
PROCEDURE _ISensorEvents_SensorInput && Capture the input event
ACTIVATE SCREEN && Print it on screen
? omouse.sensor.ROTATION.x
?? omouse.sensor.ROTATION.Y
?? omouse.sensor.ROTATION.z
?? omouse.sensor.TRANSLATION.x
?? omouse.sensor.TRANSLATION.Y
?? omouse.sensor.TRANSLATION.z
RETURN
PROCEDURE _IKeyboardEvents_KeyDown(m_key)
ACTIVATE SCREEN
? m_key
RETURN
PROCEDURE _IKeyboardEvents_Keyup(m_key)
? m_key
RETURN
ENDDEFINE