You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
[Web] Poll controllers only if at least one is detected
Keeps the spirit of #105601
This commit is contained in:
@@ -829,6 +829,12 @@ void DisplayServerWeb::gamepad_callback(int p_index, int p_connected, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DisplayServerWeb::_gamepad_callback(int p_index, int p_connected, const String &p_id, const String &p_guid) {
|
void DisplayServerWeb::_gamepad_callback(int p_index, int p_connected, const String &p_id, const String &p_guid) {
|
||||||
|
if (p_connected) {
|
||||||
|
DisplayServerWeb::get_singleton()->gamepad_count += 1;
|
||||||
|
} else {
|
||||||
|
DisplayServerWeb::get_singleton()->gamepad_count -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
Input *input = Input::get_singleton();
|
Input *input = Input::get_singleton();
|
||||||
if (p_connected) {
|
if (p_connected) {
|
||||||
input->joy_connection_changed(p_index, true, p_id, p_guid);
|
input->joy_connection_changed(p_index, true, p_id, p_guid);
|
||||||
@@ -1432,8 +1438,11 @@ DisplayServer::VSyncMode DisplayServerWeb::window_get_vsync_mode(WindowID p_vsyn
|
|||||||
void DisplayServerWeb::process_events() {
|
void DisplayServerWeb::process_events() {
|
||||||
process_keys();
|
process_keys();
|
||||||
Input::get_singleton()->flush_buffered_events();
|
Input::get_singleton()->flush_buffered_events();
|
||||||
if (godot_js_input_gamepad_sample() == OK) {
|
|
||||||
process_joypads();
|
if (gamepad_count > 0) {
|
||||||
|
if (godot_js_input_gamepad_sample() == OK) {
|
||||||
|
process_joypads();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ private:
|
|||||||
bool swap_cancel_ok = false;
|
bool swap_cancel_ok = false;
|
||||||
NativeMenu *native_menu = nullptr;
|
NativeMenu *native_menu = nullptr;
|
||||||
|
|
||||||
|
int gamepad_count = 0;
|
||||||
|
|
||||||
MouseMode mouse_mode_base = MOUSE_MODE_VISIBLE;
|
MouseMode mouse_mode_base = MOUSE_MODE_VISIBLE;
|
||||||
MouseMode mouse_mode_override = MOUSE_MODE_VISIBLE;
|
MouseMode mouse_mode_override = MOUSE_MODE_VISIBLE;
|
||||||
bool mouse_mode_override_enabled = false;
|
bool mouse_mode_override_enabled = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user