|
|
1.1 root 1: /* 1.1.1.4 root 2: Hatari - joy.c 1.1 root 3: 1.1.1.14! root 4: This file is distributed under the GNU General Public License, version 2 ! 5: or at your option any later version. Read the file gpl.txt for details. 1.1.1.4 root 6: 7: Joystick routines. 1.1 root 8: 1.1.1.6 root 9: NOTE: The ST uses the joystick port 1 as the default controller. 1.1 root 10: */ 1.1.1.10 root 11: const char Joy_fileid[] = "Hatari joy.c : " __DATE__ " " __TIME__; 1.1 root 12: 13: #include <SDL.h> 14: 15: #include "main.h" 16: #include "configuration.h" 1.1.1.6 root 17: #include "ioMem.h" 1.1 root 18: #include "joy.h" 1.1.1.5 root 19: #include "log.h" 1.1.1.12 root 20: #include "screen.h" 1.1.1.2 root 21: #include "video.h" 1.1 root 22: 1.1.1.2 root 23: #define JOY_BUTTON1 1 24: #define JOY_BUTTON2 2 1.1 root 25: 1.1.1.14! root 26: typedef struct ! 27: { ! 28: int XPos,YPos; /* the actually read axis values in range of -32768...0...32767 */ ! 29: int XAxisID,YAxisID; /* the IDs of the physical PC joystick's axis to be used to gain ST joystick axis input */ ! 30: int Buttons; /* JOY_BUTTON1 */ ! 31: } JOYREADING; ! 32: ! 33: typedef struct ! 34: { ! 35: const char *SDLJoystickName; ! 36: int XAxisID,YAxisID; /* the IDs associated with a certain SDL joystick */ ! 37: } JOYAXISMAPPING; 1.1.1.2 root 38: 1.1.1.13 root 39: static SDL_Joystick *sdlJoystick[ JOYSTICK_COUNT ] = /* SDL's joystick structures */ 1.1.1.6 root 40: { 41: NULL, NULL, NULL, NULL, NULL, NULL 42: }; 1.1.1.7 root 43: 1.1.1.13 root 44: /* Further explanation see JoyInit() */ 1.1.1.14! root 45: static JOYAXISMAPPING const *sdlJoystickMapping[ JOYSTICK_COUNT ] = /* references which axis are actually in use by the selected SDL joystick */ 1.1.1.13 root 46: { 47: NULL, NULL, NULL, NULL, NULL, NULL 48: }; 49: 50: static bool bJoystickWorking[ JOYSTICK_COUNT ] = /* Is joystick plugged in and working? */ 1.1.1.6 root 51: { 1.1.1.11 root 52: false, false, false, false, false, false 1.1.1.13 root 53: }; 1.1.1.6 root 54: 1.1.1.11 root 55: int JoystickSpaceBar = false; /* State of space-bar on joystick button 2 */ 1.1.1.13 root 56: static Uint8 nJoyKeyEmu[ JOYSTICK_COUNT ]; 1.1.1.7 root 57: static Uint16 nSteJoySelect; 1.1 root 58: 59: 60: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 61: /** 62: * This function initialises the (real) joysticks. 63: */ 1.1 root 64: void Joy_Init(void) 65: { 1.1.1.13 root 66: /* Joystick axis mapping table */ 67: /* Matthias Arndt <[email protected]> */ 68: /* Somehow, not all SDL joysticks are created equal. */ 69: /* Not all pads or sticks use axis 0 for x and axis 1 */ 70: /* for y information. */ 71: /* This table allows to remap the axis to used. */ 72: /* A joystick is identified by its SDL name and */ 73: /* followed by the X axis to use and the Y axis. */ 74: /* Find out the axis number with the tool jstest. */ 75: 76: /* FIXME: Read those settings from a configuration file and make them tunable from the GUI. */ 1.1.1.14! root 77: static const JOYAXISMAPPING AxisMappingTable [] = 1.1.1.13 root 78: { 1.1.1.14! root 79: /* USB game pad with ID ID 0079:0011, sold by Speedlink */ 1.1.1.13 root 80: {"USB Gamepad" , 3, 4}, 1.1.1.14! root 81: /* Default entry used if no other SDL joystick name does match (should be last of this list) */ 1.1.1.13 root 82: {"*DEFAULT*" , 0, 1}, 83: }; 84: 1.1.1.14! root 85: int i, j, nPadsConnected; 1.1.1.13 root 86: 1.1.1.6 root 87: /* Initialise SDL's joystick subsystem: */ 88: if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) 89: { 90: Log_Printf(LOG_ERROR, "Could not init joysticks: %s\n", SDL_GetError()); 91: return; 92: } 93: 94: /* Scan joystick connection array for working joysticks */ 95: nPadsConnected = SDL_NumJoysticks(); 1.1.1.13 root 96: for (i = 0; i < nPadsConnected && i < JOYSTICK_COUNT ; i++) 1.1.1.6 root 97: { 98: /* Open the joystick for use */ 99: sdlJoystick[i] = SDL_JoystickOpen(i); 100: /* Is joystick ok? */ 101: if (sdlJoystick[i] != NULL) 102: { 103: /* Set as working */ 1.1.1.11 root 104: bJoystickWorking[i] = true; 1.1.1.6 root 105: Log_Printf(LOG_DEBUG, "Joystick %i: %s\n", i, SDL_JoystickName(i)); 1.1.1.14! root 106: /* determine joystick axis mapping for given SDL joystick name, last is default: */ ! 107: for (j = 0; j < ARRAYSIZE(AxisMappingTable)-1; j++) { 1.1.1.13 root 108: /* check if ID string matches the one reported by SDL: */ 1.1.1.14! root 109: if(strncmp(AxisMappingTable[j].SDLJoystickName, SDL_JoystickName(i), strlen(AxisMappingTable[j].SDLJoystickName)) == 0) 1.1.1.13 root 110: break; 111: } 112: 1.1.1.14! root 113: sdlJoystickMapping[i] = &(AxisMappingTable[j]); ! 114: Log_Printf(LOG_DEBUG, "Joystick %i maps axis %d and %d (%s)\n", i, sdlJoystickMapping[i]->XAxisID, sdlJoystickMapping[i]->YAxisID, ! 115: sdlJoystickMapping[i]->SDLJoystickName ); 1.1.1.6 root 116: } 117: } 118: 1.1.1.11 root 119: JoystickSpaceBar = false; 1.1 root 120: } 121: 122: 1.1.1.2 root 123: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 124: /** 125: * Close the (real) joysticks. 126: */ 1.1.1.7 root 127: void Joy_UnInit(void) 128: { 129: int i, nPadsConnected; 130: 131: nPadsConnected = SDL_NumJoysticks(); 132: 1.1.1.13 root 133: for (i = 0; i < nPadsConnected && i < JOYSTICK_COUNT ; i++) 1.1.1.7 root 134: { 1.1.1.11 root 135: if (bJoystickWorking[i] == true) 1.1.1.7 root 136: { 137: SDL_JoystickClose(sdlJoystick[i]); 138: } 139: } 140: } 141: 142: 143: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 144: /** 145: * Read details from joystick using SDL calls 146: * NOTE ID is that of SDL 147: */ 1.1.1.9 root 148: static bool Joy_ReadJoystick(int nSdlJoyID, JOYREADING *pJoyReading) 1.1.1.6 root 149: { 1.1.1.12 root 150: /* Joystick is OK, read position from the configured joystick axis */ 151: pJoyReading->XPos = SDL_JoystickGetAxis(sdlJoystick[nSdlJoyID], pJoyReading->XAxisID); 152: pJoyReading->YPos = SDL_JoystickGetAxis(sdlJoystick[nSdlJoyID], pJoyReading->YAxisID); 1.1.1.6 root 153: /* Sets bit #0 if button #1 is pressed: */ 154: pJoyReading->Buttons = SDL_JoystickGetButton(sdlJoystick[nSdlJoyID], 0); 155: /* Sets bit #1 if button #2 is pressed: */ 156: if (SDL_JoystickGetButton(sdlJoystick[nSdlJoyID], 1)) 157: pJoyReading->Buttons |= JOY_BUTTON2; 158: 1.1.1.11 root 159: return true; 1.1 root 160: } 161: 1.1.1.2 root 162: 163: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 164: /** 165: * Read PC joystick and return ST format byte, i.e. lower 4 bits direction 166: * and top bit fire. 167: * NOTE : ID 0 is Joystick 0/Mouse and ID 1 is Joystick 1 (default), 168: * ID 2 and 3 are STE joypads and ID 4 and 5 are parport joysticks. 169: */ 1.1.1.6 root 170: Uint8 Joy_GetStickData(int nStJoyId) 1.1 root 171: { 1.1.1.6 root 172: Uint8 nData = 0; 173: JOYREADING JoyReading; 174: int nSdlJoyId; 1.1.1.12 root 175: int nAxes; /* how many joystick axes are on the current selected SDL joystick? */ 1.1.1.6 root 176: 177: nSdlJoyId = ConfigureParams.Joysticks.Joy[nStJoyId].nJoyId; 1.1.1.12 root 178: nAxes = SDL_JoystickNumAxes(sdlJoystick[nSdlJoyId]); 1.1.1.6 root 179: 180: /* Are we emulating the joystick via the keyboard? */ 181: if (ConfigureParams.Joysticks.Joy[nStJoyId].nJoystickMode == JOYSTICK_KEYBOARD) 182: { 183: /* If holding 'SHIFT' we actually want cursor key movement, so ignore any of this */ 184: if ( !(SDL_GetModState()&(KMOD_LSHIFT|KMOD_RSHIFT)) ) 185: { 186: nData = nJoyKeyEmu[nStJoyId]; 187: } 188: } 189: else if (ConfigureParams.Joysticks.Joy[nStJoyId].nJoystickMode == JOYSTICK_REALSTICK 190: && bJoystickWorking[nSdlJoyId]) 191: { 1.1.1.12 root 192: /* get joystick axis from configuration settings and make them plausible */ 1.1.1.13 root 193: JoyReading.XAxisID = sdlJoystickMapping[nSdlJoyId]->XAxisID; 194: JoyReading.YAxisID = sdlJoystickMapping[nSdlJoyId]->YAxisID; 195: 1.1.1.12 root 196: /* make selected axis IDs plausible */ 197: if( (JoyReading.XAxisID == JoyReading.YAxisID) /* same joystick axis for two directions? */ 198: ||(JoyReading.XAxisID > nAxes) /* ID for x axis beyond nr of existing axes? */ 199: ||(JoyReading.YAxisID > nAxes) /* ID for y axis beyond nr of existing axes? */ 200: ) 201: { 202: /* define sane SDL joystick axis defaults and prepare them for saving back to the config file: */ 203: JoyReading.XAxisID = 0; 204: JoyReading.YAxisID = 1; 205: } 1.1.1.13 root 206: 1.1.1.12 root 207: /* Read real joystick and map to emulated ST joystick for emulation */ 1.1.1.6 root 208: if (!Joy_ReadJoystick(nSdlJoyId, &JoyReading)) 209: { 1.1.1.12 root 210: /* Something is wrong, we cannot read the joystick from SDL */ 1.1.1.11 root 211: bJoystickWorking[nSdlJoyId] = false; 1.1.1.6 root 212: return 0; 213: } 214: 215: /* Directions */ 216: if (JoyReading.YPos <= JOYRANGE_UP_VALUE) 1.1.1.11 root 217: nData |= ATARIJOY_BITMASK_UP; 1.1.1.6 root 218: else if (JoyReading.YPos >= JOYRANGE_DOWN_VALUE) 1.1.1.11 root 219: nData |= ATARIJOY_BITMASK_DOWN; 1.1.1.6 root 220: if (JoyReading.XPos <= JOYRANGE_LEFT_VALUE) 1.1.1.11 root 221: nData |= ATARIJOY_BITMASK_LEFT; 1.1.1.6 root 222: else if (JoyReading.XPos >= JOYRANGE_RIGHT_VALUE) 1.1.1.11 root 223: nData |= ATARIJOY_BITMASK_RIGHT; 1.1.1.6 root 224: 225: /* PC Joystick button 1 is set as ST joystick button */ 226: if (JoyReading.Buttons & JOY_BUTTON1) 1.1.1.11 root 227: nData |= ATARIJOY_BITMASK_FIRE; 1.1.1.6 root 228: 229: /* Enable PC Joystick button 2 to mimick space bar (For XenonII, Flying Shark etc...) */ 230: if (nStJoyId == JOYID_JOYSTICK1 && (JoyReading.Buttons & JOY_BUTTON2)) 231: { 1.1.1.11 root 232: if (ConfigureParams.Joysticks.Joy[nStJoyId].bEnableJumpOnFire2) 1.1.1.6 root 233: { 1.1.1.11 root 234: /* If "Jump on Button 2" is enabled, PC Joystick button 2 acts as "ST Joystick up" */ 235: nData |= ATARIJOY_BITMASK_UP; 236: } else { 237: /* If "Jump on Button 2" is not enabled, PC Joystick button 2 acts as pressing SPACE on the ST keyboard */ 238: /* Only press 'space bar' if not in NULL state */ 239: if (!JoystickSpaceBar) 240: { 241: /* Press, ikbd will send packets and de-press */ 242: JoystickSpaceBar = JOYSTICK_SPACE_DOWN; 243: } 1.1.1.6 root 244: } 245: } 246: } 247: 248: /* Ignore fire button every 8 frames if enabled autofire (for both cursor emulation and joystick) */ 249: if (ConfigureParams.Joysticks.Joy[nStJoyId].bEnableAutoFire) 250: { 251: if ((nVBLs&0x7)<4) 1.1.1.11 root 252: nData &= ~ATARIJOY_BITMASK_FIRE; /* Remove top bit! */ 1.1.1.6 root 253: } 254: 255: return nData; 1.1 root 256: } 257: 1.1.1.2 root 258: 259: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 260: /** 261: * Get the fire button states. 262: * Note: More than one fire buttons are only supported for real joystick, 263: * not for keyboard emulation! 264: */ 1.1.1.6 root 265: static int Joy_GetFireButtons(int nStJoyId) 266: { 267: int nButtons = 0; 268: int nSdlJoyId; 269: int i, nMaxButtons; 270: 271: nSdlJoyId = ConfigureParams.Joysticks.Joy[nStJoyId].nJoyId; 272: 273: /* Are we emulating the joystick via the keyboard? */ 274: if (ConfigureParams.Joysticks.Joy[nStJoyId].nJoystickMode == JOYSTICK_KEYBOARD) 275: { 276: if (nJoyKeyEmu[nStJoyId] & 0x80) 277: { 278: nButtons |= 1; 279: } 280: } 281: else if (ConfigureParams.Joysticks.Joy[nStJoyId].nJoystickMode == JOYSTICK_REALSTICK 282: && bJoystickWorking[nSdlJoyId]) 283: { 284: nMaxButtons = SDL_JoystickNumButtons(sdlJoystick[nSdlJoyId]); 285: if (nMaxButtons > 17) 286: nMaxButtons = 17; 287: /* Now read all fire buttons and set a bit for each pressed button: */ 288: for (i = 0; i < nMaxButtons; i++) 289: { 290: if (SDL_JoystickGetButton(sdlJoystick[nSdlJoyId], i)) 291: { 292: nButtons |= (1 << i); 293: } 294: } 295: } 1.1.1.2 root 296: 1.1.1.6 root 297: return nButtons; 1.1 root 298: } 299: 1.1.1.2 root 300: 301: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 302: /** 303: * Set joystick cursor emulation for given port. This assumes that 304: * if the same keys have been defined for "cursor key emulation" in 305: * other ports, the emulation for them has been switched off. Returns 306: * 1 if the port number was OK, zero for error. 307: */ 1.1.1.9 root 308: bool Joy_SetCursorEmulation(int port) 1.1.1.7 root 309: { 310: if (port < 0 || port >= JOYSTICK_COUNT) { 311: return 0; 312: } 313: ConfigureParams.Joysticks.Joy[port].nJoystickMode = JOYSTICK_KEYBOARD; 314: return 1; 315: } 316: 317: 318: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 319: /** 320: * Toggle joystick cursor emulation between port 0, port 1 and being off 321: * from them. When it's turned off from them, the port's previous state 322: * is restored 323: */ 1.1 root 324: void Joy_ToggleCursorEmulation(void) 325: { 1.1.1.11 root 326: static JOYSTICKMODE saved[2] = { JOYSTICK_DISABLED, JOYSTICK_DISABLED }; 327: JOYSTICKMODE state; 328: int i, port = 2; 1.1.1.7 root 329: for (i = 0; i < 2; i++) { 330: state = ConfigureParams.Joysticks.Joy[i].nJoystickMode; 331: if (state == JOYSTICK_KEYBOARD) { 332: port = i; 333: } else { 334: saved[i] = state; 335: } 336: } 337: switch (port) { 338: case 0: /* (only) in port 0, disable cursor emu */ 339: ConfigureParams.Joysticks.Joy[0].nJoystickMode = saved[0]; 340: break; 341: case 1: /* (at least) in port 1, switch cursor emu to port 0 */ 342: ConfigureParams.Joysticks.Joy[1].nJoystickMode = saved[1]; 343: ConfigureParams.Joysticks.Joy[0].nJoystickMode = JOYSTICK_KEYBOARD; 344: break; 345: default: /* neither in port 0 or 1, enable cursor emu to port 1 */ 346: ConfigureParams.Joysticks.Joy[1].nJoystickMode = JOYSTICK_KEYBOARD; 1.1.1.6 root 347: } 348: } 349: 350: 351: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 352: /** 353: * A key has been pressed down, check if we use it for joystick emulation 354: * via keyboard. 355: */ 1.1.1.9 root 356: bool Joy_KeyDown(int symkey, int modkey) 1.1.1.6 root 357: { 358: int i; 359: 1.1.1.7 root 360: for (i = 0; i < JOYSTICK_COUNT; i++) 1.1.1.6 root 361: { 362: if (ConfigureParams.Joysticks.Joy[i].nJoystickMode == JOYSTICK_KEYBOARD 363: && !(modkey & KMOD_SHIFT)) 364: { 365: if (symkey == ConfigureParams.Joysticks.Joy[i].nKeyCodeUp) 366: { 1.1.1.11 root 367: nJoyKeyEmu[i] &= ~ATARIJOY_BITMASK_DOWN; /* Disable down */ 368: nJoyKeyEmu[i] |= ATARIJOY_BITMASK_UP; /* Enable up */ 369: return true; 1.1.1.6 root 370: } 371: else if (symkey == ConfigureParams.Joysticks.Joy[i].nKeyCodeDown) 372: { 1.1.1.11 root 373: nJoyKeyEmu[i] &= ~ATARIJOY_BITMASK_UP; /* Disable up */ 374: nJoyKeyEmu[i] |= ATARIJOY_BITMASK_DOWN; /* Enable down */ 375: return true; 1.1.1.6 root 376: } 377: else if (symkey == ConfigureParams.Joysticks.Joy[i].nKeyCodeLeft) 378: { 1.1.1.11 root 379: nJoyKeyEmu[i] &= ~ATARIJOY_BITMASK_RIGHT; /* Disable right */ 380: nJoyKeyEmu[i] |= ATARIJOY_BITMASK_LEFT; /* Enable left */ 381: return true; 1.1.1.6 root 382: } 383: else if (symkey == ConfigureParams.Joysticks.Joy[i].nKeyCodeRight) 384: { 1.1.1.11 root 385: nJoyKeyEmu[i] &= ~ATARIJOY_BITMASK_LEFT; /* Disable left */ 386: nJoyKeyEmu[i] |= ATARIJOY_BITMASK_RIGHT; /* Enable right */ 387: return true; 1.1.1.6 root 388: } 389: else if (symkey == ConfigureParams.Joysticks.Joy[i].nKeyCodeFire) 390: { 1.1.1.11 root 391: nJoyKeyEmu[i] |= ATARIJOY_BITMASK_FIRE; 392: return true; 1.1.1.6 root 393: } 394: } 395: } 396: 1.1.1.11 root 397: return false; 1.1.1.6 root 398: } 399: 400: 401: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 402: /** 403: * A key has been released, check if we use it for joystick emulation 404: * via keyboard. 405: */ 1.1.1.9 root 406: bool Joy_KeyUp(int symkey, int modkey) 1.1.1.6 root 407: { 408: int i; 409: 1.1.1.7 root 410: for (i = 0; i < JOYSTICK_COUNT; i++) 1.1.1.6 root 411: { 412: if (ConfigureParams.Joysticks.Joy[i].nJoystickMode == JOYSTICK_KEYBOARD 413: && !(modkey & KMOD_SHIFT)) 414: { 415: if (symkey == ConfigureParams.Joysticks.Joy[i].nKeyCodeUp) 416: { 1.1.1.11 root 417: nJoyKeyEmu[i] &= ~ATARIJOY_BITMASK_UP; 418: return true; 1.1.1.6 root 419: } 420: else if (symkey == ConfigureParams.Joysticks.Joy[i].nKeyCodeDown) 421: { 1.1.1.11 root 422: nJoyKeyEmu[i] &= ~ATARIJOY_BITMASK_DOWN; 423: return true; 1.1.1.6 root 424: } 425: else if (symkey == ConfigureParams.Joysticks.Joy[i].nKeyCodeLeft) 426: { 1.1.1.11 root 427: nJoyKeyEmu[i] &= ~ATARIJOY_BITMASK_LEFT; 428: return true; 1.1.1.6 root 429: } 430: else if (symkey == ConfigureParams.Joysticks.Joy[i].nKeyCodeRight) 431: { 1.1.1.11 root 432: nJoyKeyEmu[i] &= ~ATARIJOY_BITMASK_RIGHT; 433: return true; 1.1.1.6 root 434: } 435: else if (symkey == ConfigureParams.Joysticks.Joy[i].nKeyCodeFire) 436: { 1.1.1.11 root 437: nJoyKeyEmu[i] &= ~ATARIJOY_BITMASK_FIRE; 438: return true; 1.1.1.6 root 439: } 440: } 441: } 442: 1.1.1.11 root 443: return false; 1.1.1.6 root 444: } 445: 446: 447: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 448: /** 449: * Read from STE joypad buttons register (0xff9200) 450: */ 1.1.1.6 root 451: void Joy_StePadButtons_ReadWord(void) 452: { 453: Uint16 nData = 0xffff; 454: 455: if (ConfigureParams.Joysticks.Joy[JOYID_STEPADA].nJoystickMode != JOYSTICK_DISABLED 456: && (nSteJoySelect & 0x0f) != 0x0f) 457: { 458: int nButtons = Joy_GetFireButtons(JOYID_STEPADA); 459: if (!(nSteJoySelect & 0x1)) 460: { 461: if (nButtons & 0x01) /* Fire button A pressed? */ 462: nData &= ~2; 463: if (nButtons & 0x10) /* Fire button PAUSE pressed? */ 464: nData &= ~1; 465: } 466: else if (!(nSteJoySelect & 0x2)) 467: { 468: if (nButtons & 0x02) /* Fire button B pressed? */ 469: nData &= ~2; 470: } 471: else if (!(nSteJoySelect & 0x4)) 472: { 473: if (nButtons & 0x04) /* Fire button C pressed? */ 474: nData &= ~2; 475: } 476: else if (!(nSteJoySelect & 0x8)) 477: { 478: if (nButtons & 0x01) /* Fire button OPTION pressed? */ 479: nData &= ~2; 480: } 481: } 482: 483: if (ConfigureParams.Joysticks.Joy[JOYID_STEPADB].nJoystickMode != JOYSTICK_DISABLED 484: && (nSteJoySelect & 0xf0) != 0xf0) 485: { 486: int nButtons = Joy_GetFireButtons(JOYID_STEPADB); 487: if (!(nSteJoySelect & 0x10)) 488: { 489: if (nButtons & 0x01) /* Fire button A pressed? */ 490: nData &= ~8; 491: if (nButtons & 0x10) /* Fire button PAUSE pressed? */ 492: nData &= ~4; 493: } 494: else if (!(nSteJoySelect & 0x20)) 495: { 496: if (nButtons & 0x02) /* Fire button B pressed? */ 497: nData &= ~8; 498: } 499: else if (!(nSteJoySelect & 0x40)) 500: { 501: if (nButtons & 0x04) /* Fire button C pressed? */ 502: nData &= ~8; 503: } 504: else if (!(nSteJoySelect & 0x80)) 505: { 506: if (nButtons & 0x08) /* Fire button OPTION pressed? */ 507: nData &= ~8; 508: } 509: } 510: 511: IoMem_WriteWord(0xff9200, nData); 1.1 root 512: } 1.1.1.2 root 513: 1.1.1.6 root 514: 515: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 516: /** 517: * Read from STE joypad direction/buttons register (0xff9202) 518: */ 1.1.1.6 root 519: void Joy_StePadMulti_ReadWord(void) 520: { 521: Uint8 nData = 0xff; 522: 523: if (ConfigureParams.Joysticks.Joy[JOYID_STEPADA].nJoystickMode != JOYSTICK_DISABLED 524: && (nSteJoySelect & 0x0f) != 0x0f) 525: { 526: nData &= 0xf0; 527: if (!(nSteJoySelect & 0x1)) 528: { 529: nData |= ~Joy_GetStickData(JOYID_STEPADA) & 0x0f; 530: } 531: else if (!(nSteJoySelect & 0x2)) 532: { 533: nData |= ~(Joy_GetFireButtons(JOYID_STEPADA) >> 13) & 0x0f; 534: } 535: else if (!(nSteJoySelect & 0x4)) 536: { 537: nData |= ~(Joy_GetFireButtons(JOYID_STEPADA) >> 9) & 0x0f; 538: } 539: else if (!(nSteJoySelect & 0x8)) 540: { 541: nData |= ~(Joy_GetFireButtons(JOYID_STEPADA) >> 5) & 0x0f; 542: } 543: } 544: 545: if (ConfigureParams.Joysticks.Joy[JOYID_STEPADB].nJoystickMode != JOYSTICK_DISABLED 546: && (nSteJoySelect & 0xf0) != 0xf0) 547: { 548: nData &= 0x0f; 549: if (!(nSteJoySelect & 0x10)) 550: { 551: nData |= ~Joy_GetStickData(JOYID_STEPADB) << 4; 552: } 553: else if (!(nSteJoySelect & 0x20)) 554: { 555: nData |= ~(Joy_GetFireButtons(JOYID_STEPADB) >> 13) & 0x0f; 556: } 557: else if (!(nSteJoySelect & 0x40)) 558: { 559: nData |= ~(Joy_GetFireButtons(JOYID_STEPADB) >> 9) & 0x0f; 560: } 561: else if (!(nSteJoySelect & 0x80)) 562: { 563: nData |= ~(Joy_GetFireButtons(JOYID_STEPADB) >> 5) & 0x0f; 564: } 565: } 566: 567: IoMem_WriteWord(0xff9202, (nData << 8) | 0x0ff); 568: } 569: 570: 571: /*-----------------------------------------------------------------------*/ 1.1.1.8 root 572: /** 573: * Write to STE joypad selection register (0xff9202) 574: */ 1.1.1.6 root 575: void Joy_StePadMulti_WriteWord(void) 576: { 577: nSteJoySelect = IoMem_ReadWord(0xff9202); 578: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.