From 4814d19e2819f07dc0495fe3aedf9e72ac71af7e Mon Sep 17 00:00:00 2001 From: kub Date: Mon, 17 Feb 2025 23:07:12 +0100 Subject: [PATCH] platform, physical kbd only for sdl --- platform/common/config_file.c | 4 ++-- platform/common/emu.c | 6 +++--- platform/common/menu_pico.c | 21 +++++++++++++-------- platform/gp2x/emu.c | 2 +- platform/linux/emu.c | 2 +- platform/pandora/plat.c | 2 +- platform/ps2/emu.c | 2 +- platform/psp/emu.c | 2 +- 8 files changed, 23 insertions(+), 18 deletions(-) diff --git a/platform/common/config_file.c b/platform/common/config_file.c index 8cb8b98b..25286516 100644 --- a/platform/common/config_file.c +++ b/platform/common/config_file.c @@ -367,9 +367,9 @@ static int custom_read(menu_entry *me, const char *var, const char *val) case MA_CTRL_KEYBOARD: currentConfig.keyboard = 0; if (strcasecmp(val, "physical") == 0) - currentConfig.keyboard = 1; - else if (strcasecmp(val, "virtual") == 0) currentConfig.keyboard = 2; + else if (strcasecmp(val, "virtual") == 0) + currentConfig.keyboard = 1; return 1; /* PSP */ diff --git a/platform/common/emu.c b/platform/common/emu.c index 6b544091..799aa313 100644 --- a/platform/common/emu.c +++ b/platform/common/emu.c @@ -1347,9 +1347,9 @@ void emu_update_input(void) if (kbd_mode) { int mask = (PicoIn.AHW & PAHW_PICO ? 0xf : 0x0); - if (currentConfig.keyboard == 1) + if (currentConfig.keyboard == 2) count_kbd = in_update_kbd(actions_kbd); - else if (currentConfig.keyboard == 2) + else if (currentConfig.keyboard == 1) count_kbd = vkbd_update(vkbd, pl_actions[0], actions_kbd); // FIXME: Only passthrough joystick input to avoid collisions @@ -1573,7 +1573,7 @@ static void emu_loop_prep(void) plat_target_gamma_set(currentConfig.gamma, 0); vkbd = NULL; - if (currentConfig.keyboard == 2) { + if (currentConfig.keyboard == 1) { if (PicoIn.AHW & PAHW_SMS) vkbd = vkbd_init(0); else if (PicoIn.AHW & PAHW_PICO) vkbd = vkbd_init(1); } diff --git a/platform/common/menu_pico.c b/platform/common/menu_pico.c index 577a23d6..6c1905e6 100644 --- a/platform/common/menu_pico.c +++ b/platform/common/menu_pico.c @@ -427,14 +427,14 @@ static void kbd_draw(struct key *desc[], int shift, int xoffs, int yoffs, struct int i, j; struct key *key; - if (g_menuscreen_w >= 480) + if (g_menuscreen_w >= (MENU_X2 ? 960 : 480)) xoffs -= 50; for (i = 0; desc[i]; i++) { for (j = 0, key = &desc[i][j]; key->lower; j++, key++) { int color = (key != hi ? PXMAKE(0xa0, 0xa0, 0xa0) : PXMAKE(0xff, 0xff, 0xff)); char *text = (shift ? key->upper : key->lower); - if (g_menuscreen_w >= 480) + if (g_menuscreen_w >= (MENU_X2 ? 960 : 480)) text_out16_(xoffs + key->xpos*me_mfont_w, yoffs + i*me_mfont_h, text, color); else smalltext_out16(xoffs + key->xpos*me_sfont_w, yoffs + i*me_sfont_h, text, color); @@ -576,7 +576,7 @@ static int key_config_players(int id, int keys) static const char *mgn_keyboard(int id, int *offs) { - static char *kbds[] = { "OFF", "physical", "virtual" }; + static char *kbds[] = { "OFF", "virtual", "physical" }; if (currentConfig.keyboard < 0 || currentConfig.keyboard > 2) return kbds[0]; return kbds[currentConfig.keyboard]; @@ -585,18 +585,23 @@ static const char *mgn_keyboard(int id, int *offs) static int key_config_keyboard(int id, int keys) { int kid = currentConfig.keyboard; +#ifdef USE_SDL // TODO this info should come from platform! + int k = 2; +#else + int k = 1; +#endif if (keys & PBTN_LEFT) - if (--kid < 0) kid = 2; + if (--kid < 0) kid = k; if (keys & PBTN_RIGHT) - if (++kid > 2) kid = 0; + if (++kid > k) kid = 0; currentConfig.keyboard = kid; - e_menu_keyconfig[2].help = (currentConfig.keyboard == 1 ? h_kbd : NULL); + e_menu_keyconfig[2].help = (currentConfig.keyboard == 2 ? h_kbd : NULL); if (keys & PBTN_MOK) - if (currentConfig.keyboard == 1) + if (currentConfig.keyboard == 2) key_config_kbd_loop(MA_CTRL_KEYBOARD, 0); return 0; @@ -641,7 +646,7 @@ static int menu_loop_keyconfig(int id, int keys) player[strlen(player)-1] = '1'; e_menu_keyconfig[0].help = h_play12; - e_menu_keyconfig[2].help = (currentConfig.keyboard == 1 ? h_kbd : NULL); + e_menu_keyconfig[2].help = (currentConfig.keyboard == 2 ? h_kbd : NULL); me_loop_d(e_menu_keyconfig, &sel, menu_draw_prep, NULL); diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index fe87c3b1..68222af4 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -451,7 +451,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) draw_pico_ptr(); } // draw virtual keyboard on display - if (kbd_mode && currentConfig.keyboard == 2 && vkbd) + if (kbd_mode && currentConfig.keyboard == 1 && vkbd) vkbd_draw(vkbd); } diff --git a/platform/linux/emu.c b/platform/linux/emu.c index 0c66c547..f26689da 100644 --- a/platform/linux/emu.c +++ b/platform/linux/emu.c @@ -229,7 +229,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) } // draw virtual keyboard on display - if (kbd_mode && currentConfig.keyboard == 2 && vkbd) + if (kbd_mode && currentConfig.keyboard == 1 && vkbd) vkbd_draw(vkbd); if (notice) diff --git a/platform/pandora/plat.c b/platform/pandora/plat.c index 54c28f3d..b9a91d39 100644 --- a/platform/pandora/plat.c +++ b/platform/pandora/plat.c @@ -182,7 +182,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) if ((PicoIn.AHW & PAHW_MCD) && (currentConfig.EmuOpt & EOPT_EN_CD_LEDS)) draw_cd_leds(); // draw virtual keyboard on display - if (kbd_mode && currentConfig.keyboard == 2 && vkbd) + if (kbd_mode && currentConfig.keyboard == 1 && vkbd) vkbd_draw(vkbd); } diff --git a/platform/ps2/emu.c b/platform/ps2/emu.c index e9b1581e..03153ac6 100644 --- a/platform/ps2/emu.c +++ b/platform/ps2/emu.c @@ -822,7 +822,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) } // draw virtual keyboard on display - if (kbd_mode && currentConfig.keyboard == 2 && vkbd) + if (kbd_mode && currentConfig.keyboard == 1 && vkbd) vkbd_draw(vkbd); osd_buf_cnt = 0; diff --git a/platform/psp/emu.c b/platform/psp/emu.c index 052968b8..fca8cd72 100644 --- a/platform/psp/emu.c +++ b/platform/psp/emu.c @@ -715,7 +715,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) } // draw virtual keyboard on display - if (kbd_mode && currentConfig.keyboard == 2 && vkbd) + if (kbd_mode && currentConfig.keyboard == 1 && vkbd) vkbd_draw(vkbd); osd_buf_cnt = 0; -- 2.39.5