User Tools

Site Tools


en:tutorials:analog_joystick_gamepad_control

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:tutorials:analog_joystick_gamepad_control [2018/02/19 10:18 (10 months ago)]
sausage created
en:tutorials:analog_joystick_gamepad_control [2018/09/25 22:20 (3 months ago)] (current)
sausage
Line 4: Line 4:
  
 This gives you smooth multi-direction control in both the X and Y directions. This gives you smooth multi-direction control in both the X and Y directions.
 +
 +===== Axis =====
  
 Orx provides many Axis properties for your ''​Input''​ config. ​ Orx provides many Axis properties for your ''​Input''​ config. ​
  
 {{section>​en:​orx:​config:​settings_main:​input_joystick#​[joystick_axes]&​noheader&​nofooter&​noeditbutton}} {{section>​en:​orx:​config:​settings_main:​input_joystick#​[joystick_axes]&​noheader&​nofooter&​noeditbutton}}
 +
 +===== Stick Threshold =====
  
 When pushing the stick in any direction, after getting past the small threshold, the value can be read using the ''​orxInput_IsActive''​ and ''​orxInput_GetValue''​ functions. When pushing the stick in any direction, after getting past the small threshold, the value can be read using the ''​orxInput_IsActive''​ and ''​orxInput_GetValue''​ functions.
Line 47: Line 51:
  
 [MainInput] [MainInput]
-JOY_X_1  ​  = LeftRight +JOY_LX_1 ​  = LeftRight 
-JOY_Y_1  ​  = UpDown+JOY_LY_1 ​  = UpDown
 KEY_ESCAPE = Quit KEY_ESCAPE = Quit
 </​code>​ </​code>​
  
-The ''​JOY_X_1''​ above means, get values from the analog stick when it is pushed along the X axis, either left or right. No value is read until it crosses the threshold (''​DefaultThreshold''​),​ which is 0.2, After that, register a ''​LeftRight''​ value.+The ''​JOY_LX_1''​ above means, get values from the left analog stick when it is pushed along the X axis, either left or right. No value is read until it crosses the threshold (''​DefaultThreshold''​),​ which is 0.2, After that, register a ''​LeftRight''​ value.
  
-The ''​_1''​ at the end of ''​JOY_X_1''​ means joystick #1. There can be up to physical USB inputs used.+The ''​_1''​ at the end of ''​JOY_LX_1''​ means joystick #1. There can be up to 16 physical USB inputs used.
  
-In the same way, the ''​JOY_Y_1''​ means that if the analog stick has been moved up or down the Y axis, it will register ​''​UpDown''​ value.+In the same way, the ''​JOY_LY_1''​ means that if the analog stick has been moved up or down the Y axis, it will register ​an ''​UpDown''​ value. 
 + 
 +For more details, see: [[en:​tutorials:​analog_stick_threshold|Analog Stick Threshold]]
  
 Finally in the ''​Run()''​ function, we can add the code to respond to these "​movements"​. ''​Run()''​ is not normally the recommended place to put this code, but for demonstration purposes, it is fine: Finally in the ''​Run()''​ function, we can add the code to respond to these "​movements"​. ''​Run()''​ is not normally the recommended place to put this code, but for demonstration purposes, it is fine:
Line 86: Line 92:
 In the above code, the ''​LeftRight''​ and ''​UpDown''​ inputs are being checked to see if they are active. If so, get the current speed and the axis position values with ''​orxInput_GetValue''​ and set the proper speed direction value to 150 / the axis the value. The smaller the stick movement, the smaller the object movement. In the above code, the ''​LeftRight''​ and ''​UpDown''​ inputs are being checked to see if they are active. If so, get the current speed and the axis position values with ''​orxInput_GetValue''​ and set the proper speed direction value to 150 / the axis the value. The smaller the stick movement, the smaller the object movement.
  
-It's all pretty simple, ​that'​s ​all there is.+It's all pretty simple
 + 
 +===== Further reading ===== 
 + 
 +{{https://​steamcdn-a.akamaihd.net/​steamcommunity/​public/​images/​clans/​27766192/​f56593e63a2581024b98979658fb2b4e17f8d1a8.jpg?​500x120}} 
 + 
 +Steam have an interesting article on their controller usage metricstools and experiments in controller remapping. 
 + 
 +{{https://​steamcdn-a.akamaihd.net/​steamcommunity/​public/​images/​clans/​27766192/​817181596da53a62e63586af4a3334433e1e818f.jpg?​500x120}} 
 + 
 +This is a different take to Orx'​s ​use of the SDL_GameControllerDB community database. 
 + 
 +You can read the [[https://​steamcommunity.com/​games/​593110/​announcements/​detail/​1712946892833213377|article on Steam here]]. 
en/tutorials/analog_joystick_gamepad_control.1519035503.txt.gz · Last modified: 2018/02/19 10:18 (10 months ago) by sausage