diff options
Diffstat (limited to 'platform')
33 files changed, 1085 insertions, 1071 deletions
diff --git a/platform/android/android_input_handler.cpp b/platform/android/android_input_handler.cpp index e03375e8d9..dc259da886 100644 --- a/platform/android/android_input_handler.cpp +++ b/platform/android/android_input_handler.cpp @@ -45,7 +45,7 @@ void AndroidInputHandler::process_joy_event(AndroidInputHandler::JoypadEvent p_e Input::get_singleton()->joy_axis(p_event.device, (JoyAxis)p_event.index, value); break; case JOY_EVENT_HAT: - Input::get_singleton()->joy_hat(p_event.device, (HatMask)p_event.hat); + Input::get_singleton()->joy_hat(p_event.device, p_event.hat); break; default: return; @@ -82,37 +82,37 @@ void AndroidInputHandler::process_key_event(int p_keycode, int p_scancode, int p Ref<InputEventKey> ev; ev.instantiate(); int val = unicode; - int keycode = android_get_keysym(p_keycode); - int phy_keycode = android_get_keysym(p_scancode); + Key keycode = android_get_keysym(p_keycode); + Key phy_keycode = android_get_keysym(p_scancode); - if (keycode == KEY_SHIFT) { + if (keycode == Key::SHIFT) { shift_mem = p_pressed; } - if (keycode == KEY_ALT) { + if (keycode == Key::ALT) { alt_mem = p_pressed; } - if (keycode == KEY_CTRL) { + if (keycode == Key::CTRL) { control_mem = p_pressed; } - if (keycode == KEY_META) { + if (keycode == Key::META) { meta_mem = p_pressed; } - ev->set_keycode((Key)keycode); - ev->set_physical_keycode((Key)phy_keycode); + ev->set_keycode(keycode); + ev->set_physical_keycode(phy_keycode); ev->set_unicode(val); ev->set_pressed(p_pressed); _set_key_modifier_state(ev); if (val == '\n') { - ev->set_keycode(KEY_ENTER); + ev->set_keycode(Key::ENTER); } else if (val == 61448) { - ev->set_keycode(KEY_BACKSPACE); - ev->set_unicode(KEY_BACKSPACE); + ev->set_keycode(Key::BACKSPACE); + ev->set_unicode((char32_t)Key::BACKSPACE); } else if (val == 61453) { - ev->set_keycode(KEY_ENTER); - ev->set_unicode(KEY_ENTER); + ev->set_keycode(Key::ENTER); + ev->set_unicode((char32_t)Key::ENTER); } else if (p_keycode == 4) { if (DisplayServerAndroid *dsa = Object::cast_to<DisplayServerAndroid>(DisplayServer::get_singleton())) { dsa->send_window_event(DisplayServer::WINDOW_EVENT_GO_BACK_REQUEST, true); @@ -305,15 +305,15 @@ void AndroidInputHandler::process_mouse_event(int input_device, int event_action ev->set_pressed(true); buttons_state = event_buttons_mask; if (event_vertical_factor > 0) { - _wheel_button_click(event_buttons_mask, ev, MOUSE_BUTTON_WHEEL_UP, event_vertical_factor); + _wheel_button_click(event_buttons_mask, ev, MouseButton::WHEEL_UP, event_vertical_factor); } else if (event_vertical_factor < 0) { - _wheel_button_click(event_buttons_mask, ev, MOUSE_BUTTON_WHEEL_DOWN, -event_vertical_factor); + _wheel_button_click(event_buttons_mask, ev, MouseButton::WHEEL_DOWN, -event_vertical_factor); } if (event_horizontal_factor > 0) { - _wheel_button_click(event_buttons_mask, ev, MOUSE_BUTTON_WHEEL_RIGHT, event_horizontal_factor); + _wheel_button_click(event_buttons_mask, ev, MouseButton::WHEEL_RIGHT, event_horizontal_factor); } else if (event_horizontal_factor < 0) { - _wheel_button_click(event_buttons_mask, ev, MOUSE_BUTTON_WHEEL_LEFT, -event_horizontal_factor); + _wheel_button_click(event_buttons_mask, ev, MouseButton::WHEEL_LEFT, -event_horizontal_factor); } } break; } @@ -323,7 +323,7 @@ void AndroidInputHandler::_wheel_button_click(MouseButton event_buttons_mask, co Ref<InputEventMouseButton> evd = ev->duplicate(); _set_key_modifier_state(evd); evd->set_button_index(wheel_button); - evd->set_button_mask(MouseButton(event_buttons_mask ^ (1 << (wheel_button - 1)))); + evd->set_button_mask(MouseButton(event_buttons_mask ^ mouse_button_to_mask(wheel_button))); evd->set_factor(factor); Input::get_singleton()->parse_input_event(evd); Ref<InputEventMouseButton> evdd = evd->duplicate(); @@ -339,7 +339,7 @@ void AndroidInputHandler::process_double_tap(int event_android_button_mask, Poin _set_key_modifier_state(ev); ev->set_position(p_pos); ev->set_global_position(p_pos); - ev->set_pressed(event_button_mask != 0); + ev->set_pressed(event_button_mask != MouseButton::NONE); ev->set_button_index(_button_index_from_mask(event_button_mask)); ev->set_button_mask(event_button_mask); ev->set_double_click(true); @@ -348,37 +348,37 @@ void AndroidInputHandler::process_double_tap(int event_android_button_mask, Poin MouseButton AndroidInputHandler::_button_index_from_mask(MouseButton button_mask) { switch (button_mask) { - case MOUSE_BUTTON_MASK_LEFT: - return MOUSE_BUTTON_LEFT; - case MOUSE_BUTTON_MASK_RIGHT: - return MOUSE_BUTTON_RIGHT; - case MOUSE_BUTTON_MASK_MIDDLE: - return MOUSE_BUTTON_MIDDLE; - case MOUSE_BUTTON_MASK_XBUTTON1: - return MOUSE_BUTTON_XBUTTON1; - case MOUSE_BUTTON_MASK_XBUTTON2: - return MOUSE_BUTTON_XBUTTON2; + case MouseButton::MASK_LEFT: + return MouseButton::LEFT; + case MouseButton::MASK_RIGHT: + return MouseButton::RIGHT; + case MouseButton::MASK_MIDDLE: + return MouseButton::MIDDLE; + case MouseButton::MASK_XBUTTON1: + return MouseButton::MB_XBUTTON1; + case MouseButton::MASK_XBUTTON2: + return MouseButton::MB_XBUTTON2; default: - return MOUSE_BUTTON_NONE; + return MouseButton::NONE; } } MouseButton AndroidInputHandler::_android_button_mask_to_godot_button_mask(int android_button_mask) { - MouseButton godot_button_mask = MOUSE_BUTTON_NONE; + MouseButton godot_button_mask = MouseButton::NONE; if (android_button_mask & AMOTION_EVENT_BUTTON_PRIMARY) { - godot_button_mask |= MOUSE_BUTTON_MASK_LEFT; + godot_button_mask |= MouseButton::MASK_LEFT; } if (android_button_mask & AMOTION_EVENT_BUTTON_SECONDARY) { - godot_button_mask |= MOUSE_BUTTON_MASK_RIGHT; + godot_button_mask |= MouseButton::MASK_RIGHT; } if (android_button_mask & AMOTION_EVENT_BUTTON_TERTIARY) { - godot_button_mask |= MOUSE_BUTTON_MASK_MIDDLE; + godot_button_mask |= MouseButton::MASK_MIDDLE; } if (android_button_mask & AMOTION_EVENT_BUTTON_BACK) { - godot_button_mask |= MOUSE_BUTTON_MASK_XBUTTON1; + godot_button_mask |= MouseButton::MASK_XBUTTON1; } if (android_button_mask & AMOTION_EVENT_BUTTON_FORWARD) { - godot_button_mask |= MOUSE_BUTTON_MASK_XBUTTON2; + godot_button_mask |= MouseButton::MASK_XBUTTON2; } return godot_button_mask; diff --git a/platform/android/android_input_handler.h b/platform/android/android_input_handler.h index 2918ca300b..e0b4196f14 100644 --- a/platform/android/android_input_handler.h +++ b/platform/android/android_input_handler.h @@ -53,10 +53,10 @@ public: struct JoypadEvent { int device = 0; int type = 0; - int index = 0; + int index = 0; // Can be either JoyAxis or JoyButton. bool pressed = false; float value = 0; - int hat = 0; + HatMask hat = HatMask::CENTER; }; private: @@ -65,7 +65,7 @@ private: bool control_mem = false; bool meta_mem = false; - MouseButton buttons_state = MOUSE_BUTTON_NONE; + MouseButton buttons_state = MouseButton::NONE; Vector<TouchPos> touch; Point2 hover_prev_pos; // needed to calculate the relative position on hover events diff --git a/platform/android/android_keys_utils.cpp b/platform/android/android_keys_utils.cpp index 5aa546c17b..0cea0589ce 100644 --- a/platform/android/android_keys_utils.cpp +++ b/platform/android/android_keys_utils.cpp @@ -30,12 +30,12 @@ #include "android_keys_utils.h" -unsigned int android_get_keysym(unsigned int p_code) { - for (int i = 0; _ak_to_keycode[i].keysym != KEY_UNKNOWN; i++) { +Key android_get_keysym(unsigned int p_code) { + for (int i = 0; _ak_to_keycode[i].keysym != Key::UNKNOWN; i++) { if (_ak_to_keycode[i].keycode == p_code) { return _ak_to_keycode[i].keysym; } } - return KEY_UNKNOWN; + return Key::UNKNOWN; } diff --git a/platform/android/android_keys_utils.h b/platform/android/android_keys_utils.h index de6f48d33a..bac9bab6db 100644 --- a/platform/android/android_keys_utils.h +++ b/platform/android/android_keys_utils.h @@ -35,101 +35,101 @@ #include <core/os/keyboard.h> struct _WinTranslatePair { - unsigned int keysym = 0; + Key keysym = Key::NONE; unsigned int keycode = 0; }; static _WinTranslatePair _ak_to_keycode[] = { - { KEY_TAB, AKEYCODE_TAB }, - { KEY_ENTER, AKEYCODE_ENTER }, - { KEY_SHIFT, AKEYCODE_SHIFT_LEFT }, - { KEY_SHIFT, AKEYCODE_SHIFT_RIGHT }, - { KEY_ALT, AKEYCODE_ALT_LEFT }, - { KEY_ALT, AKEYCODE_ALT_RIGHT }, - { KEY_MENU, AKEYCODE_MENU }, - { KEY_PAUSE, AKEYCODE_MEDIA_PLAY_PAUSE }, - { KEY_ESCAPE, AKEYCODE_BACK }, - { KEY_SPACE, AKEYCODE_SPACE }, - { KEY_PAGEUP, AKEYCODE_PAGE_UP }, - { KEY_PAGEDOWN, AKEYCODE_PAGE_DOWN }, - { KEY_HOME, AKEYCODE_HOME }, //(0x24) - { KEY_LEFT, AKEYCODE_DPAD_LEFT }, - { KEY_UP, AKEYCODE_DPAD_UP }, - { KEY_RIGHT, AKEYCODE_DPAD_RIGHT }, - { KEY_DOWN, AKEYCODE_DPAD_DOWN }, - { KEY_PERIODCENTERED, AKEYCODE_DPAD_CENTER }, - { KEY_BACKSPACE, AKEYCODE_DEL }, - { KEY_0, AKEYCODE_0 }, ////0 key - { KEY_1, AKEYCODE_1 }, ////1 key - { KEY_2, AKEYCODE_2 }, ////2 key - { KEY_3, AKEYCODE_3 }, ////3 key - { KEY_4, AKEYCODE_4 }, ////4 key - { KEY_5, AKEYCODE_5 }, ////5 key - { KEY_6, AKEYCODE_6 }, ////6 key - { KEY_7, AKEYCODE_7 }, ////7 key - { KEY_8, AKEYCODE_8 }, ////8 key - { KEY_9, AKEYCODE_9 }, ////9 key - { KEY_A, AKEYCODE_A }, ////A key - { KEY_B, AKEYCODE_B }, ////B key - { KEY_C, AKEYCODE_C }, ////C key - { KEY_D, AKEYCODE_D }, ////D key - { KEY_E, AKEYCODE_E }, ////E key - { KEY_F, AKEYCODE_F }, ////F key - { KEY_G, AKEYCODE_G }, ////G key - { KEY_H, AKEYCODE_H }, ////H key - { KEY_I, AKEYCODE_I }, ////I key - { KEY_J, AKEYCODE_J }, ////J key - { KEY_K, AKEYCODE_K }, ////K key - { KEY_L, AKEYCODE_L }, ////L key - { KEY_M, AKEYCODE_M }, ////M key - { KEY_N, AKEYCODE_N }, ////N key - { KEY_O, AKEYCODE_O }, ////O key - { KEY_P, AKEYCODE_P }, ////P key - { KEY_Q, AKEYCODE_Q }, ////Q key - { KEY_R, AKEYCODE_R }, ////R key - { KEY_S, AKEYCODE_S }, ////S key - { KEY_T, AKEYCODE_T }, ////T key - { KEY_U, AKEYCODE_U }, ////U key - { KEY_V, AKEYCODE_V }, ////V key - { KEY_W, AKEYCODE_W }, ////W key - { KEY_X, AKEYCODE_X }, ////X key - { KEY_Y, AKEYCODE_Y }, ////Y key - { KEY_Z, AKEYCODE_Z }, ////Z key - { KEY_HOMEPAGE, AKEYCODE_EXPLORER }, - { KEY_LAUNCH0, AKEYCODE_BUTTON_A }, - { KEY_LAUNCH1, AKEYCODE_BUTTON_B }, - { KEY_LAUNCH2, AKEYCODE_BUTTON_C }, - { KEY_LAUNCH3, AKEYCODE_BUTTON_X }, - { KEY_LAUNCH4, AKEYCODE_BUTTON_Y }, - { KEY_LAUNCH5, AKEYCODE_BUTTON_Z }, - { KEY_LAUNCH6, AKEYCODE_BUTTON_L1 }, - { KEY_LAUNCH7, AKEYCODE_BUTTON_R1 }, - { KEY_LAUNCH8, AKEYCODE_BUTTON_L2 }, - { KEY_LAUNCH9, AKEYCODE_BUTTON_R2 }, - { KEY_LAUNCHA, AKEYCODE_BUTTON_THUMBL }, - { KEY_LAUNCHB, AKEYCODE_BUTTON_THUMBR }, - { KEY_LAUNCHC, AKEYCODE_BUTTON_START }, - { KEY_LAUNCHD, AKEYCODE_BUTTON_SELECT }, - { KEY_LAUNCHE, AKEYCODE_BUTTON_MODE }, - { KEY_VOLUMEMUTE, AKEYCODE_MUTE }, - { KEY_VOLUMEDOWN, AKEYCODE_VOLUME_DOWN }, - { KEY_VOLUMEUP, AKEYCODE_VOLUME_UP }, - { KEY_BACK, AKEYCODE_MEDIA_REWIND }, - { KEY_FORWARD, AKEYCODE_MEDIA_FAST_FORWARD }, - { KEY_MEDIANEXT, AKEYCODE_MEDIA_NEXT }, - { KEY_MEDIAPREVIOUS, AKEYCODE_MEDIA_PREVIOUS }, - { KEY_MEDIASTOP, AKEYCODE_MEDIA_STOP }, - { KEY_PLUS, AKEYCODE_PLUS }, - { KEY_EQUAL, AKEYCODE_EQUALS }, // the '+' key - { KEY_COMMA, AKEYCODE_COMMA }, // the ',' key - { KEY_MINUS, AKEYCODE_MINUS }, // the '-' key - { KEY_SLASH, AKEYCODE_SLASH }, // the '/?' key - { KEY_BACKSLASH, AKEYCODE_BACKSLASH }, - { KEY_BRACKETLEFT, AKEYCODE_LEFT_BRACKET }, - { KEY_BRACKETRIGHT, AKEYCODE_RIGHT_BRACKET }, - { KEY_CTRL, AKEYCODE_CTRL_LEFT }, - { KEY_CTRL, AKEYCODE_CTRL_RIGHT }, - { KEY_UNKNOWN, 0 } + { Key::TAB, AKEYCODE_TAB }, + { Key::ENTER, AKEYCODE_ENTER }, + { Key::SHIFT, AKEYCODE_SHIFT_LEFT }, + { Key::SHIFT, AKEYCODE_SHIFT_RIGHT }, + { Key::ALT, AKEYCODE_ALT_LEFT }, + { Key::ALT, AKEYCODE_ALT_RIGHT }, + { Key::MENU, AKEYCODE_MENU }, + { Key::PAUSE, AKEYCODE_MEDIA_PLAY_PAUSE }, + { Key::ESCAPE, AKEYCODE_BACK }, + { Key::SPACE, AKEYCODE_SPACE }, + { Key::PAGEUP, AKEYCODE_PAGE_UP }, + { Key::PAGEDOWN, AKEYCODE_PAGE_DOWN }, + { Key::HOME, AKEYCODE_HOME }, //(0x24) + { Key::LEFT, AKEYCODE_DPAD_LEFT }, + { Key::UP, AKEYCODE_DPAD_UP }, + { Key::RIGHT, AKEYCODE_DPAD_RIGHT }, + { Key::DOWN, AKEYCODE_DPAD_DOWN }, + { Key::PERIODCENTERED, AKEYCODE_DPAD_CENTER }, + { Key::BACKSPACE, AKEYCODE_DEL }, + { Key::KEY_0, AKEYCODE_0 }, + { Key::KEY_1, AKEYCODE_1 }, + { Key::KEY_2, AKEYCODE_2 }, + { Key::KEY_3, AKEYCODE_3 }, + { Key::KEY_4, AKEYCODE_4 }, + { Key::KEY_5, AKEYCODE_5 }, + { Key::KEY_6, AKEYCODE_6 }, + { Key::KEY_7, AKEYCODE_7 }, + { Key::KEY_8, AKEYCODE_8 }, + { Key::KEY_9, AKEYCODE_9 }, + { Key::A, AKEYCODE_A }, + { Key::B, AKEYCODE_B }, + { Key::C, AKEYCODE_C }, + { Key::D, AKEYCODE_D }, + { Key::E, AKEYCODE_E }, + { Key::F, AKEYCODE_F }, + { Key::G, AKEYCODE_G }, + { Key::H, AKEYCODE_H }, + { Key::I, AKEYCODE_I }, + { Key::J, AKEYCODE_J }, + { Key::K, AKEYCODE_K }, + { Key::L, AKEYCODE_L }, + { Key::M, AKEYCODE_M }, + { Key::N, AKEYCODE_N }, + { Key::O, AKEYCODE_O }, + { Key::P, AKEYCODE_P }, + { Key::Q, AKEYCODE_Q }, + { Key::R, AKEYCODE_R }, + { Key::S, AKEYCODE_S }, + { Key::T, AKEYCODE_T }, + { Key::U, AKEYCODE_U }, + { Key::V, AKEYCODE_V }, + { Key::W, AKEYCODE_W }, + { Key::X, AKEYCODE_X }, + { Key::Y, AKEYCODE_Y }, + { Key::Z, AKEYCODE_Z }, + { Key::HOMEPAGE, AKEYCODE_EXPLORER }, + { Key::LAUNCH0, AKEYCODE_BUTTON_A }, + { Key::LAUNCH1, AKEYCODE_BUTTON_B }, + { Key::LAUNCH2, AKEYCODE_BUTTON_C }, + { Key::LAUNCH3, AKEYCODE_BUTTON_X }, + { Key::LAUNCH4, AKEYCODE_BUTTON_Y }, + { Key::LAUNCH5, AKEYCODE_BUTTON_Z }, + { Key::LAUNCH6, AKEYCODE_BUTTON_L1 }, + { Key::LAUNCH7, AKEYCODE_BUTTON_R1 }, + { Key::LAUNCH8, AKEYCODE_BUTTON_L2 }, + { Key::LAUNCH9, AKEYCODE_BUTTON_R2 }, + { Key::LAUNCHA, AKEYCODE_BUTTON_THUMBL }, + { Key::LAUNCHB, AKEYCODE_BUTTON_THUMBR }, + { Key::LAUNCHC, AKEYCODE_BUTTON_START }, + { Key::LAUNCHD, AKEYCODE_BUTTON_SELECT }, + { Key::LAUNCHE, AKEYCODE_BUTTON_MODE }, + { Key::VOLUMEMUTE, AKEYCODE_MUTE }, + { Key::VOLUMEDOWN, AKEYCODE_VOLUME_DOWN }, + { Key::VOLUMEUP, AKEYCODE_VOLUME_UP }, + { Key::BACK, AKEYCODE_MEDIA_REWIND }, + { Key::FORWARD, AKEYCODE_MEDIA_FAST_FORWARD }, + { Key::MEDIANEXT, AKEYCODE_MEDIA_NEXT }, + { Key::MEDIAPREVIOUS, AKEYCODE_MEDIA_PREVIOUS }, + { Key::MEDIASTOP, AKEYCODE_MEDIA_STOP }, + { Key::PLUS, AKEYCODE_PLUS }, + { Key::EQUAL, AKEYCODE_EQUALS }, // the '+' key + { Key::COMMA, AKEYCODE_COMMA }, // the ',' key + { Key::MINUS, AKEYCODE_MINUS }, // the '-' key + { Key::SLASH, AKEYCODE_SLASH }, // the '/?' key + { Key::BACKSLASH, AKEYCODE_BACKSLASH }, + { Key::BRACKETLEFT, AKEYCODE_LEFT_BRACKET }, + { Key::BRACKETRIGHT, AKEYCODE_RIGHT_BRACKET }, + { Key::CTRL, AKEYCODE_CTRL_LEFT }, + { Key::CTRL, AKEYCODE_CTRL_RIGHT }, + { Key::UNKNOWN, 0 } }; /* TODO: map these android key: @@ -157,6 +157,6 @@ TODO: map these android key: AKEYCODE_SWITCH_CHARSET = 95, */ -unsigned int android_get_keysym(unsigned int p_code); +Key android_get_keysym(unsigned int p_code); #endif // ANDROID_KEYS_UTILS_H diff --git a/platform/android/java_godot_lib_jni.cpp b/platform/android/java_godot_lib_jni.cpp index c7f19e4be2..3236512f5c 100644 --- a/platform/android/java_godot_lib_jni.cpp +++ b/platform/android/java_godot_lib_jni.cpp @@ -317,8 +317,9 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joybutton(JNIEnv *env // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, jclass clazz, jint p_device, jint p_axis, jfloat p_value) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } AndroidInputHandler::JoypadEvent jevent; jevent.device = p_device; @@ -331,24 +332,27 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyaxis(JNIEnv *env, // Called on the UI thread JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, jclass clazz, jint p_device, jint p_hat_x, jint p_hat_y) { - if (step.get() <= 0) + if (step.get() <= 0) { return; + } AndroidInputHandler::JoypadEvent jevent; jevent.device = p_device; jevent.type = AndroidInputHandler::JOY_EVENT_HAT; - int hat = 0; + HatMask hat = HatMask::CENTER; if (p_hat_x != 0) { - if (p_hat_x < 0) - hat |= HatMask::HAT_MASK_LEFT; - else - hat |= HatMask::HAT_MASK_RIGHT; + if (p_hat_x < 0) { + hat |= HatMask::LEFT; + } else { + hat |= HatMask::RIGHT; + } } if (p_hat_y != 0) { - if (p_hat_y < 0) - hat |= HatMask::HAT_MASK_UP; - else - hat |= HatMask::HAT_MASK_DOWN; + if (p_hat_y < 0) { + hat |= HatMask::UP; + } else { + hat |= HatMask::DOWN; + } } jevent.hat = hat; diff --git a/platform/iphone/display_server_iphone.mm b/platform/iphone/display_server_iphone.mm index 7d13a08d39..b746c60d4e 100644 --- a/platform/iphone/display_server_iphone.mm +++ b/platform/iphone/display_server_iphone.mm @@ -261,7 +261,7 @@ void DisplayServerIPhone::key(Key p_key, bool p_pressed) { ev->set_pressed(p_pressed); ev->set_keycode(p_key); ev->set_physical_keycode(p_key); - ev->set_unicode(p_key); + ev->set_unicode((char32_t)p_key); perform_event(ev); }; diff --git a/platform/iphone/joypad_iphone.mm b/platform/iphone/joypad_iphone.mm index 45842b38aa..1bf5462d91 100644 --- a/platform/iphone/joypad_iphone.mm +++ b/platform/iphone/joypad_iphone.mm @@ -259,31 +259,31 @@ void JoypadIPhone::start_processing() { int joy_id = [self getJoyIdForController:controller]; if (element == gamepad.buttonA) { - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_A, + Input::get_singleton()->joy_button(joy_id, JoyButton::A, gamepad.buttonA.isPressed); } else if (element == gamepad.buttonB) { - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_B, + Input::get_singleton()->joy_button(joy_id, JoyButton::B, gamepad.buttonB.isPressed); } else if (element == gamepad.buttonX) { - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_X, + Input::get_singleton()->joy_button(joy_id, JoyButton::X, gamepad.buttonX.isPressed); } else if (element == gamepad.buttonY) { - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_Y, + Input::get_singleton()->joy_button(joy_id, JoyButton::Y, gamepad.buttonY.isPressed); } else if (element == gamepad.leftShoulder) { - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_LEFT_SHOULDER, + Input::get_singleton()->joy_button(joy_id, JoyButton::LEFT_SHOULDER, gamepad.leftShoulder.isPressed); } else if (element == gamepad.rightShoulder) { - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_RIGHT_SHOULDER, + Input::get_singleton()->joy_button(joy_id, JoyButton::RIGHT_SHOULDER, gamepad.rightShoulder.isPressed); } else if (element == gamepad.dpad) { - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_DPAD_UP, + Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_UP, gamepad.dpad.up.isPressed); - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_DPAD_DOWN, + Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_DOWN, gamepad.dpad.down.isPressed); - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_DPAD_LEFT, + Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_LEFT, gamepad.dpad.left.isPressed); - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_DPAD_RIGHT, + Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT, gamepad.dpad.right.isPressed); }; @@ -291,20 +291,20 @@ void JoypadIPhone::start_processing() { jx.min = -1; if (element == gamepad.leftThumbstick) { jx.value = gamepad.leftThumbstick.xAxis.value; - Input::get_singleton()->joy_axis(joy_id, JOY_AXIS_LEFT_X, jx); + Input::get_singleton()->joy_axis(joy_id, JoyAxis::LEFT_X, jx); jx.value = -gamepad.leftThumbstick.yAxis.value; - Input::get_singleton()->joy_axis(joy_id, JOY_AXIS_LEFT_Y, jx); + Input::get_singleton()->joy_axis(joy_id, JoyAxis::LEFT_Y, jx); } else if (element == gamepad.rightThumbstick) { jx.value = gamepad.rightThumbstick.xAxis.value; - Input::get_singleton()->joy_axis(joy_id, JOY_AXIS_RIGHT_X, jx); + Input::get_singleton()->joy_axis(joy_id, JoyAxis::RIGHT_X, jx); jx.value = -gamepad.rightThumbstick.yAxis.value; - Input::get_singleton()->joy_axis(joy_id, JOY_AXIS_RIGHT_Y, jx); + Input::get_singleton()->joy_axis(joy_id, JoyAxis::RIGHT_Y, jx); } else if (element == gamepad.leftTrigger) { jx.value = gamepad.leftTrigger.value; - Input::get_singleton()->joy_axis(joy_id, JOY_AXIS_TRIGGER_LEFT, jx); + Input::get_singleton()->joy_axis(joy_id, JoyAxis::TRIGGER_LEFT, jx); } else if (element == gamepad.rightTrigger) { jx.value = gamepad.rightTrigger.value; - Input::get_singleton()->joy_axis(joy_id, JOY_AXIS_TRIGGER_RIGHT, jx); + Input::get_singleton()->joy_axis(joy_id, JoyAxis::TRIGGER_RIGHT, jx); }; }; } else if (controller.microGamepad != nil) { @@ -319,18 +319,18 @@ void JoypadIPhone::start_processing() { int joy_id = [self getJoyIdForController:controller]; if (element == gamepad.buttonA) { - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_A, + Input::get_singleton()->joy_button(joy_id, JoyButton::A, gamepad.buttonA.isPressed); } else if (element == gamepad.buttonX) { - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_X, + Input::get_singleton()->joy_button(joy_id, JoyButton::X, gamepad.buttonX.isPressed); } else if (element == gamepad.dpad) { - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_DPAD_UP, + Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_UP, gamepad.dpad.up.isPressed); - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_DPAD_DOWN, + Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_DOWN, gamepad.dpad.down.isPressed); - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_DPAD_LEFT, gamepad.dpad.left.isPressed); - Input::get_singleton()->joy_button(joy_id, JOY_BUTTON_DPAD_RIGHT, gamepad.dpad.right.isPressed); + Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_LEFT, gamepad.dpad.left.isPressed); + Input::get_singleton()->joy_button(joy_id, JoyButton::DPAD_RIGHT, gamepad.dpad.right.isPressed); }; }; } diff --git a/platform/iphone/keyboard_input_view.mm b/platform/iphone/keyboard_input_view.mm index e2bd0acff4..b11d04181e 100644 --- a/platform/iphone/keyboard_input_view.mm +++ b/platform/iphone/keyboard_input_view.mm @@ -115,8 +115,8 @@ - (void)deleteText:(NSInteger)charactersToDelete { for (int i = 0; i < charactersToDelete; i++) { - DisplayServerIPhone::get_singleton()->key(KEY_BACKSPACE, true); - DisplayServerIPhone::get_singleton()->key(KEY_BACKSPACE, false); + DisplayServerIPhone::get_singleton()->key(Key::BACKSPACE, true); + DisplayServerIPhone::get_singleton()->key(Key::BACKSPACE, false); } } @@ -129,10 +129,10 @@ switch (character) { case 10: - character = KEY_ENTER; + character = (int)Key::ENTER; break; case 8198: - character = KEY_SPACE; + character = (int)Key::SPACE; break; default: break; diff --git a/platform/javascript/display_server_javascript.cpp b/platform/javascript/display_server_javascript.cpp index c7d68019a1..d12e1aeee8 100644 --- a/platform/javascript/display_server_javascript.cpp +++ b/platform/javascript/display_server_javascript.cpp @@ -151,19 +151,19 @@ int DisplayServerJavaScript::mouse_button_callback(int p_pressed, int p_button, switch (p_button) { case DOM_BUTTON_LEFT: - ev->set_button_index(MOUSE_BUTTON_LEFT); + ev->set_button_index(MouseButton::LEFT); break; case DOM_BUTTON_MIDDLE: - ev->set_button_index(MOUSE_BUTTON_MIDDLE); + ev->set_button_index(MouseButton::MIDDLE); break; case DOM_BUTTON_RIGHT: - ev->set_button_index(MOUSE_BUTTON_RIGHT); + ev->set_button_index(MouseButton::RIGHT); break; case DOM_BUTTON_XBUTTON1: - ev->set_button_index(MOUSE_BUTTON_XBUTTON1); + ev->set_button_index(MouseButton::MB_XBUTTON1); break; case DOM_BUTTON_XBUTTON2: - ev->set_button_index(MOUSE_BUTTON_XBUTTON2); + ev->set_button_index(MouseButton::MB_XBUTTON2); break; default: return false; @@ -176,7 +176,7 @@ int DisplayServerJavaScript::mouse_button_callback(int p_pressed, int p_button, if (diff < 400 && Point2(ds->last_click_pos).distance_to(ev->get_position()) < 5) { ds->last_click_ms = 0; ds->last_click_pos = Point2(-100, -100); - ds->last_click_button_index = -1; + ds->last_click_button_index = MouseButton::NONE; ev->set_double_click(true); } @@ -190,11 +190,11 @@ int DisplayServerJavaScript::mouse_button_callback(int p_pressed, int p_button, } } - int mask = Input::get_singleton()->get_mouse_button_mask(); - int button_flag = 1 << (ev->get_button_index() - 1); + MouseButton mask = Input::get_singleton()->get_mouse_button_mask(); + MouseButton button_flag = mouse_button_to_mask(ev->get_button_index()); if (ev->is_pressed()) { mask |= button_flag; - } else if (mask & button_flag) { + } else if ((mask & button_flag) != MouseButton::NONE) { mask &= ~button_flag; } else { // Received release event, but press was outside the canvas, so ignore. @@ -215,11 +215,12 @@ int DisplayServerJavaScript::mouse_button_callback(int p_pressed, int p_button, } void DisplayServerJavaScript::mouse_move_callback(double p_x, double p_y, double p_rel_x, double p_rel_y, int p_modifiers) { - int input_mask = Input::get_singleton()->get_mouse_button_mask(); + MouseButton input_mask = Input::get_singleton()->get_mouse_button_mask(); // For motion outside the canvas, only read mouse movement if dragging // started inside the canvas; imitating desktop app behaviour. - if (!get_singleton()->cursor_inside_canvas && !input_mask) + if (!get_singleton()->cursor_inside_canvas && input_mask == MouseButton::NONE) { return; + } Ref<InputEventMouseMotion> ev; ev.instantiate(); @@ -412,19 +413,19 @@ int DisplayServerJavaScript::mouse_wheel_callback(double p_delta_x, double p_del ev->set_position(input->get_mouse_position()); ev->set_global_position(ev->get_position()); - ev->set_shift_pressed(input->is_key_pressed(KEY_SHIFT)); - ev->set_alt_pressed(input->is_key_pressed(KEY_ALT)); - ev->set_ctrl_pressed(input->is_key_pressed(KEY_CTRL)); - ev->set_meta_pressed(input->is_key_pressed(KEY_META)); + ev->set_shift_pressed(input->is_key_pressed(Key::SHIFT)); + ev->set_alt_pressed(input->is_key_pressed(Key::ALT)); + ev->set_ctrl_pressed(input->is_key_pressed(Key::CTRL)); + ev->set_meta_pressed(input->is_key_pressed(Key::META)); if (p_delta_y < 0) { - ev->set_button_index(MOUSE_BUTTON_WHEEL_UP); + ev->set_button_index(MouseButton::WHEEL_UP); } else if (p_delta_y > 0) { - ev->set_button_index(MOUSE_BUTTON_WHEEL_DOWN); + ev->set_button_index(MouseButton::WHEEL_DOWN); } else if (p_delta_x > 0) { - ev->set_button_index(MOUSE_BUTTON_WHEEL_LEFT); + ev->set_button_index(MouseButton::WHEEL_LEFT); } else if (p_delta_x < 0) { - ev->set_button_index(MOUSE_BUTTON_WHEEL_RIGHT); + ev->set_button_index(MouseButton::WHEEL_RIGHT); } else { return false; } @@ -432,7 +433,7 @@ int DisplayServerJavaScript::mouse_wheel_callback(double p_delta_x, double p_del // Different browsers give wildly different delta values, and we can't // interpret deltaMode, so use default value for wheel events' factor. - int button_flag = 1 << (ev->get_button_index() - 1); + MouseButton button_flag = mouse_button_to_mask(ev->get_button_index()); ev->set_pressed(true); ev->set_button_mask(input->get_mouse_button_mask() | button_flag); @@ -509,12 +510,12 @@ void DisplayServerJavaScript::vk_input_text_callback(const char *p_text, int p_c k.instantiate(); k->set_pressed(true); k->set_echo(false); - k->set_keycode(KEY_RIGHT); + k->set_keycode(Key::RIGHT); input->parse_input_event(k); k.instantiate(); k->set_pressed(false); k->set_echo(false); - k->set_keycode(KEY_RIGHT); + k->set_keycode(Key::RIGHT); input->parse_input_event(k); } } @@ -557,12 +558,12 @@ void DisplayServerJavaScript::process_joypads() { for (int b = 0; b < s_btns_num; b++) { float value = s_btns[b]; // Buttons 6 and 7 in the standard mapping need to be - // axis to be handled as JOY_AXIS_TRIGGER by Godot. + // axis to be handled as JoyAxis::TRIGGER by Godot. if (s_standard && (b == 6 || b == 7)) { Input::JoyAxisValue joy_axis; joy_axis.min = 0; joy_axis.value = value; - JoyAxis a = b == 6 ? JOY_AXIS_TRIGGER_LEFT : JOY_AXIS_TRIGGER_RIGHT; + JoyAxis a = b == 6 ? JoyAxis::TRIGGER_LEFT : JoyAxis::TRIGGER_RIGHT; input->joy_axis(idx, a, joy_axis); } else { input->joy_button(idx, (JoyButton)b, value); diff --git a/platform/javascript/display_server_javascript.h b/platform/javascript/display_server_javascript.h index 1aa600c421..80ce772a79 100644 --- a/platform/javascript/display_server_javascript.h +++ b/platform/javascript/display_server_javascript.h @@ -67,7 +67,7 @@ private: CursorShape cursor_shape = CURSOR_ARROW; Point2i last_click_pos = Point2(-100, -100); // TODO check this again. uint64_t last_click_ms = 0; - int last_click_button_index = -1; + MouseButton last_click_button_index = MouseButton::NONE; bool swap_cancel_ok = false; diff --git a/platform/javascript/dom_keys.inc b/platform/javascript/dom_keys.inc index 0e62776923..31589f3f40 100644 --- a/platform/javascript/dom_keys.inc +++ b/platform/javascript/dom_keys.inc @@ -34,7 +34,7 @@ Key dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], bool p_physical) { #define DOM2GODOT(p_str, p_godot_code) \ if (memcmp((const void *)p_str, (void *)p_code, strlen(p_str) + 1) == 0) { \ - return KEY_##p_godot_code; \ + return Key::p_godot_code; \ } // Numpad section. @@ -105,16 +105,16 @@ Key dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], b DOM2GODOT("BracketLeft", BRACKETLEFT); DOM2GODOT("BracketRight", BRACKETRIGHT); DOM2GODOT("Comma", COMMA); - DOM2GODOT("Digit0", 0); - DOM2GODOT("Digit1", 1); - DOM2GODOT("Digit2", 2); - DOM2GODOT("Digit3", 3); - DOM2GODOT("Digit4", 4); - DOM2GODOT("Digit5", 5); - DOM2GODOT("Digit6", 6); - DOM2GODOT("Digit7", 7); - DOM2GODOT("Digit8", 8); - DOM2GODOT("Digit9", 9); + DOM2GODOT("Digit0", KEY_0); + DOM2GODOT("Digit1", KEY_1); + DOM2GODOT("Digit2", KEY_2); + DOM2GODOT("Digit3", KEY_3); + DOM2GODOT("Digit4", KEY_4); + DOM2GODOT("Digit5", KEY_5); + DOM2GODOT("Digit6", KEY_6); + DOM2GODOT("Digit7", KEY_7); + DOM2GODOT("Digit8", KEY_8); + DOM2GODOT("Digit9", KEY_9); DOM2GODOT("Equal", EQUAL); DOM2GODOT("IntlBackslash", BACKSLASH); //DOM2GODOT("IntlRo", UNKNOWN); @@ -170,7 +170,7 @@ Key dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], b DOM2GODOT("Tab", TAB); // ControlPad section. - DOM2GODOT("Delete", DELETE); + DOM2GODOT("Delete", KEY_DELETE); DOM2GODOT("End", END); DOM2GODOT("Help", HELP); DOM2GODOT("Home", HOME); @@ -227,6 +227,6 @@ Key dom_code2godot_scancode(EM_UTF8 const p_code[32], EM_UTF8 const p_key[32], b DOM2GODOT("AudioVolumeMute", VOLUMEMUTE); DOM2GODOT("AudioVolumeUp", VOLUMEUP); //DOM2GODOT("WakeUp", UNKNOWN); - return KEY_UNKNOWN; + return Key::UNKNOWN; #undef DOM2GODOT } diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 4431bd5f1b..5da9a96a90 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -36,7 +36,7 @@ #include "main/main.h" #include "platform/javascript/display_server_javascript.h" -#include "modules/modules_enabled.gen.h" +#include "modules/modules_enabled.gen.h" // For websocket. #ifdef MODULE_WEBSOCKET_ENABLED #include "modules/websocket/remote_debugger_peer_websocket.h" #endif diff --git a/platform/linuxbsd/crash_handler_linuxbsd.cpp b/platform/linuxbsd/crash_handler_linuxbsd.cpp index 0e98af71fa..9b24b24cb4 100644 --- a/platform/linuxbsd/crash_handler_linuxbsd.cpp +++ b/platform/linuxbsd/crash_handler_linuxbsd.cpp @@ -115,7 +115,7 @@ static void handle_crash(int sig) { int ret; Error err = OS::get_singleton()->execute(String("addr2line"), args, &output, &ret); if (err == OK) { - output.erase(output.length() - 1, 1); + output = output.substr(0, output.length() - 1); } fprintf(stderr, "[%ld] %s (%s)\n", (long int)i, fname, output.utf8().get_data()); diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 9349d378d0..2a62780410 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -2408,9 +2408,9 @@ String DisplayServerX11::keyboard_get_layout_name(int p_index) const { } Key DisplayServerX11::keyboard_get_keycode_from_physical(Key p_keycode) const { - unsigned int modifiers = p_keycode & KEY_MODIFIER_MASK; - unsigned int keycode_no_mod = p_keycode & KEY_CODE_MASK; - unsigned int xkeycode = KeyMappingX11::get_xlibcode((Key)keycode_no_mod); + Key modifiers = p_keycode & KeyModifierMask::MODIFIER_MASK; + Key keycode_no_mod = p_keycode & KeyModifierMask::CODE_MASK; + unsigned int xkeycode = KeyMappingX11::get_xlibcode(keycode_no_mod); KeySym xkeysym = XkbKeycodeToKeysym(x11_display, xkeycode, 0, 0); if (xkeysym >= 'a' && xkeysym <= 'z') { xkeysym -= ('a' - 'A'); @@ -2419,7 +2419,7 @@ Key DisplayServerX11::keyboard_get_keycode_from_physical(Key p_keycode) const { Key key = KeyMappingX11::get_keycode(xkeysym); // If not found, fallback to QWERTY. // This should match the behavior of the event pump - if (key == KEY_NONE) { + if (key == Key::NONE) { return p_keycode; } return (Key)(key | modifiers); @@ -2493,12 +2493,12 @@ void DisplayServerX11::_get_key_modifier_state(unsigned int p_x11_state, Ref<Inp } MouseButton DisplayServerX11::_get_mouse_button_state(MouseButton p_x11_button, int p_x11_type) { - MouseButton mask = MouseButton(1 << (p_x11_button - 1)); + MouseButton mask = mouse_button_to_mask(p_x11_button); if (p_x11_type == ButtonPress) { last_button_state |= mask; } else { - last_button_state &= MouseButton(~mask); + last_button_state &= ~mask; } return last_button_state; @@ -2565,9 +2565,9 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, if (status == XLookupChars) { bool keypress = xkeyevent->type == KeyPress; Key keycode = KeyMappingX11::get_keycode(keysym_keycode); - unsigned int physical_keycode = KeyMappingX11::get_scancode(xkeyevent->keycode); + Key physical_keycode = KeyMappingX11::get_scancode(xkeyevent->keycode); - if (keycode >= 'a' && keycode <= 'z') { + if (keycode >= Key::A + 32 && keycode <= Key::Z + 32) { keycode -= 'a' - 'A'; } @@ -2576,11 +2576,11 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, for (int i = 0; i < tmp.length(); i++) { Ref<InputEventKey> k; k.instantiate(); - if (physical_keycode == 0 && keycode == 0 && tmp[i] == 0) { + if (physical_keycode == Key::NONE && keycode == Key::NONE && tmp[i] == 0) { continue; } - if (keycode == 0) { + if (keycode == Key::NONE) { keycode = (Key)physical_keycode; } @@ -2597,10 +2597,10 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, k->set_echo(false); - if (k->get_keycode() == KEY_BACKTAB) { + if (k->get_keycode() == Key::BACKTAB) { //make it consistent across platforms. - k->set_keycode(KEY_TAB); - k->set_physical_keycode(KEY_TAB); + k->set_keycode(Key::TAB); + k->set_physical_keycode(Key::TAB); k->set_shift_pressed(true); } @@ -2629,7 +2629,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, // keysym, so it works in all platforms the same. Key keycode = KeyMappingX11::get_keycode(keysym_keycode); - unsigned int physical_keycode = KeyMappingX11::get_scancode(xkeyevent->keycode); + Key physical_keycode = KeyMappingX11::get_scancode(xkeyevent->keycode); /* Phase 3, obtain a unicode character from the keysym */ @@ -2649,11 +2649,11 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, bool keypress = xkeyevent->type == KeyPress; - if (physical_keycode == 0 && keycode == KEY_NONE && unicode == 0) { + if (physical_keycode == Key::NONE && keycode == Key::NONE && unicode == 0) { return; } - if (keycode == KEY_NONE) { + if (keycode == Key::NONE) { keycode = (Key)physical_keycode; } @@ -2716,7 +2716,7 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, k->set_pressed(keypress); - if (keycode >= 'a' && keycode <= 'z') { + if (keycode >= Key::A + 32 && keycode <= Key::Z + 32) { keycode -= int('a' - 'A'); } @@ -2725,23 +2725,23 @@ void DisplayServerX11::_handle_key_event(WindowID p_window, XKeyEvent *p_event, k->set_unicode(unicode); k->set_echo(p_echo); - if (k->get_keycode() == KEY_BACKTAB) { + if (k->get_keycode() == Key::BACKTAB) { //make it consistent across platforms. - k->set_keycode(KEY_TAB); - k->set_physical_keycode(KEY_TAB); + k->set_keycode(Key::TAB); + k->set_physical_keycode(Key::TAB); k->set_shift_pressed(true); } //don't set mod state if modifier keys are released by themselves //else event.is_action() will not work correctly here if (!k->is_pressed()) { - if (k->get_keycode() == KEY_SHIFT) { + if (k->get_keycode() == Key::SHIFT) { k->set_shift_pressed(false); - } else if (k->get_keycode() == KEY_CTRL) { + } else if (k->get_keycode() == Key::CTRL) { k->set_ctrl_pressed(false); - } else if (k->get_keycode() == KEY_ALT) { + } else if (k->get_keycode() == Key::ALT) { k->set_alt_pressed(false); - } else if (k->get_keycode() == KEY_META) { + } else if (k->get_keycode() == Key::META) { k->set_meta_pressed(false); } } @@ -3469,10 +3469,10 @@ void DisplayServerX11::process_events() { mb->set_window_id(window_id); _get_key_modifier_state(event.xbutton.state, mb); mb->set_button_index((MouseButton)event.xbutton.button); - if (mb->get_button_index() == MOUSE_BUTTON_RIGHT) { - mb->set_button_index(MOUSE_BUTTON_MIDDLE); - } else if (mb->get_button_index() == MOUSE_BUTTON_MIDDLE) { - mb->set_button_index(MOUSE_BUTTON_RIGHT); + if (mb->get_button_index() == MouseButton::RIGHT) { + mb->set_button_index(MouseButton::MIDDLE); + } else if (mb->get_button_index() == MouseButton::MIDDLE) { + mb->set_button_index(MouseButton::RIGHT); } mb->set_button_mask(_get_mouse_button_state(mb->get_button_index(), event.xbutton.type)); mb->set_position(Vector2(event.xbutton.x, event.xbutton.y)); @@ -3498,11 +3498,11 @@ void DisplayServerX11::process_events() { if (diff < 400 && Vector2(last_click_pos).distance_to(Vector2(event.xbutton.x, event.xbutton.y)) < 5) { last_click_ms = 0; last_click_pos = Point2i(-100, -100); - last_click_button_index = -1; + last_click_button_index = MouseButton::NONE; mb->set_double_click(true); } - } else if (mb->get_button_index() < 4 || mb->get_button_index() > 7) { + } else if (mb->get_button_index() < MouseButton::WHEEL_UP || mb->get_button_index() > MouseButton::WHEEL_RIGHT) { last_click_button_index = mb->get_button_index(); } @@ -3635,12 +3635,12 @@ void DisplayServerX11::process_events() { if (xi.pressure_supported) { mm->set_pressure(xi.pressure); } else { - mm->set_pressure((mouse_get_button_state() & MOUSE_BUTTON_MASK_LEFT) ? 1.0f : 0.0f); + mm->set_pressure(bool(mouse_get_button_state() & MouseButton::MASK_LEFT) ? 1.0f : 0.0f); } mm->set_tilt(xi.tilt); _get_key_modifier_state(event.xmotion.state, mm); - mm->set_button_mask(mouse_get_button_state()); + mm->set_button_mask((MouseButton)mouse_get_button_state()); mm->set_position(pos); mm->set_global_position(pos); Input::get_singleton()->set_mouse_position(pos); @@ -4251,7 +4251,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode xmbstring = nullptr; last_click_ms = 0; - last_click_button_index = -1; + last_click_button_index = MouseButton::NONE; last_click_pos = Point2i(-100, -100); last_timestamp = 0; diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index 869ff386c5..3587d587d6 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -173,8 +173,8 @@ class DisplayServerX11 : public DisplayServer { bool last_mouse_pos_valid; Point2i last_click_pos; uint64_t last_click_ms; - int last_click_button_index; - MouseButton last_button_state = MOUSE_BUTTON_NONE; + MouseButton last_click_button_index = MouseButton::NONE; + MouseButton last_button_state = MouseButton::NONE; bool app_focused = false; uint64_t time_since_no_focus = 0; diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp index 8b6dbc4c20..1c6afabfab 100644 --- a/platform/linuxbsd/joypad_linux.cpp +++ b/platform/linuxbsd/joypad_linux.cpp @@ -59,7 +59,7 @@ JoypadLinux::Joypad::~Joypad() { } void JoypadLinux::Joypad::reset() { - dpad = 0; + dpad = HatMask::CENTER; fd = -1; Input::JoyAxisValue jx; @@ -484,12 +484,12 @@ void JoypadLinux::process_joypads() { case ABS_HAT0X: if (ev.value != 0) { if (ev.value < 0) { - joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_LEFT) & ~HatMask::HAT_MASK_RIGHT); + joy->dpad = (HatMask)((joy->dpad | HatMask::LEFT) & ~HatMask::RIGHT); } else { - joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_RIGHT) & ~HatMask::HAT_MASK_LEFT); + joy->dpad = (HatMask)((joy->dpad | HatMask::RIGHT) & ~HatMask::LEFT); } } else { - joy->dpad &= ~(HatMask::HAT_MASK_LEFT | HatMask::HAT_MASK_RIGHT); + joy->dpad &= ~(HatMask::LEFT | HatMask::RIGHT); } input->joy_hat(i, (HatMask)joy->dpad); @@ -498,12 +498,12 @@ void JoypadLinux::process_joypads() { case ABS_HAT0Y: if (ev.value != 0) { if (ev.value < 0) { - joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_UP) & ~HatMask::HAT_MASK_DOWN); + joy->dpad = (HatMask)((joy->dpad | HatMask::UP) & ~HatMask::DOWN); } else { - joy->dpad = (HatMask)((joy->dpad | HatMask::HAT_MASK_DOWN) & ~HatMask::HAT_MASK_UP); + joy->dpad = (HatMask)((joy->dpad | HatMask::DOWN) & ~HatMask::UP); } } else { - joy->dpad &= ~(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_DOWN); + joy->dpad &= ~(HatMask::UP | HatMask::DOWN); } input->joy_hat(i, (HatMask)joy->dpad); diff --git a/platform/linuxbsd/joypad_linux.h b/platform/linuxbsd/joypad_linux.h index 177d7a51ce..12b9046d64 100644 --- a/platform/linuxbsd/joypad_linux.h +++ b/platform/linuxbsd/joypad_linux.h @@ -56,7 +56,7 @@ private: Input::JoyAxisValue curr_axis[MAX_ABS]; int key_map[MAX_KEY]; int abs_map[MAX_ABS]; - int dpad = 0; + HatMask dpad = HatMask::CENTER; int fd = -1; String devpath; diff --git a/platform/linuxbsd/key_mapping_x11.cpp b/platform/linuxbsd/key_mapping_x11.cpp index 829feda40a..16c2392859 100644 --- a/platform/linuxbsd/key_mapping_x11.cpp +++ b/platform/linuxbsd/key_mapping_x11.cpp @@ -40,266 +40,266 @@ struct _XTranslatePair { static _XTranslatePair _xkeysym_to_keycode[] = { // misc keys - { XK_Escape, KEY_ESCAPE }, - { XK_Tab, KEY_TAB }, - { XK_ISO_Left_Tab, KEY_BACKTAB }, - { XK_BackSpace, KEY_BACKSPACE }, - { XK_Return, KEY_ENTER }, - { XK_Insert, KEY_INSERT }, - { XK_Delete, KEY_DELETE }, - { XK_Clear, KEY_DELETE }, - { XK_Pause, KEY_PAUSE }, - { XK_Print, KEY_PRINT }, - { XK_Home, KEY_HOME }, - { XK_End, KEY_END }, - { XK_Left, KEY_LEFT }, - { XK_Up, KEY_UP }, - { XK_Right, KEY_RIGHT }, - { XK_Down, KEY_DOWN }, - { XK_Prior, KEY_PAGEUP }, - { XK_Next, KEY_PAGEDOWN }, - { XK_Shift_L, KEY_SHIFT }, - { XK_Shift_R, KEY_SHIFT }, - { XK_Shift_Lock, KEY_SHIFT }, - { XK_Control_L, KEY_CTRL }, - { XK_Control_R, KEY_CTRL }, - { XK_Meta_L, KEY_META }, - { XK_Meta_R, KEY_META }, - { XK_Alt_L, KEY_ALT }, - { XK_Alt_R, KEY_ALT }, - { XK_Caps_Lock, KEY_CAPSLOCK }, - { XK_Num_Lock, KEY_NUMLOCK }, - { XK_Scroll_Lock, KEY_SCROLLLOCK }, - { XK_Super_L, KEY_SUPER_L }, - { XK_Super_R, KEY_SUPER_R }, - { XK_Menu, KEY_MENU }, - { XK_Hyper_L, KEY_HYPER_L }, - { XK_Hyper_R, KEY_HYPER_R }, - { XK_Help, KEY_HELP }, - { XK_KP_Space, KEY_SPACE }, - { XK_KP_Tab, KEY_TAB }, - { XK_KP_Enter, KEY_KP_ENTER }, - { XK_Home, KEY_HOME }, - { XK_Left, KEY_LEFT }, - { XK_Up, KEY_UP }, - { XK_Right, KEY_RIGHT }, - { XK_Down, KEY_DOWN }, - { XK_Prior, KEY_PAGEUP }, - { XK_Next, KEY_PAGEDOWN }, - { XK_End, KEY_END }, - { XK_Begin, KEY_CLEAR }, - { XK_Insert, KEY_INSERT }, - { XK_Delete, KEY_DELETE }, - //{ XK_KP_Equal, KEY_EQUAL }, - //{ XK_KP_Separator, KEY_COMMA }, - { XK_KP_Decimal, KEY_KP_PERIOD }, - { XK_KP_Delete, KEY_KP_PERIOD }, - { XK_KP_Multiply, KEY_KP_MULTIPLY }, - { XK_KP_Divide, KEY_KP_DIVIDE }, - { XK_KP_Subtract, KEY_KP_SUBTRACT }, - { XK_KP_Add, KEY_KP_ADD }, - { XK_KP_0, KEY_KP_0 }, - { XK_KP_1, KEY_KP_1 }, - { XK_KP_2, KEY_KP_2 }, - { XK_KP_3, KEY_KP_3 }, - { XK_KP_4, KEY_KP_4 }, - { XK_KP_5, KEY_KP_5 }, - { XK_KP_6, KEY_KP_6 }, - { XK_KP_7, KEY_KP_7 }, - { XK_KP_8, KEY_KP_8 }, - { XK_KP_9, KEY_KP_9 }, + { XK_Escape, Key::ESCAPE }, + { XK_Tab, Key::TAB }, + { XK_ISO_Left_Tab, Key::BACKTAB }, + { XK_BackSpace, Key::BACKSPACE }, + { XK_Return, Key::ENTER }, + { XK_Insert, Key::INSERT }, + { XK_Delete, Key::KEY_DELETE }, + { XK_Clear, Key::KEY_DELETE }, + { XK_Pause, Key::PAUSE }, + { XK_Print, Key::PRINT }, + { XK_Home, Key::HOME }, + { XK_End, Key::END }, + { XK_Left, Key::LEFT }, + { XK_Up, Key::UP }, + { XK_Right, Key::RIGHT }, + { XK_Down, Key::DOWN }, + { XK_Prior, Key::PAGEUP }, + { XK_Next, Key::PAGEDOWN }, + { XK_Shift_L, Key::SHIFT }, + { XK_Shift_R, Key::SHIFT }, + { XK_Shift_Lock, Key::SHIFT }, + { XK_Control_L, Key::CTRL }, + { XK_Control_R, Key::CTRL }, + { XK_Meta_L, Key::META }, + { XK_Meta_R, Key::META }, + { XK_Alt_L, Key::ALT }, + { XK_Alt_R, Key::ALT }, + { XK_Caps_Lock, Key::CAPSLOCK }, + { XK_Num_Lock, Key::NUMLOCK }, + { XK_Scroll_Lock, Key::SCROLLLOCK }, + { XK_Super_L, Key::SUPER_L }, + { XK_Super_R, Key::SUPER_R }, + { XK_Menu, Key::MENU }, + { XK_Hyper_L, Key::HYPER_L }, + { XK_Hyper_R, Key::HYPER_R }, + { XK_Help, Key::HELP }, + { XK_KP_Space, Key::SPACE }, + { XK_KP_Tab, Key::TAB }, + { XK_KP_Enter, Key::KP_ENTER }, + { XK_Home, Key::HOME }, + { XK_Left, Key::LEFT }, + { XK_Up, Key::UP }, + { XK_Right, Key::RIGHT }, + { XK_Down, Key::DOWN }, + { XK_Prior, Key::PAGEUP }, + { XK_Next, Key::PAGEDOWN }, + { XK_End, Key::END }, + { XK_Begin, Key::CLEAR }, + { XK_Insert, Key::INSERT }, + { XK_Delete, Key::KEY_DELETE }, + //{ XK_KP_Equal, Key::EQUAL }, + //{ XK_KP_Separator, Key::COMMA }, + { XK_KP_Decimal, Key::KP_PERIOD }, + { XK_KP_Delete, Key::KP_PERIOD }, + { XK_KP_Multiply, Key::KP_MULTIPLY }, + { XK_KP_Divide, Key::KP_DIVIDE }, + { XK_KP_Subtract, Key::KP_SUBTRACT }, + { XK_KP_Add, Key::KP_ADD }, + { XK_KP_0, Key::KP_0 }, + { XK_KP_1, Key::KP_1 }, + { XK_KP_2, Key::KP_2 }, + { XK_KP_3, Key::KP_3 }, + { XK_KP_4, Key::KP_4 }, + { XK_KP_5, Key::KP_5 }, + { XK_KP_6, Key::KP_6 }, + { XK_KP_7, Key::KP_7 }, + { XK_KP_8, Key::KP_8 }, + { XK_KP_9, Key::KP_9 }, // same but with numlock - { XK_KP_Insert, KEY_KP_0 }, - { XK_KP_End, KEY_KP_1 }, - { XK_KP_Down, KEY_KP_2 }, - { XK_KP_Page_Down, KEY_KP_3 }, - { XK_KP_Left, KEY_KP_4 }, - { XK_KP_Begin, KEY_KP_5 }, - { XK_KP_Right, KEY_KP_6 }, - { XK_KP_Home, KEY_KP_7 }, - { XK_KP_Up, KEY_KP_8 }, - { XK_KP_Page_Up, KEY_KP_9 }, - { XK_F1, KEY_F1 }, - { XK_F2, KEY_F2 }, - { XK_F3, KEY_F3 }, - { XK_F4, KEY_F4 }, - { XK_F5, KEY_F5 }, - { XK_F6, KEY_F6 }, - { XK_F7, KEY_F7 }, - { XK_F8, KEY_F8 }, - { XK_F9, KEY_F9 }, - { XK_F10, KEY_F10 }, - { XK_F11, KEY_F11 }, - { XK_F12, KEY_F12 }, - { XK_F13, KEY_F13 }, - { XK_F14, KEY_F14 }, - { XK_F15, KEY_F15 }, - { XK_F16, KEY_F16 }, + { XK_KP_Insert, Key::KP_0 }, + { XK_KP_End, Key::KP_1 }, + { XK_KP_Down, Key::KP_2 }, + { XK_KP_Page_Down, Key::KP_3 }, + { XK_KP_Left, Key::KP_4 }, + { XK_KP_Begin, Key::KP_5 }, + { XK_KP_Right, Key::KP_6 }, + { XK_KP_Home, Key::KP_7 }, + { XK_KP_Up, Key::KP_8 }, + { XK_KP_Page_Up, Key::KP_9 }, + { XK_F1, Key::F1 }, + { XK_F2, Key::F2 }, + { XK_F3, Key::F3 }, + { XK_F4, Key::F4 }, + { XK_F5, Key::F5 }, + { XK_F6, Key::F6 }, + { XK_F7, Key::F7 }, + { XK_F8, Key::F8 }, + { XK_F9, Key::F9 }, + { XK_F10, Key::F10 }, + { XK_F11, Key::F11 }, + { XK_F12, Key::F12 }, + { XK_F13, Key::F13 }, + { XK_F14, Key::F14 }, + { XK_F15, Key::F15 }, + { XK_F16, Key::F16 }, // media keys - { XF86XK_Back, KEY_BACK }, - { XF86XK_Forward, KEY_FORWARD }, - { XF86XK_Stop, KEY_STOP }, - { XF86XK_Refresh, KEY_REFRESH }, - { XF86XK_Favorites, KEY_FAVORITES }, - { XF86XK_AudioMedia, KEY_LAUNCHMEDIA }, - { XF86XK_OpenURL, KEY_OPENURL }, - { XF86XK_HomePage, KEY_HOMEPAGE }, - { XF86XK_Search, KEY_SEARCH }, - { XF86XK_AudioLowerVolume, KEY_VOLUMEDOWN }, - { XF86XK_AudioMute, KEY_VOLUMEMUTE }, - { XF86XK_AudioRaiseVolume, KEY_VOLUMEUP }, - { XF86XK_AudioPlay, KEY_MEDIAPLAY }, - { XF86XK_AudioStop, KEY_MEDIASTOP }, - { XF86XK_AudioPrev, KEY_MEDIAPREVIOUS }, - { XF86XK_AudioNext, KEY_MEDIANEXT }, - { XF86XK_AudioRecord, KEY_MEDIARECORD }, + { XF86XK_Back, Key::BACK }, + { XF86XK_Forward, Key::FORWARD }, + { XF86XK_Stop, Key::STOP }, + { XF86XK_Refresh, Key::REFRESH }, + { XF86XK_Favorites, Key::FAVORITES }, + { XF86XK_AudioMedia, Key::LAUNCHMEDIA }, + { XF86XK_OpenURL, Key::OPENURL }, + { XF86XK_HomePage, Key::HOMEPAGE }, + { XF86XK_Search, Key::SEARCH }, + { XF86XK_AudioLowerVolume, Key::VOLUMEDOWN }, + { XF86XK_AudioMute, Key::VOLUMEMUTE }, + { XF86XK_AudioRaiseVolume, Key::VOLUMEUP }, + { XF86XK_AudioPlay, Key::MEDIAPLAY }, + { XF86XK_AudioStop, Key::MEDIASTOP }, + { XF86XK_AudioPrev, Key::MEDIAPREVIOUS }, + { XF86XK_AudioNext, Key::MEDIANEXT }, + { XF86XK_AudioRecord, Key::MEDIARECORD }, // launch keys - { XF86XK_Mail, KEY_LAUNCHMAIL }, - { XF86XK_MyComputer, KEY_LAUNCH0 }, - { XF86XK_Calculator, KEY_LAUNCH1 }, - { XF86XK_Standby, KEY_STANDBY }, + { XF86XK_Mail, Key::LAUNCHMAIL }, + { XF86XK_MyComputer, Key::LAUNCH0 }, + { XF86XK_Calculator, Key::LAUNCH1 }, + { XF86XK_Standby, Key::STANDBY }, - { XF86XK_Launch0, KEY_LAUNCH2 }, - { XF86XK_Launch1, KEY_LAUNCH3 }, - { XF86XK_Launch2, KEY_LAUNCH4 }, - { XF86XK_Launch3, KEY_LAUNCH5 }, - { XF86XK_Launch4, KEY_LAUNCH6 }, - { XF86XK_Launch5, KEY_LAUNCH7 }, - { XF86XK_Launch6, KEY_LAUNCH8 }, - { XF86XK_Launch7, KEY_LAUNCH9 }, - { XF86XK_Launch8, KEY_LAUNCHA }, - { XF86XK_Launch9, KEY_LAUNCHB }, - { XF86XK_LaunchA, KEY_LAUNCHC }, - { XF86XK_LaunchB, KEY_LAUNCHD }, - { XF86XK_LaunchC, KEY_LAUNCHE }, - { XF86XK_LaunchD, KEY_LAUNCHF }, + { XF86XK_Launch0, Key::LAUNCH2 }, + { XF86XK_Launch1, Key::LAUNCH3 }, + { XF86XK_Launch2, Key::LAUNCH4 }, + { XF86XK_Launch3, Key::LAUNCH5 }, + { XF86XK_Launch4, Key::LAUNCH6 }, + { XF86XK_Launch5, Key::LAUNCH7 }, + { XF86XK_Launch6, Key::LAUNCH8 }, + { XF86XK_Launch7, Key::LAUNCH9 }, + { XF86XK_Launch8, Key::LAUNCHA }, + { XF86XK_Launch9, Key::LAUNCHB }, + { XF86XK_LaunchA, Key::LAUNCHC }, + { XF86XK_LaunchB, Key::LAUNCHD }, + { XF86XK_LaunchC, Key::LAUNCHE }, + { XF86XK_LaunchD, Key::LAUNCHF }, - { 0, KEY_NONE } + { 0, Key::NONE } }; struct _TranslatePair { - unsigned int keysym; + Key keysym; unsigned int keycode; }; static _TranslatePair _scancode_to_keycode[] = { - { KEY_ESCAPE, 0x09 }, - { KEY_1, 0x0A }, - { KEY_2, 0x0B }, - { KEY_3, 0x0C }, - { KEY_4, 0x0D }, - { KEY_5, 0x0E }, - { KEY_6, 0x0F }, - { KEY_7, 0x10 }, - { KEY_8, 0x11 }, - { KEY_9, 0x12 }, - { KEY_0, 0x13 }, - { KEY_MINUS, 0x14 }, - { KEY_EQUAL, 0x15 }, - { KEY_BACKSPACE, 0x16 }, - { KEY_TAB, 0x17 }, - { KEY_Q, 0x18 }, - { KEY_W, 0x19 }, - { KEY_E, 0x1A }, - { KEY_R, 0x1B }, - { KEY_T, 0x1C }, - { KEY_Y, 0x1D }, - { KEY_U, 0x1E }, - { KEY_I, 0x1F }, - { KEY_O, 0x20 }, - { KEY_P, 0x21 }, - { KEY_BRACELEFT, 0x22 }, - { KEY_BRACERIGHT, 0x23 }, - { KEY_ENTER, 0x24 }, - { KEY_CTRL, 0x25 }, - { KEY_A, 0x26 }, - { KEY_S, 0x27 }, - { KEY_D, 0x28 }, - { KEY_F, 0x29 }, - { KEY_G, 0x2A }, - { KEY_H, 0x2B }, - { KEY_J, 0x2C }, - { KEY_K, 0x2D }, - { KEY_L, 0x2E }, - { KEY_SEMICOLON, 0x2F }, - { KEY_APOSTROPHE, 0x30 }, - { KEY_QUOTELEFT, 0x31 }, - { KEY_SHIFT, 0x32 }, - { KEY_BACKSLASH, 0x33 }, - { KEY_Z, 0x34 }, - { KEY_X, 0x35 }, - { KEY_C, 0x36 }, - { KEY_V, 0x37 }, - { KEY_B, 0x38 }, - { KEY_N, 0x39 }, - { KEY_M, 0x3A }, - { KEY_COMMA, 0x3B }, - { KEY_PERIOD, 0x3C }, - { KEY_SLASH, 0x3D }, - { KEY_SHIFT, 0x3E }, - { KEY_KP_MULTIPLY, 0x3F }, - { KEY_ALT, 0x40 }, - { KEY_SPACE, 0x41 }, - { KEY_CAPSLOCK, 0x42 }, - { KEY_F1, 0x43 }, - { KEY_F2, 0x44 }, - { KEY_F3, 0x45 }, - { KEY_F4, 0x46 }, - { KEY_F5, 0x47 }, - { KEY_F6, 0x48 }, - { KEY_F7, 0x49 }, - { KEY_F8, 0x4A }, - { KEY_F9, 0x4B }, - { KEY_F10, 0x4C }, - { KEY_NUMLOCK, 0x4D }, - { KEY_SCROLLLOCK, 0x4E }, - { KEY_KP_7, 0x4F }, - { KEY_KP_8, 0x50 }, - { KEY_KP_9, 0x51 }, - { KEY_KP_SUBTRACT, 0x52 }, - { KEY_KP_4, 0x53 }, - { KEY_KP_5, 0x54 }, - { KEY_KP_6, 0x55 }, - { KEY_KP_ADD, 0x56 }, - { KEY_KP_1, 0x57 }, - { KEY_KP_2, 0x58 }, - { KEY_KP_3, 0x59 }, - { KEY_KP_0, 0x5A }, - { KEY_KP_PERIOD, 0x5B }, - //{ KEY_???, 0x5E }, //NON US BACKSLASH - { KEY_F11, 0x5F }, - { KEY_F12, 0x60 }, - { KEY_KP_ENTER, 0x68 }, - { KEY_CTRL, 0x69 }, - { KEY_KP_DIVIDE, 0x6A }, - { KEY_PRINT, 0x6B }, - { KEY_ALT, 0x6C }, - { KEY_ENTER, 0x6D }, - { KEY_HOME, 0x6E }, - { KEY_UP, 0x6F }, - { KEY_PAGEUP, 0x70 }, - { KEY_LEFT, 0x71 }, - { KEY_RIGHT, 0x72 }, - { KEY_END, 0x73 }, - { KEY_DOWN, 0x74 }, - { KEY_PAGEDOWN, 0x75 }, - { KEY_INSERT, 0x76 }, - { KEY_DELETE, 0x77 }, - { KEY_VOLUMEMUTE, 0x79 }, - { KEY_VOLUMEDOWN, 0x7A }, - { KEY_VOLUMEUP, 0x7B }, - { KEY_PAUSE, 0x7F }, - { KEY_SUPER_L, 0x85 }, - { KEY_SUPER_R, 0x86 }, - { KEY_MENU, 0x87 }, - { KEY_UNKNOWN, 0 } + { Key::ESCAPE, 0x09 }, + { Key::KEY_1, 0x0A }, + { Key::KEY_2, 0x0B }, + { Key::KEY_3, 0x0C }, + { Key::KEY_4, 0x0D }, + { Key::KEY_5, 0x0E }, + { Key::KEY_6, 0x0F }, + { Key::KEY_7, 0x10 }, + { Key::KEY_8, 0x11 }, + { Key::KEY_9, 0x12 }, + { Key::KEY_0, 0x13 }, + { Key::MINUS, 0x14 }, + { Key::EQUAL, 0x15 }, + { Key::BACKSPACE, 0x16 }, + { Key::TAB, 0x17 }, + { Key::Q, 0x18 }, + { Key::W, 0x19 }, + { Key::E, 0x1A }, + { Key::R, 0x1B }, + { Key::T, 0x1C }, + { Key::Y, 0x1D }, + { Key::U, 0x1E }, + { Key::I, 0x1F }, + { Key::O, 0x20 }, + { Key::P, 0x21 }, + { Key::BRACELEFT, 0x22 }, + { Key::BRACERIGHT, 0x23 }, + { Key::ENTER, 0x24 }, + { Key::CTRL, 0x25 }, + { Key::A, 0x26 }, + { Key::S, 0x27 }, + { Key::D, 0x28 }, + { Key::F, 0x29 }, + { Key::G, 0x2A }, + { Key::H, 0x2B }, + { Key::J, 0x2C }, + { Key::K, 0x2D }, + { Key::L, 0x2E }, + { Key::SEMICOLON, 0x2F }, + { Key::APOSTROPHE, 0x30 }, + { Key::QUOTELEFT, 0x31 }, + { Key::SHIFT, 0x32 }, + { Key::BACKSLASH, 0x33 }, + { Key::Z, 0x34 }, + { Key::X, 0x35 }, + { Key::C, 0x36 }, + { Key::V, 0x37 }, + { Key::B, 0x38 }, + { Key::N, 0x39 }, + { Key::M, 0x3A }, + { Key::COMMA, 0x3B }, + { Key::PERIOD, 0x3C }, + { Key::SLASH, 0x3D }, + { Key::SHIFT, 0x3E }, + { Key::KP_MULTIPLY, 0x3F }, + { Key::ALT, 0x40 }, + { Key::SPACE, 0x41 }, + { Key::CAPSLOCK, 0x42 }, + { Key::F1, 0x43 }, + { Key::F2, 0x44 }, + { Key::F3, 0x45 }, + { Key::F4, 0x46 }, + { Key::F5, 0x47 }, + { Key::F6, 0x48 }, + { Key::F7, 0x49 }, + { Key::F8, 0x4A }, + { Key::F9, 0x4B }, + { Key::F10, 0x4C }, + { Key::NUMLOCK, 0x4D }, + { Key::SCROLLLOCK, 0x4E }, + { Key::KP_7, 0x4F }, + { Key::KP_8, 0x50 }, + { Key::KP_9, 0x51 }, + { Key::KP_SUBTRACT, 0x52 }, + { Key::KP_4, 0x53 }, + { Key::KP_5, 0x54 }, + { Key::KP_6, 0x55 }, + { Key::KP_ADD, 0x56 }, + { Key::KP_1, 0x57 }, + { Key::KP_2, 0x58 }, + { Key::KP_3, 0x59 }, + { Key::KP_0, 0x5A }, + { Key::KP_PERIOD, 0x5B }, + //{ Key::???, 0x5E }, //NON US BACKSLASH + { Key::F11, 0x5F }, + { Key::F12, 0x60 }, + { Key::KP_ENTER, 0x68 }, + { Key::CTRL, 0x69 }, + { Key::KP_DIVIDE, 0x6A }, + { Key::PRINT, 0x6B }, + { Key::ALT, 0x6C }, + { Key::ENTER, 0x6D }, + { Key::HOME, 0x6E }, + { Key::UP, 0x6F }, + { Key::PAGEUP, 0x70 }, + { Key::LEFT, 0x71 }, + { Key::RIGHT, 0x72 }, + { Key::END, 0x73 }, + { Key::DOWN, 0x74 }, + { Key::PAGEDOWN, 0x75 }, + { Key::INSERT, 0x76 }, + { Key::KEY_DELETE, 0x77 }, + { Key::VOLUMEMUTE, 0x79 }, + { Key::VOLUMEDOWN, 0x7A }, + { Key::VOLUMEUP, 0x7B }, + { Key::PAUSE, 0x7F }, + { Key::SUPER_L, 0x85 }, + { Key::SUPER_R, 0x86 }, + { Key::MENU, 0x87 }, + { Key::UNKNOWN, 0 } }; -unsigned int KeyMappingX11::get_scancode(unsigned int p_code) { - unsigned int keycode = KEY_UNKNOWN; - for (int i = 0; _scancode_to_keycode[i].keysym != KEY_UNKNOWN; i++) { +Key KeyMappingX11::get_scancode(unsigned int p_code) { + Key keycode = Key::UNKNOWN; + for (int i = 0; _scancode_to_keycode[i].keysym != Key::UNKNOWN; i++) { if (_scancode_to_keycode[i].keycode == p_code) { keycode = _scancode_to_keycode[i].keysym; break; @@ -309,9 +309,9 @@ unsigned int KeyMappingX11::get_scancode(unsigned int p_code) { return keycode; } -unsigned int KeyMappingX11::get_xlibcode(unsigned int p_keysym) { +unsigned int KeyMappingX11::get_xlibcode(Key p_keysym) { unsigned int code = 0; - for (int i = 0; _scancode_to_keycode[i].keysym != KEY_UNKNOWN; i++) { + for (int i = 0; _scancode_to_keycode[i].keysym != Key::UNKNOWN; i++) { if (_scancode_to_keycode[i].keysym == p_keysym) { code = _scancode_to_keycode[i].keycode; break; @@ -335,13 +335,13 @@ Key KeyMappingX11::get_keycode(KeySym p_keysym) { } } - return KEY_NONE; + return Key::NONE; } KeySym KeyMappingX11::get_keysym(Key p_code) { // kinda bruteforce.. could optimize. - if (p_code < 0x100) { // Latin 1, maps 1-1 + if (p_code < Key::END_LATIN1) { // Latin 1, maps 1-1 return (KeySym)p_code; } @@ -352,7 +352,7 @@ KeySym KeyMappingX11::get_keysym(Key p_code) { } } - return (KeySym)KEY_NONE; + return (KeySym)Key::NONE; } /***** UNICODE CONVERSION ******/ diff --git a/platform/linuxbsd/key_mapping_x11.h b/platform/linuxbsd/key_mapping_x11.h index d4f1554671..5f61197abe 100644 --- a/platform/linuxbsd/key_mapping_x11.h +++ b/platform/linuxbsd/key_mapping_x11.h @@ -45,11 +45,11 @@ class KeyMappingX11 { public: static Key get_keycode(KeySym p_keysym); - static unsigned int get_xlibcode(unsigned int p_keysym); - static unsigned int get_scancode(unsigned int p_code); + static unsigned int get_xlibcode(Key p_keysym); + static Key get_scancode(unsigned int p_code); static KeySym get_keysym(Key p_code); static unsigned int get_unicode_from_keysym(KeySym p_keysym); static KeySym get_keysym_from_unicode(unsigned int p_unicode); }; -#endif +#endif // KEY_MAPPING_X11_H diff --git a/platform/osx/crash_handler_osx.mm b/platform/osx/crash_handler_osx.mm index 31228b10b4..2252d5eb4f 100644 --- a/platform/osx/crash_handler_osx.mm +++ b/platform/osx/crash_handler_osx.mm @@ -146,7 +146,7 @@ static void handle_crash(int sig) { String out = ""; Error err = OS::get_singleton()->execute(String("atos"), args, &out, &ret); if (err == OK && out.substr(0, 2) != "0x") { - out.erase(out.length() - 1, 1); + out = out.substr(0, out.length() - 1); output = out; } } diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 6bd79c7d4f..f5c7731395 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -82,7 +82,7 @@ def configure(env): env.Append(CCFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15"]) env.Append(LINKFLAGS=["-arch", "arm64", "-mmacosx-version-min=10.15"]) else: - print("Building for macOS 10.12+, platform x86-64.") + print("Building for macOS 10.12+, platform x86_64.") env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) diff --git a/platform/osx/display_server_osx.h b/platform/osx/display_server_osx.h index c45b470078..3cc0b10c5b 100644 --- a/platform/osx/display_server_osx.h +++ b/platform/osx/display_server_osx.h @@ -84,8 +84,8 @@ public: bool pressed = false; bool echo = false; bool raw = false; - Key keycode = KEY_NONE; - uint32_t physical_keycode = 0; + Key keycode = Key::NONE; + Key physical_keycode = Key::NONE; uint32_t unicode = 0; }; @@ -172,7 +172,7 @@ public: MouseMode mouse_mode; Point2i last_mouse_pos; - MouseButton last_button_state = MOUSE_BUTTON_NONE; + MouseButton last_button_state = MouseButton::NONE; bool window_focused; bool drop_events; diff --git a/platform/osx/display_server_osx.mm b/platform/osx/display_server_osx.mm index 03301af0af..fec5c98a99 100644 --- a/platform/osx/display_server_osx.mm +++ b/platform/osx/display_server_osx.mm @@ -579,8 +579,8 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; ke.pressed = true; ke.echo = false; ke.raw = false; // IME input event - ke.keycode = KEY_NONE; - ke.physical_keycode = 0; + ke.keycode = Key::NONE; + ke.physical_keycode = Key::NONE; ke.unicode = codepoint; _push_to_key_event_buffer(ke); @@ -680,7 +680,7 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, M mb->set_position(pos); mb->set_global_position(pos); mb->set_button_mask(DS_OSX->last_button_state); - if (index == MOUSE_BUTTON_LEFT && pressed) { + if (index == MouseButton::LEFT && pressed) { mb->set_double_click([event clickCount] == 2); } @@ -693,10 +693,10 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, M if (([event modifierFlags] & NSEventModifierFlagControl)) { wd.mouse_down_control = true; - _mouseDownEvent(window_id, event, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MASK_RIGHT, true); + _mouseDownEvent(window_id, event, MouseButton::RIGHT, MouseButton::MASK_RIGHT, true); } else { wd.mouse_down_control = false; - _mouseDownEvent(window_id, event, MOUSE_BUTTON_LEFT, MOUSE_BUTTON_MASK_LEFT, true); + _mouseDownEvent(window_id, event, MouseButton::LEFT, MouseButton::MASK_LEFT, true); } } @@ -709,9 +709,9 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, M DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id]; if (wd.mouse_down_control) { - _mouseDownEvent(window_id, event, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MASK_RIGHT, false); + _mouseDownEvent(window_id, event, MouseButton::RIGHT, MouseButton::MASK_RIGHT, false); } else { - _mouseDownEvent(window_id, event, MOUSE_BUTTON_LEFT, MOUSE_BUTTON_MASK_LEFT, false); + _mouseDownEvent(window_id, event, MouseButton::LEFT, MouseButton::MASK_LEFT, false); } } @@ -797,7 +797,7 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, M } - (void)rightMouseDown:(NSEvent *)event { - _mouseDownEvent(window_id, event, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MASK_RIGHT, true); + _mouseDownEvent(window_id, event, MouseButton::RIGHT, MouseButton::MASK_RIGHT, true); } - (void)rightMouseDragged:(NSEvent *)event { @@ -805,16 +805,16 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, M } - (void)rightMouseUp:(NSEvent *)event { - _mouseDownEvent(window_id, event, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MASK_RIGHT, false); + _mouseDownEvent(window_id, event, MouseButton::RIGHT, MouseButton::MASK_RIGHT, false); } - (void)otherMouseDown:(NSEvent *)event { if ((int)[event buttonNumber] == 2) { - _mouseDownEvent(window_id, event, MOUSE_BUTTON_MIDDLE, MOUSE_BUTTON_MASK_MIDDLE, true); + _mouseDownEvent(window_id, event, MouseButton::MIDDLE, MouseButton::MASK_MIDDLE, true); } else if ((int)[event buttonNumber] == 3) { - _mouseDownEvent(window_id, event, MOUSE_BUTTON_XBUTTON1, MOUSE_BUTTON_MASK_XBUTTON1, true); + _mouseDownEvent(window_id, event, MouseButton::MB_XBUTTON1, MouseButton::MASK_XBUTTON1, true); } else if ((int)[event buttonNumber] == 4) { - _mouseDownEvent(window_id, event, MOUSE_BUTTON_XBUTTON2, MOUSE_BUTTON_MASK_XBUTTON2, true); + _mouseDownEvent(window_id, event, MouseButton::MB_XBUTTON2, MouseButton::MASK_XBUTTON2, true); } else { return; } @@ -826,11 +826,11 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, M - (void)otherMouseUp:(NSEvent *)event { if ((int)[event buttonNumber] == 2) { - _mouseDownEvent(window_id, event, MOUSE_BUTTON_MIDDLE, MOUSE_BUTTON_MASK_MIDDLE, false); + _mouseDownEvent(window_id, event, MouseButton::MIDDLE, MouseButton::MASK_MIDDLE, false); } else if ((int)[event buttonNumber] == 3) { - _mouseDownEvent(window_id, event, MOUSE_BUTTON_XBUTTON1, MOUSE_BUTTON_MASK_XBUTTON1, false); + _mouseDownEvent(window_id, event, MouseButton::MB_XBUTTON1, MouseButton::MASK_XBUTTON1, false); } else if ((int)[event buttonNumber] == 4) { - _mouseDownEvent(window_id, event, MOUSE_BUTTON_XBUTTON2, MOUSE_BUTTON_MASK_XBUTTON2, false); + _mouseDownEvent(window_id, event, MouseButton::MB_XBUTTON2, MouseButton::MASK_XBUTTON2, false); } else { return; } @@ -922,140 +922,140 @@ static bool isNumpadKey(unsigned int key) { // Keyboard symbol translation table static const Key _osx_to_godot_table[128] = { - /* 00 */ KEY_A, - /* 01 */ KEY_S, - /* 02 */ KEY_D, - /* 03 */ KEY_F, - /* 04 */ KEY_H, - /* 05 */ KEY_G, - /* 06 */ KEY_Z, - /* 07 */ KEY_X, - /* 08 */ KEY_C, - /* 09 */ KEY_V, - /* 0a */ KEY_SECTION, /* ISO Section */ - /* 0b */ KEY_B, - /* 0c */ KEY_Q, - /* 0d */ KEY_W, - /* 0e */ KEY_E, - /* 0f */ KEY_R, - /* 10 */ KEY_Y, - /* 11 */ KEY_T, - /* 12 */ KEY_1, - /* 13 */ KEY_2, - /* 14 */ KEY_3, - /* 15 */ KEY_4, - /* 16 */ KEY_6, - /* 17 */ KEY_5, - /* 18 */ KEY_EQUAL, - /* 19 */ KEY_9, - /* 1a */ KEY_7, - /* 1b */ KEY_MINUS, - /* 1c */ KEY_8, - /* 1d */ KEY_0, - /* 1e */ KEY_BRACERIGHT, - /* 1f */ KEY_O, - /* 20 */ KEY_U, - /* 21 */ KEY_BRACELEFT, - /* 22 */ KEY_I, - /* 23 */ KEY_P, - /* 24 */ KEY_ENTER, - /* 25 */ KEY_L, - /* 26 */ KEY_J, - /* 27 */ KEY_APOSTROPHE, - /* 28 */ KEY_K, - /* 29 */ KEY_SEMICOLON, - /* 2a */ KEY_BACKSLASH, - /* 2b */ KEY_COMMA, - /* 2c */ KEY_SLASH, - /* 2d */ KEY_N, - /* 2e */ KEY_M, - /* 2f */ KEY_PERIOD, - /* 30 */ KEY_TAB, - /* 31 */ KEY_SPACE, - /* 32 */ KEY_QUOTELEFT, - /* 33 */ KEY_BACKSPACE, - /* 34 */ KEY_UNKNOWN, - /* 35 */ KEY_ESCAPE, - /* 36 */ KEY_META, - /* 37 */ KEY_META, - /* 38 */ KEY_SHIFT, - /* 39 */ KEY_CAPSLOCK, - /* 3a */ KEY_ALT, - /* 3b */ KEY_CTRL, - /* 3c */ KEY_SHIFT, - /* 3d */ KEY_ALT, - /* 3e */ KEY_CTRL, - /* 3f */ KEY_UNKNOWN, /* Function */ - /* 40 */ KEY_UNKNOWN, /* F17 */ - /* 41 */ KEY_KP_PERIOD, - /* 42 */ KEY_UNKNOWN, - /* 43 */ KEY_KP_MULTIPLY, - /* 44 */ KEY_UNKNOWN, - /* 45 */ KEY_KP_ADD, - /* 46 */ KEY_UNKNOWN, - /* 47 */ KEY_NUMLOCK, /* Really KeypadClear... */ - /* 48 */ KEY_VOLUMEUP, /* VolumeUp */ - /* 49 */ KEY_VOLUMEDOWN, /* VolumeDown */ - /* 4a */ KEY_VOLUMEMUTE, /* Mute */ - /* 4b */ KEY_KP_DIVIDE, - /* 4c */ KEY_KP_ENTER, - /* 4d */ KEY_UNKNOWN, - /* 4e */ KEY_KP_SUBTRACT, - /* 4f */ KEY_UNKNOWN, /* F18 */ - /* 50 */ KEY_UNKNOWN, /* F19 */ - /* 51 */ KEY_EQUAL, /* KeypadEqual */ - /* 52 */ KEY_KP_0, - /* 53 */ KEY_KP_1, - /* 54 */ KEY_KP_2, - /* 55 */ KEY_KP_3, - /* 56 */ KEY_KP_4, - /* 57 */ KEY_KP_5, - /* 58 */ KEY_KP_6, - /* 59 */ KEY_KP_7, - /* 5a */ KEY_UNKNOWN, /* F20 */ - /* 5b */ KEY_KP_8, - /* 5c */ KEY_KP_9, - /* 5d */ KEY_YEN, /* JIS Yen */ - /* 5e */ KEY_UNDERSCORE, /* JIS Underscore */ - /* 5f */ KEY_COMMA, /* JIS KeypadComma */ - /* 60 */ KEY_F5, - /* 61 */ KEY_F6, - /* 62 */ KEY_F7, - /* 63 */ KEY_F3, - /* 64 */ KEY_F8, - /* 65 */ KEY_F9, - /* 66 */ KEY_UNKNOWN, /* JIS Eisu */ - /* 67 */ KEY_F11, - /* 68 */ KEY_UNKNOWN, /* JIS Kana */ - /* 69 */ KEY_F13, - /* 6a */ KEY_F16, - /* 6b */ KEY_F14, - /* 6c */ KEY_UNKNOWN, - /* 6d */ KEY_F10, - /* 6e */ KEY_MENU, - /* 6f */ KEY_F12, - /* 70 */ KEY_UNKNOWN, - /* 71 */ KEY_F15, - /* 72 */ KEY_INSERT, /* Really Help... */ - /* 73 */ KEY_HOME, - /* 74 */ KEY_PAGEUP, - /* 75 */ KEY_DELETE, - /* 76 */ KEY_F4, - /* 77 */ KEY_END, - /* 78 */ KEY_F2, - /* 79 */ KEY_PAGEDOWN, - /* 7a */ KEY_F1, - /* 7b */ KEY_LEFT, - /* 7c */ KEY_RIGHT, - /* 7d */ KEY_DOWN, - /* 7e */ KEY_UP, - /* 7f */ KEY_UNKNOWN, + /* 00 */ Key::A, + /* 01 */ Key::S, + /* 02 */ Key::D, + /* 03 */ Key::F, + /* 04 */ Key::H, + /* 05 */ Key::G, + /* 06 */ Key::Z, + /* 07 */ Key::X, + /* 08 */ Key::C, + /* 09 */ Key::V, + /* 0a */ Key::SECTION, /* ISO Section */ + /* 0b */ Key::B, + /* 0c */ Key::Q, + /* 0d */ Key::W, + /* 0e */ Key::E, + /* 0f */ Key::R, + /* 10 */ Key::Y, + /* 11 */ Key::T, + /* 12 */ Key::KEY_1, + /* 13 */ Key::KEY_2, + /* 14 */ Key::KEY_3, + /* 15 */ Key::KEY_4, + /* 16 */ Key::KEY_6, + /* 17 */ Key::KEY_5, + /* 18 */ Key::EQUAL, + /* 19 */ Key::KEY_9, + /* 1a */ Key::KEY_7, + /* 1b */ Key::MINUS, + /* 1c */ Key::KEY_8, + /* 1d */ Key::KEY_0, + /* 1e */ Key::BRACERIGHT, + /* 1f */ Key::O, + /* 20 */ Key::U, + /* 21 */ Key::BRACELEFT, + /* 22 */ Key::I, + /* 23 */ Key::P, + /* 24 */ Key::ENTER, + /* 25 */ Key::L, + /* 26 */ Key::J, + /* 27 */ Key::APOSTROPHE, + /* 28 */ Key::K, + /* 29 */ Key::SEMICOLON, + /* 2a */ Key::BACKSLASH, + /* 2b */ Key::COMMA, + /* 2c */ Key::SLASH, + /* 2d */ Key::N, + /* 2e */ Key::M, + /* 2f */ Key::PERIOD, + /* 30 */ Key::TAB, + /* 31 */ Key::SPACE, + /* 32 */ Key::QUOTELEFT, + /* 33 */ Key::BACKSPACE, + /* 34 */ Key::UNKNOWN, + /* 35 */ Key::ESCAPE, + /* 36 */ Key::META, + /* 37 */ Key::META, + /* 38 */ Key::SHIFT, + /* 39 */ Key::CAPSLOCK, + /* 3a */ Key::ALT, + /* 3b */ Key::CTRL, + /* 3c */ Key::SHIFT, + /* 3d */ Key::ALT, + /* 3e */ Key::CTRL, + /* 3f */ Key::UNKNOWN, /* Function */ + /* 40 */ Key::UNKNOWN, /* F17 */ + /* 41 */ Key::KP_PERIOD, + /* 42 */ Key::UNKNOWN, + /* 43 */ Key::KP_MULTIPLY, + /* 44 */ Key::UNKNOWN, + /* 45 */ Key::KP_ADD, + /* 46 */ Key::UNKNOWN, + /* 47 */ Key::NUMLOCK, /* Really KeypadClear... */ + /* 48 */ Key::VOLUMEUP, /* VolumeUp */ + /* 49 */ Key::VOLUMEDOWN, /* VolumeDown */ + /* 4a */ Key::VOLUMEMUTE, /* Mute */ + /* 4b */ Key::KP_DIVIDE, + /* 4c */ Key::KP_ENTER, + /* 4d */ Key::UNKNOWN, + /* 4e */ Key::KP_SUBTRACT, + /* 4f */ Key::UNKNOWN, /* F18 */ + /* 50 */ Key::UNKNOWN, /* F19 */ + /* 51 */ Key::EQUAL, /* KeypadEqual */ + /* 52 */ Key::KP_0, + /* 53 */ Key::KP_1, + /* 54 */ Key::KP_2, + /* 55 */ Key::KP_3, + /* 56 */ Key::KP_4, + /* 57 */ Key::KP_5, + /* 58 */ Key::KP_6, + /* 59 */ Key::KP_7, + /* 5a */ Key::UNKNOWN, /* F20 */ + /* 5b */ Key::KP_8, + /* 5c */ Key::KP_9, + /* 5d */ Key::YEN, /* JIS Yen */ + /* 5e */ Key::UNDERSCORE, /* JIS Underscore */ + /* 5f */ Key::COMMA, /* JIS KeypadComma */ + /* 60 */ Key::F5, + /* 61 */ Key::F6, + /* 62 */ Key::F7, + /* 63 */ Key::F3, + /* 64 */ Key::F8, + /* 65 */ Key::F9, + /* 66 */ Key::UNKNOWN, /* JIS Eisu */ + /* 67 */ Key::F11, + /* 68 */ Key::UNKNOWN, /* JIS Kana */ + /* 69 */ Key::F13, + /* 6a */ Key::F16, + /* 6b */ Key::F14, + /* 6c */ Key::UNKNOWN, + /* 6d */ Key::F10, + /* 6e */ Key::MENU, + /* 6f */ Key::F12, + /* 70 */ Key::UNKNOWN, + /* 71 */ Key::F15, + /* 72 */ Key::INSERT, /* Really Help... */ + /* 73 */ Key::HOME, + /* 74 */ Key::PAGEUP, + /* 75 */ Key::KEY_DELETE, + /* 76 */ Key::F4, + /* 77 */ Key::END, + /* 78 */ Key::F2, + /* 79 */ Key::PAGEDOWN, + /* 7a */ Key::F1, + /* 7b */ Key::LEFT, + /* 7c */ Key::RIGHT, + /* 7d */ Key::DOWN, + /* 7e */ Key::UP, + /* 7f */ Key::UNKNOWN, }; // Translates a OS X keycode to a Godot keycode static Key translateKey(unsigned int key) { if (key >= 128) { - return KEY_UNKNOWN; + return Key::UNKNOWN; } return _osx_to_godot_table[key]; @@ -1077,61 +1077,61 @@ struct _KeyCodeMap { }; static const _KeyCodeMap _keycodes[55] = { - { '`', KEY_QUOTELEFT }, - { '~', KEY_ASCIITILDE }, - { '0', KEY_0 }, - { '1', KEY_1 }, - { '2', KEY_2 }, - { '3', KEY_3 }, - { '4', KEY_4 }, - { '5', KEY_5 }, - { '6', KEY_6 }, - { '7', KEY_7 }, - { '8', KEY_8 }, - { '9', KEY_9 }, - { '-', KEY_MINUS }, - { '_', KEY_UNDERSCORE }, - { '=', KEY_EQUAL }, - { '+', KEY_PLUS }, - { 'q', KEY_Q }, - { 'w', KEY_W }, - { 'e', KEY_E }, - { 'r', KEY_R }, - { 't', KEY_T }, - { 'y', KEY_Y }, - { 'u', KEY_U }, - { 'i', KEY_I }, - { 'o', KEY_O }, - { 'p', KEY_P }, - { '[', KEY_BRACELEFT }, - { ']', KEY_BRACERIGHT }, - { '{', KEY_BRACELEFT }, - { '}', KEY_BRACERIGHT }, - { 'a', KEY_A }, - { 's', KEY_S }, - { 'd', KEY_D }, - { 'f', KEY_F }, - { 'g', KEY_G }, - { 'h', KEY_H }, - { 'j', KEY_J }, - { 'k', KEY_K }, - { 'l', KEY_L }, - { ';', KEY_SEMICOLON }, - { ':', KEY_COLON }, - { '\'', KEY_APOSTROPHE }, - { '\"', KEY_QUOTEDBL }, - { '\\', KEY_BACKSLASH }, - { '#', KEY_NUMBERSIGN }, - { 'z', KEY_Z }, - { 'x', KEY_X }, - { 'c', KEY_C }, - { 'v', KEY_V }, - { 'b', KEY_B }, - { 'n', KEY_N }, - { 'm', KEY_M }, - { ',', KEY_COMMA }, - { '.', KEY_PERIOD }, - { '/', KEY_SLASH } + { '`', Key::QUOTELEFT }, + { '~', Key::ASCIITILDE }, + { '0', Key::KEY_0 }, + { '1', Key::KEY_1 }, + { '2', Key::KEY_2 }, + { '3', Key::KEY_3 }, + { '4', Key::KEY_4 }, + { '5', Key::KEY_5 }, + { '6', Key::KEY_6 }, + { '7', Key::KEY_7 }, + { '8', Key::KEY_8 }, + { '9', Key::KEY_9 }, + { '-', Key::MINUS }, + { '_', Key::UNDERSCORE }, + { '=', Key::EQUAL }, + { '+', Key::PLUS }, + { 'q', Key::Q }, + { 'w', Key::W }, + { 'e', Key::E }, + { 'r', Key::R }, + { 't', Key::T }, + { 'y', Key::Y }, + { 'u', Key::U }, + { 'i', Key::I }, + { 'o', Key::O }, + { 'p', Key::P }, + { '[', Key::BRACELEFT }, + { ']', Key::BRACERIGHT }, + { '{', Key::BRACELEFT }, + { '}', Key::BRACERIGHT }, + { 'a', Key::A }, + { 's', Key::S }, + { 'd', Key::D }, + { 'f', Key::F }, + { 'g', Key::G }, + { 'h', Key::H }, + { 'j', Key::J }, + { 'k', Key::K }, + { 'l', Key::L }, + { ';', Key::SEMICOLON }, + { ':', Key::COLON }, + { '\'', Key::APOSTROPHE }, + { '\"', Key::QUOTEDBL }, + { '\\', Key::BACKSLASH }, + { '#', Key::NUMBERSIGN }, + { 'z', Key::Z }, + { 'x', Key::X }, + { 'c', Key::C }, + { 'v', Key::V }, + { 'b', Key::B }, + { 'n', Key::N }, + { 'm', Key::M }, + { ',', Key::COMMA }, + { '.', Key::PERIOD }, + { '/', Key::SLASH } }; static Key remapKey(unsigned int key, unsigned int state) { @@ -1345,7 +1345,7 @@ inline void sendScrollEvent(DisplayServer::WindowID window_id, MouseButton butto ERR_FAIL_COND(!DS_OSX->windows.has(window_id)); DisplayServerOSX::WindowData &wd = DS_OSX->windows[window_id]; - MouseButton mask = MouseButton(1 << (button - 1)); + MouseButton mask = mouse_button_to_mask(button); Ref<InputEventMouseButton> sc; sc.instantiate(); @@ -1418,10 +1418,10 @@ inline void sendPanEvent(DisplayServer::WindowID window_id, double dx, double dy sendPanEvent(window_id, deltaX, deltaY, [event modifierFlags]); } else { if (fabs(deltaX)) { - sendScrollEvent(window_id, 0 > deltaX ? MOUSE_BUTTON_WHEEL_RIGHT : MOUSE_BUTTON_WHEEL_LEFT, fabs(deltaX * 0.3), [event modifierFlags]); + sendScrollEvent(window_id, 0 > deltaX ? MouseButton::WHEEL_RIGHT : MouseButton::WHEEL_LEFT, fabs(deltaX * 0.3), [event modifierFlags]); } if (fabs(deltaY)) { - sendScrollEvent(window_id, 0 < deltaY ? MOUSE_BUTTON_WHEEL_UP : MOUSE_BUTTON_WHEEL_DOWN, fabs(deltaY * 0.3), [event modifierFlags]); + sendScrollEvent(window_id, 0 < deltaY ? MouseButton::WHEEL_UP : MouseButton::WHEEL_DOWN, fabs(deltaY * 0.3), [event modifierFlags]); } } } @@ -1920,6 +1920,7 @@ void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) { return; } + WindowData &wd = windows[MAIN_WINDOW_ID]; if (p_mode == MOUSE_MODE_CAPTURED) { // Apple Docs state that the display parameter is not used. // "This parameter is not used. By default, you may pass kCGDirectMainDisplay." @@ -1928,7 +1929,7 @@ void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) { CGDisplayHideCursor(kCGDirectMainDisplay); } CGAssociateMouseAndMouseCursorPosition(false); - WindowData &wd = windows[MAIN_WINDOW_ID]; + [wd.window_object setMovable:NO]; const NSRect contentRect = [wd.window_view frame]; NSRect pointInWindowRect = NSMakeRect(contentRect.size.width / 2, contentRect.size.height / 2, 0, 0); NSPoint pointOnScreen = [[wd.window_view window] convertRectToScreen:pointInWindowRect].origin; @@ -1938,17 +1939,21 @@ void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) { if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) { CGDisplayHideCursor(kCGDirectMainDisplay); } + [wd.window_object setMovable:YES]; CGAssociateMouseAndMouseCursorPosition(true); } else if (p_mode == MOUSE_MODE_CONFINED) { CGDisplayShowCursor(kCGDirectMainDisplay); + [wd.window_object setMovable:NO]; CGAssociateMouseAndMouseCursorPosition(false); } else if (p_mode == MOUSE_MODE_CONFINED_HIDDEN) { if (mouse_mode == MOUSE_MODE_VISIBLE || mouse_mode == MOUSE_MODE_CONFINED) { CGDisplayHideCursor(kCGDirectMainDisplay); } + [wd.window_object setMovable:NO]; CGAssociateMouseAndMouseCursorPosition(false); } else { // MOUSE_MODE_VISIBLE CGDisplayShowCursor(kCGDirectMainDisplay); + [wd.window_object setMovable:YES]; CGAssociateMouseAndMouseCursorPosition(true); } @@ -3200,12 +3205,12 @@ String DisplayServerOSX::keyboard_get_layout_name(int p_index) const { } Key DisplayServerOSX::keyboard_get_keycode_from_physical(Key p_keycode) const { - if (p_keycode == KEY_PAUSE) { + if (p_keycode == Key::PAUSE) { return p_keycode; } - unsigned int modifiers = p_keycode & KEY_MODIFIER_MASK; - unsigned int keycode_no_mod = p_keycode & KEY_CODE_MASK; + Key modifiers = p_keycode & KeyModifierMask::MODIFIER_MASK; + Key keycode_no_mod = p_keycode & KeyModifierMask::CODE_MASK; unsigned int osx_keycode = unmapKey((Key)keycode_no_mod); return (Key)(remapKey(osx_keycode, 0) | modifiers); } @@ -3263,8 +3268,8 @@ void DisplayServerOSX::_send_event(NSEvent *p_event) { _get_key_modifier_state([p_event modifierFlags], k); k->set_window_id(DisplayServerOSX::INVALID_WINDOW_ID); k->set_pressed(true); - k->set_keycode(KEY_PERIOD); - k->set_physical_keycode(KEY_PERIOD); + k->set_keycode(Key::PERIOD); + k->set_physical_keycode(Key::PERIOD); k->set_echo([p_event isARepeat]); Input::get_singleton()->parse_input_event(k); @@ -3291,20 +3296,20 @@ void DisplayServerOSX::_process_key_events() { _push_input(k); } else { // IME input - if ((i == 0 && ke.keycode == 0) || (i > 0 && key_event_buffer[i - 1].keycode == 0)) { + if ((i == 0 && ke.keycode == Key::NONE) || (i > 0 && key_event_buffer[i - 1].keycode == Key::NONE)) { k.instantiate(); k->set_window_id(ke.window_id); _get_key_modifier_state(ke.osx_state, k); k->set_pressed(ke.pressed); k->set_echo(ke.echo); - k->set_keycode(KEY_NONE); - k->set_physical_keycode(KEY_NONE); + k->set_keycode(Key::NONE); + k->set_physical_keycode(Key::NONE); k->set_unicode(ke.unicode); _push_input(k); } - if (ke.keycode != 0) { + if (ke.keycode != Key::NONE) { k.instantiate(); k->set_window_id(ke.window_id); @@ -3314,7 +3319,7 @@ void DisplayServerOSX::_process_key_events() { k->set_keycode(ke.keycode); k->set_physical_keycode((Key)ke.physical_keycode); - if (i + 1 < key_event_pos && key_event_buffer[i + 1].keycode == 0) { + if (i + 1 < key_event_pos && key_event_buffer[i + 1].keycode == Key::NONE) { k->set_unicode(key_event_buffer[i + 1].unicode); } diff --git a/platform/osx/joypad_osx.cpp b/platform/osx/joypad_osx.cpp index 46ed651384..d4ba7879f1 100644 --- a/platform/osx/joypad_osx.cpp +++ b/platform/osx/joypad_osx.cpp @@ -397,10 +397,10 @@ bool joypad::check_ff_features() { return false; } -static int process_hat_value(int p_min, int p_max, int p_value, bool p_offset_hat) { +static HatMask process_hat_value(int p_min, int p_max, int p_value, bool p_offset_hat) { int range = (p_max - p_min + 1); int value = p_value - p_min; - int hat_value = HatMask::HAT_MASK_CENTER; + HatMask hat_value = HatMask::CENTER; if (range == 4) { value *= 2; } @@ -410,31 +410,31 @@ static int process_hat_value(int p_min, int p_max, int p_value, bool p_offset_ha switch (value) { case 0: - hat_value = (HatMask)HatMask::HAT_MASK_UP; + hat_value = HatMask::UP; break; case 1: - hat_value = (HatMask)(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_RIGHT); + hat_value = (HatMask::UP | HatMask::RIGHT); break; case 2: - hat_value = (HatMask)HatMask::HAT_MASK_RIGHT; + hat_value = HatMask::RIGHT; break; case 3: - hat_value = (HatMask)(HatMask::HAT_MASK_DOWN | HatMask::HAT_MASK_RIGHT); + hat_value = (HatMask::DOWN | HatMask::RIGHT); break; case 4: - hat_value = (HatMask)HatMask::HAT_MASK_DOWN; + hat_value = HatMask::DOWN; break; case 5: - hat_value = (HatMask)(HatMask::HAT_MASK_DOWN | HatMask::HAT_MASK_LEFT); + hat_value = (HatMask::DOWN | HatMask::LEFT); break; case 6: - hat_value = (HatMask)HatMask::HAT_MASK_LEFT; + hat_value = HatMask::LEFT; break; case 7: - hat_value = (HatMask)(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_LEFT); + hat_value = (HatMask::UP | HatMask::LEFT); break; default: - hat_value = (HatMask)HatMask::HAT_MASK_CENTER; + hat_value = HatMask::CENTER; break; } return hat_value; @@ -480,8 +480,8 @@ void JoypadOSX::process_joypads() { for (int j = 0; j < joy.hat_elements.size(); j++) { rec_element &elem = joy.hat_elements.write[j]; int value = joy.get_hid_element_state(&elem); - int hat_value = process_hat_value(elem.min, elem.max, value, joy.offset_hat); - input->joy_hat(joy.id, (HatMask)hat_value); + HatMask hat_value = process_hat_value(elem.min, elem.max, value, joy.offset_hat); + input->joy_hat(joy.id, hat_value); } if (joy.ffservice) { diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp index b419fb4fae..f8eb4fc96d 100644 --- a/platform/uwp/joypad_uwp.cpp +++ b/platform/uwp/joypad_uwp.cpp @@ -58,12 +58,12 @@ void JoypadUWP::process_controllers() { button_mask *= 2; } - input->joy_axis(joy.id, JOY_AXIS_LEFT_X, axis_correct(reading.LeftThumbstickX)); - input->joy_axis(joy.id, JOY_AXIS_LEFT_Y, axis_correct(reading.LeftThumbstickY, true)); - input->joy_axis(joy.id, JOY_AXIS_RIGHT_X, axis_correct(reading.RightThumbstickX)); - input->joy_axis(joy.id, JOY_AXIS_RIGHT_Y, axis_correct(reading.RightThumbstickY, true)); - input->joy_axis(joy.id, JOY_AXIS_TRIGGER_LEFT, axis_correct(reading.LeftTrigger, false, true)); - input->joy_axis(joy.id, JOY_AXIS_TRIGGER_RIGHT, axis_correct(reading.RightTrigger, false, true)); + input->joy_axis(joy.id, JoyAxis::LEFT_X, axis_correct(reading.LeftThumbstickX)); + input->joy_axis(joy.id, JoyAxis::LEFT_Y, axis_correct(reading.LeftThumbstickY, true)); + input->joy_axis(joy.id, JoyAxis::RIGHT_X, axis_correct(reading.RightThumbstickX)); + input->joy_axis(joy.id, JoyAxis::RIGHT_Y, axis_correct(reading.RightThumbstickY, true)); + input->joy_axis(joy.id, JoyAxis::TRIGGER_LEFT, axis_correct(reading.LeftTrigger, false, true)); + input->joy_axis(joy.id, JoyAxis::TRIGGER_RIGHT, axis_correct(reading.RightTrigger, false, true)); uint64_t timestamp = input->get_joy_vibration_timestamp(joy.id); if (timestamp > joy.ff_timestamp) { diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index 74a9e96b2c..0b4d6b73b6 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -59,7 +59,7 @@ public: bool alt = false, shift = false, control = false; MessageType type = KEY_EVENT_MESSAGE; bool pressed = false; - Key keycode = KEY_NONE; + Key keycode = Key::NONE; unsigned int physical_keycode = 0; unsigned int unicode = 0; bool echo = false; @@ -107,7 +107,7 @@ private: bool control_mem; bool meta_mem; bool force_quit; - MouseButton last_button_state = MOUSE_BUTTON_NONE; + MouseButton last_button_state = MouseButton::NONE; CursorShape cursor_shape; diff --git a/platform/windows/detect.py b/platform/windows/detect.py index 22fbbeb74f..20deb35089 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -226,9 +226,10 @@ def configure_msvc(env, manual_msvc_config): env.AppendUnique(CCFLAGS=["/MD"]) env.AppendUnique(CCFLAGS=["/Gd", "/GR", "/nologo"]) - # Force to use Unicode encoding - env.AppendUnique(CCFLAGS=["/utf-8"]) + env.AppendUnique(CCFLAGS=["/utf-8"]) # Force to use Unicode encoding. + env.AppendUnique(CCFLAGS=["/bigobj"]) # Allow big objects, no drawbacks. env.AppendUnique(CXXFLAGS=["/TP"]) # assume all sources are C++ + if manual_msvc_config: # should be automatic if SCons found it if os.getenv("WindowsSdkDir") is not None: env.Prepend(CPPPATH=[os.getenv("WindowsSdkDir") + "/Include"]) @@ -421,6 +422,7 @@ def configure_mingw(env): ## Compile flags env.Append(CCFLAGS=["-mwindows"]) + env.Append(CCFLAGS=["-Wa,-mbig-obj"]) # Allow big objects, no drawbacks. env.Append(CPPDEFINES=["WINDOWS_ENABLED", "WASAPI_ENABLED", "WINMIDI_ENABLED"]) env.Append(CPPDEFINES=[("WINVER", env["target_win_version"]), ("_WIN32_WINNT", env["target_win_version"])]) diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index e2c9951692..9fe15366f4 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -42,6 +42,11 @@ #include "drivers/gles3/rasterizer_gles3.h" #endif +#if defined(__GNUC__) +// Workaround GCC warning from -Wcast-function-type. +#define GetProcAddress (void *)GetProcAddress +#endif + static String format_error_message(DWORD id) { LPWSTR messageBuffer = nullptr; size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, @@ -1495,13 +1500,13 @@ String DisplayServerWindows::keyboard_get_layout_language(int p_index) const { } Key DisplayServerWindows::keyboard_get_keycode_from_physical(Key p_keycode) const { - unsigned int modifiers = p_keycode & KEY_MODIFIER_MASK; - Key keycode_no_mod = (Key)(p_keycode & KEY_CODE_MASK); + Key modifiers = p_keycode & KeyModifierMask::MODIFIER_MASK; + Key keycode_no_mod = (Key)(p_keycode & KeyModifierMask::CODE_MASK); - if (keycode_no_mod == KEY_PRINT || - keycode_no_mod == KEY_KP_ADD || - keycode_no_mod == KEY_KP_5 || - (keycode_no_mod >= KEY_0 && keycode_no_mod <= KEY_9)) { + if (keycode_no_mod == Key::PRINT || + keycode_no_mod == Key::KP_ADD || + keycode_no_mod == Key::KP_5 || + (keycode_no_mod >= Key::KEY_0 && keycode_no_mod <= Key::KEY_9)) { return p_keycode; } @@ -1521,10 +1526,10 @@ Key DisplayServerWindows::keyboard_get_keycode_from_physical(Key p_keycode) cons // we limit these to ASCII to fix some layouts, including Arabic ones if (char_code >= 32 && char_code <= 127) { // Godot uses 'braces' instead of 'brackets' - if (char_code == KEY_BRACKETLEFT || char_code == KEY_BRACKETRIGHT) { + if (char_code == (unsigned int)Key::BRACKETLEFT || char_code == (unsigned int)Key::BRACKETRIGHT) { char_code += 32; } - return (Key)(char_code | modifiers); + return (Key)(char_code | (unsigned int)modifiers); } return (Key)(KeyMappingWindows::get_keysym(vk) | modifiers); @@ -2461,41 +2466,41 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA switch (uMsg) { case WM_LBUTTONDOWN: { mb->set_pressed(true); - mb->set_button_index(MOUSE_BUTTON_LEFT); + mb->set_button_index(MouseButton::LEFT); } break; case WM_LBUTTONUP: { mb->set_pressed(false); - mb->set_button_index(MOUSE_BUTTON_LEFT); + mb->set_button_index(MouseButton::LEFT); } break; case WM_MBUTTONDOWN: { mb->set_pressed(true); - mb->set_button_index(MOUSE_BUTTON_MIDDLE); + mb->set_button_index(MouseButton::MIDDLE); } break; case WM_MBUTTONUP: { mb->set_pressed(false); - mb->set_button_index(MOUSE_BUTTON_MIDDLE); + mb->set_button_index(MouseButton::MIDDLE); } break; case WM_RBUTTONDOWN: { mb->set_pressed(true); - mb->set_button_index(MOUSE_BUTTON_RIGHT); + mb->set_button_index(MouseButton::RIGHT); } break; case WM_RBUTTONUP: { mb->set_pressed(false); - mb->set_button_index(MOUSE_BUTTON_RIGHT); + mb->set_button_index(MouseButton::RIGHT); } break; case WM_LBUTTONDBLCLK: { mb->set_pressed(true); - mb->set_button_index(MOUSE_BUTTON_LEFT); + mb->set_button_index(MouseButton::LEFT); mb->set_double_click(true); } break; case WM_RBUTTONDBLCLK: { mb->set_pressed(true); - mb->set_button_index(MOUSE_BUTTON_RIGHT); + mb->set_button_index(MouseButton::RIGHT); mb->set_double_click(true); } break; case WM_MBUTTONDBLCLK: { mb->set_pressed(true); - mb->set_button_index(MOUSE_BUTTON_MIDDLE); + mb->set_button_index(MouseButton::MIDDLE); mb->set_double_click(true); } break; case WM_MOUSEWHEEL: { @@ -2506,9 +2511,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } if (motion > 0) { - mb->set_button_index(MOUSE_BUTTON_WHEEL_UP); + mb->set_button_index(MouseButton::WHEEL_UP); } else { - mb->set_button_index(MOUSE_BUTTON_WHEEL_DOWN); + mb->set_button_index(MouseButton::WHEEL_DOWN); } mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA)); } break; @@ -2520,34 +2525,34 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA } if (motion < 0) { - mb->set_button_index(MOUSE_BUTTON_WHEEL_LEFT); + mb->set_button_index(MouseButton::WHEEL_LEFT); } else { - mb->set_button_index(MOUSE_BUTTON_WHEEL_RIGHT); + mb->set_button_index(MouseButton::WHEEL_RIGHT); } mb->set_factor(fabs((double)motion / (double)WHEEL_DELTA)); } break; case WM_XBUTTONDOWN: { mb->set_pressed(true); if (HIWORD(wParam) == XBUTTON1) { - mb->set_button_index(MOUSE_BUTTON_XBUTTON1); + mb->set_button_index(MouseButton::MB_XBUTTON1); } else { - mb->set_button_index(MOUSE_BUTTON_XBUTTON2); + mb->set_button_index(MouseButton::MB_XBUTTON2); } } break; case WM_XBUTTONUP: { mb->set_pressed(false); if (HIWORD(wParam) == XBUTTON1) { - mb->set_button_index(MOUSE_BUTTON_XBUTTON1); + mb->set_button_index(MouseButton::MB_XBUTTON1); } else { - mb->set_button_index(MOUSE_BUTTON_XBUTTON2); + mb->set_button_index(MouseButton::MB_XBUTTON2); } } break; case WM_XBUTTONDBLCLK: { mb->set_pressed(true); if (HIWORD(wParam) == XBUTTON1) { - mb->set_button_index(MOUSE_BUTTON_XBUTTON1); + mb->set_button_index(MouseButton::MB_XBUTTON1); } else { - mb->set_button_index(MOUSE_BUTTON_XBUTTON2); + mb->set_button_index(MouseButton::MB_XBUTTON2); } mb->set_double_click(true); } break; @@ -2561,9 +2566,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA mb->set_alt_pressed(alt_mem); // mb->is_alt_pressed()=(wParam&MK_MENU)!=0; if (mb->is_pressed()) { - last_button_state |= MouseButton(1 << (mb->get_button_index() - 1)); + last_button_state |= mouse_button_to_mask(mb->get_button_index()); } else { - last_button_state &= (MouseButton) ~(1 << (mb->get_button_index() - 1)); + last_button_state &= ~mouse_button_to_mask(mb->get_button_index()); } mb->set_button_mask(last_button_state); @@ -2599,11 +2604,11 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA mb->set_global_position(mb->get_position()); Input::get_singleton()->parse_input_event(mb); - if (mb->is_pressed() && mb->get_button_index() > 3 && mb->get_button_index() < 8) { + if (mb->is_pressed() && mb->get_button_index() >= MouseButton::WHEEL_UP && mb->get_button_index() <= MouseButton::WHEEL_RIGHT) { // Send release for mouse wheel. Ref<InputEventMouseButton> mbd = mb->duplicate(); mbd->set_window_id(window_id); - last_button_state &= (MouseButton) ~(1 << (mbd->get_button_index() - 1)); + last_button_state &= ~mouse_button_to_mask(mbd->get_button_index()); mbd->set_button_mask(last_button_state); mbd->set_pressed(false); Input::get_singleton()->parse_input_event(mbd); @@ -2953,7 +2958,7 @@ void DisplayServerWindows::_process_key_events() { if ((ke.lParam & (1 << 24)) && (ke.wParam == VK_RETURN)) { // Special case for Numpad Enter key. - k->set_keycode(KEY_KP_ENTER); + k->set_keycode(Key::KP_ENTER); } else { k->set_keycode((Key)KeyMappingWindows::get_keysym(ke.wParam)); } diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h index 8e2c346d5b..a59f8ebb44 100644 --- a/platform/windows/display_server_windows.h +++ b/platform/windows/display_server_windows.h @@ -410,7 +410,7 @@ class DisplayServerWindows : public DisplayServer { bool shift_mem = false; bool control_mem = false; bool meta_mem = false; - MouseButton last_button_state = MOUSE_BUTTON_NONE; + MouseButton last_button_state = MouseButton::NONE; bool use_raw_input = false; bool drop_events = false; bool in_dispatch_input_event = false; diff --git a/platform/windows/gl_manager_windows.cpp b/platform/windows/gl_manager_windows.cpp index 98205d6282..1ce8b0b040 100644 --- a/platform/windows/gl_manager_windows.cpp +++ b/platform/windows/gl_manager_windows.cpp @@ -197,9 +197,6 @@ Error GLManager_Windows::window_create(DisplayServer::WindowID p_window_id, HWND return FAILED; } - // the display could be invalid .. check NYI - GLDisplay &gl_display = _displays[win.gldisplay_id]; - // make current window_make_current(_windows.size() - 1); diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index 94da63e49d..1d3761ee83 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -334,12 +334,12 @@ void JoypadWindows::process_joypads() { button_mask = button_mask * 2; } - input->joy_axis(joy.id, JOY_AXIS_LEFT_X, axis_correct(joy.state.Gamepad.sThumbLX, true)); - input->joy_axis(joy.id, JOY_AXIS_LEFT_Y, axis_correct(joy.state.Gamepad.sThumbLY, true, false, true)); - input->joy_axis(joy.id, JOY_AXIS_RIGHT_X, axis_correct(joy.state.Gamepad.sThumbRX, true)); - input->joy_axis(joy.id, JOY_AXIS_RIGHT_Y, axis_correct(joy.state.Gamepad.sThumbRY, true, false, true)); - input->joy_axis(joy.id, JOY_AXIS_TRIGGER_LEFT, axis_correct(joy.state.Gamepad.bLeftTrigger, true, true)); - input->joy_axis(joy.id, JOY_AXIS_TRIGGER_RIGHT, axis_correct(joy.state.Gamepad.bRightTrigger, true, true)); + input->joy_axis(joy.id, JoyAxis::LEFT_X, axis_correct(joy.state.Gamepad.sThumbLX, true)); + input->joy_axis(joy.id, JoyAxis::LEFT_Y, axis_correct(joy.state.Gamepad.sThumbLY, true, false, true)); + input->joy_axis(joy.id, JoyAxis::RIGHT_X, axis_correct(joy.state.Gamepad.sThumbRX, true)); + input->joy_axis(joy.id, JoyAxis::RIGHT_Y, axis_correct(joy.state.Gamepad.sThumbRY, true, false, true)); + input->joy_axis(joy.id, JoyAxis::TRIGGER_LEFT, axis_correct(joy.state.Gamepad.bLeftTrigger, true, true)); + input->joy_axis(joy.id, JoyAxis::TRIGGER_RIGHT, axis_correct(joy.state.Gamepad.bRightTrigger, true, true)); joy.last_packet = joy.state.dwPacketNumber; } uint64_t timestamp = input->get_joy_vibration_timestamp(joy.id); @@ -417,31 +417,31 @@ void JoypadWindows::post_hat(int p_device, DWORD p_dpad) { // BOOL POVCentered = (LOWORD(dwPOV) == 0xFFFF);" // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ee416628(v%3Dvs.85)#remarks if (LOWORD(p_dpad) == 0xFFFF) { - dpad_val = (HatMask)HatMask::HAT_MASK_CENTER; + dpad_val = (HatMask)HatMask::CENTER; } if (p_dpad == 0) { - dpad_val = (HatMask)HatMask::HAT_MASK_UP; + dpad_val = (HatMask)HatMask::UP; } else if (p_dpad == 4500) { - dpad_val = (HatMask)(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_RIGHT); + dpad_val = (HatMask)(HatMask::UP | HatMask::RIGHT); } else if (p_dpad == 9000) { - dpad_val = (HatMask)HatMask::HAT_MASK_RIGHT; + dpad_val = (HatMask)HatMask::RIGHT; } else if (p_dpad == 13500) { - dpad_val = (HatMask)(HatMask::HAT_MASK_RIGHT | HatMask::HAT_MASK_DOWN); + dpad_val = (HatMask)(HatMask::RIGHT | HatMask::DOWN); } else if (p_dpad == 18000) { - dpad_val = (HatMask)HatMask::HAT_MASK_DOWN; + dpad_val = (HatMask)HatMask::DOWN; } else if (p_dpad == 22500) { - dpad_val = (HatMask)(HatMask::HAT_MASK_DOWN | HatMask::HAT_MASK_LEFT); + dpad_val = (HatMask)(HatMask::DOWN | HatMask::LEFT); } else if (p_dpad == 27000) { - dpad_val = (HatMask)HatMask::HAT_MASK_LEFT; + dpad_val = (HatMask)HatMask::LEFT; } else if (p_dpad == 31500) { - dpad_val = (HatMask)(HatMask::HAT_MASK_LEFT | HatMask::HAT_MASK_UP); + dpad_val = (HatMask)(HatMask::LEFT | HatMask::UP); } input->joy_hat(p_device, dpad_val); }; diff --git a/platform/windows/key_mapping_windows.cpp b/platform/windows/key_mapping_windows.cpp index b9cf8151fc..65ee5dd46b 100644 --- a/platform/windows/key_mapping_windows.cpp +++ b/platform/windows/key_mapping_windows.cpp @@ -33,200 +33,200 @@ #include <stdio.h> struct _WinTranslatePair { - unsigned int keysym; + Key keysym; unsigned int keycode; }; static _WinTranslatePair _vk_to_keycode[] = { - { KEY_BACKSPACE, VK_BACK }, // (0x08) // backspace - { KEY_TAB, VK_TAB }, //(0x09) + { Key::BACKSPACE, VK_BACK }, // (0x08) // backspace + { Key::TAB, VK_TAB }, //(0x09) //VK_CLEAR (0x0C) - { KEY_ENTER, VK_RETURN }, //(0x0D) + { Key::ENTER, VK_RETURN }, //(0x0D) - { KEY_SHIFT, VK_SHIFT }, //(0x10) + { Key::SHIFT, VK_SHIFT }, //(0x10) - { KEY_CTRL, VK_CONTROL }, //(0x11) + { Key::CTRL, VK_CONTROL }, //(0x11) - { KEY_ALT, VK_MENU }, //(0x12) + { Key::ALT, VK_MENU }, //(0x12) - { KEY_PAUSE, VK_PAUSE }, //(0x13) + { Key::PAUSE, VK_PAUSE }, //(0x13) - { KEY_CAPSLOCK, VK_CAPITAL }, //(0x14) + { Key::CAPSLOCK, VK_CAPITAL }, //(0x14) - { KEY_ESCAPE, VK_ESCAPE }, //(0x1B) + { Key::ESCAPE, VK_ESCAPE }, //(0x1B) - { KEY_SPACE, VK_SPACE }, //(0x20) + { Key::SPACE, VK_SPACE }, //(0x20) - { KEY_PAGEUP, VK_PRIOR }, //(0x21) + { Key::PAGEUP, VK_PRIOR }, //(0x21) - { KEY_PAGEDOWN, VK_NEXT }, //(0x22) + { Key::PAGEDOWN, VK_NEXT }, //(0x22) - { KEY_END, VK_END }, //(0x23) + { Key::END, VK_END }, //(0x23) - { KEY_HOME, VK_HOME }, //(0x24) + { Key::HOME, VK_HOME }, //(0x24) - { KEY_LEFT, VK_LEFT }, //(0x25) + { Key::LEFT, VK_LEFT }, //(0x25) - { KEY_UP, VK_UP }, //(0x26) + { Key::UP, VK_UP }, //(0x26) - { KEY_RIGHT, VK_RIGHT }, //(0x27) + { Key::RIGHT, VK_RIGHT }, //(0x27) - { KEY_DOWN, VK_DOWN }, // (0x28) + { Key::DOWN, VK_DOWN }, // (0x28) //VK_SELECT (0x29) - { KEY_PRINT, VK_PRINT }, // (0x2A) + { Key::PRINT, VK_PRINT }, // (0x2A) //VK_EXECUTE (0x2B) - { KEY_PRINT, VK_SNAPSHOT }, // (0x2C) - - { KEY_INSERT, VK_INSERT }, // (0x2D) - - { KEY_DELETE, VK_DELETE }, // (0x2E) - - { KEY_HELP, VK_HELP }, // (0x2F) - - { KEY_0, (0x30) }, ////0 key - { KEY_1, (0x31) }, ////1 key - { KEY_2, (0x32) }, ////2 key - { KEY_3, (0x33) }, ////3 key - { KEY_4, (0x34) }, ////4 key - { KEY_5, (0x35) }, ////5 key - { KEY_6, (0x36) }, ////6 key - { KEY_7, (0x37) }, ////7 key - { KEY_8, (0x38) }, ////8 key - { KEY_9, (0x39) }, ////9 key - { KEY_A, (0x41) }, ////A key - { KEY_B, (0x42) }, ////B key - { KEY_C, (0x43) }, ////C key - { KEY_D, (0x44) }, ////D key - { KEY_E, (0x45) }, ////E key - { KEY_F, (0x46) }, ////F key - { KEY_G, (0x47) }, ////G key - { KEY_H, (0x48) }, ////H key - { KEY_I, (0x49) }, ////I key - { KEY_J, (0x4A) }, ////J key - { KEY_K, (0x4B) }, ////K key - { KEY_L, (0x4C) }, ////L key - { KEY_M, (0x4D) }, ////M key - { KEY_N, (0x4E) }, ////N key - { KEY_O, (0x4F) }, ////O key - { KEY_P, (0x50) }, ////P key - { KEY_Q, (0x51) }, ////Q key - { KEY_R, (0x52) }, ////R key - { KEY_S, (0x53) }, ////S key - { KEY_T, (0x54) }, ////T key - { KEY_U, (0x55) }, ////U key - { KEY_V, (0x56) }, ////V key - { KEY_W, (0x57) }, ////W key - { KEY_X, (0x58) }, ////X key - { KEY_Y, (0x59) }, ////Y key - { KEY_Z, (0x5A) }, ////Z key - - { KEY_MASK_META, VK_LWIN }, //(0x5B) - { KEY_MASK_META, VK_RWIN }, //(0x5C) - { KEY_MENU, VK_APPS }, //(0x5D) - { KEY_STANDBY, VK_SLEEP }, //(0x5F) - { KEY_KP_0, VK_NUMPAD0 }, //(0x60) - { KEY_KP_1, VK_NUMPAD1 }, //(0x61) - { KEY_KP_2, VK_NUMPAD2 }, //(0x62) - { KEY_KP_3, VK_NUMPAD3 }, //(0x63) - { KEY_KP_4, VK_NUMPAD4 }, //(0x64) - { KEY_KP_5, VK_NUMPAD5 }, //(0x65) - { KEY_KP_6, VK_NUMPAD6 }, //(0x66) - { KEY_KP_7, VK_NUMPAD7 }, //(0x67) - { KEY_KP_8, VK_NUMPAD8 }, //(0x68) - { KEY_KP_9, VK_NUMPAD9 }, //(0x69) - { KEY_KP_MULTIPLY, VK_MULTIPLY }, // (0x6A) - { KEY_KP_ADD, VK_ADD }, // (0x6B) + { Key::PRINT, VK_SNAPSHOT }, // (0x2C) + + { Key::INSERT, VK_INSERT }, // (0x2D) + + { Key::KEY_DELETE, VK_DELETE }, // (0x2E) + + { Key::HELP, VK_HELP }, // (0x2F) + + { Key::KEY_0, (0x30) }, ////0 key + { Key::KEY_1, (0x31) }, ////1 key + { Key::KEY_2, (0x32) }, ////2 key + { Key::KEY_3, (0x33) }, ////3 key + { Key::KEY_4, (0x34) }, ////4 key + { Key::KEY_5, (0x35) }, ////5 key + { Key::KEY_6, (0x36) }, ////6 key + { Key::KEY_7, (0x37) }, ////7 key + { Key::KEY_8, (0x38) }, ////8 key + { Key::KEY_9, (0x39) }, ////9 key + { Key::A, (0x41) }, ////A key + { Key::B, (0x42) }, ////B key + { Key::C, (0x43) }, ////C key + { Key::D, (0x44) }, ////D key + { Key::E, (0x45) }, ////E key + { Key::F, (0x46) }, ////F key + { Key::G, (0x47) }, ////G key + { Key::H, (0x48) }, ////H key + { Key::I, (0x49) }, ////I key + { Key::J, (0x4A) }, ////J key + { Key::K, (0x4B) }, ////K key + { Key::L, (0x4C) }, ////L key + { Key::M, (0x4D) }, ////M key + { Key::N, (0x4E) }, ////N key + { Key::O, (0x4F) }, ////O key + { Key::P, (0x50) }, ////P key + { Key::Q, (0x51) }, ////Q key + { Key::R, (0x52) }, ////R key + { Key::S, (0x53) }, ////S key + { Key::T, (0x54) }, ////T key + { Key::U, (0x55) }, ////U key + { Key::V, (0x56) }, ////V key + { Key::W, (0x57) }, ////W key + { Key::X, (0x58) }, ////X key + { Key::Y, (0x59) }, ////Y key + { Key::Z, (0x5A) }, ////Z key + + { (Key)KeyModifierMask::META, VK_LWIN }, //(0x5B) + { (Key)KeyModifierMask::META, VK_RWIN }, //(0x5C) + { Key::MENU, VK_APPS }, //(0x5D) + { Key::STANDBY, VK_SLEEP }, //(0x5F) + { Key::KP_0, VK_NUMPAD0 }, //(0x60) + { Key::KP_1, VK_NUMPAD1 }, //(0x61) + { Key::KP_2, VK_NUMPAD2 }, //(0x62) + { Key::KP_3, VK_NUMPAD3 }, //(0x63) + { Key::KP_4, VK_NUMPAD4 }, //(0x64) + { Key::KP_5, VK_NUMPAD5 }, //(0x65) + { Key::KP_6, VK_NUMPAD6 }, //(0x66) + { Key::KP_7, VK_NUMPAD7 }, //(0x67) + { Key::KP_8, VK_NUMPAD8 }, //(0x68) + { Key::KP_9, VK_NUMPAD9 }, //(0x69) + { Key::KP_MULTIPLY, VK_MULTIPLY }, // (0x6A) + { Key::KP_ADD, VK_ADD }, // (0x6B) //VK_SEPARATOR (0x6C) - { KEY_KP_SUBTRACT, VK_SUBTRACT }, // (0x6D) - { KEY_KP_PERIOD, VK_DECIMAL }, // (0x6E) - { KEY_KP_DIVIDE, VK_DIVIDE }, // (0x6F) - { KEY_F1, VK_F1 }, // (0x70) - { KEY_F2, VK_F2 }, // (0x71) - { KEY_F3, VK_F3 }, // (0x72) - { KEY_F4, VK_F4 }, // (0x73) - { KEY_F5, VK_F5 }, // (0x74) - { KEY_F6, VK_F6 }, // (0x75) - { KEY_F7, VK_F7 }, // (0x76) - { KEY_F8, VK_F8 }, // (0x77) - { KEY_F9, VK_F9 }, // (0x78) - { KEY_F10, VK_F10 }, // (0x79) - { KEY_F11, VK_F11 }, // (0x7A) - { KEY_F12, VK_F12 }, // (0x7B) - { KEY_F13, VK_F13 }, // (0x7C) - { KEY_F14, VK_F14 }, // (0x7D) - { KEY_F15, VK_F15 }, // (0x7E) - { KEY_F16, VK_F16 }, // (0x7F) - { KEY_NUMLOCK, VK_NUMLOCK }, // (0x90) - { KEY_SCROLLLOCK, VK_SCROLL }, // (0x91) - { KEY_SHIFT, VK_LSHIFT }, // (0xA0) - { KEY_SHIFT, VK_RSHIFT }, // (0xA1) - { KEY_CTRL, VK_LCONTROL }, // (0xA2) - { KEY_CTRL, VK_RCONTROL }, // (0xA3) - { KEY_MENU, VK_LMENU }, // (0xA4) - { KEY_MENU, VK_RMENU }, // (0xA5) + { Key::KP_SUBTRACT, VK_SUBTRACT }, // (0x6D) + { Key::KP_PERIOD, VK_DECIMAL }, // (0x6E) + { Key::KP_DIVIDE, VK_DIVIDE }, // (0x6F) + { Key::F1, VK_F1 }, // (0x70) + { Key::F2, VK_F2 }, // (0x71) + { Key::F3, VK_F3 }, // (0x72) + { Key::F4, VK_F4 }, // (0x73) + { Key::F5, VK_F5 }, // (0x74) + { Key::F6, VK_F6 }, // (0x75) + { Key::F7, VK_F7 }, // (0x76) + { Key::F8, VK_F8 }, // (0x77) + { Key::F9, VK_F9 }, // (0x78) + { Key::F10, VK_F10 }, // (0x79) + { Key::F11, VK_F11 }, // (0x7A) + { Key::F12, VK_F12 }, // (0x7B) + { Key::F13, VK_F13 }, // (0x7C) + { Key::F14, VK_F14 }, // (0x7D) + { Key::F15, VK_F15 }, // (0x7E) + { Key::F16, VK_F16 }, // (0x7F) + { Key::NUMLOCK, VK_NUMLOCK }, // (0x90) + { Key::SCROLLLOCK, VK_SCROLL }, // (0x91) + { Key::SHIFT, VK_LSHIFT }, // (0xA0) + { Key::SHIFT, VK_RSHIFT }, // (0xA1) + { Key::CTRL, VK_LCONTROL }, // (0xA2) + { Key::CTRL, VK_RCONTROL }, // (0xA3) + { Key::MENU, VK_LMENU }, // (0xA4) + { Key::MENU, VK_RMENU }, // (0xA5) - { KEY_BACK, VK_BROWSER_BACK }, // (0xA6) + { Key::BACK, VK_BROWSER_BACK }, // (0xA6) - { KEY_FORWARD, VK_BROWSER_FORWARD }, // (0xA7) + { Key::FORWARD, VK_BROWSER_FORWARD }, // (0xA7) - { KEY_REFRESH, VK_BROWSER_REFRESH }, // (0xA8) + { Key::REFRESH, VK_BROWSER_REFRESH }, // (0xA8) - { KEY_STOP, VK_BROWSER_STOP }, // (0xA9) + { Key::STOP, VK_BROWSER_STOP }, // (0xA9) - { KEY_SEARCH, VK_BROWSER_SEARCH }, // (0xAA) + { Key::SEARCH, VK_BROWSER_SEARCH }, // (0xAA) - { KEY_FAVORITES, VK_BROWSER_FAVORITES }, // (0xAB) + { Key::FAVORITES, VK_BROWSER_FAVORITES }, // (0xAB) - { KEY_HOMEPAGE, VK_BROWSER_HOME }, // (0xAC) + { Key::HOMEPAGE, VK_BROWSER_HOME }, // (0xAC) - { KEY_VOLUMEMUTE, VK_VOLUME_MUTE }, // (0xAD) + { Key::VOLUMEMUTE, VK_VOLUME_MUTE }, // (0xAD) - { KEY_VOLUMEDOWN, VK_VOLUME_DOWN }, // (0xAE) + { Key::VOLUMEDOWN, VK_VOLUME_DOWN }, // (0xAE) - { KEY_VOLUMEUP, VK_VOLUME_UP }, // (0xAF) + { Key::VOLUMEUP, VK_VOLUME_UP }, // (0xAF) - { KEY_MEDIANEXT, VK_MEDIA_NEXT_TRACK }, // (0xB0) + { Key::MEDIANEXT, VK_MEDIA_NEXT_TRACK }, // (0xB0) - { KEY_MEDIAPREVIOUS, VK_MEDIA_PREV_TRACK }, // (0xB1) + { Key::MEDIAPREVIOUS, VK_MEDIA_PREV_TRACK }, // (0xB1) - { KEY_MEDIASTOP, VK_MEDIA_STOP }, // (0xB2) + { Key::MEDIASTOP, VK_MEDIA_STOP }, // (0xB2) //VK_MEDIA_PLAY_PAUSE (0xB3) - { KEY_LAUNCHMAIL, VK_LAUNCH_MAIL }, // (0xB4) + { Key::LAUNCHMAIL, VK_LAUNCH_MAIL }, // (0xB4) - { KEY_LAUNCHMEDIA, VK_LAUNCH_MEDIA_SELECT }, // (0xB5) + { Key::LAUNCHMEDIA, VK_LAUNCH_MEDIA_SELECT }, // (0xB5) - { KEY_LAUNCH0, VK_LAUNCH_APP1 }, // (0xB6) + { Key::LAUNCH0, VK_LAUNCH_APP1 }, // (0xB6) - { KEY_LAUNCH1, VK_LAUNCH_APP2 }, // (0xB7) + { Key::LAUNCH1, VK_LAUNCH_APP2 }, // (0xB7) - { KEY_SEMICOLON, VK_OEM_1 }, // (0xBA) + { Key::SEMICOLON, VK_OEM_1 }, // (0xBA) - { KEY_EQUAL, VK_OEM_PLUS }, // (0xBB) // Windows 2000/XP: For any country/region, the '+' key - { KEY_COMMA, VK_OEM_COMMA }, // (0xBC) // Windows 2000/XP: For any country/region, the ',' key - { KEY_MINUS, VK_OEM_MINUS }, // (0xBD) // Windows 2000/XP: For any country/region, the '-' key - { KEY_PERIOD, VK_OEM_PERIOD }, // (0xBE) // Windows 2000/XP: For any country/region, the '.' key - { KEY_SLASH, VK_OEM_2 }, // (0xBF) //Windows 2000/XP: For the US standard keyboard, the '/?' key + { Key::EQUAL, VK_OEM_PLUS }, // (0xBB) // Windows 2000/XP: For any country/region, the '+' key + { Key::COMMA, VK_OEM_COMMA }, // (0xBC) // Windows 2000/XP: For any country/region, the ',' key + { Key::MINUS, VK_OEM_MINUS }, // (0xBD) // Windows 2000/XP: For any country/region, the '-' key + { Key::PERIOD, VK_OEM_PERIOD }, // (0xBE) // Windows 2000/XP: For any country/region, the '.' key + { Key::SLASH, VK_OEM_2 }, // (0xBF) //Windows 2000/XP: For the US standard keyboard, the '/?' key - { KEY_QUOTELEFT, VK_OEM_3 }, // (0xC0) - { KEY_BRACELEFT, VK_OEM_4 }, // (0xDB) - { KEY_BACKSLASH, VK_OEM_5 }, // (0xDC) - { KEY_BRACERIGHT, VK_OEM_6 }, // (0xDD) - { KEY_APOSTROPHE, VK_OEM_7 }, // (0xDE) + { Key::QUOTELEFT, VK_OEM_3 }, // (0xC0) + { Key::BRACELEFT, VK_OEM_4 }, // (0xDB) + { Key::BACKSLASH, VK_OEM_5 }, // (0xDC) + { Key::BRACERIGHT, VK_OEM_6 }, // (0xDD) + { Key::APOSTROPHE, VK_OEM_7 }, // (0xDE) /* {VK_OEM_8 (0xDF) {VK_OEM_102 (0xE2) // Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard */ - //{ KEY_PLAY, VK_PLAY},// (0xFA) + //{ Key::PLAY, VK_PLAY},// (0xFA) - { KEY_UNKNOWN, 0 } + { Key::UNKNOWN, 0 } }; /* @@ -237,104 +237,104 @@ VK_OEM_CLEAR (0xFE) */ static _WinTranslatePair _scancode_to_keycode[] = { - { KEY_ESCAPE, 0x01 }, - { KEY_1, 0x02 }, - { KEY_2, 0x03 }, - { KEY_3, 0x04 }, - { KEY_4, 0x05 }, - { KEY_5, 0x06 }, - { KEY_6, 0x07 }, - { KEY_7, 0x08 }, - { KEY_8, 0x09 }, - { KEY_9, 0x0A }, - { KEY_0, 0x0B }, - { KEY_MINUS, 0x0C }, - { KEY_EQUAL, 0x0D }, - { KEY_BACKSPACE, 0x0E }, - { KEY_TAB, 0x0F }, - { KEY_Q, 0x10 }, - { KEY_W, 0x11 }, - { KEY_E, 0x12 }, - { KEY_R, 0x13 }, - { KEY_T, 0x14 }, - { KEY_Y, 0x15 }, - { KEY_U, 0x16 }, - { KEY_I, 0x17 }, - { KEY_O, 0x18 }, - { KEY_P, 0x19 }, - { KEY_BRACELEFT, 0x1A }, - { KEY_BRACERIGHT, 0x1B }, - { KEY_ENTER, 0x1C }, - { KEY_CTRL, 0x1D }, - { KEY_A, 0x1E }, - { KEY_S, 0x1F }, - { KEY_D, 0x20 }, - { KEY_F, 0x21 }, - { KEY_G, 0x22 }, - { KEY_H, 0x23 }, - { KEY_J, 0x24 }, - { KEY_K, 0x25 }, - { KEY_L, 0x26 }, - { KEY_SEMICOLON, 0x27 }, - { KEY_APOSTROPHE, 0x28 }, - { KEY_QUOTELEFT, 0x29 }, - { KEY_SHIFT, 0x2A }, - { KEY_BACKSLASH, 0x2B }, - { KEY_Z, 0x2C }, - { KEY_X, 0x2D }, - { KEY_C, 0x2E }, - { KEY_V, 0x2F }, - { KEY_B, 0x30 }, - { KEY_N, 0x31 }, - { KEY_M, 0x32 }, - { KEY_COMMA, 0x33 }, - { KEY_PERIOD, 0x34 }, - { KEY_SLASH, 0x35 }, - { KEY_SHIFT, 0x36 }, - { KEY_PRINT, 0x37 }, - { KEY_ALT, 0x38 }, - { KEY_SPACE, 0x39 }, - { KEY_CAPSLOCK, 0x3A }, - { KEY_F1, 0x3B }, - { KEY_F2, 0x3C }, - { KEY_F3, 0x3D }, - { KEY_F4, 0x3E }, - { KEY_F5, 0x3F }, - { KEY_F6, 0x40 }, - { KEY_F7, 0x41 }, - { KEY_F8, 0x42 }, - { KEY_F9, 0x43 }, - { KEY_F10, 0x44 }, - { KEY_NUMLOCK, 0x45 }, - { KEY_SCROLLLOCK, 0x46 }, - { KEY_HOME, 0x47 }, - { KEY_UP, 0x48 }, - { KEY_PAGEUP, 0x49 }, - { KEY_KP_SUBTRACT, 0x4A }, - { KEY_LEFT, 0x4B }, - { KEY_KP_5, 0x4C }, - { KEY_RIGHT, 0x4D }, - { KEY_KP_ADD, 0x4E }, - { KEY_END, 0x4F }, - { KEY_DOWN, 0x50 }, - { KEY_PAGEDOWN, 0x51 }, - { KEY_INSERT, 0x52 }, - { KEY_DELETE, 0x53 }, - //{ KEY_???, 0x56 }, //NON US BACKSLASH - { KEY_F11, 0x57 }, - { KEY_F12, 0x58 }, - { KEY_META, 0x5B }, - { KEY_META, 0x5C }, - { KEY_MENU, 0x5D }, - { KEY_F13, 0x64 }, - { KEY_F14, 0x65 }, - { KEY_F15, 0x66 }, - { KEY_F16, 0x67 }, - { KEY_UNKNOWN, 0 } + { Key::ESCAPE, 0x01 }, + { Key::KEY_1, 0x02 }, + { Key::KEY_2, 0x03 }, + { Key::KEY_3, 0x04 }, + { Key::KEY_4, 0x05 }, + { Key::KEY_5, 0x06 }, + { Key::KEY_6, 0x07 }, + { Key::KEY_7, 0x08 }, + { Key::KEY_8, 0x09 }, + { Key::KEY_9, 0x0A }, + { Key::KEY_0, 0x0B }, + { Key::MINUS, 0x0C }, + { Key::EQUAL, 0x0D }, + { Key::BACKSPACE, 0x0E }, + { Key::TAB, 0x0F }, + { Key::Q, 0x10 }, + { Key::W, 0x11 }, + { Key::E, 0x12 }, + { Key::R, 0x13 }, + { Key::T, 0x14 }, + { Key::Y, 0x15 }, + { Key::U, 0x16 }, + { Key::I, 0x17 }, + { Key::O, 0x18 }, + { Key::P, 0x19 }, + { Key::BRACELEFT, 0x1A }, + { Key::BRACERIGHT, 0x1B }, + { Key::ENTER, 0x1C }, + { Key::CTRL, 0x1D }, + { Key::A, 0x1E }, + { Key::S, 0x1F }, + { Key::D, 0x20 }, + { Key::F, 0x21 }, + { Key::G, 0x22 }, + { Key::H, 0x23 }, + { Key::J, 0x24 }, + { Key::K, 0x25 }, + { Key::L, 0x26 }, + { Key::SEMICOLON, 0x27 }, + { Key::APOSTROPHE, 0x28 }, + { Key::QUOTELEFT, 0x29 }, + { Key::SHIFT, 0x2A }, + { Key::BACKSLASH, 0x2B }, + { Key::Z, 0x2C }, + { Key::X, 0x2D }, + { Key::C, 0x2E }, + { Key::V, 0x2F }, + { Key::B, 0x30 }, + { Key::N, 0x31 }, + { Key::M, 0x32 }, + { Key::COMMA, 0x33 }, + { Key::PERIOD, 0x34 }, + { Key::SLASH, 0x35 }, + { Key::SHIFT, 0x36 }, + { Key::PRINT, 0x37 }, + { Key::ALT, 0x38 }, + { Key::SPACE, 0x39 }, + { Key::CAPSLOCK, 0x3A }, + { Key::F1, 0x3B }, + { Key::F2, 0x3C }, + { Key::F3, 0x3D }, + { Key::F4, 0x3E }, + { Key::F5, 0x3F }, + { Key::F6, 0x40 }, + { Key::F7, 0x41 }, + { Key::F8, 0x42 }, + { Key::F9, 0x43 }, + { Key::F10, 0x44 }, + { Key::NUMLOCK, 0x45 }, + { Key::SCROLLLOCK, 0x46 }, + { Key::HOME, 0x47 }, + { Key::UP, 0x48 }, + { Key::PAGEUP, 0x49 }, + { Key::KP_SUBTRACT, 0x4A }, + { Key::LEFT, 0x4B }, + { Key::KP_5, 0x4C }, + { Key::RIGHT, 0x4D }, + { Key::KP_ADD, 0x4E }, + { Key::END, 0x4F }, + { Key::DOWN, 0x50 }, + { Key::PAGEDOWN, 0x51 }, + { Key::INSERT, 0x52 }, + { Key::KEY_DELETE, 0x53 }, + //{ Key::???, 0x56 }, //NON US BACKSLASH + { Key::F11, 0x57 }, + { Key::F12, 0x58 }, + { Key::META, 0x5B }, + { Key::META, 0x5C }, + { Key::MENU, 0x5D }, + { Key::F13, 0x64 }, + { Key::F14, 0x65 }, + { Key::F15, 0x66 }, + { Key::F16, 0x67 }, + { Key::UNKNOWN, 0 } }; -unsigned int KeyMappingWindows::get_keysym(unsigned int p_code) { - for (int i = 0; _vk_to_keycode[i].keysym != KEY_UNKNOWN; i++) { +Key KeyMappingWindows::get_keysym(unsigned int p_code) { + for (int i = 0; _vk_to_keycode[i].keysym != Key::UNKNOWN; i++) { if (_vk_to_keycode[i].keycode == p_code) { //printf("outcode: %x\n",_vk_to_keycode[i].keysym); @@ -342,11 +342,11 @@ unsigned int KeyMappingWindows::get_keysym(unsigned int p_code) { } } - return KEY_UNKNOWN; + return Key::UNKNOWN; } unsigned int KeyMappingWindows::get_scancode(Key p_keycode) { - for (int i = 0; _scancode_to_keycode[i].keysym != KEY_UNKNOWN; i++) { + for (int i = 0; _scancode_to_keycode[i].keysym != Key::UNKNOWN; i++) { if (_scancode_to_keycode[i].keysym == p_keycode) { return _scancode_to_keycode[i].keycode; } @@ -355,9 +355,9 @@ unsigned int KeyMappingWindows::get_scancode(Key p_keycode) { return 0; } -unsigned int KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended) { - unsigned int keycode = KEY_UNKNOWN; - for (int i = 0; _scancode_to_keycode[i].keysym != KEY_UNKNOWN; i++) { +Key KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended) { + Key keycode = Key::UNKNOWN; + for (int i = 0; _scancode_to_keycode[i].keysym != Key::UNKNOWN; i++) { if (_scancode_to_keycode[i].keycode == p_code) { keycode = _scancode_to_keycode[i].keysym; break; @@ -366,55 +366,55 @@ unsigned int KeyMappingWindows::get_scansym(unsigned int p_code, bool p_extended if (p_extended) { switch (keycode) { - case KEY_ENTER: { - keycode = KEY_KP_ENTER; + case Key::ENTER: { + keycode = Key::KP_ENTER; } break; - case KEY_SLASH: { - keycode = KEY_KP_DIVIDE; + case Key::SLASH: { + keycode = Key::KP_DIVIDE; } break; - case KEY_CAPSLOCK: { - keycode = KEY_KP_ADD; + case Key::CAPSLOCK: { + keycode = Key::KP_ADD; } break; default: break; } } else { switch (keycode) { - case KEY_NUMLOCK: { - keycode = KEY_PAUSE; + case Key::NUMLOCK: { + keycode = Key::PAUSE; } break; - case KEY_HOME: { - keycode = KEY_KP_7; + case Key::HOME: { + keycode = Key::KP_7; } break; - case KEY_UP: { - keycode = KEY_KP_8; + case Key::UP: { + keycode = Key::KP_8; } break; - case KEY_PAGEUP: { - keycode = KEY_KP_9; + case Key::PAGEUP: { + keycode = Key::KP_9; } break; - case KEY_LEFT: { - keycode = KEY_KP_4; + case Key::LEFT: { + keycode = Key::KP_4; } break; - case KEY_RIGHT: { - keycode = KEY_KP_6; + case Key::RIGHT: { + keycode = Key::KP_6; } break; - case KEY_END: { - keycode = KEY_KP_1; + case Key::END: { + keycode = Key::KP_1; } break; - case KEY_DOWN: { - keycode = KEY_KP_2; + case Key::DOWN: { + keycode = Key::KP_2; } break; - case KEY_PAGEDOWN: { - keycode = KEY_KP_3; + case Key::PAGEDOWN: { + keycode = Key::KP_3; } break; - case KEY_INSERT: { - keycode = KEY_KP_0; + case Key::INSERT: { + keycode = Key::KP_0; } break; - case KEY_DELETE: { - keycode = KEY_KP_PERIOD; + case Key::KEY_DELETE: { + keycode = Key::KP_PERIOD; } break; - case KEY_PRINT: { - keycode = KEY_KP_MULTIPLY; + case Key::PRINT: { + keycode = Key::KP_MULTIPLY; } break; default: break; diff --git a/platform/windows/key_mapping_windows.h b/platform/windows/key_mapping_windows.h index d056e88f06..0454be7310 100644 --- a/platform/windows/key_mapping_windows.h +++ b/platform/windows/key_mapping_windows.h @@ -41,9 +41,9 @@ class KeyMappingWindows { KeyMappingWindows() {} public: - static unsigned int get_keysym(unsigned int p_code); + static Key get_keysym(unsigned int p_code); static unsigned int get_scancode(Key p_keycode); - static unsigned int get_scansym(unsigned int p_code, bool p_extended); + static Key get_scansym(unsigned int p_code, bool p_extended); static bool is_extended_key(unsigned int p_code); }; |