summaryrefslogtreecommitdiff
path: root/platform/linuxbsd
diff options
context:
space:
mode:
Diffstat (limited to 'platform/linuxbsd')
-rw-r--r--platform/linuxbsd/display_server_x11.cpp66
-rw-r--r--platform/linuxbsd/display_server_x11.h4
-rw-r--r--platform/linuxbsd/joypad_linux.cpp14
-rw-r--r--platform/linuxbsd/joypad_linux.h2
-rw-r--r--platform/linuxbsd/key_mapping_x11.cpp498
-rw-r--r--platform/linuxbsd/key_mapping_x11.h6
6 files changed, 295 insertions, 295 deletions
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