Add J-PAC/I-PAC support
* Update cfg.cpp * Update cfg.h * Update input.cpp Add support for J-PAC/I-PAC * Update MiSTer.ini Added J-PAC/I-PAC VID/PIDs to ini
This commit is contained in:
69
input.cpp
69
input.cpp
@@ -853,6 +853,7 @@ enum QUIRK
|
||||
QUIRK_PDSP,
|
||||
QUIRK_PDSP_ARCADE,
|
||||
QUIRK_JAMMASD,
|
||||
QUIRK_JPAC,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@@ -2679,6 +2680,54 @@ static struct
|
||||
{KEY_L, 2, 0x12D}, // 2P 8
|
||||
};
|
||||
|
||||
// J-PAC/I-PAC has shifted keys: when 1P start is kept pressed, it acts as a shift key,
|
||||
// outputting other key signals. Example: 1P start + 2P start = KEY_ESC
|
||||
// Shifted keys are passed as normal keyboard keys.
|
||||
static struct
|
||||
{
|
||||
uint16_t key;
|
||||
uint16_t player;
|
||||
uint16_t btn;
|
||||
} jpac2joy[] =
|
||||
{
|
||||
{KEY_5, 1, 0x120}, // 1P coin (shift + 1P 1)
|
||||
{KEY_1, 1, 0x121}, // 1P start (shift key)
|
||||
{KEY_UP, 1, 0x122}, // 1P up
|
||||
{KEY_DOWN, 1, 0x123}, // 1P down
|
||||
{KEY_LEFT, 1, 0x124}, // 1P left
|
||||
{KEY_RIGHT, 1, 0x125}, // 1P right
|
||||
{KEY_LEFTCTRL, 1, 0x126}, // 1P 1
|
||||
{KEY_LEFTALT, 1, 0x127}, // 1P 2
|
||||
{KEY_SPACE, 1, 0x128}, // 1P 3
|
||||
{KEY_LEFTSHIFT, 1, 0x129}, // 1P 4
|
||||
{KEY_Z, 1, 0x12A}, // 1P 5
|
||||
{KEY_X, 1, 0x12B}, // 1P 6
|
||||
{KEY_C, 1, 0x12C}, // 1P 7
|
||||
{KEY_V, 1, 0x12D}, // 1P 8
|
||||
{KEY_TAB, 1, 0x12E}, // Tab (shift + 1P right)
|
||||
{KEY_ENTER, 1, 0x12F}, // Enter (shift + 1P left)
|
||||
// ~ Tidle supportted?
|
||||
{KEY_P, 1, 0x131}, // P (pause) (shift + 1P down)
|
||||
{KEY_F1, 1, 0x132}, // Service
|
||||
{KEY_F2, 1, 0x133}, // Test
|
||||
{KEY_F3, 1, 0x134}, // Tilt
|
||||
|
||||
{KEY_6, 2, 0x120}, // 2P coin
|
||||
{KEY_2, 2, 0x121}, // 2P start
|
||||
{KEY_R, 2, 0x122}, // 2P up
|
||||
{KEY_F, 2, 0x123}, // 2P down
|
||||
{KEY_D, 2, 0x124}, // 2P left
|
||||
{KEY_G, 2, 0x125}, // 2P right
|
||||
{KEY_A, 2, 0x126}, // 2P 1
|
||||
{KEY_S, 2, 0x127}, // 2P 2
|
||||
{KEY_Q, 2, 0x128}, // 2P 3
|
||||
{KEY_W, 2, 0x129}, // 2P 4
|
||||
{KEY_I, 2, 0x12A}, // 2P 5
|
||||
{KEY_K, 2, 0x12B}, // 2P 6
|
||||
{KEY_J, 2, 0x12C}, // 2P 7
|
||||
{KEY_L, 2, 0x12D}, // 2P 8
|
||||
};
|
||||
|
||||
int input_test(int getchar)
|
||||
{
|
||||
static char cur_leds = 0;
|
||||
@@ -2855,6 +2904,12 @@ int input_test(int getchar)
|
||||
input[n].quirk = QUIRK_JAMMASD;
|
||||
}
|
||||
|
||||
//J-PAC/I-PAC
|
||||
if (cfg.jpac_vid && cfg.jpac_pid && input[n].vid == cfg.jpac_vid && input[n].pid == cfg.jpac_pid)
|
||||
{
|
||||
input[n].quirk = QUIRK_JPAC;
|
||||
}
|
||||
|
||||
//Arduino and Teensy devices may share the same VID:PID, so additional field UNIQ is used to differentiate them
|
||||
if ((input[n].vid == 0x2341 || (input[n].vid == 0x16C0 && (input[n].pid>>8) == 0x4)) && strlen(uniq))
|
||||
{
|
||||
@@ -3095,6 +3150,20 @@ int input_test(int getchar)
|
||||
}
|
||||
}
|
||||
|
||||
if (input[dev].quirk == QUIRK_JPAC && ev.type == EV_KEY)
|
||||
{
|
||||
input[dev].num = 0;
|
||||
for (uint32_t i = 0; i <= sizeof(jpac2joy) / sizeof(jpac2joy[0]); i++)
|
||||
{
|
||||
if (jpac2joy[i].key == ev.code)
|
||||
{
|
||||
ev.code = jpac2joy[i].btn;
|
||||
input[dev].num = jpac2joy[i].player;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Menu combo on 8BitDo receiver in PSC mode
|
||||
if (input[dev].vid == 0x054c && input[dev].pid == 0x0cda && ev.type == EV_KEY)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user