1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Use tabs instead of spaces for new gamepad code

This commit is contained in:
hondres
2015-12-18 19:15:32 +01:00
parent af633c7941
commit 87dab29f4b
6 changed files with 1000 additions and 1000 deletions

View File

@@ -127,48 +127,48 @@ String InputDefault::get_joy_name(int p_idx) {
static String _hex_str(uint8_t p_byte) { static String _hex_str(uint8_t p_byte) {
static const char* dict = "0123456789abcdef"; static const char* dict = "0123456789abcdef";
char ret[3]; char ret[3];
ret[2] = 0; ret[2] = 0;
ret[0] = dict[p_byte>>4]; ret[0] = dict[p_byte>>4];
ret[1] = dict[p_byte & 0xf]; ret[1] = dict[p_byte & 0xf];
return ret; return ret;
}; };
void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid) { void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid) {
_THREAD_SAFE_METHOD_ _THREAD_SAFE_METHOD_
Joystick js; Joystick js;
js.name = p_connected ? p_name : ""; js.name = p_connected ? p_name : "";
js.uid = p_connected ? p_guid : ""; js.uid = p_connected ? p_guid : "";
js.mapping = -1; js.mapping = -1;
js.hat_current = 0; js.hat_current = 0;
if (p_connected) { if (p_connected) {
String uidname = p_guid; String uidname = p_guid;
if (p_guid == "") { if (p_guid == "") {
int uidlen = MIN(p_name.length(), 16); int uidlen = MIN(p_name.length(), 16);
for (int i=0; i<uidlen; i++) { for (int i=0; i<uidlen; i++) {
uidname = uidname + _hex_str(p_name[i]); uidname = uidname + _hex_str(p_name[i]);
}; };
}; };
js.uid = uidname; js.uid = uidname;
//printf("looking for mappings for guid %ls\n", uidname.c_str()); //printf("looking for mappings for guid %ls\n", uidname.c_str());
int mapping = -1; int mapping = -1;
for (int i=0; i < map_db.size(); i++) { for (int i=0; i < map_db.size(); i++) {
if (js.uid == map_db[i].uid) { if (js.uid == map_db[i].uid) {
mapping = i; mapping = i;
//printf("found mapping\n"); //printf("found mapping\n");
}; };
}; };
js.mapping = mapping; js.mapping = mapping;
}; };
joy_names[p_idx] = js; joy_names[p_idx] = js;
emit_signal("joy_connection_changed", p_idx, p_connected); emit_signal("joy_connection_changed", p_idx, p_connected);
}; };
Vector3 InputDefault::get_accelerometer() { Vector3 InputDefault::get_accelerometer() {
@@ -376,109 +376,109 @@ void InputDefault::set_mouse_in_window(bool p_in_window) {
// from github.com/gabomdq/SDL_GameControllerDB // from github.com/gabomdq/SDL_GameControllerDB
static const char *s_ControllerMappings [] = static const char *s_ControllerMappings [] =
{ {
#ifdef WINDOWS_ENABLED #ifdef WINDOWS_ENABLED
"8f0e1200000000000000504944564944,Acme,platform:Windows,x:b2,a:b0,b:b1,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,", "8f0e1200000000000000504944564944,Acme,platform:Windows,x:b2,a:b0,b:b1,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,",
"341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,", "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
"ffff0000000000000000504944564944,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,", "ffff0000000000000000504944564944,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,platform:Windows,",
"6d0416c2000000000000504944564944,Generic DirectInput Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,", "6d0416c2000000000000504944564944,Generic DirectInput Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
"6d0419c2000000000000504944564944,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,", "6d0419c2000000000000504944564944,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,platform:Windows,",
"88880803000000000000504944564944,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,", "88880803000000000000504944564944,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,platform:Windows,",
"4c056802000000000000504944564944,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Windows,", "4c056802000000000000504944564944,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,platform:Windows,",
"25090500000000000000504944564944,PS3 DualShock,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,platform:Windows,", "25090500000000000000504944564944,PS3 DualShock,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,platform:Windows,",
"4c05c405000000000000504944564944,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,", "4c05c405000000000000504944564944,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,platform:Windows,",
"6d0418c2000000000000504944564944,Logitech RumblePad 2 USB,platform:Windows,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,", "6d0418c2000000000000504944564944,Logitech RumblePad 2 USB,platform:Windows,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,",
"36280100000000000000504944564944,OUYA Controller,platform:Windows,a:b0,b:b3,y:b2,x:b1,start:b14,guide:b15,leftstick:b6,rightstick:b7,leftshoulder:b4,rightshoulder:b5,dpup:b8,dpleft:b10,dpdown:b9,dpright:b11,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b12,righttrigger:b13,", "36280100000000000000504944564944,OUYA Controller,platform:Windows,a:b0,b:b3,y:b2,x:b1,start:b14,guide:b15,leftstick:b6,rightstick:b7,leftshoulder:b4,rightshoulder:b5,dpup:b8,dpleft:b10,dpdown:b9,dpright:b11,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b12,righttrigger:b13,",
"4f0400b3000000000000504944564944,Thrustmaster Firestorm Dual Power,a:b0,b:b2,y:b3,x:b1,start:b10,guide:b8,back:b9,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,platform:Windows,", "4f0400b3000000000000504944564944,Thrustmaster Firestorm Dual Power,a:b0,b:b2,y:b3,x:b1,start:b10,guide:b8,back:b9,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,platform:Windows,",
"00f00300000000000000504944564944,RetroUSB.com RetroPad,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,platform:Windows,", "00f00300000000000000504944564944,RetroUSB.com RetroPad,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,platform:Windows,",
"00f0f100000000000000504944564944,RetroUSB.com Super RetroPort,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,platform:Windows,", "00f0f100000000000000504944564944,RetroUSB.com Super RetroPort,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,platform:Windows,",
"28040140000000000000504944564944,GamePad Pro USB,platform:Windows,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,lefttrigger:b6,righttrigger:b7,", "28040140000000000000504944564944,GamePad Pro USB,platform:Windows,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,lefttrigger:b6,righttrigger:b7,",
"ff113133000000000000504944564944,SVEN X-PAD,platform:Windows,a:b2,b:b3,y:b1,x:b0,start:b5,back:b4,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b8,righttrigger:b9,", "ff113133000000000000504944564944,SVEN X-PAD,platform:Windows,a:b2,b:b3,y:b1,x:b0,start:b5,back:b4,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b8,righttrigger:b9,",
"8f0e0300000000000000504944564944,Piranha xtreme,platform:Windows,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,", "8f0e0300000000000000504944564944,Piranha xtreme,platform:Windows,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,",
"8f0e0d31000000000000504944564944,Multilaser JS071 USB,platform:Windows,a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", "8f0e0d31000000000000504944564944,Multilaser JS071 USB,platform:Windows,a:b1,b:b2,y:b3,x:b0,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,",
"10080300000000000000504944564944,PS2 USB,platform:Windows,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a4,righty:a2,lefttrigger:b4,righttrigger:b5,", "10080300000000000000504944564944,PS2 USB,platform:Windows,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a4,righty:a2,lefttrigger:b4,righttrigger:b5,",
"79000600000000000000504944564944,G-Shark GS-GP702,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7,platform:Windows,", "79000600000000000000504944564944,G-Shark GS-GP702,a:b2,b:b1,x:b3,y:b0,back:b8,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7,platform:Windows,",
"4b12014d000000000000504944564944,NYKO AIRFLO,a:b0,b:b1,x:b2,y:b3,back:b8,guide:b10,start:b9,leftstick:a0,rightstick:a2,leftshoulder:a3,rightshoulder:b5,dpup:h0.1,dpdown:h0.0,dpleft:h0.8,dpright:h0.2,leftx:h0.6,lefty:h0.12,rightx:h0.9,righty:h0.4,lefttrigger:b6,righttrigger:b7,platform:Windows,", "4b12014d000000000000504944564944,NYKO AIRFLO,a:b0,b:b1,x:b2,y:b3,back:b8,guide:b10,start:b9,leftstick:a0,rightstick:a2,leftshoulder:a3,rightshoulder:b5,dpup:h0.1,dpdown:h0.0,dpleft:h0.8,dpright:h0.2,leftx:h0.6,lefty:h0.12,rightx:h0.9,righty:h0.4,lefttrigger:b6,righttrigger:b7,platform:Windows,",
"d6206dca000000000000504944564944,PowerA Pro Ex,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.0,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Windows,", "d6206dca000000000000504944564944,PowerA Pro Ex,a:b1,b:b2,x:b0,y:b3,back:b8,guide:b12,start:b9,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.0,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Windows,",
"a3060cff000000000000504944564944,Saitek P2500,a:b2,b:b3,y:b1,x:b0,start:b4,guide:b10,back:b5,leftstick:b8,rightstick:b9,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,platform:Windows,", "a3060cff000000000000504944564944,Saitek P2500,a:b2,b:b3,y:b1,x:b0,start:b4,guide:b10,back:b5,leftstick:b8,rightstick:b9,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,platform:Windows,",
"8f0e0300000000000000504944564944,Trust GTX 28,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Windows,", "8f0e0300000000000000504944564944,Trust GTX 28,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Windows,",
"4f0415b3000000000000504944564944,Thrustmaster Dual Analog 3.2,platform:Windows,x:b1,a:b0,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,", "4f0415b3000000000000504944564944,Thrustmaster Dual Analog 3.2,platform:Windows,x:b1,a:b0,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,",
"6f0e1e01000000000000504944564944,Rock Candy Gamepad for PS3,platform:Windows,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,guide:b12,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,", "6f0e1e01000000000000504944564944,Rock Candy Gamepad for PS3,platform:Windows,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,guide:b12,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,",
"83056020000000000000504944564944,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,y:b2,x:b3,start:b7,back:b6,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,platform:Windows,", "83056020000000000000504944564944,iBuffalo USB 2-axis 8-button Gamepad,a:b1,b:b0,y:b2,x:b3,start:b7,back:b6,leftshoulder:b4,rightshoulder:b5,leftx:a0,lefty:a1,platform:Windows,",
"c911f055000000000000504944564944,GAMEPAD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "c911f055000000000000504944564944,GAMEPAD,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
"79000600000000000000504944564944,Generic Speedlink,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7,", "79000600000000000000504944564944,Generic Speedlink,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7,",
"__XINPUT_DEVICE__,XInput Gamepad,a:b12,b:b13,x:b14,y:b15,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpdown:b1,dpleft:b2,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,", "__XINPUT_DEVICE__,XInput Gamepad,a:b12,b:b13,x:b14,y:b15,start:b4,back:b5,leftstick:b6,rightstick:b7,leftshoulder:b8,rightshoulder:b9,dpup:b0,dpdown:b1,dpleft:b2,dpright:b3,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,",
#endif #endif
#ifdef OSX_ENABLED #ifdef OSX_ENABLED
"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
"6d0400000000000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */ "6d0400000000000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
"6d0400000000000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "6d0400000000000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
"6d040000000000001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "6d040000000000001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,",
"6d0400000000000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* This includes F710 in DInput mode and the "Logitech Cordless RumblePad 2", at the very least. */ "6d0400000000000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* This includes F710 in DInput mode and the "Logitech Cordless RumblePad 2", at the very least. */
"4c050000000000006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "4c050000000000006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
"4c05000000000000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "4c05000000000000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
"5e040000000000008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,", "5e040000000000008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,",
#endif #endif
#if X11_ENABLED #if X11_ENABLED
"0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,", "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
"03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,", "03000000ba2200002010000001010000,Jess Technology USB Game Controller,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b3,y:b0,",
"030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d04000019c2000010010000,Logitech Cordless RumblePad 2,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
"030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006d0400001dc2000014400000,Logitech F310 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006d0400001ec2000020200000,Logitech F510 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "030000006d04000019c2000011010000,Logitech F710 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
"030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000006d0400001fc2000005030000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", "030000004c0500006802000011010000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
"030000004c050000c405000011010000,Sony DualShock 4,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:b6,righttrigger:b7,", "030000004c050000c405000011010000,Sony DualShock 4,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:b6,righttrigger:b7,",
"03000000de280000ff11000001000000,Valve Streaming Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000de280000ff11000001000000,Valve Streaming Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008e02000014010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400008e02000010010000,X360 Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "030000005e0400001907000000010000,X360 Wireless Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b11,dpright:b12,dpup:b13,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"03000000100800000100000010010000,Twin USB PS2 Adapter,a:b2,b:b1,y:b0,x:b3,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a2,lefttrigger:b4,righttrigger:b5,", "03000000100800000100000010010000,Twin USB PS2 Adapter,a:b2,b:b1,y:b0,x:b3,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a2,lefttrigger:b4,righttrigger:b5,",
"03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7,", "03000000a306000023f6000011010000,Saitek Cyborg V.1 Game Pad,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a4,lefttrigger:b6,righttrigger:b7,",
"030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,y:b3,x:b1,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,", "030000004f04000020b3000010010000,Thrustmaster 2 in 1 DT,a:b0,b:b2,y:b3,x:b1,start:b9,guide:,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,",
"030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a5,", "030000004f04000023b3000000010000,Thrustmaster Dual Trigger 3-in-1,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a5,",
"030000008f0e00000300000010010000,GreenAsia Inc. USB Joystick,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,", "030000008f0e00000300000010010000,GreenAsia Inc. USB Joystick,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b6,lefttrigger:b4,rightshoulder:b7,righttrigger:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,",
"030000008f0e00001200000010010000,GreenAsia Inc. USB Joystick,x:b2,a:b0,b:b1,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,", "030000008f0e00001200000010010000,GreenAsia Inc. USB Joystick,x:b2,a:b0,b:b1,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b5,rightshoulder:b6,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a2,",
"030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:b13,dpleft:b11,dpdown:b14,dpright:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,", "030000005e0400009102000007010000,X360 Wireless Controller,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:b13,dpleft:b11,dpdown:b14,dpright:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,",
"030000006d04000016c2000010010000,Logitech Logitech Dual Action,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,", "030000006d04000016c2000010010000,Logitech Logitech Dual Action,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,",
"03000000260900008888000000010000,GameCube {WiseGroup USB box},a:b0,b:b2,y:b3,x:b1,start:b7,leftshoulder:,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,rightstick:,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,", "03000000260900008888000000010000,GameCube {WiseGroup USB box},a:b0,b:b2,y:b3,x:b1,start:b7,leftshoulder:,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,rightstick:,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,",
"030000006d04000011c2000010010000,Logitech WingMan Cordless RumblePad,a:b0,b:b1,y:b4,x:b3,start:b8,guide:b5,back:b2,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b9,righttrigger:b10,", "030000006d04000011c2000010010000,Logitech WingMan Cordless RumblePad,a:b0,b:b1,y:b4,x:b3,start:b8,guide:b5,back:b2,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:b9,righttrigger:b10,",
"030000006d04000018c2000010010000,Logitech Logitech RumblePad 2 USB,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,", "030000006d04000018c2000010010000,Logitech Logitech RumblePad 2 USB,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,",
"05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,y:b3,x:b2,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a5,righttrigger:a4,", "05000000d6200000ad0d000001000000,Moga Pro,a:b0,b:b1,y:b3,x:b2,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a5,righttrigger:a4,",
"030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,a:b1,b:b2,x:b0,y:b3,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,", "030000004f04000009d0000000010000,Thrustmaster Run N Drive Wireless PS3,a:b1,b:b2,x:b0,y:b3,start:b9,guide:b12,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,",
"030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,a:b1,b:b2,x:b0,y:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:b6,righttrigger:b7,", "030000004f04000008d0000000010000,Thrustmaster Run N Drive Wireless,a:b1,b:b2,x:b0,y:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a5,lefttrigger:b6,righttrigger:b7,",
"0300000000f000000300000000010000,RetroUSB.com RetroPad,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,", "0300000000f000000300000000010000,RetroUSB.com RetroPad,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,",
"0300000000f00000f100000000010000,RetroUSB.com Super RetroPort,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,", "0300000000f00000f100000000010000,RetroUSB.com Super RetroPort,a:b1,b:b5,x:b0,y:b4,back:b2,start:b3,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,",
"030000006f0e00001f01000000010000,Generic X-Box pad,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "030000006f0e00001f01000000010000,Generic X-Box pad,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,",
"03000000280400000140000000010000,Gravis GamePad Pro USB ,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftx:a0,lefty:a1,", "03000000280400000140000000010000,Gravis GamePad Pro USB ,x:b0,a:b1,b:b2,y:b3,back:b8,start:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftx:a0,lefty:a1,",
"030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),x:b3,a:b0,b:b1,y:b4,back:b6,start:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b5,lefttrigger:a2,rightshoulder:b2,righttrigger:a5,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "030000005e0400008902000021010000,Microsoft X-Box pad v2 (US),x:b3,a:b0,b:b1,y:b4,back:b6,start:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b5,lefttrigger:a2,rightshoulder:b2,righttrigger:a5,leftstick:b8,rightstick:b9,leftx:a0,lefty:a1,rightx:a3,righty:a4,",
"030000006f0e00001e01000011010000,Rock Candy Gamepad for PS3,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,guide:b12,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,", "030000006f0e00001e01000011010000,Rock Candy Gamepad for PS3,a:b1,b:b2,x:b0,y:b3,back:b8,start:b9,guide:b12,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,",
"03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,y:b0,x:b3,start:b8,back:b9,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b4,righttrigger:b5,", "03000000250900000500000000010000,Sony PS2 pad with SmartJoy adapter,a:b2,b:b1,y:b0,x:b3,start:b8,back:b9,leftstick:b10,rightstick:b11,leftshoulder:b6,rightshoulder:b7,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b4,righttrigger:b5,",
"030000008916000000fd000024010000,Razer Onza Tournament,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:b13,dpleft:b11,dpdown:b14,dpright:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,", "030000008916000000fd000024010000,Razer Onza Tournament,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:b13,dpleft:b11,dpdown:b14,dpright:b12,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,",
"030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,y:b3,x:b1,start:b10,guide:b8,back:b9,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,", "030000004f04000000b3000010010000,Thrustmaster Firestorm Dual Power,a:b0,b:b2,y:b3,x:b1,start:b10,guide:b8,back:b9,leftstick:b11,rightstick:b12,leftshoulder:b4,rightshoulder:b6,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b5,righttrigger:b7,",
"03000000ad1b000001f5000033050000,Hori Pad EX Turbo 2,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,", "03000000ad1b000001f5000033050000,Hori Pad EX Turbo 2,a:b0,b:b1,y:b3,x:b2,start:b7,guide:b8,back:b6,leftstick:b9,rightstick:b10,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,",
"050000004c050000c405000000010000,PS4 Controller (Bluetooth),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "050000004c050000c405000000010000,PS4 Controller (Bluetooth),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
"060000004c0500006802000000010000,PS3 Controller (Bluetooth),a:b14,b:b13,y:b12,x:b15,start:b3,guide:b16,back:b0,leftstick:b1,rightstick:b2,leftshoulder:b10,rightshoulder:b11,dpup:b4,dpleft:b7,dpdown:b6,dpright:b5,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b8,righttrigger:b9,", "060000004c0500006802000000010000,PS3 Controller (Bluetooth),a:b14,b:b13,y:b12,x:b15,start:b3,guide:b16,back:b0,leftstick:b1,rightstick:b2,leftshoulder:b10,rightshoulder:b11,dpup:b4,dpleft:b7,dpdown:b6,dpright:b5,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b8,righttrigger:b9,",
"03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "03000000790000000600000010010000,DragonRise Inc. Generic USB Joystick,x:b3,a:b2,b:b1,y:b0,back:b8,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a3,righty:a4,",
"03000000666600000488000000010000,Super Joy Box 5 Pro,a:b2,b:b1,x:b3,y:b0,back:b9,start:b8,leftshoulder:b6,rightshoulder:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b4,righttrigger:b5,dpup:b12,dpleft:b15,dpdown:b14,dpright:b13,", "03000000666600000488000000010000,Super Joy Box 5 Pro,a:b2,b:b1,x:b3,y:b0,back:b9,start:b8,leftshoulder:b6,rightshoulder:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b4,righttrigger:b5,dpup:b12,dpleft:b15,dpdown:b14,dpright:b13,",
"05000000362800000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,", "05000000362800000100000002010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,",
"05000000362800000100000003010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,", "05000000362800000100000003010000,OUYA Game Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b1,y:b2,",
"030000008916000001fd000024010000,Razer Onza Classic Edition,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:b11,dpdown:b14,dpright:b12,dpup:b13,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "030000008916000001fd000024010000,Razer Onza Classic Edition,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:b11,dpdown:b14,dpright:b12,dpup:b13,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,",
"030000005e040000d102000001010000,Microsoft X-Box One pad,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,", "030000005e040000d102000001010000,Microsoft X-Box One pad,x:b2,a:b0,b:b1,y:b3,back:b6,guide:b8,start:b7,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:a2,rightshoulder:b5,righttrigger:a5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,",
"03000000790000001100000010010000,RetroLink Saturn Classic Controller,platform:Linux,x:b3,a:b0,b:b1,y:b4,back:b5,guide:b2,start:b8,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,", "03000000790000001100000010010000,RetroLink Saturn Classic Controller,platform:Linux,x:b3,a:b0,b:b1,y:b4,back:b5,guide:b2,start:b8,leftshoulder:b6,rightshoulder:b7,leftx:a0,lefty:a1,",
"050000007e0500003003000001000000,Nintendo Wii U Pro Controller,platform:Linux,a:b0,b:b1,x:b3,y:b2,back:b8,start:b9,guide:b10,leftshoulder:b4,rightshoulder:b5,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,dpup:b13,dpleft:b15,dpdown:b14,dpright:b16,", "050000007e0500003003000001000000,Nintendo Wii U Pro Controller,platform:Linux,a:b0,b:b1,x:b3,y:b2,back:b8,start:b9,guide:b10,leftshoulder:b4,rightshoulder:b5,leftstick:b11,rightstick:b12,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,dpup:b13,dpleft:b15,dpdown:b14,dpright:b16,",
"030000005e0400008e02000004010000,Microsoft X-Box 360 pad,platform:Linux,a:b0,b:b1,x:b2,y:b3,back:b6,start:b7,guide:b8,leftshoulder:b4,rightshoulder:b5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,", "030000005e0400008e02000004010000,Microsoft X-Box 360 pad,platform:Linux,a:b0,b:b1,x:b2,y:b3,back:b6,start:b7,guide:b8,leftshoulder:b4,rightshoulder:b5,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a3,righty:a4,lefttrigger:a2,righttrigger:a5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,",
"030000000d0f00002200000011010000,HORI CO.,LTD. REAL ARCADE Pro.V3,platform:Linux,x:b0,a:b1,b:b2,y:b3,back:b8,guide:b12,start:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,", "030000000d0f00002200000011010000,HORI CO.,LTD. REAL ARCADE Pro.V3,platform:Linux,x:b0,a:b1,b:b2,y:b3,back:b8,guide:b12,start:b9,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,",
"030000000d0f00001000000011010000,HORI CO.,LTD. FIGHTING STICK 3,platform:Linux,x:b0,a:b1,b:b2,y:b3,back:b8,guide:b12,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7", "030000000d0f00001000000011010000,HORI CO.,LTD. FIGHTING STICK 3,platform:Linux,x:b0,a:b1,b:b2,y:b3,back:b8,guide:b12,start:b9,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7",
"03000000f0250000c183000010010000,Goodbetterbest Ltd USB Controller,platform:Linux,x:b0,a:b1,b:b2,y:b3,back:b8,guide:b12,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,", "03000000f0250000c183000010010000,Goodbetterbest Ltd USB Controller,platform:Linux,x:b0,a:b1,b:b2,y:b3,back:b8,guide:b12,start:b9,dpleft:h0.8,dpdown:h0.0,dpdown:h0.4,dpright:h0.0,dpright:h0.2,dpup:h0.0,dpup:h0.1,leftshoulder:h0.0,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,",
"0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),platform:Linux,a:b0,b:b1,x:b2,y:b3,start:b7,back:b6,guide:b8,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,lefttrigger:a5,righttrigger:a4,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a2,righty:a3,", "0000000058626f782047616d65706100,Xbox Gamepad (userspace driver),platform:Linux,a:b0,b:b1,x:b2,y:b3,start:b7,back:b6,guide:b8,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,lefttrigger:a5,righttrigger:a4,leftstick:b9,rightstick:b10,leftx:a0,lefty:a1,rightx:a2,righty:a3,",
"03000000ff1100003133000010010000,PC Game Controller,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Linux,", "03000000ff1100003133000010010000,PC Game Controller,a:b2,b:b1,y:b0,x:b3,start:b9,back:b8,leftstick:b10,rightstick:b11,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7,platform:Linux,",
#endif #endif
#if defined(__ANDROID__) #if defined(__ANDROID__)
"4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "4e564944494120436f72706f72617469,NVIDIA Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,",
#endif #endif
NULL NULL
}; };
InputDefault::InputDefault() { InputDefault::InputDefault() {
@@ -512,7 +512,7 @@ InputDefault::InputDefault() {
continue; continue;
parse_mapping(entries[i]); parse_mapping(entries[i]);
}; };
}; };
int i = 0; int i = 0;
while (s_ControllerMappings[i]) { while (s_ControllerMappings[i]) {
@@ -524,244 +524,244 @@ InputDefault::InputDefault() {
uint32_t InputDefault::joy_button(uint32_t p_last_id, int p_device, int p_button, bool p_pressed) { uint32_t InputDefault::joy_button(uint32_t p_last_id, int p_device, int p_button, bool p_pressed) {
_THREAD_SAFE_METHOD_; _THREAD_SAFE_METHOD_;
Joystick& joy = joy_names[p_device]; Joystick& joy = joy_names[p_device];
//printf("got button %i, mapping is %i\n", p_button, joy.mapping); //printf("got button %i, mapping is %i\n", p_button, joy.mapping);
if (joy.last_buttons[p_button] == p_pressed) { if (joy.last_buttons[p_button] == p_pressed) {
return p_last_id; return p_last_id;
//printf("same button value\n"); //printf("same button value\n");
} }
joy.last_buttons[p_button] = p_pressed; joy.last_buttons[p_button] = p_pressed;
if (joy.mapping == -1) { if (joy.mapping == -1) {
return _button_event(p_last_id, p_device, p_button, p_pressed); return _button_event(p_last_id, p_device, p_button, p_pressed);
}; };
Map<int,JoyEvent>::Element* el = map_db[joy.mapping].buttons.find(p_button); Map<int,JoyEvent>::Element* el = map_db[joy.mapping].buttons.find(p_button);
if (!el) { if (!el) {
//don't process un-mapped events for now, it could mess things up badly for devices with additional buttons/axis //don't process un-mapped events for now, it could mess things up badly for devices with additional buttons/axis
//return _button_event(p_last_id, p_device, p_button, p_pressed); //return _button_event(p_last_id, p_device, p_button, p_pressed);
return p_last_id; return p_last_id;
}; };
JoyEvent map = el->get(); JoyEvent map = el->get();
if (map.type == TYPE_BUTTON) { if (map.type == TYPE_BUTTON) {
return _button_event(p_last_id, p_device, map.index, p_pressed); return _button_event(p_last_id, p_device, map.index, p_pressed);
}; };
if (map.type == TYPE_AXIS) { if (map.type == TYPE_AXIS) {
return _axis_event(p_last_id, p_device, map.index, p_pressed ? 1.0 : 0.0); return _axis_event(p_last_id, p_device, map.index, p_pressed ? 1.0 : 0.0);
}; };
return p_last_id; // no event? return p_last_id; // no event?
}; };
uint32_t InputDefault::joy_axis(uint32_t p_last_id, int p_device, int p_axis, const JoyAxis& p_value) { uint32_t InputDefault::joy_axis(uint32_t p_last_id, int p_device, int p_axis, const JoyAxis& p_value) {
_THREAD_SAFE_METHOD_; _THREAD_SAFE_METHOD_;
Joystick& joy = joy_names[p_device]; Joystick& joy = joy_names[p_device];
if (joy.last_axis[p_axis] == p_value.value) { if (joy.last_axis[p_axis] == p_value.value) {
return p_last_id; return p_last_id;
} }
if (p_value.value > joy.last_axis[p_axis]) { if (p_value.value > joy.last_axis[p_axis]) {
if (p_value.value < joy.last_axis[p_axis] + joy.filter ) { if (p_value.value < joy.last_axis[p_axis] + joy.filter ) {
return p_last_id; return p_last_id;
} }
} }
else if (p_value.value > joy.last_axis[p_axis] - joy.filter) { else if (p_value.value > joy.last_axis[p_axis] - joy.filter) {
return p_last_id; return p_last_id;
} }
joy.last_axis[p_axis] = p_value.value; joy.last_axis[p_axis] = p_value.value;
if (joy.mapping == -1) { if (joy.mapping == -1) {
float val = p_value.min == 0 ? -1.0f + 2.0f * p_value.value : p_value.value; float val = p_value.min == 0 ? -1.0f + 2.0f * p_value.value : p_value.value;
return _axis_event(p_last_id, p_device, p_axis, val); return _axis_event(p_last_id, p_device, p_axis, val);
}; };
Map<int,JoyEvent>::Element* el = map_db[joy.mapping].axis.find(p_axis); Map<int,JoyEvent>::Element* el = map_db[joy.mapping].axis.find(p_axis);
if (!el) { if (!el) {
//return _axis_event(p_last_id, p_device, p_axis, p_value); //return _axis_event(p_last_id, p_device, p_axis, p_value);
return p_last_id; return p_last_id;
}; };
JoyEvent map = el->get(); JoyEvent map = el->get();
if (map.type == TYPE_BUTTON) { if (map.type == TYPE_BUTTON) {
float deadzone = p_value.min == 0 ? 0.5f : 0.0f; float deadzone = p_value.min == 0 ? 0.5f : 0.0f;
return _button_event(p_last_id, p_device, map.index, p_value.value > deadzone ? true : false); return _button_event(p_last_id, p_device, map.index, p_value.value > deadzone ? true : false);
}; };
if (map.type == TYPE_AXIS) { if (map.type == TYPE_AXIS) {
float val = p_value.min == 0 ? -1.0f + 2.0f * p_value.value : p_value.value; float val = p_value.min == 0 ? -1.0f + 2.0f * p_value.value : p_value.value;
return _axis_event(p_last_id, p_device, map.index, val ); return _axis_event(p_last_id, p_device, map.index, val );
}; };
//printf("invalid mapping\n"); //printf("invalid mapping\n");
return p_last_id; return p_last_id;
}; };
uint32_t InputDefault::joy_hat(uint32_t p_last_id, int p_device, int p_val) { uint32_t InputDefault::joy_hat(uint32_t p_last_id, int p_device, int p_val) {
_THREAD_SAFE_METHOD_; _THREAD_SAFE_METHOD_;
const Joystick& joy = joy_names[p_device]; const Joystick& joy = joy_names[p_device];
JoyEvent* map; JoyEvent* map;
if (joy.mapping == -1) { if (joy.mapping == -1) {
map = hat_map_default; map = hat_map_default;
} else { } else {
map = map_db[joy.mapping].hat; map = map_db[joy.mapping].hat;
}; };
int cur_val = joy_names[p_device].hat_current; int cur_val = joy_names[p_device].hat_current;
if ( (p_val & HAT_MASK_UP) != (cur_val & HAT_MASK_UP) ) { if ( (p_val & HAT_MASK_UP) != (cur_val & HAT_MASK_UP) ) {
p_last_id = _button_event(p_last_id, p_device, map[HAT_UP].index, p_val & HAT_MASK_UP); p_last_id = _button_event(p_last_id, p_device, map[HAT_UP].index, p_val & HAT_MASK_UP);
}; };
if ( (p_val & HAT_MASK_RIGHT) != (cur_val & HAT_MASK_RIGHT) ) { if ( (p_val & HAT_MASK_RIGHT) != (cur_val & HAT_MASK_RIGHT) ) {
p_last_id = _button_event(p_last_id, p_device, map[HAT_RIGHT].index, p_val & HAT_MASK_RIGHT); p_last_id = _button_event(p_last_id, p_device, map[HAT_RIGHT].index, p_val & HAT_MASK_RIGHT);
}; };
if ( (p_val & HAT_MASK_DOWN) != (cur_val & HAT_MASK_DOWN) ) { if ( (p_val & HAT_MASK_DOWN) != (cur_val & HAT_MASK_DOWN) ) {
p_last_id = _button_event(p_last_id, p_device, map[HAT_DOWN].index, p_val & HAT_MASK_DOWN); p_last_id = _button_event(p_last_id, p_device, map[HAT_DOWN].index, p_val & HAT_MASK_DOWN);
}; };
if ( (p_val & HAT_MASK_LEFT) != (cur_val & HAT_MASK_LEFT) ) { if ( (p_val & HAT_MASK_LEFT) != (cur_val & HAT_MASK_LEFT) ) {
p_last_id = _button_event(p_last_id, p_device, map[HAT_LEFT].index, p_val & HAT_MASK_LEFT); p_last_id = _button_event(p_last_id, p_device, map[HAT_LEFT].index, p_val & HAT_MASK_LEFT);
}; };
joy_names[p_device].hat_current = p_val; joy_names[p_device].hat_current = p_val;
return p_last_id; return p_last_id;
}; };
uint32_t InputDefault::_button_event(uint32_t p_last_id, int p_device, int p_index, bool p_pressed) { uint32_t InputDefault::_button_event(uint32_t p_last_id, int p_device, int p_index, bool p_pressed) {
InputEvent ievent; InputEvent ievent;
ievent.type = InputEvent::JOYSTICK_BUTTON; ievent.type = InputEvent::JOYSTICK_BUTTON;
ievent.device = p_device; ievent.device = p_device;
ievent.ID = ++p_last_id; ievent.ID = ++p_last_id;
ievent.joy_button.button_index = p_index; ievent.joy_button.button_index = p_index;
ievent.joy_button.pressed = p_pressed; ievent.joy_button.pressed = p_pressed;
parse_input_event(ievent); parse_input_event(ievent);
return p_last_id; return p_last_id;
}; };
uint32_t InputDefault::_axis_event(uint32_t p_last_id, int p_device, int p_axis, float p_value) { uint32_t InputDefault::_axis_event(uint32_t p_last_id, int p_device, int p_axis, float p_value) {
InputEvent ievent; InputEvent ievent;
ievent.type = InputEvent::JOYSTICK_MOTION; ievent.type = InputEvent::JOYSTICK_MOTION;
ievent.device = p_device; ievent.device = p_device;
ievent.ID = ++p_last_id; ievent.ID = ++p_last_id;
ievent.joy_motion.axis = p_axis; ievent.joy_motion.axis = p_axis;
ievent.joy_motion.axis_value = p_value; ievent.joy_motion.axis_value = p_value;
parse_input_event( ievent ); parse_input_event( ievent );
return p_last_id; return p_last_id;
}; };
InputDefault::JoyEvent InputDefault::_find_to_event(String p_to) { InputDefault::JoyEvent InputDefault::_find_to_event(String p_to) {
// string names of the SDL buttons in the same order as input_event.h godot buttons // string names of the SDL buttons in the same order as input_event.h godot buttons
static const char* buttons[] = {"a", "b", "x", "y", "leftshoulder", "rightshoulder", "lefttrigger", "righttrigger", "leftstick", "rightstick", "back", "start", "dpup", "dpdown", "dpleft", "dpright", "guide", NULL }; static const char* buttons[] = {"a", "b", "x", "y", "leftshoulder", "rightshoulder", "lefttrigger", "righttrigger", "leftstick", "rightstick", "back", "start", "dpup", "dpdown", "dpleft", "dpright", "guide", NULL };
static const char* axis[] = {"leftx", "lefty", "rightx", "righty", NULL }; static const char* axis[] = {"leftx", "lefty", "rightx", "righty", NULL };
JoyEvent ret; JoyEvent ret;
ret.type = -1; ret.type = -1;
int i=0; int i=0;
while (buttons[i]) { while (buttons[i]) {
if (p_to == buttons[i]) { if (p_to == buttons[i]) {
//printf("mapping button %s\n", buttons[i]); //printf("mapping button %s\n", buttons[i]);
ret.type = TYPE_BUTTON; ret.type = TYPE_BUTTON;
ret.index = i; ret.index = i;
ret.value = 0; ret.value = 0;
return ret; return ret;
}; };
++i; ++i;
}; };
i = 0; i = 0;
while (axis[i]) { while (axis[i]) {
if (p_to == axis[i]) { if (p_to == axis[i]) {
ret.type = TYPE_AXIS; ret.type = TYPE_AXIS;
ret.index = i; ret.index = i;
ret.value = 0; ret.value = 0;
return ret; return ret;
}; };
++i; ++i;
}; };
return ret; return ret;
}; };
void InputDefault::parse_mapping(String p_mapping) { void InputDefault::parse_mapping(String p_mapping) {
_THREAD_SAFE_METHOD_; _THREAD_SAFE_METHOD_;
JoyDeviceMapping mapping; JoyDeviceMapping mapping;
Vector<String> entry = p_mapping.split(","); Vector<String> entry = p_mapping.split(",");
CharString uid; CharString uid;
uid.resize(17); uid.resize(17);
mapping.uid = entry[0]; mapping.uid = entry[0];
int idx = 1; int idx = 1;
while (++idx < entry.size()) { while (++idx < entry.size()) {
if (entry[idx] == "") if (entry[idx] == "")
continue; continue;
String from = entry[idx].get_slice(":", 1); String from = entry[idx].get_slice(":", 1);
String to = entry[idx].get_slice(":", 0); String to = entry[idx].get_slice(":", 0);
JoyEvent to_event = _find_to_event(to); JoyEvent to_event = _find_to_event(to);
if (to_event.type == -1) if (to_event.type == -1)
continue; continue;
String etype = from.substr(0, 1); String etype = from.substr(0, 1);
if (etype == "a") { if (etype == "a") {
int aid = from.substr(1, from.length()-1).to_int(); int aid = from.substr(1, from.length()-1).to_int();
mapping.axis[aid] = to_event; mapping.axis[aid] = to_event;
} else if (etype == "b") { } else if (etype == "b") {
int bid = from.substr(1, from.length()-1).to_int(); int bid = from.substr(1, from.length()-1).to_int();
mapping.buttons[bid] = to_event; mapping.buttons[bid] = to_event;
} else if (etype == "h") { } else if (etype == "h") {
int hat_value = from.get_slice(".", 1).to_int(); int hat_value = from.get_slice(".", 1).to_int();
switch (hat_value) { switch (hat_value) {
case 1: case 1:
mapping.hat[HAT_UP] = to_event; mapping.hat[HAT_UP] = to_event;
break; break;
case 2: case 2:
mapping.hat[HAT_RIGHT] = to_event; mapping.hat[HAT_RIGHT] = to_event;
break; break;
case 4: case 4:
mapping.hat[HAT_DOWN] = to_event; mapping.hat[HAT_DOWN] = to_event;
break; break;
case 8: case 8:
mapping.hat[HAT_LEFT] = to_event; mapping.hat[HAT_LEFT] = to_event;
break; break;
}; };
}; };
}; };
map_db.push_back(mapping); map_db.push_back(mapping);
//printf("added mapping with uuid %ls\n", mapping.uid.c_str()); //printf("added mapping with uuid %ls\n", mapping.uid.c_str());
}; };

View File

@@ -33,31 +33,31 @@ class InputDefault : public Input {
SpeedTrack(); SpeedTrack();
}; };
struct Joystick { struct Joystick {
StringName name; StringName name;
StringName uid; StringName uid;
bool last_buttons[JOY_BUTTON_MAX]; bool last_buttons[JOY_BUTTON_MAX];
float last_axis[JOY_AXIS_MAX]; float last_axis[JOY_AXIS_MAX];
float filter; float filter;
int last_hat; int last_hat;
int mapping; int mapping;
int hat_current; int hat_current;
Joystick() { Joystick() {
for (int i = 0; i < JOY_AXIS_MAX; i++) { for (int i = 0; i < JOY_AXIS_MAX; i++) {
last_axis[i] = 0.0f; last_axis[i] = 0.0f;
} }
for (int i = 0; i < JOY_BUTTON_MAX; i++) { for (int i = 0; i < JOY_BUTTON_MAX; i++) {
last_buttons[i] = false; last_buttons[i] = false;
} }
last_hat = HAT_MASK_CENTER; last_hat = HAT_MASK_CENTER;
filter = 0.01f; filter = 0.01f;
} }
}; };
SpeedTrack mouse_speed_track; SpeedTrack mouse_speed_track;
Map<int, Joystick> joy_names; Map<int, Joystick> joy_names;
@@ -98,22 +98,22 @@ private:
int value; int value;
}; };
struct JoyDeviceMapping { struct JoyDeviceMapping {
String uid; String uid;
Map<int,JoyEvent> buttons; Map<int,JoyEvent> buttons;
Map<int,JoyEvent> axis; Map<int,JoyEvent> axis;
JoyEvent hat[HAT_MAX]; JoyEvent hat[HAT_MAX];
}; };
JoyEvent hat_map_default[HAT_MAX]; JoyEvent hat_map_default[HAT_MAX];
Vector<JoyDeviceMapping> map_db; Vector<JoyDeviceMapping> map_db;
JoyEvent _find_to_event(String p_to); JoyEvent _find_to_event(String p_to);
uint32_t _button_event(uint32_t p_last_id, int p_device, int p_index, bool p_pressed); uint32_t _button_event(uint32_t p_last_id, int p_device, int p_index, bool p_pressed);
uint32_t _axis_event(uint32_t p_last_id, int p_device, int p_axis, float p_value); uint32_t _axis_event(uint32_t p_last_id, int p_device, int p_axis, float p_value);
float _handle_deadzone(int p_device, int p_axis, float p_value); float _handle_deadzone(int p_device, int p_axis, float p_value);
public: public:

View File

@@ -44,354 +44,354 @@ joystick_windows::joystick_windows() {
joystick_windows::joystick_windows(InputDefault* _input, HWND* hwnd) { joystick_windows::joystick_windows(InputDefault* _input, HWND* hwnd) {
input = _input; input = _input;
hWnd = hwnd; hWnd = hwnd;
joystick_count = 0; joystick_count = 0;
dinput = NULL; dinput = NULL;
xinput_dll = NULL; xinput_dll = NULL;
xinput_get_state = NULL; xinput_get_state = NULL;
load_xinput(); load_xinput();
for (int i = 0; i < JOYSTICKS_MAX; i++) for (int i = 0; i < JOYSTICKS_MAX; i++)
attached_joysticks[i] = false; attached_joysticks[i] = false;
HRESULT result; HRESULT result;
result = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&dinput, NULL); result = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&dinput, NULL);
if (FAILED(result)) { if (FAILED(result)) {
printf("failed init DINPUT: %ld\n", result); printf("failed init DINPUT: %ld\n", result);
} }
probe_joysticks(); probe_joysticks();
} }
joystick_windows::~joystick_windows() { joystick_windows::~joystick_windows() {
close_joystick(); close_joystick();
dinput->Release(); dinput->Release();
unload_xinput(); unload_xinput();
} }
bool joystick_windows::have_device(const GUID &p_guid) { bool joystick_windows::have_device(const GUID &p_guid) {
for (int i = 0; i < JOYSTICKS_MAX; i++) { for (int i = 0; i < JOYSTICKS_MAX; i++) {
if (d_joysticks[i].guid == p_guid) { if (d_joysticks[i].guid == p_guid) {
d_joysticks[i].confirmed = true; d_joysticks[i].confirmed = true;
return true; return true;
} }
} }
return false; return false;
} }
int joystick_windows::check_free_joy_slot() const { int joystick_windows::check_free_joy_slot() const {
for (int i = 0; i < JOYSTICKS_MAX; i++) { for (int i = 0; i < JOYSTICKS_MAX; i++) {
if (!attached_joysticks[i]) if (!attached_joysticks[i])
return i; return i;
} }
return -1; return -1;
} }
// adapted from SDL2, works a lot better than the MSDN version // adapted from SDL2, works a lot better than the MSDN version
bool joystick_windows::is_xinput_device(const GUID *p_guid) { bool joystick_windows::is_xinput_device(const GUID *p_guid) {
PRAWINPUTDEVICELIST dev_list = NULL; PRAWINPUTDEVICELIST dev_list = NULL;
unsigned int dev_list_count = 0; unsigned int dev_list_count = 0;
if (GetRawInputDeviceList(NULL, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == -1) { if (GetRawInputDeviceList(NULL, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == -1) {
return false; return false;
} }
dev_list = (PRAWINPUTDEVICELIST) malloc(sizeof(RAWINPUTDEVICELIST) * dev_list_count); dev_list = (PRAWINPUTDEVICELIST) malloc(sizeof(RAWINPUTDEVICELIST) * dev_list_count);
if (!dev_list) return false; if (!dev_list) return false;
if (GetRawInputDeviceList(dev_list, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == -1) { if (GetRawInputDeviceList(dev_list, &dev_list_count, sizeof(RAWINPUTDEVICELIST)) == -1) {
free(dev_list); free(dev_list);
return false; return false;
} }
for (int i = 0; i < dev_list_count; i++) { for (int i = 0; i < dev_list_count; i++) {
RID_DEVICE_INFO rdi; RID_DEVICE_INFO rdi;
char dev_name[128]; char dev_name[128];
UINT rdiSize = sizeof(rdi); UINT rdiSize = sizeof(rdi);
UINT nameSize = sizeof(dev_name); UINT nameSize = sizeof(dev_name);
rdi.cbSize = rdiSize; rdi.cbSize = rdiSize;
if ( (dev_list[i].dwType == RIM_TYPEHID) && if ( (dev_list[i].dwType == RIM_TYPEHID) &&
(GetRawInputDeviceInfoA(dev_list[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != (UINT)-1) && (GetRawInputDeviceInfoA(dev_list[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != (UINT)-1) &&
(MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == (LONG)p_guid->Data1) && (MAKELONG(rdi.hid.dwVendorId, rdi.hid.dwProductId) == (LONG)p_guid->Data1) &&
(GetRawInputDeviceInfoA(dev_list[i].hDevice, RIDI_DEVICENAME, &dev_name, &nameSize) != (UINT)-1) && (GetRawInputDeviceInfoA(dev_list[i].hDevice, RIDI_DEVICENAME, &dev_name, &nameSize) != (UINT)-1) &&
(strstr(dev_name, "IG_") != NULL)) { (strstr(dev_name, "IG_") != NULL)) {
free(dev_list); free(dev_list);
return true; return true;
} }
} }
free(dev_list); free(dev_list);
return false; return false;
} }
bool joystick_windows::setup_dinput_joystick(const DIDEVICEINSTANCE* instance) { bool joystick_windows::setup_dinput_joystick(const DIDEVICEINSTANCE* instance) {
HRESULT hr; HRESULT hr;
int num = check_free_joy_slot(); int num = check_free_joy_slot();
if (have_device(instance->guidInstance) || num == -1) if (have_device(instance->guidInstance) || num == -1)
return false; return false;
d_joysticks[joystick_count] = dinput_gamepad(); d_joysticks[joystick_count] = dinput_gamepad();
dinput_gamepad* joy = &d_joysticks[num]; dinput_gamepad* joy = &d_joysticks[num];
const DWORD devtype = (instance->dwDevType & 0xFF); const DWORD devtype = (instance->dwDevType & 0xFF);
if ((devtype != DI8DEVTYPE_JOYSTICK) && (devtype != DI8DEVTYPE_GAMEPAD) && (devtype != DI8DEVTYPE_1STPERSON)) { if ((devtype != DI8DEVTYPE_JOYSTICK) && (devtype != DI8DEVTYPE_GAMEPAD) && (devtype != DI8DEVTYPE_1STPERSON)) {
//printf("ignore device %s, type %x\n", instance->tszProductName, devtype); //printf("ignore device %s, type %x\n", instance->tszProductName, devtype);
return false; return false;
} }
hr = dinput->CreateDevice(instance->guidInstance, &joy->di_joy, NULL); hr = dinput->CreateDevice(instance->guidInstance, &joy->di_joy, NULL);
if (FAILED(hr)) { if (FAILED(hr)) {
//std::wcout << "failed to create device: " << instance->tszProductName << std::endl; //std::wcout << "failed to create device: " << instance->tszProductName << std::endl;
return false; return false;
} }
const GUID &guid = instance->guidProduct; const GUID &guid = instance->guidProduct;
char uid[128]; char uid[128];
sprintf(uid, "%08lx%04hx%04hx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx", sprintf(uid, "%08lx%04hx%04hx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx",
__builtin_bswap32(guid.Data1), guid.Data2, guid.Data3, __builtin_bswap32(guid.Data1), guid.Data2, guid.Data3,
guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);
id_to_change = num; id_to_change = num;
joy->di_joy->SetDataFormat(&c_dfDIJoystick2); joy->di_joy->SetDataFormat(&c_dfDIJoystick2);
joy->di_joy->SetCooperativeLevel(*hWnd, DISCL_FOREGROUND); joy->di_joy->SetCooperativeLevel(*hWnd, DISCL_FOREGROUND);
joy->di_joy->EnumObjects(objectsCallback, this, NULL); joy->di_joy->EnumObjects(objectsCallback, this, NULL);
joy->joy_axis.sort(); joy->joy_axis.sort();
joy->guid = instance->guidInstance; joy->guid = instance->guidInstance;
input->joy_connection_changed(num, true, instance->tszProductName, uid); input->joy_connection_changed(num, true, instance->tszProductName, uid);
joy->attached = true; joy->attached = true;
joy->id = num; joy->id = num;
attached_joysticks[num] = true; attached_joysticks[num] = true;
joy->confirmed = true; joy->confirmed = true;
joystick_count++; joystick_count++;
return true; return true;
} }
void joystick_windows::setup_joystick_object(const DIDEVICEOBJECTINSTANCE *ob, int p_joy_id) { void joystick_windows::setup_joystick_object(const DIDEVICEOBJECTINSTANCE *ob, int p_joy_id) {
if (ob->dwType & DIDFT_AXIS) { if (ob->dwType & DIDFT_AXIS) {
HRESULT res; HRESULT res;
DIPROPRANGE prop_range; DIPROPRANGE prop_range;
DIPROPDWORD dilong; DIPROPDWORD dilong;
DWORD ofs; DWORD ofs;
if (ob->guidType == GUID_XAxis) if (ob->guidType == GUID_XAxis)
ofs = DIJOFS_X; ofs = DIJOFS_X;
else if (ob->guidType == GUID_YAxis) else if (ob->guidType == GUID_YAxis)
ofs = DIJOFS_Y; ofs = DIJOFS_Y;
else if (ob->guidType == GUID_ZAxis) else if (ob->guidType == GUID_ZAxis)
ofs = DIJOFS_Z; ofs = DIJOFS_Z;
else if (ob->guidType == GUID_RxAxis) else if (ob->guidType == GUID_RxAxis)
ofs = DIJOFS_RX; ofs = DIJOFS_RX;
else if (ob->guidType == GUID_RyAxis) else if (ob->guidType == GUID_RyAxis)
ofs = DIJOFS_RY; ofs = DIJOFS_RY;
else if (ob->guidType == GUID_RzAxis) else if (ob->guidType == GUID_RzAxis)
ofs = DIJOFS_RZ; ofs = DIJOFS_RZ;
else if (ob->guidType == GUID_Slider) else if (ob->guidType == GUID_Slider)
ofs = DIJOFS_SLIDER(0); ofs = DIJOFS_SLIDER(0);
else else
return; return;
prop_range.diph.dwSize = sizeof(DIPROPRANGE); prop_range.diph.dwSize = sizeof(DIPROPRANGE);
prop_range.diph.dwHeaderSize = sizeof(DIPROPHEADER); prop_range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
prop_range.diph.dwObj = ob->dwType; prop_range.diph.dwObj = ob->dwType;
prop_range.diph.dwHow = DIPH_BYID; prop_range.diph.dwHow = DIPH_BYID;
prop_range.lMin = -MAX_JOY_AXIS; prop_range.lMin = -MAX_JOY_AXIS;
prop_range.lMax = +MAX_JOY_AXIS; prop_range.lMax = +MAX_JOY_AXIS;
dinput_gamepad &joy = d_joysticks[p_joy_id]; dinput_gamepad &joy = d_joysticks[p_joy_id];
res = joy.di_joy->SetProperty(DIPROP_RANGE, &prop_range.diph); res = joy.di_joy->SetProperty(DIPROP_RANGE, &prop_range.diph);
if (FAILED(res)) if (FAILED(res))
return; return;
dilong.diph.dwSize = sizeof(dilong); dilong.diph.dwSize = sizeof(dilong);
dilong.diph.dwHeaderSize = sizeof(dilong.diph); dilong.diph.dwHeaderSize = sizeof(dilong.diph);
dilong.diph.dwObj = ob->dwType; dilong.diph.dwObj = ob->dwType;
dilong.diph.dwHow = DIPH_BYID; dilong.diph.dwHow = DIPH_BYID;
dilong.dwData = 0; dilong.dwData = 0;
res = IDirectInputDevice8_SetProperty(joy.di_joy, DIPROP_DEADZONE, &dilong.diph); res = IDirectInputDevice8_SetProperty(joy.di_joy, DIPROP_DEADZONE, &dilong.diph);
if (FAILED(res)) if (FAILED(res))
return; return;
joy.joy_axis.push_back(ofs); joy.joy_axis.push_back(ofs);
} }
} }
BOOL CALLBACK joystick_windows::enumCallback(const DIDEVICEINSTANCE* instance, void* pContext) { BOOL CALLBACK joystick_windows::enumCallback(const DIDEVICEINSTANCE* instance, void* pContext) {
joystick_windows* self = (joystick_windows*)pContext; joystick_windows* self = (joystick_windows*)pContext;
if (self->is_xinput_device(&instance->guidProduct)) {; if (self->is_xinput_device(&instance->guidProduct)) {;
return DIENUM_CONTINUE; return DIENUM_CONTINUE;
} }
self->setup_dinput_joystick(instance); self->setup_dinput_joystick(instance);
return DIENUM_CONTINUE; return DIENUM_CONTINUE;
} }
BOOL CALLBACK joystick_windows::objectsCallback(const DIDEVICEOBJECTINSTANCE *instance, void *context) { BOOL CALLBACK joystick_windows::objectsCallback(const DIDEVICEOBJECTINSTANCE *instance, void *context) {
joystick_windows* self = (joystick_windows*)context; joystick_windows* self = (joystick_windows*)context;
self->setup_joystick_object(instance, self->id_to_change); self->setup_joystick_object(instance, self->id_to_change);
return DIENUM_CONTINUE; return DIENUM_CONTINUE;
} }
void joystick_windows::close_joystick(int id) { void joystick_windows::close_joystick(int id) {
if (id == -1) { if (id == -1) {
for (int i = 0; i < JOYSTICKS_MAX; i++) { for (int i = 0; i < JOYSTICKS_MAX; i++) {
close_joystick(i); close_joystick(i);
} }
return; return;
} }
if (!d_joysticks[id].attached) return; if (!d_joysticks[id].attached) return;
d_joysticks[id].di_joy->Unacquire(); d_joysticks[id].di_joy->Unacquire();
d_joysticks[id].di_joy->Release(); d_joysticks[id].di_joy->Release();
d_joysticks[id].attached = false; d_joysticks[id].attached = false;
attached_joysticks[d_joysticks[id].id] = false; attached_joysticks[d_joysticks[id].id] = false;
d_joysticks[id].guid.Data1 = d_joysticks[id].guid.Data2 = d_joysticks[id].guid.Data3 = 0; d_joysticks[id].guid.Data1 = d_joysticks[id].guid.Data2 = d_joysticks[id].guid.Data3 = 0;
input->joy_connection_changed(id, false, ""); input->joy_connection_changed(id, false, "");
joystick_count--; joystick_count--;
} }
void joystick_windows::probe_joysticks() { void joystick_windows::probe_joysticks() {
DWORD dwResult; DWORD dwResult;
for (DWORD i = 0; i < XUSER_MAX_COUNT; i++) { for (DWORD i = 0; i < XUSER_MAX_COUNT; i++) {
ZeroMemory(&x_joysticks[i].state, sizeof(XINPUT_STATE)); ZeroMemory(&x_joysticks[i].state, sizeof(XINPUT_STATE));
dwResult = xinput_get_state(i, &x_joysticks[i].state); dwResult = xinput_get_state(i, &x_joysticks[i].state);
if ( dwResult == ERROR_SUCCESS) { if ( dwResult == ERROR_SUCCESS) {
int id = check_free_joy_slot(); int id = check_free_joy_slot();
if (id != -1 && !x_joysticks[i].attached) { if (id != -1 && !x_joysticks[i].attached) {
x_joysticks[i].attached = true; x_joysticks[i].attached = true;
x_joysticks[i].id = id; x_joysticks[i].id = id;
attached_joysticks[id] = true; attached_joysticks[id] = true;
input->joy_connection_changed(id, true, "XInput Gamepad","__XINPUT_DEVICE__"); input->joy_connection_changed(id, true, "XInput Gamepad","__XINPUT_DEVICE__");
} }
} }
else if (x_joysticks[i].attached) { else if (x_joysticks[i].attached) {
x_joysticks[i].attached = false; x_joysticks[i].attached = false;
attached_joysticks[x_joysticks[i].id] = false; attached_joysticks[x_joysticks[i].id] = false;
input->joy_connection_changed(x_joysticks[i].id, false, ""); input->joy_connection_changed(x_joysticks[i].id, false, "");
} }
} }
for (int i = 0; i < joystick_count; i++) { for (int i = 0; i < joystick_count; i++) {
d_joysticks[i].confirmed = false; d_joysticks[i].confirmed = false;
} }
dinput->EnumDevices(DI8DEVCLASS_GAMECTRL, enumCallback, this, DIEDFL_ATTACHEDONLY); dinput->EnumDevices(DI8DEVCLASS_GAMECTRL, enumCallback, this, DIEDFL_ATTACHEDONLY);
for (int i = 0; i < joystick_count; i++) { for (int i = 0; i < joystick_count; i++) {
if (!d_joysticks[i].confirmed) { if (!d_joysticks[i].confirmed) {
close_joystick(i); close_joystick(i);
} }
} }
} }
unsigned int joystick_windows::process_joysticks(unsigned int p_last_id) { unsigned int joystick_windows::process_joysticks(unsigned int p_last_id) {
HRESULT hr; HRESULT hr;
for (int i = 0; i < XUSER_MAX_COUNT; i++) { for (int i = 0; i < XUSER_MAX_COUNT; i++) {
xinput_gamepad &joy = x_joysticks[i]; xinput_gamepad &joy = x_joysticks[i];
if (!joy.attached) { if (!joy.attached) {
continue; continue;
} }
ZeroMemory(&joy.state, sizeof(XINPUT_STATE)); ZeroMemory(&joy.state, sizeof(XINPUT_STATE));
xinput_get_state(i, &joy.state); xinput_get_state(i, &joy.state);
if (joy.state.dwPacketNumber != joy.last_packet) { if (joy.state.dwPacketNumber != joy.last_packet) {
int button_mask = XINPUT_GAMEPAD_DPAD_UP; int button_mask = XINPUT_GAMEPAD_DPAD_UP;
for (int i = 0; i <= 16; i++) { for (int i = 0; i <= 16; i++) {
p_last_id = input->joy_button(p_last_id, joy.id, i, joy.state.Gamepad.wButtons & button_mask); p_last_id = input->joy_button(p_last_id, joy.id, i, joy.state.Gamepad.wButtons & button_mask);
button_mask = button_mask * 2; button_mask = button_mask * 2;
} }
p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_0, axis_correct(joy.state.Gamepad.sThumbLX, true)); p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_0, axis_correct(joy.state.Gamepad.sThumbLX, true));
p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_1, axis_correct(joy.state.Gamepad.sThumbLY, true, false, true)); p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_1, axis_correct(joy.state.Gamepad.sThumbLY, true, false, true));
p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_2, axis_correct(joy.state.Gamepad.sThumbRX, true)); p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_2, axis_correct(joy.state.Gamepad.sThumbRX, true));
p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_3, axis_correct(joy.state.Gamepad.sThumbRY, true, false, true)); p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_3, axis_correct(joy.state.Gamepad.sThumbRY, true, false, true));
p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_4, axis_correct(joy.state.Gamepad.bLeftTrigger, true, true)); p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_4, axis_correct(joy.state.Gamepad.bLeftTrigger, true, true));
p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_5, axis_correct(joy.state.Gamepad.bRightTrigger, true, true)); p_last_id = input->joy_axis(p_last_id, joy.id, JOY_AXIS_5, axis_correct(joy.state.Gamepad.bRightTrigger, true, true));
joy.last_packet = joy.state.dwPacketNumber; joy.last_packet = joy.state.dwPacketNumber;
} }
} }
for (int i = 0; i < JOYSTICKS_MAX; i++) { for (int i = 0; i < JOYSTICKS_MAX; i++) {
dinput_gamepad* joy = &d_joysticks[i]; dinput_gamepad* joy = &d_joysticks[i];
if (!joy->attached) if (!joy->attached)
continue; continue;
DIJOYSTATE2 js; DIJOYSTATE2 js;
hr = joy->di_joy->Poll(); hr = joy->di_joy->Poll();
if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) { if (hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED) {
IDirectInputDevice8_Acquire(joy->di_joy); IDirectInputDevice8_Acquire(joy->di_joy);
joy->di_joy->Poll(); joy->di_joy->Poll();
} }
if (FAILED(hr = d_joysticks[i].di_joy->GetDeviceState(sizeof(DIJOYSTATE2), &js))) { if (FAILED(hr = d_joysticks[i].di_joy->GetDeviceState(sizeof(DIJOYSTATE2), &js))) {
//printf("failed to read joy #%d\n", i); //printf("failed to read joy #%d\n", i);
continue; continue;
} }
p_last_id = post_hat(p_last_id, i, js.rgdwPOV[0]); p_last_id = post_hat(p_last_id, i, js.rgdwPOV[0]);
for (int j = 0; j < 128; j++) { for (int j = 0; j < 128; j++) {
if (js.rgbButtons[j] & 0x80) { if (js.rgbButtons[j] & 0x80) {
if (!joy->last_buttons[j]) { if (!joy->last_buttons[j]) {
p_last_id = input->joy_button(p_last_id, i, j, true); p_last_id = input->joy_button(p_last_id, i, j, true);
joy->last_buttons[j] = true; joy->last_buttons[j] = true;
} }
} }
else { else {
if (joy->last_buttons[j]) { if (joy->last_buttons[j]) {
p_last_id = input->joy_button(p_last_id, i, j, false); p_last_id = input->joy_button(p_last_id, i, j, false);
joy->last_buttons[j] = false; joy->last_buttons[j] = false;
} }
} }
} }
// on mingw, these constants are not constants // on mingw, these constants are not constants
int count = 6; int count = 6;
@@ -407,122 +407,122 @@ unsigned int joystick_windows::process_joysticks(unsigned int p_last_id) {
}; };
}; };
}; };
} }
return p_last_id; return p_last_id;
} }
unsigned int joystick_windows::post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad) { unsigned int joystick_windows::post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad) {
int dpad_val = 0; int dpad_val = 0;
if (p_dpad == -1) { if (p_dpad == -1) {
dpad_val = InputDefault::HAT_MASK_CENTER; dpad_val = InputDefault::HAT_MASK_CENTER;
} }
if (p_dpad == 0) { if (p_dpad == 0) {
dpad_val = InputDefault::HAT_MASK_UP; dpad_val = InputDefault::HAT_MASK_UP;
} }
else if (p_dpad == 4500) { else if (p_dpad == 4500) {
dpad_val = (InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_RIGHT); dpad_val = (InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_RIGHT);
} }
else if (p_dpad == 9000) { else if (p_dpad == 9000) {
dpad_val = InputDefault::HAT_MASK_RIGHT; dpad_val = InputDefault::HAT_MASK_RIGHT;
} }
else if (p_dpad == 13500) { else if (p_dpad == 13500) {
dpad_val = (InputDefault::HAT_MASK_RIGHT | InputDefault::HAT_MASK_DOWN); dpad_val = (InputDefault::HAT_MASK_RIGHT | InputDefault::HAT_MASK_DOWN);
} }
else if (p_dpad == 18000) { else if (p_dpad == 18000) {
dpad_val = InputDefault::HAT_MASK_DOWN; dpad_val = InputDefault::HAT_MASK_DOWN;
} }
else if (p_dpad == 22500) { else if (p_dpad == 22500) {
dpad_val = (InputDefault::HAT_MASK_DOWN | InputDefault::HAT_MASK_LEFT); dpad_val = (InputDefault::HAT_MASK_DOWN | InputDefault::HAT_MASK_LEFT);
} }
else if (p_dpad == 27000) { else if (p_dpad == 27000) {
dpad_val = InputDefault::HAT_MASK_LEFT; dpad_val = InputDefault::HAT_MASK_LEFT;
} }
else if (p_dpad == 31500) { else if (p_dpad == 31500) {
dpad_val = (InputDefault::HAT_MASK_LEFT | InputDefault::HAT_MASK_UP); dpad_val = (InputDefault::HAT_MASK_LEFT | InputDefault::HAT_MASK_UP);
} }
return input->joy_hat(p_last_id, p_device, dpad_val); return input->joy_hat(p_last_id, p_device, dpad_val);
}; };
InputDefault::JoyAxis joystick_windows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const { InputDefault::JoyAxis joystick_windows::axis_correct(int p_val, bool p_xinput, bool p_trigger, bool p_negate) const {
InputDefault::JoyAxis jx; InputDefault::JoyAxis jx;
if (Math::abs(p_val) < MIN_JOY_AXIS) { if (Math::abs(p_val) < MIN_JOY_AXIS) {
jx.min = -1; jx.min = -1;
jx.value = 0.0f; jx.value = 0.0f;
return jx; return jx;
} }
if (p_xinput) { if (p_xinput) {
if (p_trigger) { if (p_trigger) {
jx.min = 0; jx.min = 0;
jx.value = (float)p_val / MAX_TRIGGER; jx.value = (float)p_val / MAX_TRIGGER;
return jx; return jx;
} }
jx.min = -1; jx.min = -1;
if (p_val < 0) { if (p_val < 0) {
jx.value = (float)p_val / MAX_JOY_AXIS; jx.value = (float)p_val / MAX_JOY_AXIS;
} }
else { else {
jx.value = (float)p_val / (MAX_JOY_AXIS - 1); jx.value = (float)p_val / (MAX_JOY_AXIS - 1);
} }
if (p_negate) { if (p_negate) {
jx.value = -jx.value; jx.value = -jx.value;
} }
return jx; return jx;
} }
jx.min = -1; jx.min = -1;
jx.value = (float)p_val / MAX_JOY_AXIS; jx.value = (float)p_val / MAX_JOY_AXIS;
return jx; return jx;
} }
void joystick_windows::load_xinput() { void joystick_windows::load_xinput() {
xinput_get_state = &_xinput_get_state; xinput_get_state = &_xinput_get_state;
xinput_dll = LoadLibrary( "XInput1_4.dll" ); xinput_dll = LoadLibrary( "XInput1_4.dll" );
if (!xinput_dll) { if (!xinput_dll) {
xinput_dll = LoadLibrary("XInput1_3.dll"); xinput_dll = LoadLibrary("XInput1_3.dll");
if (!xinput_dll) { if (!xinput_dll) {
xinput_dll = LoadLibrary("XInput9_1_0.dll"); xinput_dll = LoadLibrary("XInput9_1_0.dll");
} }
} }
if (!xinput_dll) { if (!xinput_dll) {
if (OS::get_singleton()->is_stdout_verbose()) { if (OS::get_singleton()->is_stdout_verbose()) {
print_line("Could not find XInput, using DirectInput only"); print_line("Could not find XInput, using DirectInput only");
} }
return; return;
} }
XInputGetState_t func = (XInputGetState_t)GetProcAddress((HMODULE)xinput_dll, "XInputGetState"); XInputGetState_t func = (XInputGetState_t)GetProcAddress((HMODULE)xinput_dll, "XInputGetState");
if (!func) { if (!func) {
unload_xinput(); unload_xinput();
return; return;
} }
xinput_get_state = func; xinput_get_state = func;
return; return;
} }
void joystick_windows::unload_xinput() { void joystick_windows::unload_xinput() {
if (xinput_dll) { if (xinput_dll) {
FreeLibrary((HMODULE)xinput_dll); FreeLibrary((HMODULE)xinput_dll);
} }
} }

View File

@@ -48,90 +48,90 @@ if(x != NULL) \
class joystick_windows class joystick_windows
{ {
public: public:
joystick_windows(); joystick_windows();
joystick_windows(InputDefault* _input, HWND* hwnd); joystick_windows(InputDefault* _input, HWND* hwnd);
~joystick_windows(); ~joystick_windows();
void probe_joysticks(); void probe_joysticks();
unsigned int process_joysticks(unsigned int p_last_id); unsigned int process_joysticks(unsigned int p_last_id);
private: private:
enum { enum {
JOYSTICKS_MAX = 16, JOYSTICKS_MAX = 16,
JOY_AXIS_COUNT = 6, JOY_AXIS_COUNT = 6,
MIN_JOY_AXIS = 10, MIN_JOY_AXIS = 10,
MAX_JOY_AXIS = 32768, MAX_JOY_AXIS = 32768,
MAX_JOY_BUTTONS = 128, MAX_JOY_BUTTONS = 128,
KEY_EVENT_BUFFER_SIZE = 512, KEY_EVENT_BUFFER_SIZE = 512,
MAX_TRIGGER = 255 MAX_TRIGGER = 255
}; };
struct dinput_gamepad { struct dinput_gamepad {
int id; int id;
bool attached; bool attached;
bool confirmed; bool confirmed;
bool last_buttons[MAX_JOY_BUTTONS]; bool last_buttons[MAX_JOY_BUTTONS];
DWORD last_pad; DWORD last_pad;
LPDIRECTINPUTDEVICE8 di_joy; LPDIRECTINPUTDEVICE8 di_joy;
List<DWORD> joy_axis; List<DWORD> joy_axis;
GUID guid; GUID guid;
dinput_gamepad() { dinput_gamepad() {
id = -1; id = -1;
last_pad = -1; last_pad = -1;
attached = false; attached = false;
confirmed = false; confirmed = false;
for (int i = 0; i < MAX_JOY_BUTTONS; i++) for (int i = 0; i < MAX_JOY_BUTTONS; i++)
last_buttons[i] = false; last_buttons[i] = false;
} }
}; };
struct xinput_gamepad { struct xinput_gamepad {
int id; int id;
bool attached; bool attached;
DWORD last_packet; DWORD last_packet;
XINPUT_STATE state; XINPUT_STATE state;
xinput_gamepad() { xinput_gamepad() {
attached = false; attached = false;
last_packet = 0; last_packet = 0;
} }
}; };
typedef DWORD (WINAPI *XInputGetState_t) (DWORD dwUserIndex, XINPUT_STATE* pState); typedef DWORD (WINAPI *XInputGetState_t) (DWORD dwUserIndex, XINPUT_STATE* pState);
HWND* hWnd; HWND* hWnd;
HANDLE xinput_dll; HANDLE xinput_dll;
LPDIRECTINPUT8 dinput; LPDIRECTINPUT8 dinput;
InputDefault* input; InputDefault* input;
int id_to_change; int id_to_change;
int joystick_count; int joystick_count;
bool attached_joysticks[JOYSTICKS_MAX]; bool attached_joysticks[JOYSTICKS_MAX];
dinput_gamepad d_joysticks[JOYSTICKS_MAX]; dinput_gamepad d_joysticks[JOYSTICKS_MAX];
xinput_gamepad x_joysticks[XUSER_MAX_COUNT]; xinput_gamepad x_joysticks[XUSER_MAX_COUNT];
static BOOL CALLBACK enumCallback(const DIDEVICEINSTANCE* p_instance, void* p_context); static BOOL CALLBACK enumCallback(const DIDEVICEINSTANCE* p_instance, void* p_context);
static BOOL CALLBACK objectsCallback(const DIDEVICEOBJECTINSTANCE* instance, void* context); static BOOL CALLBACK objectsCallback(const DIDEVICEOBJECTINSTANCE* instance, void* context);
void setup_joystick_object(const DIDEVICEOBJECTINSTANCE* ob, int p_joy_id); void setup_joystick_object(const DIDEVICEOBJECTINSTANCE* ob, int p_joy_id);
void close_joystick(int id = -1); void close_joystick(int id = -1);
void load_xinput(); void load_xinput();
void unload_xinput(); void unload_xinput();
int check_free_joy_slot() const; int check_free_joy_slot() const;
unsigned int post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad); unsigned int post_hat(unsigned int p_last_id, int p_device, DWORD p_dpad);
bool have_device(const GUID &p_guid); bool have_device(const GUID &p_guid);
bool is_xinput_device(const GUID* p_guid); bool is_xinput_device(const GUID* p_guid);
bool setup_dinput_joystick(const DIDEVICEINSTANCE* instance); bool setup_dinput_joystick(const DIDEVICEINSTANCE* instance);
InputDefault::JoyAxis axis_correct(int p_val, bool p_xinput = false, bool p_trigger = false, bool p_negate = false) const; InputDefault::JoyAxis axis_correct(int p_val, bool p_xinput = false, bool p_trigger = false, bool p_negate = false) const;
XInputGetState_t xinput_get_state; XInputGetState_t xinput_get_state;
}; };
#endif #endif

View File

@@ -43,360 +43,360 @@
static const char* ignore_str = "/dev/input/js"; static const char* ignore_str = "/dev/input/js";
joystick_linux::Joystick::Joystick() { joystick_linux::Joystick::Joystick() {
fd = -1; fd = -1;
dpad = 0; dpad = 0;
} }
void joystick_linux::Joystick::reset() { void joystick_linux::Joystick::reset() {
num_buttons = 0; num_buttons = 0;
num_axes = 0; num_axes = 0;
dpad = 0; dpad = 0;
fd = -1; fd = -1;
for (int i=0; i < MAX_ABS; i++) { for (int i=0; i < MAX_ABS; i++) {
abs_map[i] = -1; abs_map[i] = -1;
} }
} }
joystick_linux::joystick_linux(InputDefault *in) joystick_linux::joystick_linux(InputDefault *in)
{ {
exit_udev = false; exit_udev = false;
input = in; input = in;
joy_mutex = Mutex::create(); joy_mutex = Mutex::create();
joy_thread = Thread::create(joy_thread_func, this); joy_thread = Thread::create(joy_thread_func, this);
} }
joystick_linux::~joystick_linux() { joystick_linux::~joystick_linux() {
exit_udev = true; exit_udev = true;
Thread::wait_to_finish(joy_thread); Thread::wait_to_finish(joy_thread);
close_joystick(); close_joystick();
} }
void joystick_linux::joy_thread_func(void *p_user) { void joystick_linux::joy_thread_func(void *p_user) {
if (p_user) { if (p_user) {
joystick_linux* joy = (joystick_linux*) p_user; joystick_linux* joy = (joystick_linux*) p_user;
joy->run_joystick_thread(); joy->run_joystick_thread();
} }
return; return;
} }
void joystick_linux::run_joystick_thread() { void joystick_linux::run_joystick_thread() {
udev *_udev = udev_new(); udev *_udev = udev_new();
ERR_FAIL_COND(!_udev); ERR_FAIL_COND(!_udev);
enumerate_joysticks(_udev); enumerate_joysticks(_udev);
monitor_joysticks(_udev); monitor_joysticks(_udev);
udev_unref(_udev); udev_unref(_udev);
} }
void joystick_linux::enumerate_joysticks(udev *p_udev) { void joystick_linux::enumerate_joysticks(udev *p_udev) {
udev_enumerate *enumerate; udev_enumerate *enumerate;
udev_list_entry *devices, *dev_list_entry; udev_list_entry *devices, *dev_list_entry;
udev_device *dev; udev_device *dev;
enumerate = udev_enumerate_new(p_udev); enumerate = udev_enumerate_new(p_udev);
udev_enumerate_add_match_subsystem(enumerate,"input"); udev_enumerate_add_match_subsystem(enumerate,"input");
udev_enumerate_add_match_property(enumerate, "ID_INPUT_JOYSTICK", "1"); udev_enumerate_add_match_property(enumerate, "ID_INPUT_JOYSTICK", "1");
udev_enumerate_scan_devices(enumerate); udev_enumerate_scan_devices(enumerate);
devices = udev_enumerate_get_list_entry(enumerate); devices = udev_enumerate_get_list_entry(enumerate);
udev_list_entry_foreach(dev_list_entry, devices) { udev_list_entry_foreach(dev_list_entry, devices) {
const char* path = udev_list_entry_get_name(dev_list_entry); const char* path = udev_list_entry_get_name(dev_list_entry);
dev = udev_device_new_from_syspath(p_udev, path); dev = udev_device_new_from_syspath(p_udev, path);
const char* devnode = udev_device_get_devnode(dev); const char* devnode = udev_device_get_devnode(dev);
if (devnode != NULL && strstr(devnode, ignore_str) == NULL) { if (devnode != NULL && strstr(devnode, ignore_str) == NULL) {
joy_mutex->lock(); joy_mutex->lock();
open_joystick(devnode); open_joystick(devnode);
joy_mutex->unlock(); joy_mutex->unlock();
} }
udev_device_unref(dev); udev_device_unref(dev);
} }
udev_enumerate_unref(enumerate); udev_enumerate_unref(enumerate);
} }
void joystick_linux::monitor_joysticks(udev *p_udev) { void joystick_linux::monitor_joysticks(udev *p_udev) {
udev_device *dev = NULL; udev_device *dev = NULL;
udev_monitor *mon = udev_monitor_new_from_netlink(p_udev, "udev"); udev_monitor *mon = udev_monitor_new_from_netlink(p_udev, "udev");
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL); udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
udev_monitor_enable_receiving(mon); udev_monitor_enable_receiving(mon);
int fd = udev_monitor_get_fd(mon); int fd = udev_monitor_get_fd(mon);
while (!exit_udev) { while (!exit_udev) {
fd_set fds; fd_set fds;
struct timeval tv; struct timeval tv;
int ret; int ret;
FD_ZERO(&fds); FD_ZERO(&fds);
FD_SET(fd, &fds); FD_SET(fd, &fds);
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 0; tv.tv_usec = 0;
ret = select(fd+1, &fds, NULL, NULL, &tv); ret = select(fd+1, &fds, NULL, NULL, &tv);
/* Check if our file descriptor has received data. */ /* Check if our file descriptor has received data. */
if (ret > 0 && FD_ISSET(fd, &fds)) { if (ret > 0 && FD_ISSET(fd, &fds)) {
/* Make the call to receive the device. /* Make the call to receive the device.
select() ensured that this will not block. */ select() ensured that this will not block. */
dev = udev_monitor_receive_device(mon); dev = udev_monitor_receive_device(mon);
if (dev && udev_device_get_devnode(dev) != 0) { if (dev && udev_device_get_devnode(dev) != 0) {
joy_mutex->lock(); joy_mutex->lock();
const char* action = udev_device_get_action(dev); const char* action = udev_device_get_action(dev);
const char* devnode = udev_device_get_devnode(dev); const char* devnode = udev_device_get_devnode(dev);
if (strstr(devnode, ignore_str) == NULL) { if (strstr(devnode, ignore_str) == NULL) {
if (strcmp(action, "add") == 0) if (strcmp(action, "add") == 0)
open_joystick(devnode); open_joystick(devnode);
else if (strcmp(action, "remove") == 0) else if (strcmp(action, "remove") == 0)
close_joystick(get_joy_from_path(devnode)); close_joystick(get_joy_from_path(devnode));
} }
udev_device_unref(dev); udev_device_unref(dev);
joy_mutex->unlock(); joy_mutex->unlock();
} }
} }
usleep(50000); usleep(50000);
} }
//printf("exit udev\n"); //printf("exit udev\n");
udev_monitor_unref(mon); udev_monitor_unref(mon);
} }
int joystick_linux::get_free_joy_slot() const { int joystick_linux::get_free_joy_slot() const {
for (int i = 0; i < JOYSTICKS_MAX; i++) { for (int i = 0; i < JOYSTICKS_MAX; i++) {
if (joysticks[i].fd == -1) return i; if (joysticks[i].fd == -1) return i;
} }
return -1; return -1;
} }
int joystick_linux::get_joy_from_path(String p_path) const { int joystick_linux::get_joy_from_path(String p_path) const {
for (int i = 0; i < JOYSTICKS_MAX; i++) { for (int i = 0; i < JOYSTICKS_MAX; i++) {
if (joysticks[i].devpath == p_path) { if (joysticks[i].devpath == p_path) {
return i; return i;
} }
} }
return -2; return -2;
} }
void joystick_linux::close_joystick(int p_id) { void joystick_linux::close_joystick(int p_id) {
if (p_id == -1) { if (p_id == -1) {
for (int i=0; i<JOYSTICKS_MAX; i++) { for (int i=0; i<JOYSTICKS_MAX; i++) {
close_joystick(i); close_joystick(i);
}; };
return; return;
} }
else if (p_id < 0) return; else if (p_id < 0) return;
Joystick &joy = joysticks[p_id]; Joystick &joy = joysticks[p_id];
if (joy.fd != -1) { if (joy.fd != -1) {
libevdev_free(joy.dev); libevdev_free(joy.dev);
close(joy.fd); close(joy.fd);
joy.fd = -1; joy.fd = -1;
input->joy_connection_changed(p_id, false, ""); input->joy_connection_changed(p_id, false, "");
}; };
}; };
static String _hex_str(uint8_t p_byte) { static String _hex_str(uint8_t p_byte) {
static const char* dict = "0123456789abcdef"; static const char* dict = "0123456789abcdef";
char ret[3]; char ret[3];
ret[2] = 0; ret[2] = 0;
ret[0] = dict[p_byte>>4]; ret[0] = dict[p_byte>>4];
ret[1] = dict[p_byte & 0xF]; ret[1] = dict[p_byte & 0xF];
return ret; return ret;
}; };
void joystick_linux::setup_joystick_properties(int p_id) { void joystick_linux::setup_joystick_properties(int p_id) {
Joystick* joy = &joysticks[p_id]; Joystick* joy = &joysticks[p_id];
libevdev* dev = joy->dev; libevdev* dev = joy->dev;
for (int i = BTN_JOYSTICK; i < KEY_MAX; ++i) { for (int i = BTN_JOYSTICK; i < KEY_MAX; ++i) {
if (libevdev_has_event_code(dev, EV_KEY, i)) { if (libevdev_has_event_code(dev, EV_KEY, i)) {
joy->key_map[i] = joy->num_buttons++; joy->key_map[i] = joy->num_buttons++;
} }
} }
for (int i = BTN_MISC; i < BTN_JOYSTICK; ++i) { for (int i = BTN_MISC; i < BTN_JOYSTICK; ++i) {
if (libevdev_has_event_code(dev, EV_KEY, i)) { if (libevdev_has_event_code(dev, EV_KEY, i)) {
joy->key_map[i] = joy->num_buttons++; joy->key_map[i] = joy->num_buttons++;
} }
} }
for (int i = 0; i < ABS_MISC; ++i) { for (int i = 0; i < ABS_MISC; ++i) {
/* Skip hats */ /* Skip hats */
if (i == ABS_HAT0X) { if (i == ABS_HAT0X) {
i = ABS_HAT3Y; i = ABS_HAT3Y;
continue; continue;
} }
if (libevdev_has_event_code(dev, EV_ABS, i)) { if (libevdev_has_event_code(dev, EV_ABS, i)) {
joy->abs_map[i] = joy->num_axes++; joy->abs_map[i] = joy->num_axes++;
} }
} }
} }
void joystick_linux::open_joystick(const char *p_path) { void joystick_linux::open_joystick(const char *p_path) {
int joy_num = get_free_joy_slot(); int joy_num = get_free_joy_slot();
int fd = open(p_path, O_RDONLY | O_NONBLOCK); int fd = open(p_path, O_RDONLY | O_NONBLOCK);
if (fd != -1 && joy_num != -1) { if (fd != -1 && joy_num != -1) {
int rc = libevdev_new_from_fd(fd, &joysticks[joy_num].dev); int rc = libevdev_new_from_fd(fd, &joysticks[joy_num].dev);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "Failed to init libevdev (%s)\n", strerror(-rc)); fprintf(stderr, "Failed to init libevdev (%s)\n", strerror(-rc));
return; return;
} }
libevdev *dev = joysticks[joy_num].dev; libevdev *dev = joysticks[joy_num].dev;
//check if the device supports basic gamepad events, prevents certain keyboards from //check if the device supports basic gamepad events, prevents certain keyboards from
//being detected as joysticks //being detected as joysticks
if (libevdev_has_event_type(dev, EV_ABS) && libevdev_has_event_type(dev, EV_KEY) && if (libevdev_has_event_type(dev, EV_ABS) && libevdev_has_event_type(dev, EV_KEY) &&
(libevdev_has_event_code(dev, EV_KEY, BTN_A) || libevdev_has_event_code(dev, EV_KEY, BTN_THUMBL) || libevdev_has_event_code(dev, EV_KEY, BTN_TOP))) { (libevdev_has_event_code(dev, EV_KEY, BTN_A) || libevdev_has_event_code(dev, EV_KEY, BTN_THUMBL) || libevdev_has_event_code(dev, EV_KEY, BTN_TOP))) {
char uid[128]; char uid[128];
String name = libevdev_get_name(dev); String name = libevdev_get_name(dev);
uint16_t bus = __bswap_16(libevdev_get_id_bustype(dev)); uint16_t bus = __bswap_16(libevdev_get_id_bustype(dev));
uint16_t vendor = __bswap_16(libevdev_get_id_vendor(dev)); uint16_t vendor = __bswap_16(libevdev_get_id_vendor(dev));
uint16_t product = __bswap_16(libevdev_get_id_product(dev)); uint16_t product = __bswap_16(libevdev_get_id_product(dev));
uint16_t version = __bswap_16(libevdev_get_id_version(dev)); uint16_t version = __bswap_16(libevdev_get_id_version(dev));
joysticks[joy_num].reset(); joysticks[joy_num].reset();
Joystick &joy = joysticks[joy_num]; Joystick &joy = joysticks[joy_num];
joy.fd = fd; joy.fd = fd;
joy.devpath = String(p_path); joy.devpath = String(p_path);
setup_joystick_properties(joy_num); setup_joystick_properties(joy_num);
sprintf(uid, "%04x%04x", bus, 0); sprintf(uid, "%04x%04x", bus, 0);
if (vendor && product && version) { if (vendor && product && version) {
sprintf(uid + String(uid).length(), "%04x%04x%04x%04x%04x%04x", vendor,0,product,0,version,0); sprintf(uid + String(uid).length(), "%04x%04x%04x%04x%04x%04x", vendor,0,product,0,version,0);
input->joy_connection_changed(joy_num, true, name, uid); input->joy_connection_changed(joy_num, true, name, uid);
} }
else { else {
String uidname = uid; String uidname = uid;
int uidlen = MIN(name.length(), 11); int uidlen = MIN(name.length(), 11);
for (int i=0; i<uidlen; i++) { for (int i=0; i<uidlen; i++) {
uidname = uidname + _hex_str(name[i]); uidname = uidname + _hex_str(name[i]);
} }
uidname += "00"; uidname += "00";
input->joy_connection_changed(joy_num, true, name, uidname); input->joy_connection_changed(joy_num, true, name, uidname);
} }
} }
else { else {
//device is not a gamepad, clean up //device is not a gamepad, clean up
libevdev_free(dev); libevdev_free(dev);
close(fd); close(fd);
} }
} }
} }
InputDefault::JoyAxis joystick_linux::axis_correct(const input_absinfo *p_abs, int p_value) const { InputDefault::JoyAxis joystick_linux::axis_correct(const input_absinfo *p_abs, int p_value) const {
int min = p_abs->minimum; int min = p_abs->minimum;
int max = p_abs->maximum; int max = p_abs->maximum;
InputDefault::JoyAxis jx; InputDefault::JoyAxis jx;
if (min < 0) { if (min < 0) {
jx.min = -1; jx.min = -1;
if (p_value < 0) { if (p_value < 0) {
jx.value = (float) -p_value / min; jx.value = (float) -p_value / min;
} }
jx.value = (float) p_value / max; jx.value = (float) p_value / max;
} }
if (min == 0) { if (min == 0) {
jx.min = 0; jx.min = 0;
jx.value = 0.0f + (float) p_value / max; jx.value = 0.0f + (float) p_value / max;
} }
return jx; return jx;
} }
uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) { uint32_t joystick_linux::process_joysticks(uint32_t p_event_id) {
if (joy_mutex->try_lock() != OK) { if (joy_mutex->try_lock() != OK) {
return p_event_id; return p_event_id;
} }
for (int i=0; i<JOYSTICKS_MAX; i++) { for (int i=0; i<JOYSTICKS_MAX; i++) {
if (joysticks[i].fd == -1) continue; if (joysticks[i].fd == -1) continue;
input_event ev; input_event ev;
Joystick* joy = &joysticks[i]; Joystick* joy = &joysticks[i];
libevdev* dev = joy->dev; libevdev* dev = joy->dev;
int rc = 1; int rc = 1;
rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev); rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
if (rc < 0 && rc != -EAGAIN) { if (rc < 0 && rc != -EAGAIN) {
continue; continue;
} }
while (rc == LIBEVDEV_READ_STATUS_SYNC || rc == LIBEVDEV_READ_STATUS_SUCCESS) { while (rc == LIBEVDEV_READ_STATUS_SYNC || rc == LIBEVDEV_READ_STATUS_SUCCESS) {
switch (ev.type) { switch (ev.type) {
case EV_KEY: case EV_KEY:
p_event_id = input->joy_button(p_event_id, i, joy->key_map[ev.code], ev.value); p_event_id = input->joy_button(p_event_id, i, joy->key_map[ev.code], ev.value);
break; break;
case EV_ABS: case EV_ABS:
switch (ev.code) { switch (ev.code) {
case ABS_HAT0X: case ABS_HAT0X:
if (ev.value != 0) { if (ev.value != 0) {
if (ev.value < 0) joy->dpad |= InputDefault::HAT_MASK_LEFT; if (ev.value < 0) joy->dpad |= InputDefault::HAT_MASK_LEFT;
else joy->dpad |= InputDefault::HAT_MASK_RIGHT; else joy->dpad |= InputDefault::HAT_MASK_RIGHT;
} }
else joy->dpad &= ~(InputDefault::HAT_MASK_LEFT | InputDefault::HAT_MASK_RIGHT); else joy->dpad &= ~(InputDefault::HAT_MASK_LEFT | InputDefault::HAT_MASK_RIGHT);
p_event_id = input->joy_hat(p_event_id, i, joy->dpad); p_event_id = input->joy_hat(p_event_id, i, joy->dpad);
break; break;
case ABS_HAT0Y: case ABS_HAT0Y:
if (ev.value != 0) { if (ev.value != 0) {
if (ev.value < 0) joy->dpad |= InputDefault::HAT_MASK_UP; if (ev.value < 0) joy->dpad |= InputDefault::HAT_MASK_UP;
else joy->dpad |= InputDefault::HAT_MASK_DOWN; else joy->dpad |= InputDefault::HAT_MASK_DOWN;
} }
else joy->dpad &= ~(InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_DOWN); else joy->dpad &= ~(InputDefault::HAT_MASK_UP | InputDefault::HAT_MASK_DOWN);
p_event_id = input->joy_hat(p_event_id, i, joy->dpad); p_event_id = input->joy_hat(p_event_id, i, joy->dpad);
break; break;
default: default:
if (joy->abs_map[ev.code] != -1) { if (joy->abs_map[ev.code] != -1) {
InputDefault::JoyAxis value = axis_correct(libevdev_get_abs_info(dev, ev.code), ev.value); InputDefault::JoyAxis value = axis_correct(libevdev_get_abs_info(dev, ev.code), ev.value);
p_event_id = input->joy_axis(p_event_id, i, joy->abs_map[ev.code], value); p_event_id = input->joy_axis(p_event_id, i, joy->abs_map[ev.code], value);
} }
break; break;
} }
break; break;
} }
rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev); rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
} }
} }
joy_mutex->unlock(); joy_mutex->unlock();
return p_event_id; return p_event_id;
} }
#endif #endif

View File

@@ -40,53 +40,53 @@ struct input_absinfo;
class joystick_linux class joystick_linux
{ {
public: public:
joystick_linux(InputDefault *in); joystick_linux(InputDefault *in);
~joystick_linux(); ~joystick_linux();
uint32_t process_joysticks(uint32_t p_event_id); uint32_t process_joysticks(uint32_t p_event_id);
private: private:
enum { enum {
JOYSTICKS_MAX = 16, JOYSTICKS_MAX = 16,
MAX_ABS = 63, MAX_ABS = 63,
MAX_KEY = 767, // Hack because <linux/input.h> can't be included here MAX_KEY = 767, // Hack because <linux/input.h> can't be included here
BT_MISC = 256, BT_MISC = 256,
HAT_MAX = 4, HAT_MAX = 4,
}; };
struct Joystick { struct Joystick {
int key_map[MAX_KEY - BT_MISC]; int key_map[MAX_KEY - BT_MISC];
int abs_map[MAX_ABS]; int abs_map[MAX_ABS];
int num_buttons; int num_buttons;
int num_axes; int num_axes;
int dpad; int dpad;
int fd; int fd;
String devpath; String devpath;
struct libevdev *dev; struct libevdev *dev;
Joystick(); Joystick();
void reset(); void reset();
}; };
bool exit_udev; bool exit_udev;
Mutex *joy_mutex; Mutex *joy_mutex;
Thread *joy_thread; Thread *joy_thread;
InputDefault *input; InputDefault *input;
Joystick joysticks[JOYSTICKS_MAX]; Joystick joysticks[JOYSTICKS_MAX];
static void joy_thread_func(void *p_user); static void joy_thread_func(void *p_user);
int get_joy_from_path(String path) const; int get_joy_from_path(String path) const;
int get_free_joy_slot() const; int get_free_joy_slot() const;
void setup_joystick_properties(int p_id); void setup_joystick_properties(int p_id);
void close_joystick(int p_id = -1); void close_joystick(int p_id = -1);
void enumerate_joysticks(struct udev *_udev); void enumerate_joysticks(struct udev *_udev);
void monitor_joysticks(struct udev *_udev); void monitor_joysticks(struct udev *_udev);
void run_joystick_thread(); void run_joystick_thread();
void open_joystick(const char* path); void open_joystick(const char* path);
InputDefault::JoyAxis axis_correct(const input_absinfo *abs, int value) const; InputDefault::JoyAxis axis_correct(const input_absinfo *abs, int value) const;
}; };
#endif #endif