diff --git a/src/osdep/amiberry.cpp b/src/osdep/amiberry.cpp index 423e45e6..0c4f5aa6 100644 --- a/src/osdep/amiberry.cpp +++ b/src/osdep/amiberry.cpp @@ -59,12 +59,10 @@ extern void SetLastActiveConfig(const char* filename); char start_path_data[MAX_DPATH]; char currentDir[MAX_DPATH]; -#ifdef CAPSLOCK_DEBIAN_WORKAROUND #include #include unsigned char kbd_led_status; char kbd_flags; -#endif static char config_path[MAX_DPATH]; static char rom_path[MAX_DPATH]; @@ -77,10 +75,8 @@ char last_loaded_config[MAX_DPATH] = {'\0'}; int max_uae_width; int max_uae_height; - extern "C" int main(int argc, char* argv[]); - void sleep_millis(int ms) { usleep(ms * 1000); @@ -573,8 +569,8 @@ int target_cfgfile_load(struct uae_prefs* p, const char* filename, int type, int ptr = strstr(const_cast(filename), ".uae"); if (ptr > nullptr) { - auto type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST; - result = cfgfile_load(p, filename, &type, 0, 1); + auto config_type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST; + result = cfgfile_load(p, filename, &config_type, 0, 1); } if (result) extractFileName(filename, last_loaded_config); @@ -582,7 +578,7 @@ int target_cfgfile_load(struct uae_prefs* p, const char* filename, int type, int if (result) { - for (int i = 0; i < p->nr_floppies; ++i) + for (auto i = 0; i < p->nr_floppies; ++i) { if (!DISK_validate_filename(p, p->floppyslots[i].df, 0, nullptr, nullptr, nullptr)) p->floppyslots[i].df[0] = 0; @@ -1041,7 +1037,6 @@ int main(int argc, char* argv[]) alloc_AmigaMem(); RescanROMs(); -#ifdef CAPSLOCK_DEBIAN_WORKAROUND // set capslock state based upon current "real" state ioctl(0, KDGKBLED, &kbd_flags); ioctl(0, KDGETLED, &kbd_led_status); @@ -1058,7 +1053,6 @@ int main(int argc, char* argv[]) inputdevice_do_keyboard(AK_CAPSLOCK, 0); } ioctl(0, KDSETLED, kbd_led_status); -#endif real_main(argc, argv); @@ -1087,56 +1081,86 @@ int handle_msgpump() auto got = 0; SDL_Event rEvent; + // Default Enter GUI key is F12 + int enter_gui_key = SDLK_F12; + if (strncmp(currprefs.open_gui, "", 1) != 0) + { + // If we have a value in the config, we use that instead + // SDL2-only for now +#ifdef USE_SDL2 + enter_gui_key = SDL_GetKeyFromName(currprefs.open_gui); +#endif + } + + // We don't set a default value for Quitting + int quit_key = 0; + if (strncmp(currprefs.quit_amiberry, "", 1) != 0) + { + // If we have a value in the config, we use that instead + // SDL2-only for now +#ifdef USE_SDL2 + quit_key = SDL_GetKeyFromName(currprefs.quit_amiberry); +#endif + } + while (SDL_PollEvent(&rEvent)) { got = 1; #ifdef USE_SDL1 Uint8* keystate = SDL_GetKeyState(nullptr); -#endif - -#ifdef USE_SDL2 +#elif USE_SDL2 const Uint8* keystate = SDL_GetKeyboardState(nullptr); #endif - switch (rEvent.type) { case SDL_QUIT: uae_quit(); break; - //case SDL_JOYBUTTONDOWN: - // if (currprefs.button_for_menu != -1 && rEvent.jbutton.button == currprefs.button_for_menu) - // inputdevice_add_inputcode(AKS_ENTERGUI, 1); - // if (currprefs.button_for_quit != -1 && rEvent.jbutton.button == currprefs.button_for_quit) - // inputdevice_add_inputcode(AKS_QUIT, 1); - // break; - case SDL_KEYDOWN: + // If the Enter GUI key was pressed, handle it + if (enter_gui_key && rEvent.key.keysym.sym == enter_gui_key) + { + inputdevice_add_inputcode(AKS_ENTERGUI, 1); + break; + } + + // If the Quit emulator key was pressed, handle it + if (quit_key && rEvent.key.keysym.sym == quit_key) + { + inputdevice_add_inputcode(AKS_QUIT, 1); + break; + } + + // If the reset combination was pressed, handle it #ifdef USE_SDL1 // Strangely in FBCON left window is seen as left alt ?? - //if (keyboard_type == 2) // KEYCODE_FBCON - //{ - // if (keystate[SDLK_LCTRL] && (keystate[SDLK_LSUPER] || keystate[SDLK_LALT]) && (keystate[SDLK_RSUPER] || keystate[ - // SDLK_MENU])) - if (keystate[SDLK_LCTRL] && keystate[SDLK_LSUPER] && (keystate[SDLK_RSUPER] || keystate[SDLK_MENU])) -#endif -#ifdef USE_SDL2 + if (keyboard_type == 2) // KEYCODE_FBCON + { + if (keystate[SDLK_LCTRL] && (keystate[SDLK_LSUPER] || keystate[SDLK_LALT]) && (keystate[SDLK_RSUPER] || keystate[ + SDLK_MENU])) + { + uae_reset(0, 1); + break; + } + } + else if (keystate[SDLK_LCTRL] && keystate[SDLK_LSUPER] && (keystate[SDLK_RSUPER] || keystate[SDLK_MENU])) +#elif USE_SDL2 if (keystate[SDL_SCANCODE_LCTRL] && keystate[SDL_SCANCODE_LGUI] && (keystate[SDL_SCANCODE_RGUI] || keystate[SDL_SCANCODE_APPLICATION])) #endif { uae_reset(0, 1); break; } + #ifdef USE_SDL1 // fix Caps Lock keypress shown as SDLK_UNKNOWN (scancode = 58) if (rEvent.key.keysym.scancode == 58 && rEvent.key.keysym.sym == SDLK_UNKNOWN) rEvent.key.keysym.sym = SDLK_CAPSLOCK; #endif - switch (rEvent.key.keysym.sym) + if (rEvent.key.keysym.sym == SDLK_CAPSLOCK) { -#ifdef CAPSLOCK_DEBIAN_WORKAROUND - case SDLK_CAPSLOCK: // capslock // Treat CAPSLOCK as a toggle. If on, set off and vice/versa ioctl(0, KDGKBLED, &kbd_flags); ioctl(0, KDGETLED, &kbd_led_status); @@ -1157,7 +1181,7 @@ int handle_msgpump() ioctl(0, KDSETLED, kbd_led_status); ioctl(0, KDSKBLED, kbd_flags); break; -#endif + #ifdef PANDORA case SDLK_LCTRL: // Select key inputdevice_add_inputcode (AKS_ENTERGUI, 1); @@ -1173,15 +1197,32 @@ int handle_msgpump() // Holding left or right shoulder button -> stylus does right mousebutton doStylusRightClick = 1; } -#endif - default: - translate_amiberry_keys(rEvent.key.keysym.sym, 1); break; +#endif } + + // Handle all other keys + //translate_amiberry_keys(rEvent.key.keysym.sym, 1); +#ifdef USE_SDL1 + if (keyboard_type == KEYCODE_UNK) + inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1); + else + inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1); +#elif USE_SDL2 + inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1); +#endif break; case SDL_KEYUP: - translate_amiberry_keys(rEvent.key.keysym.sym, 0); + //translate_amiberry_keys(rEvent.key.keysym.sym, 0); +#ifdef USE_SDL1 + if (keyboard_type == KEYCODE_UNK) + inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0); + else + inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0); +#elif USE_SDL2 + inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0); +#endif break; case SDL_MOUSEBUTTONDOWN: @@ -1219,9 +1260,9 @@ int handle_msgpump() { if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE) { - const int mouseScale = currprefs.input_joymouse_multiplier / 2; - const int x = rEvent.motion.xrel; - const int y = rEvent.motion.yrel; + const auto mouseScale = currprefs.input_joymouse_multiplier / 2; + const auto x = rEvent.motion.xrel; + const auto y = rEvent.motion.yrel; #if defined (PANDORA) || defined (ANDROIDSDL) if(rEvent.motion.x == 0 && x > -4) x = -4; @@ -1237,8 +1278,7 @@ int handle_msgpump() } } break; - default: - break; + #ifdef USE_SDL2 case SDL_MOUSEWHEEL: if (currprefs.jports[0].id == JSEM_MICE || currprefs.jports[1].id == JSEM_MICE) @@ -1250,6 +1290,9 @@ int handle_msgpump() } break; #endif + + default: + break; } } return got; diff --git a/src/osdep/amiberry_input.cpp b/src/osdep/amiberry_input.cpp index 5ec1424b..7762759e 100644 --- a/src/osdep/amiberry_input.cpp +++ b/src/osdep/amiberry_input.cpp @@ -1060,7 +1060,10 @@ static void read_joystick(void) { current_controller_map.dpad_right = -1; } - if (current_controller_map.dpad_up == current_controller_map.hotkey_button) { current_controller_map.dpad_up = -1; } + if (current_controller_map.dpad_up == current_controller_map.hotkey_button) + { + current_controller_map.dpad_up = -1; + } if (current_controller_map.dpad_down == current_controller_map.hotkey_button) { current_controller_map.dpad_down = -1; @@ -1241,8 +1244,8 @@ int input_get_default_joystick(struct uae_input_device* uid, const int num, int v = port ? INPUTEVENT_JOY2_VERT : INPUTEVENT_JOY1_VERT; } - setid(uid, num, ID_AXIS_OFFSET + (n * 2) + 0, 0, port, h, gp); - setid(uid, num, ID_AXIS_OFFSET + (n * 2) + 1, 0, port, v, gp); + setid(uid, num, ID_AXIS_OFFSET + n * 2 + 0, 0, port, h, gp); + setid(uid, num, ID_AXIS_OFFSET + n * 2 + 1, 0, port, v, gp); } } else // ports 2, 3 (parallel ports) ... both sticks, @@ -1251,8 +1254,8 @@ int input_get_default_joystick(struct uae_input_device* uid, const int num, int { h = port - 2 ? INPUTEVENT_PAR_JOY1_HORIZ : INPUTEVENT_PAR_JOY2_HORIZ; v = port - 2 ? INPUTEVENT_PAR_JOY1_VERT : INPUTEVENT_PAR_JOY2_VERT; - setid(uid, num, ID_AXIS_OFFSET + (n * 2) + 0, 0, port, h, gp); - setid(uid, num, ID_AXIS_OFFSET + (n * 2) + 1, 0, port, v, gp); + setid(uid, num, ID_AXIS_OFFSET + n * 2 + 0, 0, port, h, gp); + setid(uid, num, ID_AXIS_OFFSET + n * 2 + 1, 0, port, v, gp); } } @@ -1275,69 +1278,70 @@ int input_get_default_joystick(struct uae_input_device* uid, const int num, int { if (CHECK_BIT(currprefs.jports[port].mousemap,0)) { - thismap[0].dpad_up_action = (thismap[0].dpad_up_action - ? thismap[0].dpad_up_action - : (port ? INPUTEVENT_MOUSE2_UP : INPUTEVENT_MOUSE1_UP)); - thismap[0].dpad_down_action = (thismap[0].dpad_down_action - ? thismap[0].dpad_down_action - : (port ? INPUTEVENT_MOUSE2_DOWN : INPUTEVENT_MOUSE1_DOWN)); - thismap[0].dpad_left_action = (thismap[0].dpad_left_action - ? thismap[0].dpad_left_action - : (port ? INPUTEVENT_MOUSE2_LEFT : INPUTEVENT_MOUSE1_LEFT)); - thismap[0].dpad_right_action = (thismap[0].dpad_right_action - ? thismap[0].dpad_right_action - : (port ? INPUTEVENT_MOUSE2_RIGHT : INPUTEVENT_MOUSE1_RIGHT)); + thismap[0].dpad_up_action = thismap[0].dpad_up_action + ? thismap[0].dpad_up_action + : port ? INPUTEVENT_MOUSE2_UP : INPUTEVENT_MOUSE1_UP; + thismap[0].dpad_down_action = thismap[0].dpad_down_action + ? thismap[0].dpad_down_action + : port ? INPUTEVENT_MOUSE2_DOWN : INPUTEVENT_MOUSE1_DOWN; + thismap[0].dpad_left_action = thismap[0].dpad_left_action + ? thismap[0].dpad_left_action + : port ? INPUTEVENT_MOUSE2_LEFT : INPUTEVENT_MOUSE1_LEFT; + thismap[0].dpad_right_action = thismap[0].dpad_right_action + ? thismap[0].dpad_right_action + : port ? INPUTEVENT_MOUSE2_RIGHT : INPUTEVENT_MOUSE1_RIGHT; } else { - thismap[0].dpad_up_action = (thismap[0].dpad_up_action - ? thismap[0].dpad_up_action - : (port ? INPUTEVENT_JOY2_UP : INPUTEVENT_JOY1_UP)); - thismap[0].dpad_down_action = (thismap[0].dpad_down_action - ? thismap[0].dpad_down_action - : (port ? INPUTEVENT_JOY2_DOWN : INPUTEVENT_JOY1_DOWN)); - thismap[0].dpad_left_action = (thismap[0].dpad_left_action - ? thismap[0].dpad_left_action - : (port ? INPUTEVENT_JOY2_LEFT : INPUTEVENT_JOY1_LEFT)); - thismap[0].dpad_right_action = (thismap[0].dpad_right_action - ? thismap[0].dpad_right_action - : (port ? INPUTEVENT_JOY2_RIGHT : INPUTEVENT_JOY1_RIGHT)); + thismap[0].dpad_up_action = thismap[0].dpad_up_action + ? thismap[0].dpad_up_action + : port ? INPUTEVENT_JOY2_UP : INPUTEVENT_JOY1_UP; + thismap[0].dpad_down_action = thismap[0].dpad_down_action + ? thismap[0].dpad_down_action + : port ? INPUTEVENT_JOY2_DOWN : INPUTEVENT_JOY1_DOWN; + thismap[0].dpad_left_action = thismap[0].dpad_left_action + ? thismap[0].dpad_left_action + : port ? INPUTEVENT_JOY2_LEFT : INPUTEVENT_JOY1_LEFT; + thismap[0].dpad_right_action = thismap[0].dpad_right_action + ? thismap[0].dpad_right_action + : port ? INPUTEVENT_JOY2_RIGHT : INPUTEVENT_JOY1_RIGHT; } // standard fire buttons if (mode == JSEM_MODE_JOYSTICK_CD32) // CD32 joypad { - thismap[0].south_action = (thismap[0].south_action - ? thismap[0].south_action - : (port ? INPUTEVENT_JOY2_CD32_RED : INPUTEVENT_JOY1_CD32_RED)); - thismap[0].east_action = (thismap[0].east_action - ? thismap[0].east_action - : (port ? INPUTEVENT_JOY2_CD32_BLUE : INPUTEVENT_JOY1_CD32_BLUE)); - thismap[0].west_action = (thismap[0].west_action - ? thismap[0].west_action - : (port ? INPUTEVENT_JOY2_CD32_GREEN : INPUTEVENT_JOY1_CD32_GREEN)); - thismap[0].north_action = (thismap[0].north_action - ? thismap[0].north_action - : (port ? INPUTEVENT_JOY2_CD32_YELLOW : INPUTEVENT_JOY1_CD32_YELLOW)); - thismap[0].start_action = (thismap[0].start_action - ? thismap[0].start_action - : (port ? INPUTEVENT_JOY2_CD32_PLAY : INPUTEVENT_JOY1_CD32_PLAY)); + thismap[0].south_action = thismap[0].south_action + ? thismap[0].south_action + : port ? INPUTEVENT_JOY2_CD32_RED : INPUTEVENT_JOY1_CD32_RED; + thismap[0].east_action = thismap[0].east_action + ? thismap[0].east_action + : port ? INPUTEVENT_JOY2_CD32_BLUE : INPUTEVENT_JOY1_CD32_BLUE; + thismap[0].west_action = thismap[0].west_action + ? thismap[0].west_action + : port ? INPUTEVENT_JOY2_CD32_GREEN : INPUTEVENT_JOY1_CD32_GREEN; + thismap[0].north_action = thismap[0].north_action + ? thismap[0].north_action + : port ? INPUTEVENT_JOY2_CD32_YELLOW : INPUTEVENT_JOY1_CD32_YELLOW; + thismap[0].start_action = thismap[0].start_action + ? thismap[0].start_action + : port ? INPUTEVENT_JOY2_CD32_PLAY : INPUTEVENT_JOY1_CD32_PLAY; } else // default, normal joystick { - thismap[0].south_action = (thismap[0].south_action - ? thismap[0].south_action - : (port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON)); - thismap[0].east_action = (thismap[0].east_action - ? thismap[0].east_action - : (port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON)); - thismap[0].west_action = (thismap[0].west_action - ? thismap[0].west_action - : (port ? INPUTEVENT_JOY2_UP : INPUTEVENT_JOY1_UP)); - thismap[0].north_action = (thismap[0].north_action - ? thismap[0].north_action - : (port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON)); + thismap[0].south_action = thismap[0].south_action + ? thismap[0].south_action + : port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON; + thismap[0].east_action = thismap[0].east_action + ? thismap[0].east_action + : port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON; + thismap[0].west_action = thismap[0].west_action + ? thismap[0].west_action + : port ? INPUTEVENT_JOY2_UP : INPUTEVENT_JOY1_UP; + thismap[0].north_action = thismap[0].north_action + ? thismap[0].north_action + : port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON; - thismap[0].start_action = (thismap[0].start_action ? thismap[0].start_action : INPUTEVENT_KEY_P); + // DISABLED for now (should not trigger keyboard input when using Keyboard as Joystick!) + //thismap[0].start_action = thismap[0].start_action ? thismap[0].start_action : INPUTEVENT_KEY_P; } @@ -1346,67 +1350,69 @@ int input_get_default_joystick(struct uae_input_device* uid, const int num, int // if we use right-analogue as mouse, then we will use shoulder buttons as LMB/RMB //if (1==0) { - thismap[0].left_shoulder_action = (thismap[0].left_shoulder_action - ? thismap[0].left_shoulder_action + thismap[0].left_shoulder_action = thismap[0].left_shoulder_action + ? thismap[0].left_shoulder_action + : port + ? INPUTEVENT_JOY2_FIRE_BUTTON + : INPUTEVENT_JOY1_FIRE_BUTTON; + thismap[0].right_shoulder_action = thismap[0].right_shoulder_action + ? thismap[0].right_shoulder_action : port - ? INPUTEVENT_JOY2_FIRE_BUTTON - : INPUTEVENT_JOY1_FIRE_BUTTON); - thismap[0].right_shoulder_action = (thismap[0].right_shoulder_action - ? thismap[0].right_shoulder_action - : port - ? INPUTEVENT_JOY2_2ND_BUTTON - : INPUTEVENT_JOY1_2ND_BUTTON); + ? INPUTEVENT_JOY2_2ND_BUTTON + : INPUTEVENT_JOY1_2ND_BUTTON; } else if (mode == JSEM_MODE_JOYSTICK_CD32) // CD32 joypad, use RWD/FWD { - thismap[0].left_shoulder_action = (thismap[0].left_shoulder_action - ? thismap[0].left_shoulder_action - : (port ? INPUTEVENT_JOY2_CD32_RWD : INPUTEVENT_JOY1_CD32_RWD)); + thismap[0].left_shoulder_action = thismap[0].left_shoulder_action + ? thismap[0].left_shoulder_action + : port ? INPUTEVENT_JOY2_CD32_RWD : INPUTEVENT_JOY1_CD32_RWD; - thismap[0].right_shoulder_action = (thismap[0].right_shoulder_action - ? thismap[0].right_shoulder_action - : (port ? INPUTEVENT_JOY2_CD32_FFW : INPUTEVENT_JOY1_CD32_FFW)); - } - else // default, normal joystick - { - thismap[0].left_shoulder_action = (thismap[0].left_shoulder_action - ? thismap[0].left_shoulder_action - : INPUTEVENT_KEY_SPACE); - thismap[0].right_shoulder_action = (thismap[0].right_shoulder_action - ? thismap[0].right_shoulder_action - : INPUTEVENT_KEY_RETURN); + thismap[0].right_shoulder_action = thismap[0].right_shoulder_action + ? thismap[0].right_shoulder_action + : port ? INPUTEVENT_JOY2_CD32_FFW : INPUTEVENT_JOY1_CD32_FFW; } + // DISABLED for now (should not trigger keyboard input when using Keyboard as Joystick!) + //else // default, normal joystick + //{ + // thismap[0].left_shoulder_action = thismap[0].left_shoulder_action + // ? thismap[0].left_shoulder_action + // : INPUTEVENT_KEY_SPACE; + // thismap[0].right_shoulder_action = thismap[0].right_shoulder_action + // ? thismap[0].right_shoulder_action + // : INPUTEVENT_KEY_RETURN; + //} } else // ports 2, 3 ... parallel ports { - thismap[0].dpad_up_action = (thismap[0].dpad_up_action - ? thismap[0].dpad_up_action - : (port - 2 ? INPUTEVENT_PAR_JOY2_UP : INPUTEVENT_PAR_JOY1_UP)); - thismap[0].dpad_down_action = (thismap[0].dpad_down_action - ? thismap[0].dpad_down_action - : (port - 2 ? INPUTEVENT_PAR_JOY2_DOWN : INPUTEVENT_PAR_JOY1_DOWN)); - thismap[0].dpad_left_action = (thismap[0].dpad_left_action - ? thismap[0].dpad_left_action - : (port - 2 ? INPUTEVENT_PAR_JOY2_LEFT : INPUTEVENT_PAR_JOY1_LEFT)); - thismap[0].dpad_right_action = (thismap[0].dpad_right_action - ? thismap[0].dpad_right_action - : (port - 2 ? INPUTEVENT_PAR_JOY2_RIGHT : INPUTEVENT_PAR_JOY1_RIGHT)); + thismap[0].dpad_up_action = thismap[0].dpad_up_action + ? thismap[0].dpad_up_action + : port - 2 ? INPUTEVENT_PAR_JOY2_UP : INPUTEVENT_PAR_JOY1_UP; + thismap[0].dpad_down_action = thismap[0].dpad_down_action + ? thismap[0].dpad_down_action + : port - 2 ? INPUTEVENT_PAR_JOY2_DOWN : INPUTEVENT_PAR_JOY1_DOWN; + thismap[0].dpad_left_action = thismap[0].dpad_left_action + ? thismap[0].dpad_left_action + : port - 2 ? INPUTEVENT_PAR_JOY2_LEFT : INPUTEVENT_PAR_JOY1_LEFT; + thismap[0].dpad_right_action = thismap[0].dpad_right_action + ? thismap[0].dpad_right_action + : port - 2 ? INPUTEVENT_PAR_JOY2_RIGHT : INPUTEVENT_PAR_JOY1_RIGHT; - thismap[0].south_action = (thismap[0].south_action - ? thismap[0].south_action - : (port - 2 ? INPUTEVENT_PAR_JOY2_FIRE_BUTTON : INPUTEVENT_PAR_JOY1_FIRE_BUTTON)); - thismap[0].east_action = (thismap[0].east_action - ? thismap[0].east_action - : (port - 2 ? INPUTEVENT_PAR_JOY2_2ND_BUTTON : INPUTEVENT_PAR_JOY1_2ND_BUTTON)); + thismap[0].south_action = thismap[0].south_action + ? thismap[0].south_action + : port - 2 ? INPUTEVENT_PAR_JOY2_FIRE_BUTTON : INPUTEVENT_PAR_JOY1_FIRE_BUTTON; + thismap[0].east_action = thismap[0].east_action + ? thismap[0].east_action + : port - 2 ? INPUTEVENT_PAR_JOY2_2ND_BUTTON : INPUTEVENT_PAR_JOY1_2ND_BUTTON; - thismap[0].start_action = (thismap[0].start_action ? thismap[0].start_action : INPUTEVENT_KEY_P); - thismap[0].left_shoulder_action = (thismap[0].left_shoulder_action - ? thismap[0].left_shoulder_action - : INPUTEVENT_KEY_SPACE); - thismap[0].right_shoulder_action = (thismap[0].right_shoulder_action - ? thismap[0].right_shoulder_action - : INPUTEVENT_KEY_RETURN); + // DISABLED for now (should not trigger keyboard input when using Keyboard as Joystick!) + //thismap[0].start_action = thismap[0].start_action ? thismap[0].start_action : INPUTEVENT_KEY_P; + //thismap[0].left_shoulder_action = thismap[0].left_shoulder_action + // ? thismap[0].left_shoulder_action + // : INPUTEVENT_KEY_SPACE; + //thismap[0].right_shoulder_action = thismap[0].right_shoulder_action + // ? thismap[0].right_shoulder_action + // : INPUTEVENT_KEY_RETURN; } diff --git a/src/osdep/gui/PanelInput.cpp b/src/osdep/gui/PanelInput.cpp index d87a5ba3..f6985de7 100644 --- a/src/osdep/gui/PanelInput.cpp +++ b/src/osdep/gui/PanelInput.cpp @@ -114,62 +114,10 @@ StringListModel ctrlPortMouseModeList(mousemapValues, 4); const char* joyportmodes[] = {"Mouse", "Joystick", "CD32", "Default"}; StringListModel ctrlPortModeList(joyportmodes, 4); -const char *tapDelayValues[] = { "Normal", "Short", "None" }; -StringListModel tapDelayList(tapDelayValues, 3); #ifdef PANDORA -const char* mappingValues[] = -{ - "CD32 rwd", "CD32 ffw", "CD32 play", "CD32 yellow", "CD32 green", - "Joystick Right", "Joystick Left", "Joystick Down", "Joystick Up", - "Joystick fire but.2", "Joystick fire but.1", "Mouse right button", "Mouse left button", - "------------------", - "Arrow Up", "Arrow Down", "Arrow Left", "Arrow Right", "Numpad 0", "Numpad 1", "Numpad 2", - "Numpad 3", "Numpad 4", "Numpad 5", "Numpad 6", "Numpad 7", "Numpad 8", "Numpad 9", - "Numpad Enter", "Numpad /", "Numpad *", "Numpad -", "Numpad +", - "Numpad Delete", "Numpad (", "Numpad )", - "Space", "Backspace", "Tab", "Return", "Escape", "Delete", - "Left Shift", "Right Shift", "CAPS LOCK", "CTRL", "Left ALT", "Right ALT", - "Left Amiga Key", "Right Amiga Key", "Help", "Left Bracket", "Right Bracket", - "Semicolon", "Comma", "Period", "Slash", "Backslash", "Quote", "#", - "", "Backquote", "-", "=", - "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", - "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", - "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", - "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "NULL" -}; -StringListModel mappingList(mappingValues, 110); -static int amigaKey[] = -{ - REMAP_CD32_RWD, REMAP_CD32_FFW, REMAP_CD32_PLAY, REMAP_CD32_YELLOW, REMAP_CD32_GREEN, - REMAP_JOY_RIGHT, REMAP_JOY_LEFT, REMAP_JOY_DOWN, REMAP_JOY_UP, REMAP_JOYBUTTON_TWO, REMAP_JOYBUTTON_ONE, REMAP_MOUSEBUTTON_RIGHT, REMAP_MOUSEBUTTON_LEFT, - 0, AK_UP, AK_DN, AK_LF, AK_RT, AK_NP0, AK_NP1, AK_NP2, /* 13 - 20 */ - AK_NP3, AK_NP4, AK_NP5, AK_NP6, AK_NP7, AK_NP8, AK_NP9, AK_ENT, /* 21 - 28 */ - AK_NPDIV, AK_NPMUL, AK_NPSUB, AK_NPADD, AK_NPDEL, AK_NPLPAREN, AK_NPRPAREN, AK_SPC, /* 29 - 36 */ - AK_BS, AK_TAB, AK_RET, AK_ESC, AK_DEL, AK_LSH, AK_RSH, AK_CAPSLOCK, /* 37 - 44 */ - AK_CTRL, AK_LALT, AK_RALT, AK_LAMI, AK_RAMI, AK_HELP, AK_LBRACKET, AK_RBRACKET, /* 45 - 52 */ - AK_SEMICOLON, AK_COMMA, AK_PERIOD, AK_SLASH, AK_BACKSLASH, AK_QUOTE, AK_NUMBERSIGN, AK_LTGT, /* 53 - 60 */ - AK_BACKQUOTE, AK_MINUS, AK_EQUAL, AK_A, AK_B, AK_C, AK_D, AK_E, /* 61 - 68 */ - AK_F, AK_G, AK_H, AK_I, AK_J, AK_K, AK_L, AK_M, /* 69 - 76 */ - AK_N, AK_O, AK_P, AK_Q, AK_R, AK_S, AK_T, AK_U, /* 77 - 84 */ - AK_V, AK_W, AK_X, AK_Y, AK_Z, AK_1, AK_2, AK_3, /* 85 - 92 */ - AK_4, AK_5, AK_6, AK_7, AK_8, AK_9, AK_0, AK_F1, /* 93 - 100 */ - AK_F2, AK_F3, AK_F4, AK_F5, AK_F6, AK_F7, AK_F8, AK_F9, /* 101 - 108 */ - AK_F10, 0 -}; /* 109 - 110 */ -#ifdef USE_SDL1 -extern int customControlMap[SDLK_LAST]; -#endif - -static int GetAmigaKeyIndex(int key) -{ - for (int i = 0; i < 110; ++i) - { - if (amigaKey[i] == key) - return i; - } - return 13; // Default: no key -} +const char *tapDelayValues[] = { "Normal", "Short", "None" }; +StringListModel tapDelayList(tapDelayValues, 3); #endif class InputActionListener : public gcn::ActionListener @@ -365,8 +313,6 @@ static InputActionListener* inputActionListener; void InitPanelInput(const struct _ConfigCategory& category) { - -#ifndef PANDORA if (ctrlPortList.getNumberOfElements() == 0) { auto idx = 0; @@ -392,7 +338,6 @@ void InitPanelInput(const struct _ConfigCategory& category) portListIDs[idx] = JSEM_JOYS + i; } } -#endif inputActionListener = new InputActionListener(); const auto textFieldWidth = category.panel->getWidth() - (2 * DISTANCE_BORDER - SMALL_BUTTON_WIDTH - DISTANCE_NEXT_X); diff --git a/src/osdep/keyboard.cpp b/src/osdep/keyboard.cpp index d823b7d9..97f42170 100644 --- a/src/osdep/keyboard.cpp +++ b/src/osdep/keyboard.cpp @@ -14,6 +14,256 @@ #include "gui.h" #include +char keyboard_type = 0; + +static struct uae_input_device_kbr_default keytrans_amiga_x11[] = { + +{ 9, INPUTEVENT_KEY_ESC }, +{ 67, INPUTEVENT_KEY_F1 }, +{ 68, INPUTEVENT_KEY_F2 }, +{ 69, INPUTEVENT_KEY_F3 }, +{ 70, INPUTEVENT_KEY_F4 }, +{ 71, INPUTEVENT_KEY_F5 }, +{ 72, INPUTEVENT_KEY_F6 }, +{ 73, INPUTEVENT_KEY_F7 }, +{ 74, INPUTEVENT_KEY_F8 }, +{ 75, INPUTEVENT_KEY_F9 }, +{ 76, INPUTEVENT_KEY_F10 }, +//{ 95, INPUTEVENT_KEY_F11}, +//{ 96, INPUTEVENT_KEY_F12}, + +{ 49, INPUTEVENT_KEY_BACKQUOTE }, + +{ 10, INPUTEVENT_KEY_1 }, +{ 11, INPUTEVENT_KEY_2 }, +{ 12, INPUTEVENT_KEY_3 }, +{ 13, INPUTEVENT_KEY_4 }, +{ 14, INPUTEVENT_KEY_5 }, +{ 15, INPUTEVENT_KEY_6 }, +{ 16, INPUTEVENT_KEY_7 }, +{ 17, INPUTEVENT_KEY_8 }, +{ 18, INPUTEVENT_KEY_9 }, +{ 19, INPUTEVENT_KEY_0 }, +{ 20, INPUTEVENT_KEY_SUB }, +{ 21, INPUTEVENT_KEY_EQUALS }, +{ 22, INPUTEVENT_KEY_BACKSPACE }, + +{ 23, INPUTEVENT_KEY_TAB }, +{ 24, INPUTEVENT_KEY_Q }, +{ 25, INPUTEVENT_KEY_W }, +{ 26, INPUTEVENT_KEY_E }, +{ 27, INPUTEVENT_KEY_R }, +{ 28, INPUTEVENT_KEY_T }, +{ 29, INPUTEVENT_KEY_Y }, +{ 30, INPUTEVENT_KEY_U }, +{ 31, INPUTEVENT_KEY_I }, +{ 32, INPUTEVENT_KEY_O }, +{ 33, INPUTEVENT_KEY_P }, +{ 34, INPUTEVENT_KEY_LEFTBRACKET }, +{ 35, INPUTEVENT_KEY_RIGHTBRACKET }, +{ 36, INPUTEVENT_KEY_RETURN }, + +{ 66, INPUTEVENT_KEY_CAPS_LOCK }, +{ 38, INPUTEVENT_KEY_A }, +{ 39, INPUTEVENT_KEY_S }, +{ 40, INPUTEVENT_KEY_D }, +{ 41, INPUTEVENT_KEY_F }, +{ 42, INPUTEVENT_KEY_G }, +{ 43, INPUTEVENT_KEY_H }, +{ 44, INPUTEVENT_KEY_J }, +{ 45, INPUTEVENT_KEY_K }, +{ 46, INPUTEVENT_KEY_L }, +{ 47, INPUTEVENT_KEY_SEMICOLON }, +{ 48, INPUTEVENT_KEY_SINGLEQUOTE }, +{ 51, INPUTEVENT_KEY_BACKSLASH }, + +{ 50, INPUTEVENT_KEY_SHIFT_LEFT }, +{ 94, INPUTEVENT_KEY_LTGT }, +{ 52, INPUTEVENT_KEY_Z }, +{ 53, INPUTEVENT_KEY_X }, +{ 54, INPUTEVENT_KEY_C }, +{ 55, INPUTEVENT_KEY_V }, +{ 56, INPUTEVENT_KEY_B }, +{ 57, INPUTEVENT_KEY_N }, +{ 58, INPUTEVENT_KEY_M }, +{ 59, INPUTEVENT_KEY_COMMA }, +{ 60, INPUTEVENT_KEY_PERIOD }, +{ 61, INPUTEVENT_KEY_DIV }, +{ 62, INPUTEVENT_KEY_SHIFT_RIGHT }, + +{ 37, INPUTEVENT_KEY_CTRL }, +{ 64, INPUTEVENT_KEY_ALT_LEFT }, +{ 65, INPUTEVENT_KEY_SPACE }, + +{ 108, INPUTEVENT_KEY_ALT_RIGHT }, + +//{ 78, INPUTEVENT_KEY_SCROLLOCK}, + +//{ 77, INPUTEVENT_KEY_NUMLOCK}, +{ 106, INPUTEVENT_KEY_NP_DIV }, +{ 63, INPUTEVENT_KEY_NP_MUL }, +{ 82, INPUTEVENT_KEY_NP_SUB }, + +{ 79, INPUTEVENT_KEY_NP_7 }, +{ 80, INPUTEVENT_KEY_NP_8 }, +{ 81, INPUTEVENT_KEY_NP_9 }, +{ 86, INPUTEVENT_KEY_NP_ADD }, + +{ 83, INPUTEVENT_KEY_NP_4 }, +{ 84, INPUTEVENT_KEY_NP_5 }, +{ 85, INPUTEVENT_KEY_NP_6 }, + +{ 87, INPUTEVENT_KEY_NP_1 }, +{ 88, INPUTEVENT_KEY_NP_2 }, +{ 89, INPUTEVENT_KEY_NP_3 }, +{ 104, INPUTEVENT_KEY_ENTER }, // The ENT from keypad.. + +{ 90, INPUTEVENT_KEY_NP_0 }, +{ 91, INPUTEVENT_KEY_NP_PERIOD }, + +{ 111, INPUTEVENT_KEY_CURSOR_UP }, +{ 113, INPUTEVENT_KEY_CURSOR_LEFT }, +{ 116, INPUTEVENT_KEY_CURSOR_DOWN }, +{ 114, INPUTEVENT_KEY_CURSOR_RIGHT }, + + +{ 110, INPUTEVENT_KEY_NP_LPAREN }, // Map home to left parent (as fsuae) +{ 112, INPUTEVENT_KEY_NP_RPAREN }, // Map pageup to right parent (as fsuae) + +{ 115, INPUTEVENT_KEY_HELP }, // Help mapped to End key (as fsuae) + +{ 119, INPUTEVENT_KEY_DEL }, + +{ 133, INPUTEVENT_KEY_AMIGA_LEFT }, // Left amiga mapped to left Windows +{ 134, INPUTEVENT_KEY_AMIGA_RIGHT }, // Right amiga mapped to right windows key. +{ 135, INPUTEVENT_KEY_AMIGA_RIGHT }, // Right amiga mapped to Menu key. +{ -1, 0 } +}; + +static struct uae_input_device_kbr_default keytrans_amiga_fbcon[] = { + +{ 9 - 8, INPUTEVENT_KEY_ESC }, +{ 67 - 8, INPUTEVENT_KEY_F1 }, +{ 68 - 8, INPUTEVENT_KEY_F2 }, +{ 69 - 8, INPUTEVENT_KEY_F3 }, +{ 70 - 8, INPUTEVENT_KEY_F4 }, +{ 71 - 8, INPUTEVENT_KEY_F5 }, +{ 72 - 8, INPUTEVENT_KEY_F6 }, +{ 73 - 8, INPUTEVENT_KEY_F7 }, +{ 74 - 8, INPUTEVENT_KEY_F8 }, +{ 75 - 8, INPUTEVENT_KEY_F9 }, +{ 76 - 8, INPUTEVENT_KEY_F10 }, +// { 95 -8 , INPUTEVENT_KEY_F11}, +// { 96 -8 , INPUTEVENT_KEY_F12}, + +{ 49 - 8, INPUTEVENT_KEY_BACKQUOTE }, + +{ 10 - 8, INPUTEVENT_KEY_1 }, +{ 11 - 8, INPUTEVENT_KEY_2 }, +{ 12 - 8, INPUTEVENT_KEY_3 }, +{ 13 - 8, INPUTEVENT_KEY_4 }, +{ 14 - 8, INPUTEVENT_KEY_5 }, +{ 15 - 8, INPUTEVENT_KEY_6 }, +{ 16 - 8, INPUTEVENT_KEY_7 }, +{ 17 - 8, INPUTEVENT_KEY_8 }, +{ 18 - 8, INPUTEVENT_KEY_9 }, +{ 19 - 8, INPUTEVENT_KEY_0 }, +{ 20 - 8, INPUTEVENT_KEY_SUB }, +{ 21 - 8, INPUTEVENT_KEY_EQUALS }, +{ 22 - 8, INPUTEVENT_KEY_BACKSPACE }, + +{ 23 - 8, INPUTEVENT_KEY_TAB }, +{ 24 - 8, INPUTEVENT_KEY_Q }, +{ 25 - 8, INPUTEVENT_KEY_W }, +{ 26 - 8, INPUTEVENT_KEY_E }, +{ 27 - 8, INPUTEVENT_KEY_R }, +{ 28 - 8, INPUTEVENT_KEY_T }, +{ 29 - 8, INPUTEVENT_KEY_Y }, +{ 30 - 8, INPUTEVENT_KEY_U }, +{ 31 - 8, INPUTEVENT_KEY_I }, +{ 32 - 8, INPUTEVENT_KEY_O }, +{ 33 - 8, INPUTEVENT_KEY_P }, +{ 34 - 8, INPUTEVENT_KEY_LEFTBRACKET }, +{ 35 - 8, INPUTEVENT_KEY_RIGHTBRACKET }, +{ 36 - 8, INPUTEVENT_KEY_RETURN }, + +{ 66 - 8, INPUTEVENT_KEY_CAPS_LOCK }, +{ 38 - 8, INPUTEVENT_KEY_A }, +{ 39 - 8, INPUTEVENT_KEY_S }, +{ 40 - 8, INPUTEVENT_KEY_D }, +{ 41 - 8, INPUTEVENT_KEY_F }, +{ 42 - 8, INPUTEVENT_KEY_G }, +{ 43 - 8, INPUTEVENT_KEY_H }, +{ 44 - 8, INPUTEVENT_KEY_J }, +{ 45 - 8, INPUTEVENT_KEY_K }, +{ 46 - 8, INPUTEVENT_KEY_L }, +{ 47 - 8, INPUTEVENT_KEY_SEMICOLON }, +{ 48 - 8, INPUTEVENT_KEY_SINGLEQUOTE }, +{ 51 - 8, INPUTEVENT_KEY_BACKSLASH }, + +{ 50 - 8, INPUTEVENT_KEY_SHIFT_LEFT }, +{ 94 - 8, INPUTEVENT_KEY_LTGT }, +{ 52 - 8, INPUTEVENT_KEY_Z }, +{ 53 - 8, INPUTEVENT_KEY_X }, +{ 54 - 8, INPUTEVENT_KEY_C }, +{ 55 - 8, INPUTEVENT_KEY_V }, +{ 56 - 8, INPUTEVENT_KEY_B }, +{ 57 - 8, INPUTEVENT_KEY_N }, +{ 58 - 8, INPUTEVENT_KEY_M }, +{ 59 - 8, INPUTEVENT_KEY_COMMA }, +{ 60 - 8, INPUTEVENT_KEY_PERIOD }, +{ 61 - 8, INPUTEVENT_KEY_DIV }, +{ 62 - 8, INPUTEVENT_KEY_SHIFT_RIGHT }, + +{ 37 - 8, INPUTEVENT_KEY_CTRL }, +{ 64 - 8, INPUTEVENT_KEY_ALT_LEFT }, +{ 65 - 8, INPUTEVENT_KEY_SPACE }, + +{ 108 - 8, INPUTEVENT_KEY_ALT_RIGHT }, + +//{ 78 -8 , INPUTEVENT_KEY_SCROLLOCK}, + +//{ 77 -8 , INPUTEVENT_KEY_NUMLOCK}, +{ 106 - 8, INPUTEVENT_KEY_NP_DIV }, +{ 63 - 8, INPUTEVENT_KEY_NP_MUL }, +{ 82 - 8, INPUTEVENT_KEY_NP_SUB }, + +{ 79 - 8, INPUTEVENT_KEY_NP_7 }, +{ 80 - 8, INPUTEVENT_KEY_NP_8 }, +{ 81 - 8, INPUTEVENT_KEY_NP_9 }, +{ 86 - 8, INPUTEVENT_KEY_NP_ADD }, + +{ 83 - 8, INPUTEVENT_KEY_NP_4 }, +{ 84 - 8, INPUTEVENT_KEY_NP_5 }, +{ 85 - 8, INPUTEVENT_KEY_NP_6 }, + +{ 87 - 8, INPUTEVENT_KEY_NP_1 }, +{ 88 - 8, INPUTEVENT_KEY_NP_2 }, +{ 89 - 8, INPUTEVENT_KEY_NP_3 }, +{ 104 - 8, INPUTEVENT_KEY_ENTER }, // The ENT from keypad.. + +{ 90 - 8, INPUTEVENT_KEY_NP_0 }, +{ 91 - 8, INPUTEVENT_KEY_PERIOD }, + +{ 111 - 8, INPUTEVENT_KEY_CURSOR_UP }, +{ 113 - 8, INPUTEVENT_KEY_CURSOR_LEFT }, +{ 116 - 8, INPUTEVENT_KEY_CURSOR_DOWN }, +{ 114 - 8, INPUTEVENT_KEY_CURSOR_RIGHT }, + + +{ 110 - 8, INPUTEVENT_KEY_NP_LPAREN }, // Map home to left parent (as fsuae) +{ 112 - 8, INPUTEVENT_KEY_NP_RPAREN }, // Map pageup to right parent (as fsuae) + +{ 115 - 8, INPUTEVENT_KEY_HELP }, // Help mapped to End key (as fsuae) + +{ 119 - 8, INPUTEVENT_KEY_DEL }, + +{ 133 - 8, INPUTEVENT_KEY_AMIGA_LEFT }, // Left amiga mapped to left Windows +{ 134 - 8, INPUTEVENT_KEY_AMIGA_RIGHT }, // Right amiga mapped to right windows key. +{ 135 - 8, INPUTEVENT_KEY_AMIGA_RIGHT }, // Right amiga mapped to Menu key. +{ -1, 0 } +}; + static struct uae_input_device_kbr_default keytrans_amiga[] = { { VK_ESCAPE, INPUTEVENT_KEY_ESC }, @@ -162,6 +412,18 @@ static struct uae_input_device_kbr_default *keytrans[] = keytrans_amiga }; +static struct uae_input_device_kbr_default *keytrans_x11[] = { + keytrans_amiga_x11, + keytrans_amiga_x11, + keytrans_amiga_x11 +}; + +static struct uae_input_device_kbr_default *keytrans_fbcon[] = { + keytrans_amiga_fbcon, + keytrans_amiga_fbcon, + keytrans_amiga_fbcon +}; + #ifdef USE_SDL1 static int kb_np[] = { SDLK_KP4, -1, SDLK_KP6, -1, SDLK_KP8, -1, SDLK_KP2, -1, SDLK_KP0, SDLK_KP5, -1, SDLK_KP_PERIOD, -1, SDLK_KP_ENTER, -1, -1 }; #elif USE_SDL2 @@ -212,7 +474,28 @@ static int *kbmaps[] = { void keyboard_settrans(void) { +#ifdef USE_SDL1 + char vid_drv_name[32]; + // get display type... + SDL_VideoDriverName(vid_drv_name, sizeof vid_drv_name); + if (strcmp(vid_drv_name, "x11") == 0) + { + keyboard_type = KEYCODE_X11; + inputdevice_setkeytranslation(keytrans_x11, kbmaps); + } + else if (strcmp(vid_drv_name, "fbcon") == 0) + { + keyboard_type = KEYCODE_FBCON; + inputdevice_setkeytranslation(keytrans_fbcon, kbmaps); + } + else + { + keyboard_type = KEYCODE_UNK; + inputdevice_setkeytranslation(keytrans, kbmaps); + } +#elif USE_SDL2 inputdevice_setkeytranslation(keytrans, kbmaps); +#endif } static bool specialpressed() @@ -261,240 +544,6 @@ static const int np[] = { SDLK_KP_8, 8, SDLK_KP_9, 9, -1 }; #endif -void translate_amiberry_keys(int scancode, int newstate) -{ - if (newstate) - { - const int defaultguikey = SDLK_F12; - if (strncmp(currprefs.open_gui, "",1) == 0) - { -#ifdef USE_SDL1 - if (scancode == defaultguikey) - { - //if (specialpressed() && ctrlpressed() && shiftpressed() && altpressed()) - inputdevice_add_inputcode(AKS_ENTERGUI, 1); - } -#elif USE_SDL2 - if (scancode == defaultguikey && SDL_GetKeyFromName(currprefs.open_gui) != scancode) { - if (specialpressed() && ctrlpressed() && shiftpressed() && altpressed()) - inputdevice_add_inputcode(AKS_ENTERGUI, 1); - } - else if (scancode == SDL_GetKeyFromName(currprefs.open_gui)) { - inputdevice_add_inputcode(AKS_ENTERGUI, 1); - } -#endif - } - else if (!specialpressed() && !ctrlpressed() && !shiftpressed() && !altpressed() && scancode == defaultguikey) { - inputdevice_add_inputcode(AKS_ENTERGUI, 1); - } -#ifdef USE_SDL2 - if (strncmp(currprefs.quit_amiberry, "", 1) != 0 && scancode == SDL_GetKeyFromName(currprefs.quit_amiberry)) - { - inputdevice_add_inputcode(AKS_QUIT, 1); - } -#endif - } - - if (!specialpressed() && newstate) { - if (scancode == SDLK_CAPSLOCK) { - host_capslockstate = host_capslockstate ? 0 : 1; - capslockstate = host_capslockstate; - } -#ifdef USE_SDL1 - if (scancode == SDLK_NUMLOCK) { - host_numlockstate = host_numlockstate ? 0 : 1; - capslockstate = host_numlockstate; - } -#elif USE_SDL2 - if (scancode == SDLK_NUMLOCKCLEAR) { - host_numlockstate = host_numlockstate ? 0 : 1; - capslockstate = host_numlockstate; - } -#endif -#ifdef USE_SDL1 - if (scancode == SDLK_SCROLLOCK) { - host_scrolllockstate = host_scrolllockstate ? 0 : 1; - capslockstate = host_scrolllockstate; - } -#elif USE_SDL2 - if (scancode == SDLK_SCROLLLOCK) { - host_scrolllockstate = host_scrolllockstate ? 0 : 1; - capslockstate = host_scrolllockstate; - } -#endif - } - - int translatedScancode = scancode; - switch (scancode) - { - case SDLK_UP: - translatedScancode = AK_UP; - break; - case SDLK_DOWN: - translatedScancode = AK_DN; - break; - case SDLK_LEFT: - translatedScancode = AK_LF; - break; - case SDLK_RIGHT: - translatedScancode = AK_RT; - break; - case SDLK_F1: - translatedScancode = AK_F1; - break; - case SDLK_F2: - translatedScancode = AK_F2; - break; - case SDLK_F3: - translatedScancode = AK_F3; - break; - case SDLK_F4: - translatedScancode = AK_F4; - break; - case SDLK_F5: - translatedScancode = AK_F5; - break; - case SDLK_F6: - translatedScancode = AK_F6; - break; - case SDLK_F7: - translatedScancode = AK_F7; - break; - case SDLK_F8: - translatedScancode = AK_F8; - break; - case SDLK_F9: - translatedScancode = AK_F9; - break; - case SDLK_F10: - translatedScancode = AK_F10; - break; - case SDLK_LSHIFT: - translatedScancode = AK_LSH; - break; - case SDLK_RSHIFT: - translatedScancode = AK_RSH; - break; -#ifdef USE_SDL1 - case SDLK_RSUPER: - case SDLK_RMETA: - translatedScancode = AK_RAMI; - break; - case SDLK_LSUPER: - case SDLK_LMETA: - translatedScancode = AK_LAMI; - break; -#elif USE_SDL2 - case SDLK_RGUI: - case SDLK_APPLICATION: - translatedScancode = AK_RAMI; - break; - case SDLK_LGUI: - translatedScancode = AK_LAMI; - break; -#endif - case SDLK_LALT: - translatedScancode = AK_LALT; - break; - case SDLK_RALT: - translatedScancode = AK_RALT; - break; - case SDLK_LCTRL: - case SDLK_RCTRL: - translatedScancode = AK_CTRL; - break; - case SDLK_PAGEDOWN: - translatedScancode = AK_HELP; - break; -#ifdef USE_SDL1 - case SDLK_KP0: - translatedScancode = AK_NP0; - break; - case SDLK_KP1: - translatedScancode = AK_NP1; - break; - case SDLK_KP2: - translatedScancode = AK_NP2; - break; - case SDLK_KP3: - translatedScancode = AK_NP3; - break; - case SDLK_KP4: - translatedScancode = AK_NP4; - break; - case SDLK_KP5: - translatedScancode = AK_NP5; - break; - case SDLK_KP6: - translatedScancode = AK_NP6; - break; - case SDLK_KP7: - translatedScancode = AK_NP7; - break; - case SDLK_KP8: - translatedScancode = AK_NP8; - break; - case SDLK_KP9: - translatedScancode = AK_NP9; - break; -#elif USE_SDL2 - case SDLK_KP_0: - translatedScancode = AK_NP0; - break; - case SDLK_KP_1: - translatedScancode = AK_NP1; - break; - case SDLK_KP_2: - translatedScancode = AK_NP2; - break; - case SDLK_KP_3: - translatedScancode = AK_NP3; - break; - case SDLK_KP_4: - translatedScancode = AK_NP4; - break; - case SDLK_KP_5: - translatedScancode = AK_NP5; - break; - case SDLK_KP_6: - translatedScancode = AK_NP6; - break; - case SDLK_KP_7: - translatedScancode = AK_NP7; - break; - case SDLK_KP_8: - translatedScancode = AK_NP8; - break; - case SDLK_KP_9: - translatedScancode = AK_NP9; - break; -#endif - case SDLK_KP_ENTER: - translatedScancode = AK_ENT; - break; - case SDLK_KP_DIVIDE: - translatedScancode = AK_NPDIV; - break; - case SDLK_KP_MULTIPLY: - translatedScancode = AK_NPMUL; - break; - case SDLK_KP_MINUS: - translatedScancode = AK_NPSUB; - break; - case SDLK_KP_PLUS: - translatedScancode = AK_NPADD; - break; - case SDLK_KP_PERIOD: - translatedScancode = AK_NPDEL; - break; - } - - if (translatedScancode != scancode) - inputdevice_do_keyboard(translatedScancode, newstate); - else - inputdevice_translatekeycode(0, translatedScancode, newstate); -} - int target_checkcapslock(const int scancode, int *state) { #ifdef USE_SDL1 diff --git a/src/osdep/target.h b/src/osdep/target.h index b8631a3b..ed276d39 100644 --- a/src/osdep/target.h +++ b/src/osdep/target.h @@ -47,7 +47,7 @@ void graphics_subshutdown (void); void amiberry_stop_sound(); void keyboard_settrans(); -void translate_amiberry_keys(int symbol, int newstate); + #ifdef PANDORA int translate_pandora_keys(int symbol, int *modifier); #endif