diff --git a/input.cpp b/input.cpp index ce8bbb0..496bb8f 100644 --- a/input.cpp +++ b/input.cpp @@ -991,6 +991,7 @@ enum QUIRK QUIRK_DS4, QUIRK_DS4TOUCH, QUIRK_MADCATZ360, + QUIRK_PDSP, }; typedef struct @@ -1032,6 +1033,7 @@ typedef struct } devInput; static devInput input[NUMDEV] = {}; +static int pd_mode[NUMDEV] = {}; #define BTN_NUM (sizeof(devInput::map) / sizeof(devInput::map[0])) @@ -1778,7 +1780,14 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int if (!input[dev].has_map) { - if (!FileLoadJoymap(get_map_name(dev, 0), &input[dev].map, sizeof(input[dev].map))) + if (input[dev].quirk == QUIRK_PDSP) + { + memset(input[dev].map, 0, sizeof(input[dev].map)); + input[dev].map[SYS_BTN_A] = 0x01220120; + input[dev].map[SPIN_LEFT] = 0x123; + input[dev].map[SPIN_RIGHT] = 0x124; + } + else if (!FileLoadJoymap(get_map_name(dev, 0), &input[dev].map, sizeof(input[dev].map))) { memset(input[dev].map, 0, sizeof(input[dev].map)); if (!is_menu_core()) @@ -1846,7 +1855,9 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int } //mapping - if (mapping && (mapping_dev >= 0 || ev->value) && !((mapping_type < 2 || !mapping_button) && (cancel || enter))) + if (mapping && (mapping_dev >= 0 || ev->value) + && !((mapping_type < 2 || !mapping_button) && (cancel || enter)) + && input[dev].quirk != QUIRK_PDSP) { int idx = 0; @@ -2161,8 +2172,12 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int int found = 0; for (int i = 0; i < NUMDEV; i++) { - found = (input[i].num == num); - if (found) break; + // paddles overlay on top of other gamepad + if ((input[dev].quirk != QUIRK_PDSP) || (input[i].quirk == QUIRK_PDSP)) + { + found = (input[i].num == num); + if (found) break; + } } if (!found) @@ -2173,6 +2188,15 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int } } + if (input[dev].quirk == QUIRK_PDSP) + { + if (ev->code == 0x120) pd_mode[input[dev].num] = 1; + } + else + { + pd_mode[input[dev].num] = 0; + } + if (input[dev].lightgun_req && !user_io_osd_is_visible()) { if (osd_event == 1) @@ -2445,6 +2469,9 @@ static void input_cb(struct input_event *ev, struct input_absinfo *absinfo, int case EV_ABS: if (!user_io_osd_is_visible()) { + // allow analog either from overlaid paddle or gamepad + if (pd_mode[input[dev].num] ^ (input[dev].quirk == QUIRK_PDSP)) break; + int hrange = (absinfo->maximum - absinfo->minimum) / 2; int dead = hrange/63; @@ -2697,6 +2724,12 @@ int input_test(int getchar) input[n].quirk = QUIRK_MADCATZ360; } + if (!strcasecmp(input[n].uniq, "MiSTer PD/SP v1")) + { + input[n].quirk = QUIRK_PDSP; + memset(input[n].uniq, 0, sizeof(input[n].uniq)); + } + ioctl(pool[n].fd, EVIOCGRAB, (grabbed | user_io_osd_is_visible()) ? 1 : 0); n++; @@ -3089,7 +3122,7 @@ int input_test(int getchar) if (!noabs) input_cb(&ev, &absinfo, i); //sumulate digital directions from analog - if (ev.type == EV_ABS && !(mapping && mapping_type <= 1 && mapping_button < -4) && !(ev.code <= 1 && input[dev].lightgun)) + if (ev.type == EV_ABS && !(mapping && mapping_type <= 1 && mapping_button < -4) && !(ev.code <= 1 && input[dev].lightgun) && input[dev].quirk != QUIRK_PDSP) { input_absinfo *pai = 0; uint8_t axis_edge = 0; diff --git a/input.h b/input.h index 151aee2..f4fb6f9 100644 --- a/input.h +++ b/input.h @@ -66,6 +66,9 @@ #define SYS_BTN_CNT_OK 21 #define SYS_BTN_CNT_ESC 22 +#define SPIN_LEFT 30 +#define SPIN_RIGHT 31 + #define KEY_EMU (KEY_MAX+1) void set_kbdled(int mask, int state); diff --git a/user_io.cpp b/user_io.cpp index c0fd4ff..9286eb4 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -969,9 +969,12 @@ void user_io_digital_joystick(unsigned char joystick, uint32_t map, int newdir) return; } + static int use32 = 0; + use32 |= map >> 16; + spi_uio_cmd_cont((joy < 2) ? (UIO_JOYSTICK0 + joy) : (UIO_JOYSTICK2 + joy - 2)); spi_w(map); - if(joy_bcount>12) spi_w(map>>16); + if(use32) spi_w(map>>16); DisableIO(); if (!is_minimig() && joy_transl == 1 && newdir)