| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/gui/dialogs.h" |
| 34 |
|
| 35 |
class OptionButton; |
| 36 |
class Tree; |
| 37 |
class EventListenerLineEdit; |
| 38 |
class CheckBox; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
class InputEventConfigurationDialog : public ConfirmationDialog { |
| 43 |
GDCLASS(InputEventConfigurationDialog, ConfirmationDialog) |
| 44 |
private: |
| 45 |
struct IconCache { |
| 46 |
Ref<Texture2D> keyboard; |
| 47 |
Ref<Texture2D> mouse; |
| 48 |
Ref<Texture2D> joypad_button; |
| 49 |
Ref<Texture2D> joypad_axis; |
| 50 |
} icon_cache; |
| 51 |
|
| 52 |
Ref<InputEvent> event; |
| 53 |
Ref<InputEvent> original_event; |
| 54 |
|
| 55 |
bool in_tree_update = false; |
| 56 |
|
| 57 |
|
| 58 |
EventListenerLineEdit *event_listener = nullptr; |
| 59 |
Label *event_as_text = nullptr; |
| 60 |
|
| 61 |
|
| 62 |
int allowed_input_types; |
| 63 |
Tree *input_list_tree = nullptr; |
| 64 |
LineEdit *input_list_search = nullptr; |
| 65 |
|
| 66 |
|
| 67 |
VBoxContainer *additional_options_container = nullptr; |
| 68 |
|
| 69 |
HBoxContainer *device_container = nullptr; |
| 70 |
OptionButton *device_id_option = nullptr; |
| 71 |
|
| 72 |
HBoxContainer *mod_container = nullptr; |
| 73 |
|
| 74 |
enum ModCheckbox { |
| 75 |
MOD_ALT, |
| 76 |
MOD_SHIFT, |
| 77 |
MOD_CTRL, |
| 78 |
MOD_META, |
| 79 |
MOD_MAX |
| 80 |
}; |
| 81 |
#if defined(MACOS_ENABLED) |
| 82 |
String mods[MOD_MAX] = { "Option", "Shift", "Ctrl", "Command" }; |
| 83 |
#elif defined(WINDOWS_ENABLED) |
| 84 |
String mods[MOD_MAX] = { "Alt", "Shift", "Ctrl", "Windows" }; |
| 85 |
#else |
| 86 |
String mods[MOD_MAX] = { "Alt", "Shift", "Ctrl", "Meta" }; |
| 87 |
#endif |
| 88 |
String mods_tip[MOD_MAX] = { |
| 89 |
TTRC("Alt or Option key"), |
| 90 |
TTRC("Shift key"), |
| 91 |
TTRC("Control key"), |
| 92 |
TTRC("Meta/Windows or Command key"), |
| 93 |
}; |
| 94 |
|
| 95 |
CheckBox *mod_checkboxes[MOD_MAX]; |
| 96 |
CheckBox *autoremap_command_or_control_checkbox = nullptr; |
| 97 |
|
| 98 |
enum KeyMode { |
| 99 |
KEYMODE_KEYCODE, |
| 100 |
KEYMODE_PHY_KEYCODE, |
| 101 |
KEYMODE_UNICODE, |
| 102 |
}; |
| 103 |
|
| 104 |
OptionButton *key_mode = nullptr; |
| 105 |
|
| 106 |
HBoxContainer *location_container = nullptr; |
| 107 |
OptionButton *key_location = nullptr; |
| 108 |
|
| 109 |
void _set_event(const Ref<InputEvent> &p_event, const Ref<InputEvent> &p_original_event, bool p_update_input_list_selection = true); |
| 110 |
void _on_listen_input_changed(const Ref<InputEvent> &p_event); |
| 111 |
|
| 112 |
void _search_term_updated(const String &p_term); |
| 113 |
void _update_input_list(); |
| 114 |
void _input_list_item_activated(); |
| 115 |
void _input_list_item_selected(); |
| 116 |
|
| 117 |
void _mod_toggled(bool p_checked, int p_index); |
| 118 |
void _autoremap_command_or_control_toggled(bool p_checked); |
| 119 |
void _key_mode_selected(int p_mode); |
| 120 |
void _key_location_selected(int p_location); |
| 121 |
|
| 122 |
void _device_selection_changed(int p_option_button_index); |
| 123 |
void _set_current_device(int p_device); |
| 124 |
int _get_current_device() const; |
| 125 |
|
| 126 |
protected: |
| 127 |
void _notification(int p_what); |
| 128 |
|
| 129 |
public: |
| 130 |
|
| 131 |
|
| 132 |
void popup_and_configure(const Ref<InputEvent> &p_event = Ref<InputEvent>(), const String &p_current_action_name = ""); |
| 133 |
Ref<InputEvent> get_event() const; |
| 134 |
|
| 135 |
void set_allowed_input_types(int p_type_masks); |
| 136 |
|
| 137 |
InputEventConfigurationDialog(); |
| 138 |
}; |