1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-16 14:00:40 +00:00

Merge pull request #111503 from JestemStefan/fix_111176

Fix `Input.is_joy_known` response for SDL joypads
This commit is contained in:
Thaddeus Crews
2025-11-12 17:26:22 -06:00
3 changed files with 11 additions and 9 deletions

View File

@@ -656,10 +656,16 @@ void Input::joy_connection_changed(int p_idx, bool p_connected, const String &p_
int mapping = fallback_mapping; int mapping = fallback_mapping;
// Bypass the mapping system if the joypad's mapping is already handled by its driver // Bypass the mapping system if the joypad's mapping is already handled by its driver
// (for example, the SDL joypad driver). // (for example, the SDL joypad driver).
if (!p_joypad_info.get("mapping_handled", false)) { if (p_joypad_info.get("mapping_handled", false)) {
js.is_known = true;
} else {
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;
if (mapping != fallback_mapping) {
js.is_known = true;
}
break;
} }
} }
} }
@@ -1877,13 +1883,7 @@ void Input::set_fallback_mapping(const String &p_guid) {
//platforms that use the remapping system can override and call to these ones //platforms that use the remapping system can override and call to these ones
bool Input::is_joy_known(int p_device) { bool Input::is_joy_known(int p_device) {
if (joy_names.has(p_device)) { return joy_names.has(p_device) && joy_names[p_device].is_known;
int mapping = joy_names[p_device].mapping;
if (mapping != -1 && mapping != fallback_mapping) {
return true;
}
}
return false;
} }
String Input::get_joy_guid(int p_device) const { String Input::get_joy_guid(int p_device) const {

View File

@@ -177,6 +177,7 @@ private:
StringName name; StringName name;
StringName uid; StringName uid;
bool connected = false; bool connected = false;
bool is_known = false;
bool last_buttons[(size_t)JoyButton::MAX] = { false }; bool last_buttons[(size_t)JoyButton::MAX] = { false };
float last_axis[(size_t)JoyAxis::MAX] = { 0.0f }; float last_axis[(size_t)JoyAxis::MAX] = { 0.0f };
HatMask last_hat = HatMask::CENTER; HatMask last_hat = HatMask::CENTER;

View File

@@ -186,7 +186,8 @@ void JoypadSDL::process_events() {
sdl_instance_id_to_joypad_id.insert(sdl_event.jdevice.which, joy_id); sdl_instance_id_to_joypad_id.insert(sdl_event.jdevice.which, joy_id);
Dictionary joypad_info; Dictionary joypad_info;
joypad_info["mapping_handled"] = true; // Skip Godot's mapping system because SDL already handles the joypad's mapping. // Skip Godot's mapping system if SDL already handles the joypad's mapping.
joypad_info["mapping_handled"] = SDL_IsGamepad(sdl_event.jdevice.which);
joypad_info["raw_name"] = String(SDL_GetJoystickName(joy)); joypad_info["raw_name"] = String(SDL_GetJoystickName(joy));
joypad_info["vendor_id"] = itos(SDL_GetJoystickVendor(joy)); joypad_info["vendor_id"] = itos(SDL_GetJoystickVendor(joy));
joypad_info["product_id"] = itos(SDL_GetJoystickProduct(joy)); joypad_info["product_id"] = itos(SDL_GetJoystickProduct(joy));