mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-06-08 09:29:31 +00:00
Revert SDL2 hotkey code to original version
This reverts commits3b7a89aad9
ande28a9fc3a9
.
This commit is contained in:
parent
3b7a89aad9
commit
4c1c549ed6
|
@ -69,9 +69,6 @@
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#define CODE_INVALID -1
|
|
||||||
#define CODE_HOTKEY -2
|
|
||||||
|
|
||||||
// Supported video modes
|
// Supported video modes
|
||||||
using std::vector;
|
using std::vector;
|
||||||
static vector<VIDEO_MODE> VideoModes;
|
static vector<VIDEO_MODE> VideoModes;
|
||||||
|
@ -877,7 +874,7 @@ static void keycode_init(void)
|
||||||
|
|
||||||
// Default translation table
|
// Default translation table
|
||||||
for (int i=0; i<256; i++)
|
for (int i=0; i<256; i++)
|
||||||
keycode_table[i] = CODE_INVALID;
|
keycode_table[i] = -1;
|
||||||
|
|
||||||
// Search for server vendor string, then read keycodes
|
// Search for server vendor string, then read keycodes
|
||||||
char video_driver[256];
|
char video_driver[256];
|
||||||
|
@ -1661,8 +1658,8 @@ static int modify_opt_cmd(int code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Translate key event to Mac keycode, returns CODE_INVALID if no keycode was found
|
* Translate key event to Mac keycode, returns -1 if no keycode was found
|
||||||
* and CODE_HOTKEY if the key was recognized as a hotkey
|
* and -2 if the key was recognized as a hotkey
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int kc_decode(SDL_keysym const & ks, bool key_down)
|
static int kc_decode(SDL_keysym const & ks, bool key_down)
|
||||||
|
@ -1718,8 +1715,8 @@ static int kc_decode(SDL_keysym const & ks, bool key_down)
|
||||||
case SDLK_PERIOD: case SDLK_GREATER: return 0x2f;
|
case SDLK_PERIOD: case SDLK_GREATER: return 0x2f;
|
||||||
case SDLK_SLASH: case SDLK_QUESTION: return 0x2c;
|
case SDLK_SLASH: case SDLK_QUESTION: return 0x2c;
|
||||||
|
|
||||||
case SDLK_TAB: if (is_hotkey_down(ks)) {if (!key_down) drv->suspend(); return CODE_HOTKEY;} else return 0x30;
|
case SDLK_TAB: if (is_hotkey_down(ks)) {if (!key_down) drv->suspend(); return -2;} else return 0x30;
|
||||||
case SDLK_RETURN: if (is_hotkey_down(ks)) {if (!key_down) toggle_fullscreen = true; return CODE_HOTKEY;} else return 0x24;
|
case SDLK_RETURN: if (is_hotkey_down(ks)) {if (!key_down) toggle_fullscreen = true; return -2;} else return 0x24;
|
||||||
case SDLK_SPACE: return 0x31;
|
case SDLK_SPACE: return 0x31;
|
||||||
case SDLK_BACKSPACE: return 0x33;
|
case SDLK_BACKSPACE: return 0x33;
|
||||||
|
|
||||||
|
@ -1730,11 +1727,13 @@ static int kc_decode(SDL_keysym const & ks, bool key_down)
|
||||||
case SDLK_PAGEUP: return 0x74;
|
case SDLK_PAGEUP: return 0x74;
|
||||||
case SDLK_PAGEDOWN: return 0x79;
|
case SDLK_PAGEDOWN: return 0x79;
|
||||||
|
|
||||||
case SDLK_LCTRL: case SDLK_RCTRL: ctrl_down = key_down; return 0x36;
|
case SDLK_LCTRL: return 0x36;
|
||||||
case SDLK_LSHIFT: case SDLK_RSHIFT: return 0x38;
|
case SDLK_RCTRL: return 0x36;
|
||||||
case SDLK_LALT: case SDLK_RALT: alt_down = key_down; return 0x3a;
|
case SDLK_LSHIFT: return 0x38;
|
||||||
case SDLK_LMETA: case SDLK_RMETA: super_down = key_down; return 0x37;
|
case SDLK_RSHIFT: return 0x38;
|
||||||
case SDLK_LSUPER: case SDLK_RSUPER: super_down = key_down; return 0x37; // "Windows" key
|
case SDLK_LALT: case SDLK_RALT: return 0x3a;
|
||||||
|
case SDLK_LMETA: case SDLK_RMETA: return 0x37;
|
||||||
|
case SDLK_LSUPER: case SDLK_RSUPER: return 0x37; // "Windows" key
|
||||||
case SDLK_MENU: return 0x32;
|
case SDLK_MENU: return 0x32;
|
||||||
case SDLK_CAPSLOCK: return 0x39;
|
case SDLK_CAPSLOCK: return 0x39;
|
||||||
case SDLK_NUMLOCK: return 0x47;
|
case SDLK_NUMLOCK: return 0x47;
|
||||||
|
@ -1744,13 +1743,13 @@ static int kc_decode(SDL_keysym const & ks, bool key_down)
|
||||||
case SDLK_LEFT: return 0x3b;
|
case SDLK_LEFT: return 0x3b;
|
||||||
case SDLK_RIGHT: return 0x3c;
|
case SDLK_RIGHT: return 0x3c;
|
||||||
|
|
||||||
case SDLK_ESCAPE: if (is_hotkey_down(ks)) {if (!key_down) { quit_full_screen = true; emerg_quit = true; } return CODE_HOTKEY;} else return 0x35;
|
case SDLK_ESCAPE: if (is_hotkey_down(ks)) {if (!key_down) { quit_full_screen = true; emerg_quit = true; } return -2;} else return 0x35;
|
||||||
|
|
||||||
case SDLK_F1: if (is_hotkey_down(ks)) {if (!key_down) SysMountFirstFloppy(); return CODE_HOTKEY;} else return 0x7a;
|
case SDLK_F1: if (is_hotkey_down(ks)) {if (!key_down) SysMountFirstFloppy(); return -2;} else return 0x7a;
|
||||||
case SDLK_F2: return 0x78;
|
case SDLK_F2: return 0x78;
|
||||||
case SDLK_F3: return 0x63;
|
case SDLK_F3: return 0x63;
|
||||||
case SDLK_F4: return 0x76;
|
case SDLK_F4: return 0x76;
|
||||||
case SDLK_F5: if (is_hotkey_down(ks)) {if (!key_down) drv->toggle_mouse_grab(); return CODE_HOTKEY;} else return 0x60;
|
case SDLK_F5: if (is_hotkey_down(ks)) {if (!key_down) drv->toggle_mouse_grab(); return -2;} else return 0x60;
|
||||||
case SDLK_F6: return 0x61;
|
case SDLK_F6: return 0x61;
|
||||||
case SDLK_F7: return 0x62;
|
case SDLK_F7: return 0x62;
|
||||||
case SDLK_F8: return 0x64;
|
case SDLK_F8: return 0x64;
|
||||||
|
@ -1782,7 +1781,7 @@ static int kc_decode(SDL_keysym const & ks, bool key_down)
|
||||||
case SDLK_KP_EQUALS: return 0x51;
|
case SDLK_KP_EQUALS: return 0x51;
|
||||||
}
|
}
|
||||||
D(bug("Unhandled SDL keysym: %d\n", ks.sym));
|
D(bug("Unhandled SDL keysym: %d\n", ks.sym));
|
||||||
return CODE_INVALID;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int event2keycode(SDL_KeyboardEvent const &ev, bool key_down)
|
static int event2keycode(SDL_KeyboardEvent const &ev, bool key_down)
|
||||||
|
@ -1865,16 +1864,23 @@ static void handle_events(void)
|
||||||
|
|
||||||
// Keyboard
|
// Keyboard
|
||||||
case SDL_KEYDOWN: {
|
case SDL_KEYDOWN: {
|
||||||
int code = CODE_INVALID;
|
int code = -1;
|
||||||
// This is called to process the hotkeys
|
if (use_keycodes && !is_modifier_key(event.key)) {
|
||||||
if (use_keycodes && !is_modifier_key(event.key) && event2keycode(event.key, true) != CODE_HOTKEY)
|
if (event2keycode(event.key, true) != -2) // This is called to process the hotkeys
|
||||||
code = keycode_table[event.key.keysym.scancode & 0xff];
|
code = keycode_table[event.key.keysym.scancode & 0xff];
|
||||||
if (code == CODE_INVALID)
|
} else
|
||||||
code = event2keycode(event.key, true);
|
code = event2keycode(event.key, true);
|
||||||
if (code >= 0) {
|
if (code >= 0) {
|
||||||
if (!emul_suspended) {
|
if (!emul_suspended) {
|
||||||
if (code == 0x3a || code == 0x37)
|
if (code == 0x36) {
|
||||||
code = modify_opt_cmd(code);
|
ctrl_down = true;
|
||||||
|
} else if (code == 0x3a) {
|
||||||
|
alt_down = true;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
} else if (code == 0x37) {
|
||||||
|
super_down = true;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
}
|
||||||
if (code == 0x39) { // Caps Lock pressed
|
if (code == 0x39) { // Caps Lock pressed
|
||||||
if (caps_on) {
|
if (caps_on) {
|
||||||
ADBKeyUp(code);
|
ADBKeyUp(code);
|
||||||
|
@ -1893,15 +1899,22 @@ static void handle_events(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_KEYUP: {
|
case SDL_KEYUP: {
|
||||||
int code = CODE_INVALID;
|
int code = -1;
|
||||||
// This is called to process the hotkeys
|
if (use_keycodes && !is_modifier_key(event.key)) {
|
||||||
if (use_keycodes && !is_modifier_key(event.key) && event2keycode(event.key, false) != CODE_HOTKEY)
|
if (event2keycode(event.key, false) != -2) // This is called to process the hotkeys
|
||||||
code = keycode_table[event.key.keysym.scancode & 0xff];
|
code = keycode_table[event.key.keysym.scancode & 0xff];
|
||||||
if (code == CODE_INVALID)
|
} else
|
||||||
code = event2keycode(event.key, false);
|
code = event2keycode(event.key, false);
|
||||||
if (code >= 0) {
|
if (code >= 0) {
|
||||||
if (code == 0x3a ||code == 0x37)
|
if (code == 0x36) {
|
||||||
code = modify_opt_cmd(code);
|
ctrl_down = false;
|
||||||
|
} else if (code == 0x3a) {
|
||||||
|
alt_down = false;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
} else if (code == 0x37) {
|
||||||
|
super_down = false;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
}
|
||||||
if (code == 0x39) { // Caps Lock released
|
if (code == 0x39) { // Caps Lock released
|
||||||
if (caps_on) {
|
if (caps_on) {
|
||||||
ADBKeyUp(code);
|
ADBKeyUp(code);
|
||||||
|
|
|
@ -2142,10 +2142,12 @@ static int kc_decode(SDL_Keysym const & ks, bool key_down)
|
||||||
case SDLK_PAGEUP: return 0x74;
|
case SDLK_PAGEUP: return 0x74;
|
||||||
case SDLK_PAGEDOWN: return 0x79;
|
case SDLK_PAGEDOWN: return 0x79;
|
||||||
|
|
||||||
case SDLK_LCTRL: SDLK_RCTRL: ctrl_down = key_down; return 0x36;
|
case SDLK_LCTRL: return 0x36;
|
||||||
case SDLK_LSHIFT: SDLK_RSHIFT: return 0x38;
|
case SDLK_RCTRL: return 0x36;
|
||||||
case SDLK_LALT: case SDLK_RALT: alt_down = key_down; return 0x3a;
|
case SDLK_LSHIFT: return 0x38;
|
||||||
case SDLK_LGUI: case SDLK_RGUI: super_down = key_down; return 0x37;
|
case SDLK_RSHIFT: return 0x38;
|
||||||
|
case SDLK_LALT: case SDLK_RALT: return 0x3a;
|
||||||
|
case SDLK_LGUI: case SDLK_RGUI: return 0x37;
|
||||||
case SDLK_MENU: return 0x32;
|
case SDLK_MENU: return 0x32;
|
||||||
case SDLK_CAPSLOCK: return 0x39;
|
case SDLK_CAPSLOCK: return 0x39;
|
||||||
case SDLK_NUMLOCKCLEAR: return 0x47;
|
case SDLK_NUMLOCKCLEAR: return 0x47;
|
||||||
|
@ -2355,15 +2357,24 @@ static void handle_events(void)
|
||||||
code = event2keycode(event.key, true);
|
code = event2keycode(event.key, true);
|
||||||
if (code >= 0) {
|
if (code >= 0) {
|
||||||
if (!emul_suspended) {
|
if (!emul_suspended) {
|
||||||
if (code == 0x3a || code == 0x37)
|
if (code == 0x36) {
|
||||||
code = modify_opt_cmd(code);
|
ctrl_down = true;
|
||||||
if (code == 0x39)
|
} else if (code == 0x3a) {
|
||||||
|
alt_down = true;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
} else if (code == 0x37) {
|
||||||
|
super_down = true;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
}
|
||||||
|
if (code == 0x39) {
|
||||||
(SDL_GetModState() & KMOD_CAPS ? ADBKeyDown : ADBKeyUp)(code);
|
(SDL_GetModState() & KMOD_CAPS ? ADBKeyDown : ADBKeyUp)(code);
|
||||||
else
|
} else
|
||||||
ADBKeyDown(code);
|
ADBKeyDown(code);
|
||||||
|
|
||||||
} else if (code == 0x31)
|
} else {
|
||||||
|
if (code == 0x31)
|
||||||
drv->resume(); // Space wakes us up
|
drv->resume(); // Space wakes us up
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2374,8 +2385,15 @@ static void handle_events(void)
|
||||||
if (code == CODE_INVALID)
|
if (code == CODE_INVALID)
|
||||||
code = event2keycode(event.key, false);
|
code = event2keycode(event.key, false);
|
||||||
if (code >= 0) {
|
if (code >= 0) {
|
||||||
if (code == 0x3a ||code == 0x37)
|
if (code == 0x36) {
|
||||||
code = modify_opt_cmd(code);
|
ctrl_down = false;
|
||||||
|
} else if (code == 0x3a) {
|
||||||
|
alt_down = false;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
} else if (code == 0x37) {
|
||||||
|
super_down = false;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
}
|
||||||
if (code != 0x39)
|
if (code != 0x39)
|
||||||
ADBKeyUp(code);
|
ADBKeyUp(code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,9 +69,6 @@
|
||||||
#define DEBUG 0
|
#define DEBUG 0
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
#define CODE_INVALID -1
|
|
||||||
#define CODE_HOTKEY -2
|
|
||||||
|
|
||||||
|
|
||||||
// Supported video modes
|
// Supported video modes
|
||||||
static vector<video_mode> VideoModes;
|
static vector<video_mode> VideoModes;
|
||||||
|
@ -481,14 +478,15 @@ static void set_window_name(Window w, int name)
|
||||||
static void set_window_name(Window w, bool mouse_grabbed) {
|
static void set_window_name(Window w, bool mouse_grabbed) {
|
||||||
const char *title = PrefsFindString("title");
|
const char *title = PrefsFindString("title");
|
||||||
std::string s = title ? title : GetString(STR_WINDOW_TITLE);
|
std::string s = title ? title : GetString(STR_WINDOW_TITLE);
|
||||||
if (mouse_grabbed) {
|
if (mouse_grabbed)
|
||||||
s += GetString(STR_WINDOW_TITLE_GRABBED_PRE);
|
{
|
||||||
|
s += GetString(STR_WINDOW_TITLE_GRABBED_PRE);
|
||||||
int hotkey = PrefsFindInt32("hotkey");
|
int hotkey = PrefsFindInt32("hotkey");
|
||||||
hotkey = hotkey ? hotkey : 1;
|
hotkey = hotkey ? hotkey : 1;
|
||||||
if (hotkey & 1) s += GetString(STR_WINDOW_TITLE_GRABBED1);
|
if (hotkey & 1) s += GetString(STR_WINDOW_TITLE_GRABBED1);
|
||||||
if (hotkey & 2) s += GetString(STR_WINDOW_TITLE_GRABBED2);
|
if (hotkey & 2) s += GetString(STR_WINDOW_TITLE_GRABBED2);
|
||||||
if (hotkey & 4) s += GetString(STR_WINDOW_TITLE_GRABBED4);
|
if (hotkey & 4) s += GetString(STR_WINDOW_TITLE_GRABBED4);
|
||||||
s += GetString(STR_WINDOW_TITLE_GRABBED_POST);
|
s += GetString(STR_WINDOW_TITLE_GRABBED_POST);
|
||||||
}
|
}
|
||||||
XStoreName(x_display, w, s.c_str());
|
XStoreName(x_display, w, s.c_str());
|
||||||
XSetIconName(x_display, w, GetString(STR_WINDOW_TITLE));
|
XSetIconName(x_display, w, GetString(STR_WINDOW_TITLE));
|
||||||
|
@ -1470,7 +1468,7 @@ static void keycode_init(void)
|
||||||
|
|
||||||
// Default translation table
|
// Default translation table
|
||||||
for (int i=0; i<256; i++)
|
for (int i=0; i<256; i++)
|
||||||
keycode_table[i] = CODE_INVALID;
|
keycode_table[i] = -1;
|
||||||
|
|
||||||
// Search for server vendor string, then read keycodes
|
// Search for server vendor string, then read keycodes
|
||||||
const char *vendor = ServerVendor(x_display);
|
const char *vendor = ServerVendor(x_display);
|
||||||
|
@ -1757,7 +1755,7 @@ bool VideoInit(bool classic)
|
||||||
default_width = -1; default_height = -1; // use entire screen
|
default_width = -1; default_height = -1; // use entire screen
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_XF86_DGA
|
#ifdef ENABLE_XF86_DGA
|
||||||
} else if (has_dga && sscanf(mode_str, "dga/%d/%d", &default_width, &default_height) == 2) {
|
} else if (has_dga & sscanf(mode_str, "dga/%d/%d", &default_width, &default_height) == 2) {
|
||||||
display_type = DISPLAY_DGA;
|
display_type = DISPLAY_DGA;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -2015,8 +2013,8 @@ void X11_monitor_desc::switch_to_current_mode(void)
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Translate key event to Mac keycode, returns CODE_INVALID if no keycode was found
|
* Translate key event to Mac keycode, returns -1 if no keycode was found
|
||||||
* and CODE_HOTKEY if the key was recognized as a hotkey
|
* and -2 if the key was recognized as a hotkey
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int kc_decode(KeySym ks, bool key_down)
|
static int kc_decode(KeySym ks, bool key_down)
|
||||||
|
@ -2072,7 +2070,7 @@ static int kc_decode(KeySym ks, bool key_down)
|
||||||
case XK_period: case XK_greater: return 0x2f;
|
case XK_period: case XK_greater: return 0x2f;
|
||||||
case XK_slash: case XK_question: return 0x2c;
|
case XK_slash: case XK_question: return 0x2c;
|
||||||
|
|
||||||
case XK_Tab: if (is_hotkey_down()) {if (key_down) drv->suspend(); return CODE_HOTKEY;} else return 0x30;
|
case XK_Tab: if (is_hotkey_down()) {if (key_down) drv->suspend(); return -2;} else return 0x30;
|
||||||
case XK_Return: return 0x24;
|
case XK_Return: return 0x24;
|
||||||
case XK_space: return 0x31;
|
case XK_space: return 0x31;
|
||||||
case XK_BackSpace: return 0x33;
|
case XK_BackSpace: return 0x33;
|
||||||
|
@ -2089,10 +2087,14 @@ static int kc_decode(KeySym ks, bool key_down)
|
||||||
case XK_Page_Down: return 0x79;
|
case XK_Page_Down: return 0x79;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case XK_Control_L: case XK_Control_R: if (!emul_suspended) ctrl_down = key_down; return 0x36;
|
case XK_Control_L: return 0x36;
|
||||||
case XK_Shift_L: case XK_Shift_R: return 0x38;
|
case XK_Control_R: return 0x36;
|
||||||
case XK_Alt_L: case XK_Alt_R: if (!emul_suspended) alt_down = key_down; return 0x3a;
|
case XK_Shift_L: return 0x38;
|
||||||
case XK_Meta_L: case XK_Meta_R: if (!emul_suspended) super_down = key_down; return 0x37;
|
case XK_Shift_R: return 0x38;
|
||||||
|
case XK_Alt_L: return 0x3a;
|
||||||
|
case XK_Alt_R: return 0x3a;
|
||||||
|
case XK_Meta_L: return 0x37;
|
||||||
|
case XK_Meta_R: return 0x37;
|
||||||
case XK_Menu: return 0x32;
|
case XK_Menu: return 0x32;
|
||||||
case XK_Caps_Lock: return 0x39;
|
case XK_Caps_Lock: return 0x39;
|
||||||
case XK_Num_Lock: return 0x47;
|
case XK_Num_Lock: return 0x47;
|
||||||
|
@ -2102,13 +2104,13 @@ static int kc_decode(KeySym ks, bool key_down)
|
||||||
case XK_Left: return 0x3b;
|
case XK_Left: return 0x3b;
|
||||||
case XK_Right: return 0x3c;
|
case XK_Right: return 0x3c;
|
||||||
|
|
||||||
case XK_Escape: if (is_hotkey_down()) {if (key_down) { quit_full_screen = true; emerg_quit = true; } return CODE_HOTKEY;} else return 0x35;
|
case XK_Escape: if (is_hotkey_down()) {if (key_down) { quit_full_screen = true; emerg_quit = true; } return -2;} else return 0x35;
|
||||||
|
|
||||||
case XK_F1: if (is_hotkey_down()) {if (key_down) SysMountFirstFloppy(); return CODE_HOTKEY;} else return 0x7a;
|
case XK_F1: if (is_hotkey_down()) {if (key_down) SysMountFirstFloppy(); return -2;} else return 0x7a;
|
||||||
case XK_F2: return 0x78;
|
case XK_F2: return 0x78;
|
||||||
case XK_F3: return 0x63;
|
case XK_F3: return 0x63;
|
||||||
case XK_F4: return 0x76;
|
case XK_F4: return 0x76;
|
||||||
case XK_F5: if (is_hotkey_down()) {if (key_down) drv->toggle_mouse_grab(); return CODE_HOTKEY;} else return 0x60;
|
case XK_F5: if (is_hotkey_down()) {if (key_down) drv->toggle_mouse_grab(); return -2;} else return 0x60;
|
||||||
case XK_F6: return 0x61;
|
case XK_F6: return 0x61;
|
||||||
case XK_F7: return 0x62;
|
case XK_F7: return 0x62;
|
||||||
case XK_F8: return 0x64;
|
case XK_F8: return 0x64;
|
||||||
|
@ -2153,7 +2155,7 @@ static int kc_decode(KeySym ks, bool key_down)
|
||||||
case XK_KP_Enter: return 0x4c;
|
case XK_KP_Enter: return 0x4c;
|
||||||
case XK_KP_Equal: return 0x51;
|
case XK_KP_Equal: return 0x51;
|
||||||
}
|
}
|
||||||
return CODE_INVALID;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int event2keycode(XKeyEvent &ev, bool key_down)
|
static int event2keycode(XKeyEvent &ev, bool key_down)
|
||||||
|
@ -2166,11 +2168,11 @@ static int event2keycode(XKeyEvent &ev, bool key_down)
|
||||||
int as = kc_decode(ks, key_down);
|
int as = kc_decode(ks, key_down);
|
||||||
if (as >= 0)
|
if (as >= 0)
|
||||||
return as;
|
return as;
|
||||||
if (as == CODE_HOTKEY)
|
if (as == -2)
|
||||||
return as;
|
return as;
|
||||||
} while (ks != NoSymbol);
|
} while (ks != NoSymbol);
|
||||||
|
|
||||||
return CODE_INVALID;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2245,10 +2247,22 @@ static void handle_events(void)
|
||||||
// Keyboard
|
// Keyboard
|
||||||
case KeyPress: {
|
case KeyPress: {
|
||||||
int code = event2keycode(event.xkey, true);
|
int code = event2keycode(event.xkey, true);
|
||||||
if (use_keycodes && code != CODE_HOTKEY) // This is called to process the hotkeys
|
if(!emul_suspended)
|
||||||
code = keycode_table[event.xkey.keycode & 0xff];
|
{
|
||||||
if (code == 0x3a || code == 0x37)
|
if (code == 0x36) {
|
||||||
code = modify_opt_cmd(code);
|
ctrl_down = true;
|
||||||
|
} else if (code == 0x3a) {
|
||||||
|
alt_down = true;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
} else if (code == 0x37) {
|
||||||
|
super_down = true;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (use_keycodes) {
|
||||||
|
if (code != -2) // This is called to process the hotkeys
|
||||||
|
code = keycode_table[event.xkey.keycode & 0xff];
|
||||||
|
}
|
||||||
if (code >= 0) {
|
if (code >= 0) {
|
||||||
if (!emul_suspended) {
|
if (!emul_suspended) {
|
||||||
if (code == 0x39) { // Caps Lock pressed
|
if (code == 0x39) { // Caps Lock pressed
|
||||||
|
@ -2270,12 +2284,25 @@ static void handle_events(void)
|
||||||
}
|
}
|
||||||
case KeyRelease: {
|
case KeyRelease: {
|
||||||
int code = event2keycode(event.xkey, false);
|
int code = event2keycode(event.xkey, false);
|
||||||
if (use_keycodes && code != CODE_HOTKEY) // This is called to process the hotkeys
|
if(!emul_suspended)
|
||||||
code = keycode_table[event.xkey.keycode & 0xff];
|
{
|
||||||
if (code == 0x3a || code == 0x37)
|
if (code == 0x36) {
|
||||||
code = modify_opt_cmd(code);
|
ctrl_down = false;
|
||||||
if (code >= 0 && code != 0x39) // Don't propagate Caps Lock releases
|
} else if (code == 0x3a) {
|
||||||
|
alt_down = false;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
} else if (code == 0x37) {
|
||||||
|
super_down = false;
|
||||||
|
code = modify_opt_cmd(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (use_keycodes) {
|
||||||
|
if (code != -2) // This is called to process the hotkeys
|
||||||
|
code = keycode_table[event.xkey.keycode & 0xff];
|
||||||
|
}
|
||||||
|
if (code >= 0 && code != 0x39) { // Don't propagate Caps Lock releases
|
||||||
ADBKeyUp(code);
|
ADBKeyUp(code);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user