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