如何使用Pygame为Xbox One控制器触发器设置范围? [英] How can I set the range for Xbox One controller Triggers using Pygame?

查看:154
本文介绍了如何使用Pygame为Xbox One控制器触发器设置范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Pygame 1.9.2与Python 3.4配合使用来为机器人创建控制程序.该控制器是通过USB连接的新Xbox One控制器,可以与pygame正常工作.问题在于,触发按钮被视为Axes,根据您按的力度,其值从-1到1.是否可以将其更改为从0到1的范围,或不包含负数的任何其他范围?

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?

谢谢

推荐答案

(x + 1.0) / 2.0其中,x是您从控制器获得的值,应该为0..1(+ 1.0是为了使您获得在0..2)

(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)

这篇关于如何使用Pygame为Xbox One控制器触发器设置范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆