diff options
author | hondres <liu.gam3@gmail.com> | 2016-01-24 05:11:59 +0100 |
---|---|---|
committer | hondres <liu.gam3@gmail.com> | 2016-01-24 05:29:09 +0100 |
commit | e7c920fdbabd65a86864ec9610f895bee82f05ba (patch) | |
tree | d97aa6da8b4ff05a1164d0bdeadff4c83b3be1cd /main/input_default.cpp | |
parent | 6c27df8df609337867c108c5adb66174393e190b (diff) |
support gamepad remapping on android
Diffstat (limited to 'main/input_default.cpp')
-rw-r--r-- | main/input_default.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp index 4e5d753ea9..bafc227fb2 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -164,6 +164,12 @@ void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_ //printf("found mapping\n"); }; }; +#ifdef ANDROID_ENABLED + //Use a default mapping for Android, as we recieve events using indices of a SDL_GAMECONTROLLER. + //So we need to map those to our own joystick layout + if (mapping == -1) + mapping = 0; +#endif js.mapping = mapping; }; joy_names[p_idx] = js; @@ -513,6 +519,10 @@ InputDefault::InputDefault() { hat_map_default[HAT_LEFT].index = JOY_DPAD_LEFT; hat_map_default[HAT_LEFT].value = 0; +#ifdef ANDROID_ENABLED + //add the default mapping first, in case someone actually sets the env variable on their phone + parse_mapping("Default Android Gamepad,Default Controller,leftx:a0,lefty:a1,dpdown:h0.4,rightstick:b8,rightshoulder:b10,rightx:a2,start:b6,righty:a3,dpleft:h0.8,lefttrigger:a4,x:b2,dpup:h0.1,back:b4,leftstick:b7,leftshoulder:b9,y:b3,a:b0,dpright:h0.2,righttrigger:a5,b:b1,"); +#endif String env_mapping = OS::get_singleton()->get_environment("SDL_GAMECONTROLLERCONFIG"); if (env_mapping != "") { @@ -865,6 +875,10 @@ String InputDefault::get_joy_guid(int p_device) const { //platforms that use the remapping system can override and call to these ones bool InputDefault::is_joy_mapped(int p_device) { +#ifdef ANDROID_ENABLED + if (joy_names[p_device].mapping == 0) + return false; +#endif return joy_names[p_device].mapping != -1 ? true : false; } |