From 12974d0df6be3cde6faaa8620f239f40410efa12 Mon Sep 17 00:00:00 2001 From: Gyorgy Szombathelyi Date: Thu, 18 Apr 2019 14:47:21 +0200 Subject: [PATCH 1/4] Don't send digital USB joystick events continously It just confuses joystick emulation --- usb/hid.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/usb/hid.c b/usb/hid.c index fcf531d..4a1a294 100644 --- a/usb/hid.c +++ b/usb/hid.c @@ -776,12 +776,15 @@ static void usb_process_iface (usb_hid_iface_info_t *iface, // if real DB9 mouse is preffered, switch the id back to 1 idx = (idx == 0) && mist_cfg.joystick0_prefer_db9 ? 1 : idx; - // run even if not changed - user_io_digital_joystick(idx, jmap); + // don't run if not changed + if (vjoy != iface->jmap) { + user_io_digital_joystick(idx, jmap); + // new API with all extra buttons + user_io_digital_joystick_ext(idx, vjoy); + } + + iface->jmap = vjoy; - // new API with all extra buttons - user_io_digital_joystick_ext(idx, vjoy); - // also send analog values user_io_analog_joystick(idx, a[0]-128, a[1]-128); From 57b41474afc3df09822a1fc9e62d0dd0485e43cb Mon Sep 17 00:00:00 2001 From: Gyorgy Szombathelyi Date: Thu, 18 Apr 2019 18:12:12 +0200 Subject: [PATCH 2/4] Option to (un)follow DB9 renumbering with joystick emulation joystick_emu_fixed_index - default 0(off) --- mist.ini | 3 ++- mist_cfg.c | 2 ++ mist_cfg.h | 1 + user_io.c | 20 +++++++++++--------- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/mist.ini b/mist.ini index 8b1fd25..96fba7e 100644 --- a/mist.ini +++ b/mist.ini @@ -3,5 +3,6 @@ scandoubler_disable=0 ; set to 1 to run supported cores in 15khz joystick_disable_shortcuts=0 ; set to 1 to remove joystick -> keyboard commands joystick_ignore_hat=0 ; set to 1 if having issues on gamepads with 'POV hat' mouse_boot_mode=0 ; set to 1 if a mouse does not work well +joystick_emu_fixed_index=0 ; set to 1 for always emulating the first two joystick via keyboard joystick_remap=0583,2060,1,2,4,8,10,20,20,8,400,800,40,80 -key_menu_as_rgui=0 ; set to 1 to make the MENU key map to RGUI in Minimig (e.g. for Right Amiga) \ No newline at end of file +key_menu_as_rgui=0 ; set to 1 to make the MENU key map to RGUI in Minimig (e.g. for Right Amiga) diff --git a/mist_cfg.c b/mist_cfg.c index 0e1fd14..b3aaea8 100644 --- a/mist_cfg.c +++ b/mist_cfg.c @@ -31,6 +31,7 @@ mist_cfg_t mist_cfg = { .joystick_ignore_osd = 0, .joystick_disable_shortcuts = 0, .joystick0_prefer_db9 = 0, + .joystick_emu_fixed_index = 0, .key_menu_as_rgui = 0, .keyrah_mode = 0, .reset_combo = 0, @@ -57,6 +58,7 @@ const ini_var_t mist_ini_vars[] = { {"JOYSTICK_DISABLE_SHORTCUTS", (void*)(&(mist_cfg.joystick_disable_shortcuts)), UINT8, 0, 1, 1}, {"JOYSTICK_IGNORE_OSD", (void*)(&(mist_cfg.joystick_ignore_osd)), UINT8, 0, 1, 1}, {"JOYSTICK0_PREFER_DB9", (void*)(&(mist_cfg.joystick0_prefer_db9)), UINT8, 0, 1, 1}, + {"JOYSTICK_EMU_FIXED_INDEX", (void*)(&(mist_cfg.joystick_emu_fixed_index)), UINT8, 0, 1, 1}, {"KEY_MENU_AS_RGUI", (void*)(&(mist_cfg.key_menu_as_rgui)), UINT8, 0, 1, 1}, {"KEY_REMAP", (void*)user_io_key_remap, CUSTOM_HANDLER, 0, 0, 1}, {"HID_BUTTON_REMAP", (void*)hid_joystick_button_remap, CUSTOM_HANDLER, 0, 0, 1}, diff --git a/mist_cfg.h b/mist_cfg.h index 038b5f2..867d4f6 100644 --- a/mist_cfg.h +++ b/mist_cfg.h @@ -20,6 +20,7 @@ typedef struct { uint8_t joystick_ignore_osd; uint8_t joystick_disable_shortcuts; uint8_t joystick0_prefer_db9; + uint8_t joystick_emu_fixed_index; uint8_t key_menu_as_rgui; uint8_t reset_combo; uint8_t ypbpr; diff --git a/user_io.c b/user_io.c index bcf9f34..7400574 100644 --- a/user_io.c +++ b/user_io.c @@ -562,6 +562,14 @@ static uint8_t joystick_renumber(uint8_t j) { return j; } +void user_io_joystick_emu() { + // iprintf("joystick_emu_fixed_index: %d\n", mist_cfg.joystick_emu_fixed_index); + // joystick emulation also follows renumbering if requested (default) + if(emu_mode == EMU_JOY0) user_io_joystick(mist_cfg.joystick_emu_fixed_index ? 0 : joystick_renumber(0), emu_state); + if(emu_mode == EMU_JOY1) user_io_joystick(mist_cfg.joystick_emu_fixed_index ? 1 : joystick_renumber(1), emu_state); +} + + // 16 byte fifo for amiga key codes to limit max key rate sent into the core #define KBD_FIFO_SIZE 16 // must be power of 2 static unsigned short kbd_fifo[KBD_FIFO_SIZE]; @@ -1790,8 +1798,7 @@ void user_io_kbd(unsigned char m, unsigned char *k, uint8_t priority, unsigned s // check if state of joystick buttons has changed if(last_btn != (emu_state & (JOY_BTN1|JOY_BTN2|JOY_BTN3|JOY_BTN4))) { - if(emu_mode == EMU_JOY0) user_io_joystick(joystick_renumber(0), emu_state); - if(emu_mode == EMU_JOY1) user_io_joystick(joystick_renumber(1), emu_state); + user_io_joystick_emu(); } } @@ -1858,8 +1865,7 @@ void user_io_kbd(unsigned char m, unsigned char *k, uint8_t priority, unsigned s if(is_emu_key(pressed[i], keyrah) && !osd_is_visible) { emu_state &= ~is_emu_key(pressed[i], keyrah); - if(emu_mode == EMU_JOY0) user_io_joystick(joystick_renumber(0), emu_state); - if(emu_mode == EMU_JOY1) user_io_joystick(joystick_renumber(1), emu_state); + user_io_joystick_emu(); if(keyrah == 2) { unsigned char b; @@ -1913,11 +1919,7 @@ void user_io_kbd(unsigned char m, unsigned char *k, uint8_t priority, unsigned s if(is_emu_key(k[i], keyrah) && !osd_is_visible) { emu_state |= is_emu_key(k[i], keyrah); - - // joystick emulation is also affected by the presence of - // usb joysticks - if(emu_mode == EMU_JOY0) user_io_joystick(joystick_renumber(0), emu_state); - if(emu_mode == EMU_JOY1) user_io_joystick(joystick_renumber(1), emu_state); + user_io_joystick_emu(); if(keyrah == 2) { unsigned char b; From 03c340441324bb2cfc565e73999569a3fb1dccbc Mon Sep 17 00:00:00 2001 From: Gyorgy Szombathelyi Date: Thu, 18 Apr 2019 19:08:00 +0200 Subject: [PATCH 3/4] Fix a buffer index error (count = 0 -> buffer index = -1) in joymapping --- usb/joymapping.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/usb/joymapping.c b/usb/joymapping.c index 5524eb1..65b8b95 100644 --- a/usb/joymapping.c +++ b/usb/joymapping.c @@ -95,11 +95,10 @@ void virtual_joystick_remap(char *s) { token = strtok (s, ","); while(token!=NULL) { //if (count==0) joystick_mappers[i].vid = strtol(token, NULL, 16); -- VID mapping already done - value = strtol(token, NULL, 16); + value = strtol(token, NULL, 16); if (count==1) { joystick_mappers[i].pid = value; - } - else { + } else if (count >= 2) { //parse sub-tokens sequentially and assign 16-bit value to them joystick_mappers[i].mapping[off+count-2] = value; hid_debugf("parsed: %x/%x %d -> %d", From b59c761dafd03fd0432c4a7119144cfec4197a0e Mon Sep 17 00:00:00 2001 From: Gyorgy Szombathelyi Date: Thu, 18 Apr 2019 19:09:18 +0200 Subject: [PATCH 4/4] Increase ini line length to 90 --- ini_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ini_parser.c b/ini_parser.c index 43221e3..c74e66f 100644 --- a/ini_parser.c +++ b/ini_parser.c @@ -21,7 +21,7 @@ #define INI_EOT 4 // End-Of-Transmission #define INI_BUF_SIZE 512 -#define INI_LINE_SIZE 65 +#define INI_LINE_SIZE 90 #define INI_SECTION_START '[' #define INI_SECTION_END ']'