简体   繁体   English

在Linux中等效于XInput *函数?

[英]What's the equivalent of XInput* functions in Linux?

I'm porting an application that uses the Xbox controller to Linux. 我正在将使用Xbox控制器的应用程序移植到Linux。 On windows, it essentially just uses XInputGetState() to read the state of the controller, so I'm looking for a replacement for that function on Linux. 在Windows上,它实际上仅使用XInputGetState()来读取控制器的状态,因此我正在寻找Linux上该功能的替代品。

I see that wine hasn't implemented XInputGetState() , but at the same time there are a large number of games supporting the Xbox controller on Linux, so it's doable. 我看到wine尚未实现XInputGetState() ,但是同时有很多游戏在Linux上支持Xbox控制器,因此它是可行的。

Does anyone know what library can be used to interact with an Xbox controller on Linux? 有谁知道可以使用什么库与Linux上的Xbox控制器进行交互?

You can either: 您可以:

  1. use the SDL library 使用SDL库
  2. use the functions in linux/joystick.h yourself 自己使用linux/joystick.h的功能
  3. find some other library which abstracts (3) for you like this or the one linked by user3716731. 找到其他一些可以像这样为您摘要(3)或由user3716731链接的库。

The (1-2) solutions are mainly C , but so is the XInput API, so you probably can deal with it. (1-2)解决方案主要是C ,但是XInput API也是如此,因此您可以处理它。

I would probably go with number 1, because that approach should have the best documentation. 我可能会选择1,因为这种方法应该具有最好的文档。

So I know its not pure C++ however there is a great addon for openFrameworks called ofxGamePad that is compatible with linux. 因此,我知道它不是纯C ++,但是openFrameworks有一个很棒的附加组件,称为offxGamePad ,它与linux兼容。 I have had success using it with linux for a gamepad. 我已经成功地将它与linux一起用于游戏手柄。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM