summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/input_default.cpp30
-rw-r--r--main/input_default.h2
-rw-r--r--platform/android/os_android.cpp2
3 files changed, 15 insertions, 19 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 51a6292b88..acb9de6a8a 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -476,6 +476,7 @@ static const char *s_ControllerMappings [] =
#endif
#if defined(__ANDROID__)
+ "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,",
"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
@@ -855,6 +856,16 @@ void InputDefault::remove_joy_mapping(String p_guid) {
}
}
+void InputDefault::set_fallback_mapping(String p_guid) {
+
+ for (int i = 0; i < map_db.size(); i++) {
+ if (map_db[i].uid == p_guid) {
+ fallback_mapping = i;
+ return;
+ }
+ }
+}
+
//Defaults to simple implementation for platforms with a fixed gamepad layout, like consoles.
bool InputDefault::is_joy_known(int p_device) {
@@ -867,25 +878,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) {
- if (joy_names[p_device].mapping == fallback_mapping)
- return false;
- return joy_names[p_device].mapping != -1 ? true : false;
+ int mapping = joy_names[p_device].mapping;
+ return mapping != -1 ? (mapping == fallback_mapping) : false;
}
String InputDefault::get_joy_guid_remapped(int p_device) const {
return joy_names[p_device].uid;
}
-
-void InputDefault::set_fallback_mapping(String p_mapping) {
-
- int prev_fallback = fallback_mapping;
- parse_mapping(p_mapping);
- fallback_mapping = map_db.size() -1;
-
- for (int i = 0; i < joy_names.size(); i++) {
- if (joy_names[i].mapping == prev_fallback) {
- joy_names[i].mapping = fallback_mapping;
- }
- }
-}
-
diff --git a/main/input_default.h b/main/input_default.h
index 7432a3715d..2f98d279d6 100644
--- a/main/input_default.h
+++ b/main/input_default.h
@@ -169,7 +169,7 @@ public:
bool is_joy_mapped(int p_device);
String get_joy_guid_remapped(int p_device) const;
- void set_fallback_mapping(String p_mapping);
+ void set_fallback_mapping(String p_guid);
InputDefault();
};
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp
index c80284afcf..1751334c9b 100644
--- a/platform/android/os_android.cpp
+++ b/platform/android/os_android.cpp
@@ -178,7 +178,7 @@ void OS_Android::initialize(const VideoMode& p_desired,int p_video_driver,int p_
physics_2d_server->init();
input = memnew( InputDefault );
- input->set_fallback_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,");
+ input->set_fallback_mapping("Default Android Gamepad");
}
void OS_Android::set_main_loop( MainLoop * p_main_loop ) {