summaryrefslogtreecommitdiff
path: root/main/input_default.cpp
diff options
context:
space:
mode:
authorpunto- <ariel@godotengine.org>2016-01-26 09:21:28 -0300
committerpunto- <ariel@godotengine.org>2016-01-26 09:21:28 -0300
commit1c900b130b95e17396827e1a0c1a3aa60415ba4d (patch)
tree8e67330165a4ad4e43df55b308be865246d95e3b /main/input_default.cpp
parente4cb104e6daa9c2e5781535ac8790f406ae53f08 (diff)
parent4d17eca5043382f0e13fbddb5602f15c5ae5e355 (diff)
Merge pull request #3450 from Hinsbart/clear-joy-state
clear joystick state on disconnection
Diffstat (limited to 'main/input_default.cpp')
-rw-r--r--main/input_default.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp
index 4e5d753ea9..676ac85ada 100644
--- a/main/input_default.cpp
+++ b/main/input_default.cpp
@@ -140,7 +140,7 @@ static String _hex_str(uint8_t p_byte) {
void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid) {
_THREAD_SAFE_METHOD_
- Joystick js;
+ Joystick js;
js.name = p_connected ? p_name : "";
js.uid = p_connected ? p_guid : "";
js.mapping = -1;
@@ -165,6 +165,16 @@ void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_
};
};
js.mapping = mapping;
+ }
+ else {
+ for (int i = 0; i < JOY_BUTTON_MAX; i++) {
+
+ if (i < JOY_AXIS_MAX)
+ set_joy_axis(p_idx, i, 0.0f);
+
+ int c = _combine_device(i, p_idx);
+ joy_buttons_pressed.erase(c);
+ };
};
joy_names[p_idx] = js;