mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Replace repetitive meta/ctrl condition with a method
This commit is contained in:
parent
2d86b69bf1
commit
98141c3d73
11 changed files with 25 additions and 13 deletions
|
|
@ -361,7 +361,7 @@ bool keycode_has_unicode(Key p_keycode) {
|
|||
|
||||
String keycode_get_string(Key p_code) {
|
||||
Vector<String> keycode_string;
|
||||
if ((p_code & KeyModifierMask::CMD_OR_CTRL) != Key::NONE && !(OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios"))) {
|
||||
if ((p_code & KeyModifierMask::CMD_OR_CTRL) != Key::NONE && !OS::prefer_meta_over_ctrl()) {
|
||||
keycode_string.push_back(find_keycode_name(Key::CTRL));
|
||||
}
|
||||
if ((p_code & KeyModifierMask::CTRL) != Key::NONE) {
|
||||
|
|
@ -373,7 +373,7 @@ String keycode_get_string(Key p_code) {
|
|||
if ((p_code & KeyModifierMask::SHIFT) != Key::NONE) {
|
||||
keycode_string.push_back(find_keycode_name(Key::SHIFT));
|
||||
}
|
||||
if ((p_code & KeyModifierMask::CMD_OR_CTRL) != Key::NONE && (OS::get_singleton()->has_feature("macos") || OS::get_singleton()->has_feature("web_macos") || OS::get_singleton()->has_feature("web_ios"))) {
|
||||
if ((p_code & KeyModifierMask::CMD_OR_CTRL) != Key::NONE && OS::prefer_meta_over_ctrl()) {
|
||||
keycode_string.push_back(find_keycode_name(Key::META));
|
||||
}
|
||||
if ((p_code & KeyModifierMask::META) != Key::NONE) {
|
||||
|
|
|
|||
|
|
@ -55,6 +55,16 @@ OS *OS::get_singleton() {
|
|||
return singleton;
|
||||
}
|
||||
|
||||
bool OS::prefer_meta_over_ctrl() {
|
||||
#if defined(MACOS_ENABLED) || defined(APPLE_EMBEDDED_ENABLED)
|
||||
return true;
|
||||
#elif defined(WEB_ENABLED)
|
||||
return singleton->has_feature("web_macos") || singleton->has_feature("web_ios");
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t OS::get_ticks_msec() const {
|
||||
return get_ticks_usec() / 1000ULL;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,6 +132,8 @@ public:
|
|||
|
||||
static OS *get_singleton();
|
||||
|
||||
static bool prefer_meta_over_ctrl();
|
||||
|
||||
void set_current_rendering_driver_name(const String &p_driver_name) { _current_rendering_driver_name = p_driver_name; }
|
||||
void set_current_rendering_method(const String &p_name) { _current_rendering_method = p_name; }
|
||||
void set_gles_over_gl(bool p_enabled) { _is_gles_over_gl = p_enabled; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue