summaryrefslogtreecommitdiffstats
path: root/editor
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-10-21 16:39:10 -0500
committerThaddeus Crews <repiteo@outlook.com>2024-10-21 16:39:10 -0500
commitecc2eb73fc7532b7352274fb8145850bafaf6c20 (patch)
treeb7a4ee45f8c5b75d174bb6ad2615988516a458f3 /editor
parent975f42227f3870db153ead3f90da95e4c32a6593 (diff)
parent916d480686e339746ac4fc89079c26fe72caad53 (diff)
downloadredot-engine-ecc2eb73fc7532b7352274fb8145850bafaf6c20.tar.gz
Merge pull request #97707 from Sauermann/fix-input-device-clash
Fix `InputEvent` device id clash
Diffstat (limited to 'editor')
-rw-r--r--editor/event_listener_line_edit.cpp2
-rw-r--r--editor/input_event_configuration_dialog.cpp15
2 files changed, 9 insertions, 8 deletions
diff --git a/editor/event_listener_line_edit.cpp b/editor/event_listener_line_edit.cpp
index a6b30233fc..8fde728027 100644
--- a/editor/event_listener_line_edit.cpp
+++ b/editor/event_listener_line_edit.cpp
@@ -121,7 +121,7 @@ String EventListenerLineEdit::get_event_text(const Ref<InputEvent> &p_event, boo
}
String EventListenerLineEdit::get_device_string(int p_device) {
- if (p_device == InputMap::ALL_DEVICES) {
+ if (p_device == InputEvent::DEVICE_ID_ALL_DEVICES) {
return TTR("All Devices");
}
return TTR("Device") + " " + itos(p_device);
diff --git a/editor/input_event_configuration_dialog.cpp b/editor/input_event_configuration_dialog.cpp
index c60197b96b..a2aeeb11bd 100644
--- a/editor/input_event_configuration_dialog.cpp
+++ b/editor/input_event_configuration_dialog.cpp
@@ -551,18 +551,18 @@ void InputEventConfigurationDialog::_input_list_item_selected() {
}
void InputEventConfigurationDialog::_device_selection_changed(int p_option_button_index) {
- // Subtract 1 as option index 0 corresponds to "All Devices" (value of -1)
- // and option index 1 corresponds to device 0, etc...
- event->set_device(p_option_button_index - 1);
+ // Option index 0 corresponds to "All Devices" (value of -3).
+ // Otherwise subtract 1 as option index 1 corresponds to device 0, etc...
+ event->set_device(p_option_button_index == 0 ? InputEvent::DEVICE_ID_ALL_DEVICES : p_option_button_index - 1);
event_as_text->set_text(EventListenerLineEdit::get_event_text(event, true));
}
void InputEventConfigurationDialog::_set_current_device(int p_device) {
- device_id_option->select(p_device + 1);
+ device_id_option->select(p_device == InputEvent::DEVICE_ID_ALL_DEVICES ? 0 : p_device + 1);
}
int InputEventConfigurationDialog::_get_current_device() const {
- return device_id_option->get_selected() - 1;
+ return device_id_option->get_selected() == 0 ? InputEvent::DEVICE_ID_ALL_DEVICES : device_id_option->get_selected() - 1;
}
void InputEventConfigurationDialog::_notification(int p_what) {
@@ -705,11 +705,12 @@ InputEventConfigurationDialog::InputEventConfigurationDialog() {
device_id_option = memnew(OptionButton);
device_id_option->set_h_size_flags(Control::SIZE_EXPAND_FILL);
- for (int i = -1; i < 8; i++) {
+ device_id_option->add_item(EventListenerLineEdit::get_device_string(InputEvent::DEVICE_ID_ALL_DEVICES));
+ for (int i = 0; i < 8; i++) {
device_id_option->add_item(EventListenerLineEdit::get_device_string(i));
}
device_id_option->connect(SceneStringName(item_selected), callable_mp(this, &InputEventConfigurationDialog::_device_selection_changed));
- _set_current_device(InputMap::ALL_DEVICES);
+ _set_current_device(InputEvent::DEVICE_ID_ALL_DEVICES);
device_container->add_child(device_id_option);
device_container->hide();