Reading controller triggers individually with LWJGL

限于喜欢 提交于 2019-12-13 06:43:26

问题


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

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.

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?


回答1:


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.

Quoting the article:

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.

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.

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

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

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



来源:https://stackoverflow.com/questions/24222795/reading-controller-triggers-individually-with-lwjgl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!