This started as a project on building something based on gyroscopic motion, but I realized I don't entirely understand those figures, so I started building a sort of debugging tool and it got out of hand. This should work on any system, and lists stats for pretty much all input. Touch input feedback doesn't seem accurate, and if someone could explain to me why I'd be grateful. Hopefully someone finds this useful or interesting.
EDIT: I figured it out. I accidentally left one of my debug lines uncommented. >.<
// Project: MotionInputDemo
// Created: 2015-07-12
// set window properties
CompleteRawJoystickDetection()
SetWindowTitle( "MotionInputDemo" )
SetWindowSize( 1600, 900, 0 )
// Fix to a landscape mode
SetOrientationAllowed( 0, 0, 1, 0 )
// set display properties
SetVirtualResolution( GetDeviceWidth(), GetDeviceHeight() )
//SetOrientationAllowed( 1, 1, 1, 1 )
// What can this device do?
b_HasGyro = GetGyroSensorExists()
b_HasAccel = GetAccelerometerExists()
b_HasRot = GetRotationVectorSensorExists()
b_HasKey = GetKeyboardExists()
b_HasMouse = GetMouseExists()
b_HasJoy = GetJoystickExists()
b_HasLight = GetLightSensorExists()
b_HasProx = GetProximitySensorExists()
i_NumJoys = 0
for i=1 to 4
if GetRawJoystickExists( i )
i_NumJoys = i_NumJoys + 1
endif
next i
i_Key = -1
SetPrintSize( GetDeviceWidth()/ 72)
do
if b_HasGyro
Print( "Gyroscope detected." )
PrintC( "-Velocity: X:" )
PrintC( GetRawGyroVelocityX() )
PrintC( ", Y:")
PrintC( GetRawGyroVelocityY() )
PrintC( ", Z:")
Print( GetRawGyroVelocityZ() )
Print( "")
endif
if b_HasAccel
Print( "Accelerometer detected." )
PrintC( "-Direction: X:" )
PrintC( GetRawAccelX() )
PrintC( ", Y:")
PrintC( GetRawAccelY() )
PrintC( ", Z:")
Print( GetRawAccelZ() )
Print( "" )
endif
if b_HasRot
Print( "Rotation sensor detected." )
PrintC( "-Rotation: W:" )
PrintC( GetRawRotationVectorW() )
PrintC( ", X:")
PrintC( GetRawRotationVectorX() )
PrintC( ", Y:")
PrintC( GetRawRotationVectorY() )
PrintC( ", Z:")
Print( GetRawRotationVectorZ() )
Print( "" )
endif
if b_HasKey
Print( "Keyboard detected." )
PrintC( "-Last key pressed: ")
if GetRawKeyReleased( GetRawLastKey() )
i_Key = -1
elseif GetRawKeyPressed( GetRawLastKey() )
i_Key = GetRawLastKey()
endif
if ( i_Key >= 32 ) and ( i_Key <=126 )
PrintC( Chr( i_Key ) )
PrintC( ", " )
endif
Print( i_Key )
Print( "" )
endif
if b_HasMouse
Print( "Mouse detected." )
PrintC( "-Position: X:" )
PrintC( GetRawMouseX() )
PrintC( ", Y:" )
Print( GetRawMouseY() )
PrintC( "-Buttons: L:" )
PrintC( GetRawMouseLeftState() )
PrintC( ", R:" )
PrintC( GetRawMouseRightState() )
PrintC( ", M:" )
Print( GetRawMouseMiddleState() )
PrintC( "-Wheel: " )
Print( GetRawMouseWheel() )
Print( "" )
endif
if b_HasJoy
for t=1 to i_NumJoys
if GetRawJoystickConnected( t )
Print( "Gamepad detected." )
PrintC( "-Buttons:" )
for i=1 to 32
if GetRawJoystickButtonState( t, i )
PrintC(" ")
PrintC( i )
endif
next i
Print( "" )
PrintC( "-Axes: X:" )
PrintC( GetRawJoystickX( t ) )
PrintC( ", Y:" )
PrintC( GetRawJoystickY( t ) )
PrintC( ", Z:" )
Print( GetRawJoystickZ( t ) )
PrintC( "-Rotation: X:" )
PrintC( GetRawJoystickRX( t ) )
PrintC( ", Y:" )
PrintC( GetRawJoystickRY( t ) )
PrintC( ", Z:" )
Print( GetRawJoystickRZ( t ) )
Print( "" )
endif
next t
endif
if b_HasLight
Print( "Light sensor detected." )
PrintC( "-Lumens: " )
Print( GetRawLightLevel() )
Print( "" )
endif
if b_HasProx
Print( "Proximity sensor detected." )
PrintC( "-Proximity: " )
Print( GetRawProximityDistance() )
Print( "" )
endif
i_Touch = GetRawTouchCount( 0 )
//For PC debugging
// i_Touch = 5
if i_Touch > 0
Print( "Touch information:" )
i_TID = GetRawFirstTouchEvent( 0 )
q = 1
while q <= i_Touch
PrintC("-Touch #")
Print( q )
PrintC( "--Event type ( 0=default, 1=tap, 2=hold, 3=drag ): " )
PrintC( GetRawTouchType( i_TID ) )
PrintC( "at X:" )
PrintC( GetRawTouchCurrentX( i_TID ) )
PrintC( ", Y:" )
Print( GetRawTouchCurrentY( i_TID ) )
if q < i_Touch
i_TID = GetRawNextTouchEvent()
endif
inc q
endwhile
endif
// Print( ScreenFPS() )
Sync()
loop