How do I set the range for Xbox One controller triggers using Pygame?

I am using Pygame 1.9.2 with Python 3.4 to create a robot control program. The controller is the new USB-connected Xbox One controller that works great with pygame. The problem is that the trigger buttons are considered Axes, which give values ​​from -1 to 1 depending on how hard you press. Is there a way to change this to a range from 0 to 1 or any other range that does not include negative numbers?

thank

0
source share
1 answer

(x + 1.0) / 2.0where xis what you get from the controller should give you a range of 0..1 ( + 1.0should get you in a range 0..2)

0

Source: https://habr.com/ru/post/1696256/


All Articles