How can I set the range for Xbox One controller Tr

2019-09-01 07:53发布

I am using Pygame 1.9.2 with Python 3.4 to create a control program for a robot. The controller is a new Xbox One controller connected via USB which is working fine 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?

Thanks

1条回答
Juvenile、少年°
2楼-- · 2019-09-01 08:30

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

查看更多
登录 后发表回答