我在游戏 handle 支持方面遇到了问题。
try // to create the Controllers
{
Controllers.create();
}
catch(Exception exep)
{}
int allControllers=0;
allControllers=Controllers.getControllerCount(); //finding out how much
//of it do we have
它说我有 3 个 Controller 。 但 Gamepad 是 Controller 编号 0。 因为当我轮询 n1 或 n2 Controller 时——游戏就崩溃了。
有谁知道如何从这个列表中自动选择可用的游戏 handle 并避免崩溃?
最佳答案
看来没有人能做到。我一直在努力,到目前为止只有一种解决方案。在这里:
for(int co=0;co<allControllers;co++)
{
gamepad = Controllers.getController(co);
GamePadName=gamepad.getName();
if(GamePadName.charAt(0)!='H' && GamePadName.charAt(0)!='U')
Keys=checkGamepad(Keys);
}
有两个 Controller 无法轮询。在某些 PC 上,它们被称为“HID something”,在其他 PC 上,它们被称为“USB Keybord”、“USB Mouse”。也许在其他 PC 上它们会以其他方式被调用。所以我们没有轮询这些 Controller ,游戏也没有崩溃……这似乎是一个糟糕的解决方案,但我认为没有更好的办法。
关于java - LWJGL 中不是游戏 handle 的 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29761563/