1

我有一个便宜的 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;
}
4

1 回答 1

2

如果只有一个操纵杆映射到设备或类似设备,我的问题的答案似乎是“否” /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 控制器获取 devices/dev/input/event13/dev/input/js1,但我的 NEO-GEO X 控制器只有 device /dev/input/js0,因此脱离循环会导致它被忽略。

在这种情况下,一种解决方法是将没有相应“事件”设备的设备添加到SDL_JOYSTICK_DEVICE

感谢 Brian McFarland 的帮助,让我们了解了这一点。

于 2015-05-16T15:39:01.517 回答