使用LWJGL单独读取控制器触发器 [英] Reading controller triggers individually with LWJGL

查看:75
本文介绍了使用LWJGL单独读取控制器触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在正在编写的游戏中使用控制器.我使用 LWJGL Controller 类来读取控制器状态.

I would like to use a controller with a game I'm writing. I use the LWJGL Controller class to read the controller state.

似乎已将触发器的状态汇总为一个表示两个触发器的状态总和的值.左触发状态的值在-1和0之间变化,右触发状态在0和1之间变化.

The state of the triggers seems to have been summarised into a single value that represents the sum of the state of both triggers. The left trigger state is a value that varies between -1 and 0, the right between 0 and 1.

我目前使用getAxisValue()方法来获取组合状态.

I currently use the getAxisValue() method to get the combined state.

我希望能够分别读取这些值.有什么办法可以做到吗?

I would like to be able to read these values separately. Is there any way I can do this?

推荐答案

组合触发轴"问题是由DirectInput引起的. JInput使用DirectInput轮询360控制器.在本文中据解释,轴的合并是有意的更改,以保持与旧版游戏的兼容性.

The "Combined trigger axis" issue is caused by DirectInput. JInput uses DirectInput to poll the 360 controller. In this article is explained that the combining of axis was an intentional change to keep compatability with legacy games.

引用该文章:

DirectInput中左右触发器的组合是设计使然.游戏始终假设没有用户与设备交互时DirectInput设备轴居中.但是,Xbox 360控制器旨在不保留触发器时注册最小值,而不是中心值.因此,较早的游戏将假定用户交互.

The combination of the left and right triggers in DirectInput is by design. Games have always assumed that DirectInput device axes are centered when there is no user interaction with the device. However, the Xbox 360 controller was designed to register minimum value, not center, when the triggers are not being held. Older games would therefore assume user interaction.

解决方案是组合触发器,将一个触发器设置为正向,将另一个触发器设置为负向,因此没有用户交互指示控件"的DirectInput位于中心.

The solution was to combine the triggers, setting one trigger to a positive direction and the other to a negative direction, so no user interaction is indicative to DirectInput of the "control" being at center.

为了分别测试触发值,必须使用XInput. `

In order to test the trigger values separately, you must use XInput. `

LWJGL无法提供单独的触发值,因为它实际上依赖于DirectInput.

LWJGL can not offer separate trigger values because it in effect relies on DirectInput.

最好的做法是为XInput查找Java绑定,该绑定确实允许使用单独的触发器值.

The best course of action would be to find java bindings for XInput, which does allow separate trigger values.

这篇关于使用LWJGL单独读取控制器触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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