Merge pull request #5489 from cathoderaydude/keybinds

Shortcut & keybind overhaul
This commit is contained in:
Miran Grča
2025-04-21 02:25:23 +02:00
committed by GitHub
44 changed files with 903 additions and 251 deletions

View File

@@ -73,7 +73,7 @@ if(WIN32)
# Default value for the `WIN32` target property, which specifies whether
# to build the application for the Windows GUI or console subsystem
option(CMAKE_WIN32_EXECUTABLE "Build a Windows GUI executable" ON)
option(CMAKE_WIN32_EXECUTABLE "Build a Windows GUI executable" OFF)
else()
# Prefer dynamic builds everywhere else
set(PREFER_STATIC OFF)

View File

@@ -222,6 +222,37 @@ int other_ide_present = 0; /* IDE control
int other_scsi_present = 0; /* SCSI controllers from non-SCSI cards are
present */
// Accelerator key array
struct accelKey acc_keys[NUM_ACCELS];
// Default accelerator key values
struct accelKey def_acc_keys[NUM_ACCELS] = {
{ .name="send_ctrl_alt_del", .desc="Send Control+Alt+Del",
.seq="Ctrl+F12" },
{ .name="send_ctrl_alt_esc", .desc="Send Control+Alt+Escape",
.seq="Ctrl+F10" },
{ .name="fullscreen", .desc="Toggle fullscreen",
.seq="Ctrl+Alt+PgUp" },
{ .name="screenshot", .desc="Screenshot",
.seq="Ctrl+F11" },
{ .name="release_mouse", .desc="Release mouse pointer",
.seq="Ctrl+End" },
{ .name="hard_reset", .desc="Hard reset",
.seq="Ctrl+Alt+F12" },
{ .name="pause", .desc="Toggle pause",
.seq="Ctrl+Alt+F1" },
{ .name="mute", .desc="Toggle mute",
.seq="Ctrl+Alt+M" }
};
/* Statistics. */
extern int mmuflush;
extern int readlnum;
@@ -654,7 +685,6 @@ usage:
#ifdef USE_INSTRUMENT
printf("-J or --instrument name - set 'name' to be the profiling instrument\n");
#endif
printf("-K or --keycodes codes - set 'codes' to be the uncapture combination\n");
printf("-L or --logfile path - set 'path' to be the logfile\n");
printf("-M or --missing - dump missing machines and video cards\n");
printf("-N or --noconfirm - do not ask for confirmation on quit\n");
@@ -745,13 +775,6 @@ usage:
do_nothing = 1;
} else if (!strcasecmp(argv[c], "--nohook") || !strcasecmp(argv[c], "-W")) {
hook_enabled = 0;
} else if (!strcasecmp(argv[c], "--keycodes") || !strcasecmp(argv[c], "-K")) {
if ((c + 1) == argc)
goto usage;
sscanf(argv[++c], "%03hX,%03hX,%03hX,%03hX,%03hX,%03hX",
&key_prefix_1_1, &key_prefix_1_2, &key_prefix_2_1, &key_prefix_2_2,
&key_uncapture_1, &key_uncapture_2);
} else if (!strcasecmp(argv[c], "--clearboth") || !strcasecmp(argv[c], "-X")) {
if ((c + 1) == argc)
goto usage;
@@ -1003,6 +1026,14 @@ usage:
gdbstub_init();
// Initialize the keyboard accelerator list with default values
for(int x=0;x<NUM_ACCELS;x++) {
strcpy(acc_keys[x].name, def_acc_keys[x].name);
strcpy(acc_keys[x].desc, def_acc_keys[x].desc);
strcpy(acc_keys[x].seq, def_acc_keys[x].seq);
}
/* All good! */
return 1;
}
@@ -1789,3 +1820,16 @@ do_pause(int p)
}
atomic_store(&pause_ack, 0);
}
// Helper to find an accelerator key and return it's index in acc_keys
int FindAccelerator(const char *name) {
for(int x=0;x<NUM_ACCELS;x++)
{
if(strcmp(acc_keys[x].name, name) == 0)
{
return(x);
}
}
// No key was found
return -1;
}

View File

@@ -107,6 +107,7 @@ config_log(const char *fmt, ...)
# define config_log(fmt, ...)
#endif
/* Load "General" section. */
static void
load_general(void)
@@ -1762,6 +1763,34 @@ load_gl3_shaders(void)
}
#endif
/* Load "Keybinds" section. */
static void
load_keybinds(void)
{
ini_section_t cat = ini_find_section(config, "Keybinds");
char *p;
char temp[512];
memset(temp, 0, sizeof(temp));
// Now load values from config
for(int x=0;x<NUM_ACCELS;x++)
{
p = ini_section_get_string(cat, acc_keys[x].name, "none");
// If there's no binding in the file, leave it alone.
if (strcmp(p, "none") != 0)
{
// It would be ideal to validate whether the user entered a
// valid combo at this point, but the Qt method for testing that is
// not available from C. Fortunately, if you feed Qt an invalid
// keysequence string it just assigns nothing, so this won't blow up.
// However, to improve the user experience, we should validate keys
// and erase any bad combos from config on mainwindow load.
strcpy(acc_keys[x].seq, p);
}
}
}
/* Load the specified or a default configuration file. */
void
config_load(void)
@@ -1863,6 +1892,7 @@ config_load(void)
#ifndef USE_SDL_UI
load_gl3_shaders(); /* GL3 Shaders */
#endif
load_keybinds(); /* Load shortcut keybinds */
/* Migrate renamed device configurations. */
c = ini_find_section(config, "MDA");
@@ -2488,6 +2518,26 @@ save_ports(void)
ini_delete_section_if_empty(config, cat);
}
/* Save "Keybinds" section. */
static void
save_keybinds(void)
{
ini_section_t cat = ini_find_or_create_section(config, "Keybinds");
for(int x=0;x<NUM_ACCELS;x++)
{
// Has accelerator been changed from default?
if (strcmp(def_acc_keys[x].seq, acc_keys[x].seq) == 0)
{
ini_section_delete_var(cat, acc_keys[x].name);
} else {
ini_section_set_string(cat, acc_keys[x].name, acc_keys[x].seq);
}
}
ini_delete_section_if_empty(config, cat);
}
/* Save "Storage Controllers" section. */
static void
save_storage_controllers(void)
@@ -3098,6 +3148,7 @@ config_save(void)
#ifndef USE_SDL_UI
save_gl3_shaders(); /* GL3 Shaders */
#endif
save_keybinds(); /* Key bindings */
ini_write(config, cfg_path);
}

View File

@@ -36,14 +36,6 @@ uint16_t scancode_map[768] = { 0 };
int keyboard_scan;
/* F8+F12 */
uint16_t key_prefix_1_1 = 0x042; /* F8 */
uint16_t key_prefix_1_2 = 0x000; /* Invalid */
uint16_t key_prefix_2_1 = 0x000; /* Invalid */
uint16_t key_prefix_2_2 = 0x000; /* Invalid */
uint16_t key_uncapture_1 = 0x058; /* F12 */
uint16_t key_uncapture_2 = 0x000; /* Invalid */
#ifdef ENABLE_KBC_AT_LOG
int kbc_at_do_log = ENABLE_KBC_AT_LOG;
@@ -481,19 +473,6 @@ keyboard_isfsexit_up(void)
return (!recv_key_ui[0x01d] && !recv_key_ui[0x11d] && !recv_key_ui[0x038] && !recv_key_ui[0x138] && !recv_key_ui[0x051] && !recv_key_ui[0x151]);
}
/* Do we have the mouse uncapture combination in the keyboard buffer? */
int
keyboard_ismsexit(void)
{
if ((key_prefix_2_1 != 0x000) || (key_prefix_2_2 != 0x000))
return ((recv_key_ui[key_prefix_1_1] || recv_key_ui[key_prefix_1_2]) &&
(recv_key_ui[key_prefix_2_1] || recv_key_ui[key_prefix_2_2]) &&
(recv_key_ui[key_uncapture_1] || recv_key_ui[key_uncapture_2]));
else
return ((recv_key_ui[key_prefix_1_1] || recv_key_ui[key_prefix_1_2]) &&
(recv_key_ui[key_uncapture_1] || recv_key_ui[key_uncapture_2]));
}
/* This is so we can disambiguate scan codes that would otherwise conflict and get
passed on incorrectly. */
uint16_t

View File

@@ -172,14 +172,6 @@ extern int pit_mode; /* (C) force setting PIT mode */
extern int fm_driver; /* (C) select FM sound driver */
extern int hook_enabled; /* (C) Keyboard hook is enabled */
/* Keyboard variables for future key combination redefinition. */
extern uint16_t key_prefix_1_1;
extern uint16_t key_prefix_1_2;
extern uint16_t key_prefix_2_1;
extern uint16_t key_prefix_2_2;
extern uint16_t key_uncapture_1;
extern uint16_t key_uncapture_2;
extern char exe_path[2048]; /* path (dir) of executable */
extern char usr_path[1024]; /* path (dir) of user data */
extern char cfg_path[1024]; /* full path of config file */
@@ -244,6 +236,17 @@ extern int framecountx;
extern volatile int cpu_thread_run;
extern uint8_t postcard_codes[POSTCARDS_NUM];
// Accelerator key structure, defines, helper functions
struct accelKey {
char name[64];
char desc[64];
char seq[64];
};
#define NUM_ACCELS 8
extern struct accelKey acc_keys[NUM_ACCELS];
extern struct accelKey def_acc_keys[NUM_ACCELS];
extern int FindAccelerator(const char *name);
#ifdef __cplusplus
}
#endif

View File

@@ -283,7 +283,6 @@ extern int keyboard_isfsenter(void);
extern int keyboard_isfsenter_up(void);
extern int keyboard_isfsexit(void);
extern int keyboard_isfsexit_up(void);
extern int keyboard_ismsexit(void);
extern void keyboard_set_is_amstrad(int ams);
extern void kbc_at_set_ps2(void *priv, uint8_t ps2);
extern void kbc_at_write_p(void *priv, uint8_t port, uint8_t mask, uint8_t val);

View File

@@ -137,6 +137,11 @@ add_library(ui STATIC
qt_joystickconfiguration.cpp
qt_joystickconfiguration.hpp
qt_joystickconfiguration.ui
qt_keybind.cpp
qt_keybind.hpp
qt_keybind.ui
qt_singlekeyseqedit.cpp
qt_singlekeyseqedit.hpp
qt_filefield.cpp
qt_filefield.hpp

View File

@@ -630,8 +630,8 @@ msgstr "Error fatal"
msgid " - PAUSED"
msgstr " - EN PAUSA"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Premeu Ctrl+Alt+PgDn per tornar al mode de finestra."
msgid "Press %s to return to windowed mode."
msgstr "Premeu %s per tornar al mode de finestra."
msgid "Speed"
msgstr "Velocitat"
@@ -717,11 +717,11 @@ msgstr "Altres perifèrics"
msgid "Click to capture mouse"
msgstr "Feu clic per capturar el ratolí"
msgid "Press %1 to release mouse"
msgstr "Premeu %1 per alliberar el ratolí"
msgid "Press %s to release mouse"
msgstr "Premeu %s per alliberar el ratolí"
msgid "Press %1 or middle button to release mouse"
msgstr "Premeu %1 o el botó central per alliberar el ratolí"
msgid "Press %s or middle button to release mouse"
msgstr "Premeu %s o el botó central per alliberar el ratolí"
msgid "Bus"
msgstr "Bus"

View File

@@ -630,8 +630,8 @@ msgstr "Kritická chyba"
msgid " - PAUSED"
msgstr " - POZASTAVENO"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Stiskněte Ctrl+Alt+PgDn pro návrat z režimu celé obrazovky."
msgid "Press %s to return to windowed mode."
msgstr "Stiskněte %s pro návrat z režimu celé obrazovky."
msgid "Speed"
msgstr "Rychlost"
@@ -717,11 +717,11 @@ msgstr "Jiné příslušenství"
msgid "Click to capture mouse"
msgstr "Klikněte pro zabraní myši"
msgid "Press %1 to release mouse"
msgstr "Stiskněte %1 pro uvolnění myši"
msgid "Press %s to release mouse"
msgstr "Stiskněte %s pro uvolnění myši"
msgid "Press %1 or middle button to release mouse"
msgstr "Stiskněte %1 nebo prostřední tlačítko pro uvolnění myši"
msgid "Press %s or middle button to release mouse"
msgstr "Stiskněte %s nebo prostřední tlačítko pro uvolnění myši"
msgid "Bus"
msgstr "Sběrnice"

View File

@@ -630,8 +630,8 @@ msgstr "Fataler Fehler"
msgid " - PAUSED"
msgstr " - PAUSIERT"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Strg+Alt+Bild ab, zur Rückkehr in den Fenstermodus."
msgid "Press %s to return to windowed mode."
msgstr "%s ab, zur Rückkehr in den Fenstermodus."
msgid "Speed"
msgstr "Geschwindigkeit"
@@ -717,11 +717,11 @@ msgstr "Andere Peripheriegeräte"
msgid "Click to capture mouse"
msgstr "Klicken zum Einfangen des Mauszeigers"
msgid "Press %1 to release mouse"
msgstr "Drücke %1 zur Mausfreigabe"
msgid "Press %s to release mouse"
msgstr "Drücke %s zur Mausfreigabe"
msgid "Press %1 or middle button to release mouse"
msgstr "Drücke %1 oder die mittlere Maustaste zur Mausfreigabe"
msgid "Press %s or middle button to release mouse"
msgstr "Drücke %s oder die mittlere Maustaste zur Mausfreigabe"
msgid "Ctrl+End"
msgstr "Strg+Ende"

View File

@@ -630,8 +630,8 @@ msgstr "Error fatal"
msgid " - PAUSED"
msgstr " - EN PAUSA"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Pulsa Ctrl+Alt+PgDn para volver a modo ventana."
msgid "Press %s to return to windowed mode."
msgstr "Pulsa %s para volver a modo ventana."
msgid "Speed"
msgstr "Velocidad"
@@ -717,11 +717,11 @@ msgstr "Otros periféricos"
msgid "Click to capture mouse"
msgstr "Haga click para capturar el ratón"
msgid "Press %1 to release mouse"
msgstr "Pulse %1 para liberar el ratón"
msgid "Press %s to release mouse"
msgstr "Pulse %s para liberar el ratón"
msgid "Press %1 or middle button to release mouse"
msgstr "Pulse %1 o el botón central para liberar el ratón"
msgid "Press %s or middle button to release mouse"
msgstr "Pulse %s o el botón central para liberar el ratón"
msgid "Bus"
msgstr "Bus"

View File

@@ -630,8 +630,8 @@ msgstr "Vakava virhe"
msgid " - PAUSED"
msgstr " - TAUKO"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Paina Ctrl+Alt+PgDn palataksesi ikkunoituun tilaan."
msgid "Press %s to return to windowed mode."
msgstr "Paina %s palataksesi ikkunoituun tilaan."
msgid "Speed"
msgstr "Nopeus"
@@ -717,11 +717,11 @@ msgstr "Muut oheislaitteet"
msgid "Click to capture mouse"
msgstr "Kaappaa hiiri klikkaamalla"
msgid "Press %1 to release mouse"
msgstr "Paina %1 vapauttaaksesi hiiren"
msgid "Press %s to release mouse"
msgstr "Paina %s vapauttaaksesi hiiren"
msgid "Press %1 or middle button to release mouse"
msgstr "Paina %1 tai keskipainiketta vapauttaaksesi hiiren"
msgid "Press %s or middle button to release mouse"
msgstr "Paina %s tai keskipainiketta vapauttaaksesi hiiren"
msgid "Bus"
msgstr "Väylä"

View File

@@ -630,8 +630,8 @@ msgstr "Erreur fatale"
msgid " - PAUSED"
msgstr " - EN PAUSE"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Appuyez sur Ctrl+Alt+PgDn pour revenir au mode fenêtré."
msgid "Press %s to return to windowed mode."
msgstr "Appuyez sur %s pour revenir au mode fenêtré."
msgid "Speed"
msgstr "Vitesse"
@@ -717,11 +717,11 @@ msgstr "Autres périfériques"
msgid "Click to capture mouse"
msgstr "Cliquer pour capturer la souris"
msgid "Press %1 to release mouse"
msgstr "Appuyer sur %1 pour libérer la souris"
msgid "Press %s to release mouse"
msgstr "Appuyer sur %s pour libérer la souris"
msgid "Press %1 or middle button to release mouse"
msgstr "Appuyer sur %1 ou le bouton central pour libérer la souris"
msgid "Press %s or middle button to release mouse"
msgstr "Appuyer sur %s ou le bouton central pour libérer la souris"
msgid "Bus"
msgstr "Bus"

View File

@@ -630,8 +630,8 @@ msgstr "Fatalna greška"
msgid " - PAUSED"
msgstr " - ZASTAO"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Pritisnite Ctrl+Alt+PgDn za povratak u prozorski način rada."
msgid "Press %s to return to windowed mode."
msgstr "Pritisnite %s za povratak u prozorski način rada."
msgid "Speed"
msgstr "Brzina"
@@ -717,11 +717,11 @@ msgstr "Ostali periferni uređaji"
msgid "Click to capture mouse"
msgstr "Kliknite da uhvatite miš"
msgid "Press %1 to release mouse"
msgstr "Pritisnite %1 za otpustanje miša"
msgid "Press %s to release mouse"
msgstr "Pritisnite %s za otpustanje miša"
msgid "Press %1 or middle button to release mouse"
msgstr "Pritisnite %1 ili srednji gumb miša za otpuštanje miša"
msgid "Press %s or middle button to release mouse"
msgstr "Pritisnite %s ili srednji gumb miša za otpuštanje miša"
msgid "Bus"
msgstr "Bus"

View File

@@ -630,8 +630,8 @@ msgstr "Végzetes hiba"
msgid " - PAUSED"
msgstr " - SZÜNETELT"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Használja a Ctrl+Alt+PgDn gombokat az ablakhoz való visszatéréshez."
msgid "Press %s to return to windowed mode."
msgstr "Használja a %s gombokat az ablakhoz való visszatéréshez."
msgid "Speed"
msgstr "Sebesség"
@@ -717,11 +717,11 @@ msgstr "Egyéb perifériák"
msgid "Click to capture mouse"
msgstr "Kattintson az egér elfogásához"
msgid "Press %1 to release mouse"
msgstr "Nyomja meg az %1-t az egér elengédéséhez"
msgid "Press %s to release mouse"
msgstr "Nyomja meg az %s-t az egér elengédéséhez"
msgid "Press %1 or middle button to release mouse"
msgstr "Nyomja meg az %1-t vagy a középső gombot az egér elengédéséhez"
msgid "Press %s or middle button to release mouse"
msgstr "Nyomja meg az %s-t vagy a középső gombot az egér elengédéséhez"
msgid "Bus"
msgstr "Busz"

View File

@@ -630,8 +630,8 @@ msgstr "Errore fatale"
msgid " - PAUSED"
msgstr " - IN PAUSA"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Usa Ctrl+Alt+PgDn per tornare alla modalità finestra."
msgid "Press %s to return to windowed mode."
msgstr "Usa %s per tornare alla modalità finestra."
msgid "Speed"
msgstr "Velocità"
@@ -717,11 +717,11 @@ msgstr "Altre periferiche"
msgid "Click to capture mouse"
msgstr "Fare clic per catturare mouse"
msgid "Press %1 to release mouse"
msgstr "Premi %1 per rilasciare il mouse"
msgid "Press %s to release mouse"
msgstr "Premi %s per rilasciare il mouse"
msgid "Press %1 or middle button to release mouse"
msgstr "Premi %1 o pulsante centrale per rilasciare il mouse"
msgid "Press %s or middle button to release mouse"
msgstr "Premi %s o pulsante centrale per rilasciare il mouse"
msgid "Bus"
msgstr "Bus"

View File

@@ -630,8 +630,8 @@ msgstr "致命的なエラー"
msgid " - PAUSED"
msgstr " - 一時停止"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Ctrl+Alt+PgDnでウィンドウ モードに戻ります。"
msgid "Press %s to return to windowed mode."
msgstr "%sでウィンドウ モードに戻ります。"
msgid "Speed"
msgstr "速度"
@@ -717,11 +717,11 @@ msgstr "他の周辺デバイス"
msgid "Click to capture mouse"
msgstr "左クリックでマウスをキャプチャします"
msgid "Press %1 to release mouse"
msgstr "%1キーでマウスを解放します"
msgid "Press %s to release mouse"
msgstr "%sキーでマウスを解放します"
msgid "Press %1 or middle button to release mouse"
msgstr "%1キーまたは中クリックでマウスを解放します"
msgid "Press %s or middle button to release mouse"
msgstr "%sキーまたは中クリックでマウスを解放します"
msgid "Bus"
msgstr "バス"

View File

@@ -630,8 +630,8 @@ msgstr "치명적인 오류"
msgid " - PAUSED"
msgstr " - 일시 중지됨"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Ctrl+Alt+PgDn 키를 누르면 창 모드로 전환합니다."
msgid "Press %s to return to windowed mode."
msgstr "%s 키를 누르면 창 모드로 전환합니다."
msgid "Speed"
msgstr "속도"
@@ -717,11 +717,11 @@ msgstr "기타 주변기기"
msgid "Click to capture mouse"
msgstr "이 창을 클릭하면 마우스를 사용합니다"
msgid "Press %1 to release mouse"
msgstr "%1키를 누르면 마우스를 해제합니다"
msgid "Press %s to release mouse"
msgstr "%s키를 누르면 마우스를 해제합니다"
msgid "Press %1 or middle button to release mouse"
msgstr "%1키 또는 가운데 버튼을 클릭하면 마우스를 해제합니다"
msgid "Press %s or middle button to release mouse"
msgstr "%s키 또는 가운데 버튼을 클릭하면 마우스를 해제합니다"
msgid "Bus"
msgstr "버스"

View File

@@ -630,8 +630,8 @@ msgstr "Fatale fout"
msgid " - PAUSED"
msgstr " - GEPAUZEERD"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Druk op Ctrl+Alt+PgDn om terug te gaan naar de venstermodus."
msgid "Press %s to return to windowed mode."
msgstr "Druk op %s om terug te gaan naar de venstermodus."
msgid "Speed"
msgstr "Snelheid"
@@ -717,11 +717,11 @@ msgstr "Andere randapparatuur"
msgid "Click to capture mouse"
msgstr "Klik om muis vast te leggen"
msgid "Press %1 to release mouse"
msgstr "Druk op %1 om de muis los te laten"
msgid "Press %s to release mouse"
msgstr "Druk op %s om de muis los te laten"
msgid "Press %1 or middle button to release mouse"
msgstr "Druk op %1 of middelste knop om de muis los te laten"
msgid "Press %s or middle button to release mouse"
msgstr "Druk op %s of middelste knop om de muis los te laten"
msgid "Bus"
msgstr "Bus"

View File

@@ -630,8 +630,8 @@ msgstr "Fatalny błąd"
msgid " - PAUSED"
msgstr " - PAUSED"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Naciśnij klawisze Ctrl+Alt+PgDn aby wrócić to trybu okna."
msgid "Press %s to return to windowed mode."
msgstr "Naciśnij klawisze %s aby wrócić to trybu okna."
msgid "Speed"
msgstr "Szybkość"
@@ -717,11 +717,11 @@ msgstr "Inne urządzenia peryferyjne"
msgid "Click to capture mouse"
msgstr "Kliknij w celu przechwycenia myszy"
msgid "Press %1 to release mouse"
msgstr "Naciśnij klawisze %1 w celu uwolnienia myszy"
msgid "Press %s to release mouse"
msgstr "Naciśnij klawisze %s w celu uwolnienia myszy"
msgid "Press %1 or middle button to release mouse"
msgstr "Naciśnij klawisze %1 lub środkowy przycisk w celu uwolnienia myszy"
msgid "Press %s or middle button to release mouse"
msgstr "Naciśnij klawisze %s lub środkowy przycisk w celu uwolnienia myszy"
msgid "Bus"
msgstr "Magistrala"

View File

@@ -630,8 +630,8 @@ msgstr "Erro fatal"
msgid " - PAUSED"
msgstr " - PAUSADO"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Use Ctrl+Alt+PgDn para retornar ao modo janela"
msgid "Press %s to return to windowed mode."
msgstr "Use %s para retornar ao modo janela"
msgid "Speed"
msgstr "Velocidade"
@@ -717,11 +717,11 @@ msgstr "Outros periféricos"
msgid "Click to capture mouse"
msgstr "Clique para capturar o mouse"
msgid "Press %1 to release mouse"
msgstr "Aperte %1 para liberar o mouse"
msgid "Press %s to release mouse"
msgstr "Aperte %s para liberar o mouse"
msgid "Press %1 or middle button to release mouse"
msgstr "Aperte %1 ou botão do meio para liberar o mouse"
msgid "Press %s or middle button to release mouse"
msgstr "Aperte %s ou botão do meio para liberar o mouse"
msgid "Bus"
msgstr "Barramento"

View File

@@ -630,8 +630,8 @@ msgstr "Erro fatal"
msgid " - PAUSED"
msgstr " - EM PAUSA"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Pressione Ctrl+Alt+PgDn para voltar ao modo de janela."
msgid "Press %s to return to windowed mode."
msgstr "Pressione %s para voltar ao modo de janela."
msgid "Speed"
msgstr "Velocidade"
@@ -717,11 +717,11 @@ msgstr "Outros dispositivos"
msgid "Click to capture mouse"
msgstr "Clique para capturar o rato"
msgid "Press %1 to release mouse"
msgstr "Pressione %1 para soltar o rato"
msgid "Press %s to release mouse"
msgstr "Pressione %s para soltar o rato"
msgid "Press %1 or middle button to release mouse"
msgstr "Pressione %1 ou tecla média para soltar o rato"
msgid "Press %s or middle button to release mouse"
msgstr "Pressione %s ou tecla média para soltar o rato"
msgid "Bus"
msgstr "Barramento"

View File

@@ -630,8 +630,8 @@ msgstr "Неустранимая ошибка"
msgid " - PAUSED"
msgstr " - ПАУЗА"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Нажмите Ctrl+Alt+PgDn для возврата в оконный режим."
msgid "Press %s to return to windowed mode."
msgstr "Нажмите %s для возврата в оконный режим."
msgid "Speed"
msgstr "Скорость"
@@ -717,11 +717,11 @@ msgstr "Другая периферия"
msgid "Click to capture mouse"
msgstr "Щёлкните мышью для захвата курсора"
msgid "Press %1 to release mouse"
msgstr "Нажмите %1, чтобы освободить курсор"
msgid "Press %s to release mouse"
msgstr "Нажмите %s, чтобы освободить курсор"
msgid "Press %1 or middle button to release mouse"
msgstr "Нажмите %1 или среднюю кнопку мыши, чтобы освободить курсор"
msgid "Press %s or middle button to release mouse"
msgstr "Нажмите %s или среднюю кнопку мыши, чтобы освободить курсор"
msgid "Bus"
msgstr "Шина"

View File

@@ -630,8 +630,8 @@ msgstr "Kritická chyba"
msgid " - PAUSED"
msgstr " - POZASTAVENÝ"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Stlačte Ctrl+Alt+PgDn pre návrat z režimu celej obrazovky."
msgid "Press %s to return to windowed mode."
msgstr "Stlačte %s pre návrat z režimu celej obrazovky."
msgid "Speed"
msgstr "Rýchlosť"
@@ -717,11 +717,11 @@ msgstr "Iné príslušenstvo"
msgid "Click to capture mouse"
msgstr "Kliknite pre zabráni myši"
msgid "Press %1 to release mouse"
msgstr "Stlačte %1 pre uvoľnenie myši"
msgid "Press %s to release mouse"
msgstr "Stlačte %s pre uvoľnenie myši"
msgid "Press %1 or middle button to release mouse"
msgstr "Stlačte %1 alebo prostredné tlačidlo na uvoľnenie myši"
msgid "Press %s or middle button to release mouse"
msgstr "Stlačte %s alebo prostredné tlačidlo na uvoľnenie myši"
msgid "Bus"
msgstr "Zbernica"

View File

@@ -630,8 +630,8 @@ msgstr "Kritična napaka"
msgid " - PAUSED"
msgstr " - ZAUSTAVLJEN"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Pritisnite Ctrl+Alt+PgDn za povratek iz celozaslonskega načina."
msgid "Press %s to return to windowed mode."
msgstr "Pritisnite %s za povratek iz celozaslonskega načina."
msgid "Speed"
msgstr "Hitrost"
@@ -717,11 +717,11 @@ msgstr "Druga periferija"
msgid "Click to capture mouse"
msgstr "Kliknite za zajem miške"
msgid "Press %1 to release mouse"
msgstr "Pritisnite %1 za izpust miške"
msgid "Press %s to release mouse"
msgstr "Pritisnite %s za izpust miške"
msgid "Press %1 or middle button to release mouse"
msgstr "Pritisnite %1 ali srednji gumb za izpust miške"
msgid "Press %s or middle button to release mouse"
msgstr "Pritisnite %s ali srednji gumb za izpust miške"
msgid "Bus"
msgstr "Vodilo"

View File

@@ -630,8 +630,8 @@ msgstr "Allvarligt fel"
msgid " - PAUSED"
msgstr " - PAUSAD"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Tryck på Ctrl+Alt+PgDn för att återvända till fönsterläge."
msgid "Press %s to return to windowed mode."
msgstr "Tryck på %s för att återvända till fönsterläge."
msgid "Speed"
msgstr "Hastighet"
@@ -717,11 +717,11 @@ msgstr "Andra tillbehör"
msgid "Click to capture mouse"
msgstr "Klicka för att fånga upp musen"
msgid "Press %1 to release mouse"
msgstr "Tryck på %1 för att släppa musen"
msgid "Press %s to release mouse"
msgstr "Tryck på %s för att släppa musen"
msgid "Press %1 or middle button to release mouse"
msgstr "Tryck på %1 eller mellersta musknappen för att släppa musen"
msgid "Press %s or middle button to release mouse"
msgstr "Tryck på %s eller mellersta musknappen för att släppa musen"
msgid "Bus"
msgstr "Buss"

View File

@@ -630,8 +630,8 @@ msgstr "Kritik hata"
msgid " - PAUSED"
msgstr " - DURAKLATILDI"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Pencere moduna geri dönmek için Ctrl+Alt+PgDn tuşlarına basın."
msgid "Press %s to return to windowed mode."
msgstr "Pencere moduna geri dönmek için %s tuşlarına basın."
msgid "Speed"
msgstr "Hız"
@@ -717,11 +717,11 @@ msgstr "Diğer cihazlar"
msgid "Click to capture mouse"
msgstr "Farenin yakalanması için tıklayın"
msgid "Press %1 to release mouse"
msgstr "Farenin bırakılması için %1 tuşlarına basın"
msgid "Press %s to release mouse"
msgstr "Farenin bırakılması için %s tuşlarına basın"
msgid "Press %1 or middle button to release mouse"
msgstr "Farenin bırakılması için %1 tuşlarına veya tekerlek tuşuna basın"
msgid "Press %s or middle button to release mouse"
msgstr "Farenin bırakılması için %s tuşlarına veya tekerlek tuşuna basın"
msgid "Bus"
msgstr "Veri yolu"

View File

@@ -630,8 +630,8 @@ msgstr "Непереробна помилка"
msgid " - PAUSED"
msgstr " - ПРИЗУПИНЕННЯ"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Натисніть Ctrl+Alt+PgDn для повернення у віконний режим."
msgid "Press %s to return to windowed mode."
msgstr "Натисніть %s для повернення у віконний режим."
msgid "Speed"
msgstr "Швидкість"
@@ -717,11 +717,11 @@ msgstr "Інша периферія"
msgid "Click to capture mouse"
msgstr "Клацніть мишею для захвату курсора"
msgid "Press %1 to release mouse"
msgstr "Натисніть %1, щоб звільнити курсор"
msgid "Press %s to release mouse"
msgstr "Натисніть %s, щоб звільнити курсор"
msgid "Press %1 or middle button to release mouse"
msgstr "Натисніть %1 або середню кнопку миші, щоб звільнити курсор"
msgid "Press %s or middle button to release mouse"
msgstr "Натисніть %s або середню кнопку миші, щоб звільнити курсор"
msgid "Bus"
msgstr "Шина"

View File

@@ -630,8 +630,8 @@ msgstr "Lỗi nghiêm trọng"
msgid " - PAUSED"
msgstr " - TẠM DỪNG"
msgid "Press Ctrl+Alt+PgDn to return to windowed mode."
msgstr "Bấm Ctrl+Alt+PgDn để quay lại chế độ cửa sổ."
msgid "Press %s to return to windowed mode."
msgstr "Bấm %s để quay lại chế độ cửa sổ."
msgid "Speed"
msgstr "Vận tốc"
@@ -717,11 +717,11 @@ msgstr "Thiết bị ngoại vi khác"
msgid "Click to capture mouse"
msgstr "Nhấp vào khung hình để 'nhốt' chuột vào"
msgid "Press %1 to release mouse"
msgstr "Nhấn %1 để thả chuột"
msgid "Press %s to release mouse"
msgstr "Nhấn %s để thả chuột"
msgid "Press %1 or middle button to release mouse"
msgstr "Nhấn %1 hoặc nhấp chuột giữa để thả chuột"
msgid "Press %s or middle button to release mouse"
msgstr "Nhấn %s hoặc nhấp chuột giữa để thả chuột"
msgid "Bus"
msgstr "Bus"

View File

@@ -717,11 +717,11 @@ msgstr "其他外围设备"
msgid "Click to capture mouse"
msgstr "单击窗口捕捉鼠标"
msgid "Press %1 to release mouse"
msgstr "按下 %1 释放鼠标"
msgid "Press %s to release mouse"
msgstr "按下 %s 释放鼠标"
msgid "Press %1 or middle button to release mouse"
msgstr "按下 %1 或鼠标中键释放鼠标"
msgid "Press %s or middle button to release mouse"
msgstr "按下 %s 或鼠标中键释放鼠标"
msgid "Bus"
msgstr "总线"

View File

@@ -717,11 +717,11 @@ msgstr "其他周邊裝置"
msgid "Click to capture mouse"
msgstr "點擊視窗捕捉滑鼠"
msgid "Press %1 to release mouse"
msgstr "按下 %1 釋放滑鼠"
msgid "Press %s to release mouse"
msgstr "按下 %s 釋放滑鼠"
msgid "Press %1 or middle button to release mouse"
msgstr "按下 %1 或滑鼠中鍵釋放滑鼠"
msgid "Press %s or middle button to release mouse"
msgstr "按下 %s 或滑鼠中鍵釋放滑鼠"
msgid "Bus"
msgstr "匯流排"

View File

@@ -87,4 +87,4 @@ plat_vidapi_name(int api)
}
return name;
}
}

101
src/qt/qt_keybind.cpp Normal file
View File

@@ -0,0 +1,101 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* Device configuration UI code.
*
*
*
* Authors: Joakim L. Gilje <jgilje@jgilje.net>
* Cacodemon345
*
* Copyright 2021 Joakim L. Gilje
* Copyright 2022 Cacodemon345
*/
#include "qt_keybind.hpp"
#include "ui_qt_keybind.h"
#include "qt_settings.hpp"
#include "qt_singlekeyseqedit.hpp"
#include <QDebug>
#include <QComboBox>
#include <QPushButton>
#include <QFormLayout>
#include <QSpinBox>
#include <QCheckBox>
#include <QFrame>
#include <QLineEdit>
#include <QLabel>
#include <QDir>
#include <QSettings>
#include <QKeyEvent>
#include <QKeySequence>
#include <QKeySequenceEdit>
extern "C" {
#include <86box/86box.h>
#include <86box/ini.h>
#include <86box/config.h>
#include <86box/device.h>
#include <86box/midi_rtmidi.h>
#include <86box/mem.h>
#include <86box/random.h>
#include <86box/rom.h>
}
#include "qt_filefield.hpp"
#include "qt_models_common.hpp"
#ifdef Q_OS_LINUX
# include <sys/stat.h>
# include <sys/sysmacros.h>
#endif
#ifdef Q_OS_WINDOWS
#include <windows.h>
#endif
KeyBinder::KeyBinder(QWidget *parent)
: QDialog(parent)
, ui(new Ui::KeyBinder)
{
ui->setupUi(this);
singleKeySequenceEdit *seq = new singleKeySequenceEdit();
ui->formLayout->addRow(seq);
seq->setObjectName("keySequence");
this->setTabOrder(seq, ui->buttonBox);
}
KeyBinder::~KeyBinder()
{
delete ui;
}
void
KeyBinder::showEvent( QShowEvent* event ) {
QWidget::showEvent( event );
this->findChild<QKeySequenceEdit*>()->setFocus();
}
bool KeyBinder::eventFilter(QObject *obj, QEvent *event)
{
return QObject::eventFilter(obj, event);
}
QKeySequence
KeyBinder::BindKey(QString CurValue)
{
KeyBinder kb;
kb.setWindowTitle("Bind Key");
kb.setFixedSize(kb.minimumSizeHint());
kb.findChild<QKeySequenceEdit*>()->setKeySequence(QKeySequence::fromString(CurValue));
if (kb.exec() == QDialog::Accepted) {
QKeySequenceEdit *seq = kb.findChild<QKeySequenceEdit*>();
return (seq->keySequence());
} else {
return (false);
}
}

33
src/qt/qt_keybind.hpp Normal file
View File

@@ -0,0 +1,33 @@
#ifndef QT_KeyBinder_HPP
#define QT_KeyBinder_HPP
#include <QDialog>
#include "qt_settings.hpp"
extern "C" {
struct _device_;
}
namespace Ui {
class KeyBinder;
}
class Settings;
class KeyBinder : public QDialog {
Q_OBJECT
public:
explicit KeyBinder(QWidget *parent = nullptr);
~KeyBinder() override;
static QKeySequence BindKey(QString CurValue);
private:
Ui::KeyBinder *ui;
bool eventFilter(QObject *obj, QEvent *event);
void showEvent( QShowEvent* event );
};
#endif // QT_KeyBinder_HPP

85
src/qt/qt_keybind.ui Normal file
View File

@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KeyBinder</class>
<widget class="QDialog" name="KeyBinder">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>103</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Enter key combo:</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::StandardButton::Cancel|QDialogButtonBox::StandardButton::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>KeyBinder</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>KeyBinder</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@@ -139,6 +139,7 @@ namespace IOKit {
# include "be_keyboard.hpp"
extern MainWindow *main_window;
QShortcut *windowedShortcut;
filter_result
keyb_filter(BMessage *message, BHandler **target, BMessageFilter *filter)
@@ -675,17 +676,6 @@ MainWindow::MainWindow(QWidget *parent)
/* Remove default Shift+F10 handler, which unfocuses keyboard input even with no context menu. */
connect(new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_F10), this), &QShortcut::activated, this, [](){});
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
auto windowedShortcut = new QShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_PageDown), this);
#else
auto windowedShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_PageDown), this);
#endif
windowedShortcut->setContext(Qt::ShortcutContext::ApplicationShortcut);
connect(windowedShortcut, &QShortcut::activated, this, [this] () {
if (video_fullscreen)
ui->actionFullscreen->trigger();
});
connect(this, &MainWindow::initRendererMonitor, this, &MainWindow::initRendererMonitorSlot);
connect(this, &MainWindow::initRendererMonitorForNonQtThread, this, &MainWindow::initRendererMonitorSlot, Qt::BlockingQueuedConnection);
connect(this, &MainWindow::destroyRendererMonitor, this, &MainWindow::destroyRendererMonitorSlot);
@@ -761,6 +751,8 @@ MainWindow::MainWindow(QWidget *parent)
});
}
#endif
updateShortcuts();
}
void
@@ -826,6 +818,57 @@ MainWindow::closeEvent(QCloseEvent *event)
event->accept();
}
void MainWindow::updateShortcuts()
{
/*
Update menu shortcuts from accelerator table
Note that these only work in windowed mode. If you add any new shortcuts,
you have to go duplicate them in MainWindow::eventFilter()
*/
// First we need to wipe all existing accelerators, otherwise Qt will
// run into conflicts with old ones.
ui->actionTake_screenshot->setShortcut(QKeySequence());
ui->actionCtrl_Alt_Del->setShortcut(QKeySequence());
ui->actionCtrl_Alt_Esc->setShortcut(QKeySequence());
ui->actionHard_Reset->setShortcut(QKeySequence());
ui->actionPause->setShortcut(QKeySequence());
ui->actionMute_Unmute->setShortcut(QKeySequence());
int accID;
QKeySequence seq;
accID = FindAccelerator("screenshot");
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionTake_screenshot->setShortcut(seq);
accID = FindAccelerator("send_ctrl_alt_del");
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionCtrl_Alt_Del->setShortcut(seq);
accID = FindAccelerator("send_ctrl_alt_esc");
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionCtrl_Alt_Esc->setShortcut(seq);
accID = FindAccelerator("hard_reset");
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionHard_Reset->setShortcut(seq);
accID = FindAccelerator("fullscreen");
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionFullscreen->setShortcut(seq);
accID = FindAccelerator("pause");
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionPause->setShortcut(seq);
accID = FindAccelerator("mute");
seq = QKeySequence::fromString(acc_keys[accID].seq);
ui->actionMute_Unmute->setShortcut(seq);
}
void
MainWindow::resizeEvent(QResizeEvent *event)
{
@@ -1026,6 +1069,7 @@ MainWindow::on_actionSettings_triggered()
case QDialog::Accepted:
settings.save();
config_changed = 2;
updateShortcuts();
pc_reset_hard();
break;
case QDialog::Rejected:
@@ -1250,7 +1294,10 @@ MainWindow::on_actionFullscreen_triggered()
if (video_fullscreen_first) {
bool wasCaptured = mouse_capture == 1;
QMessageBox questionbox(QMessageBox::Icon::Information, tr("Entering fullscreen mode"), tr("Press Ctrl+Alt+PgDn to return to windowed mode."), QMessageBox::Ok, this);
char strFullscreen[100];
sprintf(strFullscreen, qPrintable(tr("Press %s to return to windowed mode.")), acc_keys[FindAccelerator("fullscreen")].seq);
QMessageBox questionbox(QMessageBox::Icon::Information, tr("Entering fullscreen mode"), QString(strFullscreen), QMessageBox::Ok, this);
QCheckBox *chkbox = new QCheckBox(tr("Don't show this message again"));
questionbox.setCheckBox(chkbox);
chkbox->setChecked(!video_fullscreen_first);
@@ -1294,9 +1341,78 @@ MainWindow::getTitle(wchar_t *title)
}
}
// Helper to find an accelerator key and return it's sequence
// TODO: Is there a more central place to put this?
QKeySequence
MainWindow::FindAcceleratorSeq(const char *name)
{
int accID = FindAccelerator(name);
if(accID == -1)
return false;
return(QKeySequence::fromString(acc_keys[accID].seq));
}
bool
MainWindow::eventFilter(QObject *receiver, QEvent *event)
{
// Detect shortcuts when menubar is hidden
// TODO: Could this be simplified by proxying the event and manually
// shoving it into the menubar?
if (event->type() == QEvent::KeyPress)
{
this->keyPressEvent((QKeyEvent *) event);
// We check for mouse release even if we aren't fullscreen,
// because it's not a menu accelerator.
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *ke = (QKeyEvent *) event;
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("release_mouse"))
{
plat_mouse_capture(0);
}
}
if (event->type() == QEvent::KeyPress && video_fullscreen != 0)
{
QKeyEvent *ke = (QKeyEvent *) event;
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("screenshot"))
{
ui->actionTake_screenshot->trigger();
}
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("fullscreen"))
{
ui->actionFullscreen->trigger();
}
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("hard_reset"))
{
ui->actionHard_Reset->trigger();
}
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_del"))
{
ui->actionCtrl_Alt_Del->trigger();
}
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("send_ctrl_alt_esc"))
{
ui->actionCtrl_Alt_Esc->trigger();
}
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("pause"))
{
ui->actionPause->trigger();
}
if ((QKeySequence)(ke->key() | ke->modifiers()) == FindAcceleratorSeq("mute"))
{
ui->actionMute_Unmute->trigger();
}
return true;
}
}
if (!dopause) {
if (event->type() == QEvent::Shortcut) {
auto shortcutEvent = (QShortcutEvent *) event;
@@ -1306,8 +1422,8 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event)
}
}
if (event->type() == QEvent::KeyPress) {
event->accept();
this->keyPressEvent((QKeyEvent *) event);
event->accept();
return true;
}
if (event->type() == QEvent::KeyRelease) {
@@ -1327,7 +1443,7 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event)
plat_pause(curdopause);
}
}
return QMainWindow::eventFilter(receiver, event);
}
@@ -1393,10 +1509,7 @@ MainWindow::keyPressEvent(QKeyEvent *event)
processKeyboardInput(true, event->nativeScanCode());
#endif
}
if (keyboard_ismsexit())
plat_mouse_capture(0);
event->accept();
}

View File

@@ -5,6 +5,7 @@
#include <QLabel>
#include <QEvent>
#include <QFocusEvent>
#include <QShortcut>
#include <memory>
#include <array>
@@ -32,7 +33,10 @@ public:
QSize getRenderWidgetSize();
void setSendKeyboardInput(bool enabled);
void reloadAllRenderers();
QShortcut *windowedShortcut;
QKeySequence FindAcceleratorSeq(const char *name);
std::array<std::unique_ptr<RendererStack>, 8> renderers;
signals:
void paint(const QImage &image);
@@ -159,6 +163,7 @@ private:
std::unique_ptr<MachineStatus> status;
std::shared_ptr<MediaMenu> mm;
void updateShortcuts();
void processKeyboardInput(bool down, uint32_t keycode);
#ifdef Q_OS_MACOS
uint32_t last_modifiers = 0;
@@ -184,7 +189,6 @@ private:
friend class RendererStack; // For UI variable access by non-primary renderer windows.
friend class WindowsRawInputFilter; // Needed to reload renderers on style sheet changes.
bool isShowMessage = false;
};

View File

@@ -595,8 +595,14 @@ ProgSettings::reloadStrings()
{
translatedstrings.clear();
translatedstrings[STRING_MOUSE_CAPTURE] = QCoreApplication::translate("", "Click to capture mouse").toStdWString();
translatedstrings[STRING_MOUSE_RELEASE] = QCoreApplication::translate("", "Press %1 to release mouse").arg(QCoreApplication::translate("", MOUSE_CAPTURE_KEYSEQ)).toStdWString();
translatedstrings[STRING_MOUSE_RELEASE_MMB] = QCoreApplication::translate("", "Press %1 or middle button to release mouse").arg(QCoreApplication::translate("", MOUSE_CAPTURE_KEYSEQ)).toStdWString();
char mouseCaptureKeyseq[100];
sprintf(mouseCaptureKeyseq, qPrintable(QCoreApplication::translate("", "Press %s to release mouse")), acc_keys[FindAccelerator("release_mouse")].seq);
translatedstrings[STRING_MOUSE_RELEASE] = QString(mouseCaptureKeyseq).toStdWString();
sprintf(mouseCaptureKeyseq, qPrintable(QCoreApplication::translate("", "Press %s or middle button to release mouse")), acc_keys[FindAccelerator("release_mouse")].seq);
translatedstrings[STRING_MOUSE_RELEASE_MMB] = QString(mouseCaptureKeyseq).toStdWString();
translatedstrings[STRING_INVALID_CONFIG] = QCoreApplication::translate("", "Invalid configuration").toStdWString();
translatedstrings[STRING_NO_ST506_ESDI_CDROM] = QCoreApplication::translate("", "MFM/RLL or ESDI CD-ROM drives never existed").toStdWString();
translatedstrings[STRING_PCAP_ERROR_NO_DEVICES] = QCoreApplication::translate("", "No PCap devices found").toStdWString();

View File

@@ -16,8 +16,12 @@
*/
#include "qt_settingsinput.hpp"
#include "ui_qt_settingsinput.h"
#include "qt_mainwindow.hpp"
#include "qt_progsettings.hpp"
#include <QDebug>
#include <QKeySequence>
#include <string>
extern "C" {
#include <86box/86box.h>
@@ -25,11 +29,18 @@ extern "C" {
#include <86box/machine.h>
#include <86box/mouse.h>
#include <86box/gameport.h>
#include <86box/ui.h>
}
#include "qt_models_common.hpp"
#include "qt_deviceconfig.hpp"
#include "qt_joystickconfiguration.hpp"
#include "qt_keybind.hpp"
extern MainWindow *main_window;
// Temporary working copy of key list
accelKey acc_keys_t[NUM_ACCELS];
SettingsInput::SettingsInput(QWidget *parent)
: QWidget(parent)
@@ -37,9 +48,51 @@ SettingsInput::SettingsInput(QWidget *parent)
{
ui->setupUi(this);
QStandardItemModel *model;
QStringList horizontalHeader;
QStringList verticalHeader;
horizontalHeader.append(tr("Action"));
horizontalHeader.append(tr("Keybind"));
QTableWidget *keyTable = ui->tableKeys;
keyTable->setRowCount(10);
keyTable->setColumnCount(3);
keyTable->setColumnHidden(2, true);
keyTable->setColumnWidth(0, 200);
keyTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
QStringList headers;
//headers << "Action" << "Bound key";
keyTable->setHorizontalHeaderLabels(headers);
keyTable->verticalHeader()->setVisible(false);
keyTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
keyTable->setSelectionBehavior(QAbstractItemView::SelectRows);
keyTable->setSelectionMode(QAbstractItemView::SingleSelection);
keyTable->setShowGrid(true);
// Make a working copy of acc_keys so we can check for dupes later without getting
// confused
for(int x=0;x<NUM_ACCELS;x++) {
strcpy(acc_keys_t[x].name, acc_keys[x].name);
strcpy(acc_keys_t[x].desc, acc_keys[x].desc);
strcpy(acc_keys_t[x].seq, acc_keys[x].seq);
}
refreshInputList();
connect(ui->tableKeys, &QTableWidget::cellDoubleClicked,
this, &SettingsInput::on_tableKeys_doubleClicked);
connect(ui->pushButtonBind, &QPushButton::clicked,
this, &SettingsInput::on_pushButtonBind_Clicked);
connect(ui->pushButtonClearBind, &QPushButton::clicked,
this, &SettingsInput::on_pushButtonClearBind_Clicked);
onCurrentMachineChanged(machine);
}
SettingsInput::~SettingsInput()
{
delete ui;
@@ -50,8 +103,16 @@ SettingsInput::save()
{
mouse_type = ui->comboBoxMouse->currentData().toInt();
joystick_type = ui->comboBoxJoystick->currentData().toInt();
// Copy accelerators from working set to global set
for(int x=0;x<NUM_ACCELS;x++) {
strcpy(acc_keys[x].name, acc_keys_t[x].name);
strcpy(acc_keys[x].desc, acc_keys_t[x].desc);
strcpy(acc_keys[x].seq, acc_keys_t[x].seq);
}
ProgSettings::reloadStrings();
}
void
SettingsInput::onCurrentMachineChanged(int machineId)
{
@@ -105,6 +166,100 @@ SettingsInput::onCurrentMachineChanged(int machineId)
ui->comboBoxJoystick->setCurrentIndex(selectedRow);
}
void
SettingsInput::refreshInputList()
{
for (int x=0;x<NUM_ACCELS;x++) {
ui->tableKeys->setItem(x, 0, new QTableWidgetItem(tr(acc_keys_t[x].desc)));
ui->tableKeys->setItem(x, 1, new QTableWidgetItem(acc_keys_t[x].seq));
ui->tableKeys->setItem(x, 2, new QTableWidgetItem(acc_keys_t[x].name));
}
}
void
SettingsInput::on_tableKeys_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
{
// Enable/disable bind/clear buttons if user clicked valid row
QTableWidgetItem *cell = ui->tableKeys->item(currentRow,1);
if (!cell)
{
ui->pushButtonBind->setEnabled(false);
ui->pushButtonClearBind->setEnabled(false);
}
else
{
ui->pushButtonBind->setEnabled(true);
ui->pushButtonClearBind->setEnabled(true);
}
}
void
SettingsInput::on_tableKeys_doubleClicked(int row, int col)
{
// Edit bind
QTableWidgetItem *cell = ui->tableKeys->item(row,1);
if (!cell) return;
QKeySequence keyseq = KeyBinder::BindKey(cell->text());
if (keyseq != false) {
// If no change was made, don't change anything.
if (keyseq.toString(QKeySequence::NativeText) == cell->text()) return;
// Otherwise, check for conflicts.
// Check against the *working* copy - NOT the one in use by the app,
// so we don't test against shortcuts the user already changed.
for(int x=0;x<NUM_ACCELS;x++)
{
if(QString::fromStdString(acc_keys_t[x].seq) == keyseq.toString(QKeySequence::NativeText))
{
// That key is already in use
main_window->showMessage(MBX_ANSI & MBX_INFO, "Bind conflict", "This key combo is already in use", false);
return;
}
}
// If we made it here, there were no conflicts.
// Go ahead and apply the bind.
// Find the correct accelerator key entry
int accKeyID = FindAccelerator(qPrintable(ui->tableKeys->item(row,2)->text()));
if (accKeyID < 0) return; // this should never happen
// Make the change
cell->setText(keyseq.toString(QKeySequence::NativeText));
strcpy(acc_keys_t[accKeyID].seq, qPrintable(keyseq.toString(QKeySequence::NativeText)));
refreshInputList();
}
}
void
SettingsInput::on_pushButtonBind_Clicked()
{
// Edit bind
QTableWidgetItem *cell = ui->tableKeys->currentItem();
if (!cell) return;
on_tableKeys_doubleClicked(cell->row(), cell->column());
}
void
SettingsInput::on_pushButtonClearBind_Clicked()
{
// Wipe bind
QTableWidgetItem *cell = ui->tableKeys->currentItem();
if (!cell) return;
cell->setText("");
// Find the correct accelerator key entry
int accKeyID = FindAccelerator(qPrintable(ui->tableKeys->item(cell->row(),2)->text()));
if (accKeyID < 0) return; // this should never happen
// Make the change
cell->setText("");
strcpy(acc_keys_t[accKeyID].seq, "");
}
void
SettingsInput::on_comboBoxMouse_currentIndexChanged(int index)
{

View File

@@ -2,6 +2,12 @@
#define QT_SETTINGSINPUT_HPP
#include <QWidget>
#include <QtGui/QStandardItemModel>
#include <QtGui/QStandardItem>
#include <QItemDelegate>
#include <QPainter>
#include <QVariant>
#include <QTableWidget>
namespace Ui {
class SettingsInput;
@@ -27,10 +33,15 @@ private slots:
void on_pushButtonJoystick2_clicked();
void on_pushButtonJoystick3_clicked();
void on_pushButtonJoystick4_clicked();
void on_tableKeys_doubleClicked(int row, int col);
void on_tableKeys_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);
void on_pushButtonBind_Clicked();
void on_pushButtonClearBind_Clicked();
private:
Ui::SettingsInput *ui;
int machineId = 0;
void refreshInputList();
};
#endif // QT_SETTINGSINPUT_HPP

View File

@@ -23,17 +23,16 @@
<property name="rightMargin">
<number>0</number>
</property>
<item row="2" column="1">
<widget class="QPushButton" name="pushButtonJoystick2">
<property name="text">
<string>Joystick 2...</string>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="comboBoxMouse">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Joystick:</string>
<property name="maxVisibleItems">
<number>30</number>
</property>
</widget>
</item>
@@ -44,13 +43,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Mouse:</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButtonJoystick3">
<property name="text">
@@ -58,21 +50,15 @@
</property>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="5" column="3">
<widget class="QPushButton" name="pushButtonBind">
<property name="enabled">
<bool>false</bool>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
<property name="text">
<string>Bind</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="pushButtonJoystick1">
@@ -81,6 +67,44 @@
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="comboBoxJoystick">
<property name="maxVisibleItems">
<number>30</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Mouse:</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QPushButton" name="pushButtonClearBind">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Clear binding</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Joystick:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pushButtonJoystick2">
<property name="text">
<string>Joystick 2...</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pushButtonConfigureMouse">
<property name="sizePolicy">
@@ -94,23 +118,29 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="comboBoxMouse">
<property name="maxVisibleItems">
<number>30</number>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Key Bindings:</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="comboBoxJoystick">
<property name="maxVisibleItems">
<number>30</number>
<item row="4" column="0" colspan="4">
<widget class="QTableWidget" name="tableKeys">
<property name="editTriggers">
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
</property>
<property name="tabKeyNavigation">
<bool>false</bool>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
</property>
</widget>
</item>

View File

@@ -0,0 +1,20 @@
#include "qt_singlekeyseqedit.hpp"
/*
This subclass of QKeySequenceEdit restricts the input to only a single
shortcut instead of an unlimited number with a fixed timeout.
*/
singleKeySequenceEdit::singleKeySequenceEdit(QWidget *parent) : QKeySequenceEdit(parent) {}
void singleKeySequenceEdit::keyPressEvent(QKeyEvent *event)
{
QKeySequenceEdit::keyPressEvent(event);
if (this->keySequence().count() > 0) {
QKeySequenceEdit::setKeySequence(this->keySequence());
// This could have unintended consequences since it will happen
// every single time the user presses a key.
emit editingFinished();
}
}

View File

@@ -0,0 +1,16 @@
#ifndef SINGLEKEYSEQUENCEEDIT_H
#define SINGLEKEYSEQUENCEEDIT_H
#include <QKeySequenceEdit>
#include <QWidget>
class singleKeySequenceEdit : public QKeySequenceEdit
{
Q_OBJECT
public:
singleKeySequenceEdit(QWidget *parent = nullptr);
void keyPressEvent(QKeyEvent *) override;
};
#endif // SINGLEKEYSEQUENCEEDIT_H

View File

@@ -1338,9 +1338,6 @@ main(int argc, char **argv)
}
}
}
if (mouse_capture && keyboard_ismsexit()) {
plat_mouse_capture(0);
}
if (blitreq) {
extern void sdl_blit(int x, int y, int w, int h);
sdl_blit(params.x, params.y, params.w, params.h);