我有一个便宜的PS3控制器和一个NEO-GEO X控制器。它们都在例如上被检测到。Fedora 20和Lubuntu 14.04。它们出现在lsusb中
Bus 001 Device 012: ID 0e8f:0003 GreenAsia Inc. MaxFire Blaze2
Bus 001 Device 016: ID 1292:4e47 Innomedia
设备显示在下方/dev/input
。在它们上运行udevadm都表明GreenAsia设备使用pantherlord
驱动程序,而另一设备使用hid-generic
如果我运行以下测试代码,则SDL仅报告GreenAsia设备。如果我将其拔出,则将检测到其他设备。这是SDL的已知限制还是其他一些问题?
// from http://www.libsdl.org/release/SDL-1.2.15/docs/html/guideinput.html
#include "SDL/SDL.h"
int main () {
if (SDL_Init( SDL_INIT_VIDEO | SDL_INIT_JOYSTICK ) < 0)
{
fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
printf("%i joysticks were found.\n\n", SDL_NumJoysticks() );
printf("The names of the joysticks are:\n");
for( int i=0; i < SDL_NumJoysticks(); i++ )
{
printf(" %s\n", SDL_JoystickName(i));
}
return 0;
}
如果只有一个操纵杆映射到设备/dev/input/event13
或类似设备,则我的问题的答案似乎为“否” ,在我的情况下,这就是我的PS3控制器发生的情况。
在SDL_SYS_JoystickInit
有下面的代码
#if SDL_INPUT_LINUXEV
/* This is a special case...
If the event devices are valid then the joystick devices
will be duplicates but without extra information about their
hats or balls. Unfortunately, the event devices can't
currently be calibrated, so it's a win-lose situation.
So : /dev/input/eventX = /dev/input/jsY = /dev/jsY
*/
if ( (i == 0) && (numjoysticks > 0) )
break;
#endif
当i
为0时,它正在寻找“事件”设备。我的PS3控制器获取设备/dev/input/event13
和/dev/input/js1
,但我的NEO-GEO X控制器仅包含该设备/dev/input/js0
,因此从循环中断开会导致其被忽略。
在这种情况下,一种解决方法是将没有相应“事件”设备的设备添加到 SDL_JOYSTICK_DEVICE
感谢Brian McFarland的帮助,以帮助您深入浅出。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句