For my 3D game project, I have to use the Joystick axis value to scale the force applied on Rigid Body piloted by the player. For the 3 first axis having values ranging from -32768 to 32767 (the same range as a "Word" variable) are useful but for the last one it's not useful at all. This axis should range for 0 to 65535 (the same range as a "Unicode" variable).
In 2007, I have created this solution but even if it work I'm sure a much faster and simple solution exist.
Code: Select all
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : Joystick Throttle Input Correction
; File Name : ThrottleInputCorrection.pb
; File version: 1.0.0
; Programming : OK
; Programmed by : Guimauve
; Date : 02-02-2007
; Last Update : 09-08-2012
; PureBasic code : 4.70 Beta 1
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Procedure.u ThrottleInputCorrection(Input.w)
If Input < 0
ProcedureReturn Input - 32768
ElseIf Input = 0
ProcedureReturn 32768
ElseIf Input > 0
ProcedureReturn Input + 32768
EndIf
EndProcedure
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Here we test when the throttle is set near 0%"
Debug ""
For Index = -32768 To -32763
Debug ThrottleInputCorrection(Index)
Next
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Here we test when the throttle is set near 50%"
Debug ""
For Index = -3 To 3
Debug ThrottleInputCorrection(Index)
Next
Debug ""
Debug "; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
Debug "; Here we test when the throttle is set near 100%"
Debug ""
For Index = 32762 To 32767
Debug ThrottleInputCorrection(Index)
Next
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
Best regards
Guimauve