Code cleanup in keyboard handling

This commit is contained in:
Dimitris Panokostas 2017-12-19 00:12:45 +01:00
parent 4058af1271
commit 3f8a881cfb

View file

@ -263,54 +263,38 @@ static const int np[] = {
void translate_amiberry_keys(int scancode, int newstate) void translate_amiberry_keys(int scancode, int newstate)
{ {
int code = 0; if (newstate)
bool amode = currprefs.input_keyboard_type == 0; {
bool special = false;
static int swapperdrive = 0;
int scancode_new = scancode;
if (newstate) {
int defaultguikey = SDLK_F12; int defaultguikey = SDLK_F12;
if (currprefs.open_gui != "") { if (currprefs.open_gui != "")
{
#ifdef USE_SDL1 #ifdef USE_SDL1
if (scancode_new == defaultguikey) if (scancode == defaultguikey)
{ {
scancode = 0;
if (specialpressed() && ctrlpressed() && shiftpressed() && altpressed()) if (specialpressed() && ctrlpressed() && shiftpressed() && altpressed())
inputdevice_add_inputcode(AKS_ENTERGUI, 1); inputdevice_add_inputcode(AKS_ENTERGUI, 1);
} }
#elif USE_SDL2 #elif USE_SDL2
if (scancode_new == defaultguikey && SDL_GetKeyFromName(currprefs.open_gui) != scancode_new) { if (scancode_new == defaultguikey && SDL_GetKeyFromName(currprefs.open_gui) != scancode) {
scancode = 0;
if (specialpressed() && ctrlpressed() && shiftpressed() && altpressed()) if (specialpressed() && ctrlpressed() && shiftpressed() && altpressed())
inputdevice_add_inputcode(AKS_ENTERGUI, 1); inputdevice_add_inputcode(AKS_ENTERGUI, 1);
} }
else if (scancode_new == SDL_GetKeyFromName(currprefs.open_gui)) { else if (scancode == SDL_GetKeyFromName(currprefs.open_gui)) {
inputdevice_add_inputcode(AKS_ENTERGUI, 1); inputdevice_add_inputcode(AKS_ENTERGUI, 1);
scancode = 0;
} }
#endif #endif
} }
else if (!specialpressed() && !ctrlpressed() && !shiftpressed() && !altpressed() && scancode_new == defaultguikey) { else if (!specialpressed() && !ctrlpressed() && !shiftpressed() && !altpressed() && scancode == defaultguikey) {
inputdevice_add_inputcode(AKS_ENTERGUI, 1); inputdevice_add_inputcode(AKS_ENTERGUI, 1);
scancode = 0;
} }
#ifdef USE_SDL2 #ifdef USE_SDL2
if (currprefs.quit_amiberry != "" && scancode_new == SDL_GetKeyFromName(currprefs.quit_amiberry)) if (currprefs.quit_amiberry != "" && scancode == SDL_GetKeyFromName(currprefs.quit_amiberry))
{ {
inputdevice_add_inputcode(AKS_QUIT, 1); inputdevice_add_inputcode(AKS_QUIT, 1);
scancode = 0;
} }
#endif #endif
} }
if (code) {
inputdevice_add_inputcode(code, 1);
return;
}
scancode = scancode_new;
if (!specialpressed() && newstate) { if (!specialpressed() && newstate) {
if (scancode == SDLK_CAPSLOCK) { if (scancode == SDLK_CAPSLOCK) {
host_capslockstate = host_capslockstate ? 0 : 1; host_capslockstate = host_capslockstate ? 0 : 1;
@ -505,11 +489,6 @@ void translate_amiberry_keys(int scancode, int newstate)
break; break;
} }
if (special) {
inputdevice_checkqualifierkeycode(0, translatedScancode, newstate);
return;
}
if (translatedScancode != scancode) if (translatedScancode != scancode)
inputdevice_do_keyboard(translatedScancode, newstate); inputdevice_do_keyboard(translatedScancode, newstate);
else else