@@ -9,31 +9,37 @@ class EvdevGamepadDevice : public GamepadDevice
99 : GamepadDevice(maple_port, " evdev" ), _fd(fd), _rumble_effect_id(-1 ), _devnode(devnode)
1010 {
1111 fcntl (fd, F_SETFL, O_NONBLOCK);
12- char name [256 ] = " Unknown" ;
13- if (ioctl (fd, EVIOCGNAME (sizeof (name) ), name ) < 0 )
12+ char buf [256 ] = " Unknown" ;
13+ if (ioctl (fd, EVIOCGNAME (sizeof (buf) - 1 ), buf ) < 0 )
1414 perror (" evdev: ioctl(EVIOCGNAME)" );
1515 else
16- printf (" evdev: Opened device '%s' " , name);
17- _name = name;
16+ printf (" evdev: Opened device '%s' " , buf);
17+ _name = buf;
18+ buf[0 ] = 0 ;
19+ if (ioctl (fd, EVIOCGUNIQ (sizeof (buf) - 1 ), buf) == 0 )
20+ _unique_id = buf;
21+ if (_unique_id.empty ())
22+ _unique_id = devnode;
23+
1824 if (!find_mapping (mapping_file))
1925 {
2026#if defined(TARGET_PANDORA)
2127 mapping_file = " controller_pandora.cfg" ;
2228#elif defined(TARGET_GCW0)
2329 mapping_file = " controller_gcwz.cfg" ;
2430#else
25- if (! strcmp (name, " Microsoft X-Box 360 pad" )
26- || ! strcmp (name, " Xbox 360 Wireless Receiver" )
27- || ! strcmp (name, " Xbox 360 Wireless Receiver (XBOX)" ) )
31+ if (_name == " Microsoft X-Box 360 pad"
32+ || _name == " Xbox 360 Wireless Receiver"
33+ || _name == " Xbox 360 Wireless Receiver (XBOX)" )
2834 {
2935 mapping_file = " controller_xpad.cfg" ;
3036 }
31- else if (strstr (name, " Xbox Gamepad (userspace driver)" ) != NULL )
37+ else if (_name. find ( " Xbox Gamepad (userspace driver)" ) != std::string::npos )
3238 {
3339 mapping_file = " controller_xboxdrv.cfg" ;
3440 }
35- else if (strstr (name, " keyboard" ) != NULL ||
36- strstr (name, " Keyboard" ) != NULL )
41+ else if (_name. find ( " keyboard" ) != std::string::npos
42+ || _name. find ( " Keyboard" ) != std::string::npos )
3743 {
3844 mapping_file = " keyboard.cfg" ;
3945 }
0 commit comments