From 1ad6ca0a81e627bb5fe8b7c88f16213abbf6ddef Mon Sep 17 00:00:00 2001 From: hondres Date: Fri, 22 Jan 2016 22:56:05 +0100 Subject: add mappings and increase max number of buttons --- main/input_default.cpp | 9 ++++++--- main/input_default.h | 4 ++-- platform/javascript/os_javascript.cpp | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main/input_default.cpp b/main/input_default.cpp index 4bbb6b7807..4e5d753ea9 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -481,9 +481,12 @@ static const char *s_ControllerMappings [] = #ifdef JAVASCRIPT_ENABLED "Default HTML5 Gamepad, Default Mapping,leftx:a0,lefty:a1,dpdown:b13,rightstick:b11,rightshoulder:b5,rightx:a2,start:b9,righty:a3,dpleft:b14,lefttrigger:a6,x:b2,dpup:b12,back:b8,leftstick:b10,leftshoulder:b4,y:b3,a:b0,dpright:b15,righttrigger:a7,b:b1,", - "303534632d303236382d536f6e792050,PS3 Controller USB,leftx:a0,lefty:a1,dpdown:b6,rightstick:b2,rightshoulder:b11,rightx:a2,start:b3,righty:a3,dpleft:b7,lefttrigger:b8,x:b15,dpup:b4,back:b0,leftstick:b1,leftshoulder:b10,y:b12,a:b14,dpright:b5,righttrigger:b9,b:b13,", - "303534632d303563342d536f6e792043,PS4 Controller USB,leftx:a0,lefty:a1,dpdown:a7,rightstick:b11,rightshoulder:b5,rightx:a2,start:b9,righty:a5,dpleft:a6,lefttrigger:a3,x:b0,dpup:a7,back:b8,leftstick:b10,leftshoulder:b4,y:b3,a:b1,dpright:a6,righttrigger:a4,b:b2,", - "303435652d303238652d4d6963726f73,Nacon X360 Clone(XInput),leftx:a0,lefty:a1,dpdown:a7,rightstick:b10,rightshoulder:b5,rightx:a3,start:b7,righty:a4,dpleft:a6,lefttrigger:a2,x:b2,dpup:a7,back:b6,leftstick:b9,leftshoulder:b4,y:b3,a:b0,dpright:a6,righttrigger:a5,b:b1,", + "303534632d303236382d536f6e792050,PS3 Controller USB/Linux,leftx:a0,lefty:a1,dpdown:b6,rightstick:b2,rightshoulder:b11,rightx:a2,start:b3,righty:a3,dpleft:b7,lefttrigger:b8,x:b15,dpup:b4,back:b0,leftstick:b1,leftshoulder:b10,y:b12,a:b14,dpright:b5,righttrigger:b9,b:b13,", + "303534632d303563342d536f6e792043,PS4 Controller USB/Linux,leftx:a0,lefty:a1,dpdown:a7,rightstick:b11,rightshoulder:b5,rightx:a2,start:b9,righty:a5,dpleft:a6,lefttrigger:a3,x:b0,dpup:a7,back:b8,leftstick:b10,leftshoulder:b4,y:b3,a:b1,dpright:a6,righttrigger:a4,b:b2,", + "303534632d303563342d576972656c65,PS4 Controller USB/Win,leftx:a0,lefty:a1,dpdown:b15,rightstick:b11,rightshoulder:b5,rightx:a2,start:b9,righty:a5,lefttrigger:a3,x:b0,dpup:b14,dpleft:b16,dpright:b17,back:b8,leftstick:b10,leftshoulder:b4,y:b3,a:b1,righttrigger:b7,b:b2,", + "303435652d303238652d4d6963726f73,Wired X360 Controller,leftx:a0,lefty:a1,dpdown:a7,rightstick:b10,rightshoulder:b5,rightx:a3,start:b7,righty:a4,dpleft:a6,lefttrigger:a2,x:b2,dpup:a7,back:b6,leftstick:b9,leftshoulder:b4,y:b3,a:b0,dpright:a6,righttrigger:a5,b:b1,", + "303435652d303731392d58626f782033,Wireless X360 Controller,leftx:a0,lefty:a1,dpdown:b14,rightstick:b10,rightshoulder:b5,rightx:a3,start:b7,righty:a4,dpleft:b11,lefttrigger:a2,x:b2,dpup:b13,back:b6,leftstick:b9,leftshoulder:b4,y:b3,a:b0,dpright:b12,righttrigger:a5,b:b1,", + "c2a94d6963726f736f66742058626f78,Wireless X360 Controller,leftx:a0,lefty:a1,dpdown:b14,rightstick:b10,rightshoulder:b5,rightx:a3,start:b7,righty:a4,dpleft:b11,lefttrigger:a2,x:b2,dpup:b13,back:b6,leftstick:b9,leftshoulder:b4,y:b3,a:b0,dpright:b12,righttrigger:a5,b:b1,", #endif NULL }; diff --git a/main/input_default.h b/main/input_default.h index bbfd9ced2c..a75865e0cb 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -36,7 +36,7 @@ class InputDefault : public Input { struct Joystick { StringName name; StringName uid; - bool last_buttons[JOY_BUTTON_MAX]; + bool last_buttons[JOY_BUTTON_MAX + 2]; //html5 needs support for 18 buttons to map some devices correctly float last_axis[JOY_AXIS_MAX]; float filter; int last_hat; @@ -50,7 +50,7 @@ class InputDefault : public Input { last_axis[i] = 0.0f; } - for (int i = 0; i < JOY_BUTTON_MAX; i++) { + for (int i = 0; i < JOY_BUTTON_MAX + 2; i++) { last_buttons[i] = false; } diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index ffbcd98240..562733ab89 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -623,7 +623,7 @@ void OS_JavaScript::process_joysticks() { emscripten_get_gamepad_status(i, &state); if (state.connected) { - int num_buttons = MIN(state.numButtons, 16); + int num_buttons = MIN(state.numButtons, 18); int num_axes = MIN(state.numAxes, 8); for (int j = 0; j < num_buttons; j++) { -- cgit v1.2.3