static int event_joystick(SDL_JoyAxisEvent a) { static int last = 0; int direction = last; if (a.axis == 0) { direction &= ~(IKBD_JOY_RIGHT | IKBD_JOY_LEFT); if (a.value > 5000) direction |= IKBD_JOY_RIGHT; else if (a.value < -5000) direction |= IKBD_JOY_LEFT; } else if(a.axis == 1) { direction &= ~(IKBD_JOY_UP | IKBD_JOY_DOWN); if (a.value > 5000) direction |= IKBD_JOY_DOWN; else if (a.value < -5000) direction |= IKBD_JOY_UP; } if (direction != last) ikbd_joystick(direction); last = direction; return EVENT_NONE; }
void user_io_digital_joystick(unsigned char joystick, unsigned char map) { // if osd is open control it via joystick if(osd_is_visible) { static const uint8_t joy2kbd[] = { OSDCTRLMENU, OSDCTRLMENU, OSDCTRLMENU, OSDCTRLSELECT, OSDCTRLUP, OSDCTRLDOWN, OSDCTRLLEFT, OSDCTRLRIGHT }; static uint8_t last_map = 0; // iprintf("joy to osd\n"); // OsdKeySet(0x80 | usb2ami[pressed[i]]); return; } // iprintf("j%d: %x\n", joystick, map); // "only" 6 joysticks are supported if(joystick >= 6) return; // mist cores process joystick events for joystick 0 and 1 via the // ikbd if((core_type == CORE_TYPE_MINIMIG) || (core_type == CORE_TYPE_MINIMIG2) || (core_type == CORE_TYPE_PACE) || (core_type == CORE_TYPE_ARCHIE) || ((core_type == CORE_TYPE_MIST) && (joystick >= 2)) || (core_type == CORE_TYPE_8BIT)) { // joystick 3 and 4 were introduced later spi_uio_cmd8((joystick < 2)?(UIO_JOYSTICK0 + joystick):((UIO_JOYSTICK2 + joystick - 2)), map); } // atari ST handles joystick 0 and 1 through the ikbd emulated by the io controller if((core_type == CORE_TYPE_MIST) && (joystick < 2)) ikbd_joystick(joystick, map); }