mirror of
https://github.com/mist-devel/mist-firmware.git
synced 2026-02-12 18:47:09 +00:00
Merge pull request #30 from gyurco/master
Joystick emulation via keyboard shouldn't be affected by renumbering
This commit is contained in:
@@ -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 ']'
|
||||
|
||||
3
mist.ini
3
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)
|
||||
key_menu_as_rgui=0 ; set to 1 to make the MENU key map to RGUI in Minimig (e.g. for Right Amiga)
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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;
|
||||
|
||||
13
usb/hid.c
13
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);
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
20
user_io.c
20
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;
|
||||
|
||||
Reference in New Issue
Block a user