Skip to content
Permalink
Browse files

No need to try to emulate analog axis when SDL support digital hats

  • Loading branch information
pmandin committed Oct 31, 2004
1 parent e76a4cd commit 9d76ae567b5352f5a0c5a0191af2b231211285d1
Showing with 71 additions and 76 deletions.
  1. +11 −10 README.MiNT
  2. +60 −66 src/joystick/mint/SDL_sysjoystick.c
@@ -48,18 +48,18 @@ Keyboard (GEMDOS, BIOS, GEM, Ikbd)
Mouse (XBIOS, GEM, Ikbd)
Video (XBIOS (Fullscreen), GEM (Windowed and Fullscreen))
Timer (VBL vector, GNU pth library)
Joystick and joypad (Ikbd, Hardware)
Joysticks and joypads (Ikbd, Hardware)
Audio (Hardware, XBIOS, GSXB, MCSN, STFA, /dev/audio if threads enabled)
Threads (Multitasking OS only via GNU pth library)
Shared object loader (using LDG library from http://ldg.atari.org/)
Audio CD (MetaDOS)

- Driver combinations:
Video Kbd Mouse Timer Joystick
xbios ikbd ikbd vbl(2) ikbd
xbios gemdos xbios vbl(2) xbios
xbios bios xbios vbl(2) xbios
gem gem gem(1) vbl(2) xbios
Video Kbd Mouse Timer Joysticks Joypads
xbios ikbd ikbd vbl(2) ikbd hardware
xbios gemdos xbios vbl(2) xbios hardware
xbios bios xbios vbl(2) xbios hardware
gem gem gem(1) vbl(2) xbios hardware

(1) GEM does not report relative mouse motion, so xbios mouse driver is used
to report this type event.
@@ -116,10 +116,11 @@ SDL_JOYSTICK_ATARI:

The second joystick port on IKBD is used by the mouse, so not usable.

Joypads are multibuttons controller (Atari Jaguar console-like).
Joysticks are 1 button, 2 axis controllers.
Lightpen and analog paddle are 2 buttons, 2 axis controllers. The 2
buttons are those affected to 1 button joysticks on the same port.
Descriptions of joysticks/joypads:
- Joypads: 1 hat, 17 buttons (Atari Jaguar console-like).
- Joysticks: 1 hat, 1 button.
- Lightpen, analog paddles: 2 axis, 2 buttons. The 2 buttons are those
affected to 1 button joysticks on the same port.

==============================================================================
VI. More informations about drivers:
@@ -302,26 +302,36 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
if (numjoystick==-1)
return -1;

if ((numjoystick==PORTA_PAD) || (numjoystick==PORTB_PAD)) {
joystick->nbuttons=JP_NUM_BUTTONS;
} else if ((numjoystick==PORTA_LP) || (numjoystick==PORTA_ANPAD) ||
(numjoystick==PORTB_ANPAD)) {
joystick->nbuttons=2;
} else {
joystick->nbuttons=1;
}
joystick->naxes=2;
joystick->nballs=0;
joystick->naxes=0;
joystick->nhats=0;
joystick->nballs=0;

switch(numjoystick) {
case PORTA_PAD:
case PORTB_PAD:
joystick->nhats=1;
joystick->nbuttons=JP_NUM_BUTTONS;
break;
case PORTA_LP:
case PORTA_ANPAD:
case PORTB_ANPAD:
joystick->naxes=2;
joystick->nbuttons=2;
break;
default:
joystick->nhats=1;
joystick->nbuttons=1;
break;
}

return(0);
}

void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
{
int numjoystick;
Uint8 hatstate;
Uint32 curstate,prevstate;
Sint16 curaxis;

numjoystick=GetEnabledAtariJoystick(joystick->index);
if (numjoystick==-1)
@@ -347,26 +357,21 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
}

if (curstate != prevstate) {
/* X axis */
if ((curstate & (IKBD_JOY_LEFT|IKBD_JOY_RIGHT)) != (prevstate & (IKBD_JOY_LEFT|IKBD_JOY_RIGHT))) {
curaxis=0;
if (curstate & IKBD_JOY_LEFT) {
curaxis=0x8000;
} else if (curstate & IKBD_JOY_RIGHT) {
curaxis=0x7fff;
}
SDL_PrivateJoystickAxis(joystick,0,curaxis);
hatstate = SDL_HAT_CENTERED;
if (curstate & IKBD_JOY_LEFT) {
hatstate |= SDL_HAT_LEFT;
}
/* Y axis */
if ((curstate & (IKBD_JOY_UP|IKBD_JOY_DOWN)) != (prevstate & (IKBD_JOY_UP|IKBD_JOY_DOWN))) {
curaxis=0;
if (curstate & IKBD_JOY_UP) {
curaxis=0x8000;
} else if (curstate & IKBD_JOY_DOWN) {
curaxis=0x7fff;
}
SDL_PrivateJoystickAxis(joystick,1,curaxis);
if (curstate & IKBD_JOY_RIGHT) {
hatstate |= SDL_HAT_RIGHT;
}
if (curstate & IKBD_JOY_UP) {
hatstate |= SDL_HAT_UP;
}
if (curstate & IKBD_JOY_DOWN) {
hatstate |= SDL_HAT_DOWN;
}
SDL_PrivateJoystickHat(joystick, 0, hatstate);

/* Button */
if ((curstate & IKBD_JOY_FIRE) && !(prevstate & IKBD_JOY_FIRE)) {
SDL_PrivateJoystickButton(joystick,0,SDL_PRESSED);
@@ -384,31 +389,25 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
int numjoypad,i;

numjoypad=0;
/* if (numjoystick==PORTA_PAD) numjoypad=0;*/
if (numjoystick==PORTB_PAD) numjoypad=1;

curstate=jp_joypads[numjoypad];
if (curstate!=prevstate) {
/* X axis */
if ((curstate & ((1<<JP_LEFT)|(1<<JP_RIGHT))) != (prevstate & ((1<<JP_LEFT)|(1<<JP_RIGHT)))) {
curaxis=0;
if (curstate & (1<<JP_LEFT)) {
curaxis=0x8000;
} else if (curstate & (1<<JP_RIGHT)) {
curaxis=0x7fff;
}
SDL_PrivateJoystickAxis(joystick,0,curaxis);
hatstate = SDL_HAT_CENTERED;
if (curstate & (1<<JP_LEFT)) {
hatstate |= SDL_HAT_LEFT;
}
/* Y axis */
if ((curstate & ((1<<JP_UP)|(1<<JP_DOWN))) != (prevstate & ((1<<JP_UP)|(1<<JP_DOWN)))) {
curaxis=0;
if (curstate & (1<<JP_UP)) {
curaxis=0x8000;
} else if (curstate & (1<<JP_DOWN)) {
curaxis=0x7fff;
}
SDL_PrivateJoystickAxis(joystick,1,curaxis);
if (curstate & (1<<JP_RIGHT)) {
hatstate |= SDL_HAT_RIGHT;
}
if (curstate & (1<<JP_UP)) {
hatstate |= SDL_HAT_UP;
}
if (curstate & (1<<JP_DOWN)) {
hatstate |= SDL_HAT_DOWN;
}
SDL_PrivateJoystickHat(joystick, 0, hatstate);

/* Buttons */
for (i=0;i<JP_NUM_BUTTONS;i++) {
int button;
@@ -442,26 +441,21 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
curstate |= ((jp_fires>>fire_shift) & 1)<<4;

if (curstate != prevstate) {
/* X axis */
if ((curstate & (PORT_JS_LEFT|PORT_JS_RIGHT)) != (prevstate & (PORT_JS_LEFT|PORT_JS_RIGHT))) {
curaxis=0;
if (curstate & PORT_JS_LEFT) {
curaxis=0x8000;
} else if (curstate & PORT_JS_RIGHT) {
curaxis=0x7fff;
}
SDL_PrivateJoystickAxis(joystick,0,curaxis);
hatstate = SDL_HAT_CENTERED;
if (curstate & PORT_JS_LEFT) {
hatstate |= SDL_HAT_LEFT;
}
/* Y axis */
if ((curstate & (PORT_JS_UP|PORT_JS_DOWN)) != (prevstate & (PORT_JS_UP|PORT_JS_DOWN))) {
curaxis=0;
if (curstate & PORT_JS_UP) {
curaxis=0x8000;
} else if (curstate & PORT_JS_DOWN) {
curaxis=0x7fff;
}
SDL_PrivateJoystickAxis(joystick,1,curaxis);
if (curstate & PORT_JS_RIGHT) {
hatstate |= SDL_HAT_RIGHT;
}
if (curstate & PORT_JS_UP) {
hatstate |= SDL_HAT_UP;
}
if (curstate & PORT_JS_DOWN) {
hatstate |= SDL_HAT_DOWN;
}
SDL_PrivateJoystickHat(joystick, 0, hatstate);

/* Button */
if ((curstate & PORT_JS_FIRE) && !(prevstate & PORT_JS_FIRE)) {
SDL_PrivateJoystickButton(joystick,0,SDL_PRESSED);

0 comments on commit 9d76ae5

Please sign in to comment.