Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
672 lines (577 loc) · 19.1 KB

SDL_sysjoystick.c

File metadata and controls

672 lines (577 loc) · 19.1 KB
 
1
2
/*
SDL - Simple DirectMedia Layer
Feb 1, 2006
Feb 1, 2006
3
Copyright (C) 1997-2006 Sam Lantinga
4
5
This library is free software; you can redistribute it and/or
Feb 1, 2006
Feb 1, 2006
6
modify it under the terms of the GNU Lesser General Public
7
License as published by the Free Software Foundation; either
Feb 1, 2006
Feb 1, 2006
8
version 2.1 of the License, or (at your option) any later version.
9
10
11
12
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Feb 1, 2006
Feb 1, 2006
13
Lesser General Public License for more details.
Feb 1, 2006
Feb 1, 2006
15
16
17
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19
20
21
Sam Lantinga
slouken@libsdl.org
*/
Feb 21, 2006
Feb 21, 2006
22
#include "SDL_config.h"
Apr 14, 2006
Apr 14, 2006
24
25
#ifdef SDL_JOYSTICK_MINT
26
27
28
29
30
31
/*
* Atari Joystick/Joypad drivers
*
* Patrice Mandin
*/
Dec 7, 2002
Dec 7, 2002
32
#include <mint/cookie.h>
33
34
#include <mint/osbind.h>
Feb 8, 2006
Feb 8, 2006
35
#include "SDL_events.h"
Feb 16, 2006
Feb 16, 2006
36
37
#include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h"
Feb 21, 2006
Feb 21, 2006
39
40
41
#include "../../video/ataricommon/SDL_ikbdinterrupt_s.h"
#include "../../video/ataricommon/SDL_xbiosevents_c.h"
#include "../../video/ataricommon/SDL_xbiosinterrupt_s.h"
42
43
44
45
/*--- Const ---*/
/* We can have:
Mar 10, 2002
Mar 10, 2002
46
47
1 joystick on IKBD port 1, read via hardware I/O
or same joystick on IKBD port 1, read via xbios
48
49
50
51
52
53
54
2 joypads on ports A,B
or 4 joysticks on joypads ports A,B
or 1 lightpen on joypad port A
or 2 analog paddles on joypads ports A,B
2 joysticks on parallel port
*/
Jul 10, 2006
Jul 10, 2006
55
56
57
58
59
60
61
62
63
64
65
66
67
enum
{
IKBD_JOY1 = 0,
XBIOS_JOY1,
PORTA_PAD,
PORTB_PAD,
PORTA_JOY0,
PORTA_JOY1,
PORTB_JOY0,
PORTB_JOY1,
PORTA_LP,
PORTA_ANPAD,
PORTB_ANPAD,
Jul 10, 2006
Jul 10, 2006
69
70
PARA_JOY0,
PARA_JOY1,
Jul 10, 2006
Jul 10, 2006
72
MAX_JOYSTICKS
Jul 10, 2006
Jul 10, 2006
75
76
77
78
79
80
81
82
enum
{
MCH_ST = 0,
MCH_STE,
MCH_TT,
MCH_F30,
MCH_CLONE,
MCH_ARANYM
83
84
85
86
87
88
89
90
};
/* Joypad buttons
* Procontroller note:
* L,R are connected to 4,6
* X,Y,Z are connected to 7,8,9
*/
Jul 10, 2006
Jul 10, 2006
91
92
93
94
95
96
97
98
enum
{
JP_UP = 0, JP_DOWN, JP_LEFT, JP_RIGHT,
JP_KPMULT, JP_KP7, JP_KP4, JP_KP1,
JP_KP0, JP_KP8, JP_KP5, JP_KP2,
JP_KPNUM, JP_KP9, JP_KP6, JP_KP3,
JP_PAUSE, JP_FIRE0, JP_UNDEF0, JP_FIRE1,
JP_UNDEF1, JP_FIRE2, JP_UNDEF2, JP_OPTION
99
100
101
102
103
104
105
106
107
108
109
110
};
#define JP_NUM_BUTTONS 17
#define PORT_JS_RIGHT (1<<0)
#define PORT_JS_LEFT (1<<1)
#define PORT_JS_DOWN (1<<2)
#define PORT_JS_UP (1<<3)
#define PORT_JS_FIRE (1<<4)
/*--- Types ---*/
Jul 10, 2006
Jul 10, 2006
111
112
113
114
115
typedef struct
{
SDL_bool enabled;
unsigned char *name;
Uint32 prevstate;
116
117
118
119
} atarijoy_t;
/*--- Variables ---*/
Jul 10, 2006
Jul 10, 2006
120
121
122
123
124
125
126
127
128
129
130
131
static atarijoy_t atarijoysticks[MAX_JOYSTICKS] = {
{SDL_FALSE, "IKBD joystick port 1", 0},
{SDL_FALSE, "Xbios joystick port 1", 0},
{SDL_FALSE, "Joypad port A", 0},
{SDL_FALSE, "Joypad port B", 0},
{SDL_FALSE, "Joystick 0 port A", 0},
{SDL_FALSE, "Joystick 1 port A", 0},
{SDL_FALSE, "Joystick 0 port B", 0},
{SDL_FALSE, "Joystick 1 port B", 0},
{SDL_FALSE, "Lightpen port A", 0},
{SDL_FALSE, "Analog paddle port A", 0},
{SDL_FALSE, "Analog paddle port B", 0}
Jul 10, 2006
Jul 10, 2006
133
134
, {SDL_FALSE, "Joystick 0 parallel port", 0},
{SDL_FALSE, "Joystick 1 parallel port", 0}
135
136
137
#endif
};
Jul 10, 2006
Jul 10, 2006
138
139
140
141
142
143
static const int jp_buttons[JP_NUM_BUTTONS] = {
JP_FIRE0, JP_FIRE1, JP_FIRE2, JP_PAUSE,
JP_OPTION, JP_KPMULT, JP_KPNUM, JP_KP0,
JP_KP1, JP_KP2, JP_KP3, JP_KP4,
JP_KP5, JP_KP6, JP_KP7, JP_KP8,
JP_KP9
144
145
};
Jul 10, 2006
Jul 10, 2006
146
static SDL_bool joypad_ports_enabled = SDL_FALSE;
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* Updated joypad ports */
static Uint16 jp_paddles[4];
static Uint16 jp_lightpens[2];
static Uint16 jp_directions;
static Uint16 jp_fires;
static Uint32 jp_joypads[2];
/*--- Functions prototypes ---*/
static int GetEnabledAtariJoystick(int index);
static void UpdateJoypads(void);
/*--- Functions ---*/
Jul 10, 2006
Jul 10, 2006
162
163
int
SDL_SYS_JoystickInit(void)
Jul 10, 2006
Jul 10, 2006
165
166
167
168
int i;
unsigned long cookie_mch;
const char *envr = SDL_getenv("SDL_JOYSTICK_ATARI");
169
#define TEST_JOY_ENABLED(env,idstring,num) \
Feb 7, 2006
Feb 7, 2006
170
if (SDL_strstr(env,idstring"-off")) { \
171
172
atarijoysticks[num].enabled=SDL_FALSE; \
} \
Feb 7, 2006
Feb 7, 2006
173
if (SDL_strstr(env,idstring"-on")) { \
174
175
176
atarijoysticks[num].enabled=SDL_TRUE; \
}
Jul 10, 2006
Jul 10, 2006
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
/* Cookie _MCH present ? if not, assume ST machine */
if (Getcookie(C__MCH, &cookie_mch) != C_FOUND) {
cookie_mch = MCH_ST << 16;
}
/* Enable some default joysticks */
if ((cookie_mch == MCH_ST << 16) || ((cookie_mch >> 16) == MCH_STE) ||
(cookie_mch == MCH_TT << 16) || (cookie_mch == MCH_F30 << 16) ||
(cookie_mch == MCH_ARANYM << 16)) {
atarijoysticks[IKBD_JOY1].enabled = (SDL_AtariIkbd_enabled != 0);
}
if ((cookie_mch == MCH_STE << 16) || (cookie_mch == MCH_F30 << 16)) {
atarijoysticks[PORTA_PAD].enabled = SDL_TRUE;
atarijoysticks[PORTB_PAD].enabled = SDL_TRUE;
}
if (!atarijoysticks[IKBD_JOY1].enabled) {
atarijoysticks[XBIOS_JOY1].enabled = (SDL_AtariXbios_enabled != 0);
}
/* Read environment for joysticks to enable */
if (envr) {
/* IKBD on any Atari, maybe clones */
if ((cookie_mch == MCH_ST << 16) || ((cookie_mch >> 16) == MCH_STE)
|| (cookie_mch == MCH_TT << 16) || (cookie_mch == MCH_F30 << 16)
|| (cookie_mch == MCH_ARANYM << 16)) {
if (SDL_AtariIkbd_enabled != 0) {
TEST_JOY_ENABLED(envr, "ikbd-joy1", IKBD_JOY1);
}
}
/* Joypads ports only on STE and Falcon */
if ((cookie_mch == MCH_STE << 16) || (cookie_mch == MCH_F30 << 16)) {
TEST_JOY_ENABLED(envr, "porta-pad", PORTA_PAD);
if (!atarijoysticks[PORTA_PAD].enabled) {
TEST_JOY_ENABLED(envr, "porta-joy0", PORTA_JOY0);
TEST_JOY_ENABLED(envr, "porta-joy1", PORTA_JOY1);
if (!(atarijoysticks[PORTA_JOY0].enabled)
&& !(atarijoysticks[PORTA_JOY1].enabled)) {
TEST_JOY_ENABLED(envr, "porta-lp", PORTA_LP);
if (!atarijoysticks[PORTA_LP].enabled) {
TEST_JOY_ENABLED(envr, "porta-anpad", PORTA_ANPAD);
}
}
}
TEST_JOY_ENABLED(envr, "portb-pad", PORTB_PAD);
if (!atarijoysticks[PORTB_PAD].enabled) {
TEST_JOY_ENABLED(envr, "portb-joy0", PORTB_JOY0);
TEST_JOY_ENABLED(envr, "portb-joy1", PORTB_JOY1);
if (!(atarijoysticks[PORTB_JOY0].enabled)
&& !(atarijoysticks[PORTB_JOY1].enabled)) {
TEST_JOY_ENABLED(envr, "portb-anpad", PORTB_ANPAD);
}
}
}
if (!atarijoysticks[IKBD_JOY1].enabled) {
if (SDL_AtariXbios_enabled != 0) {
TEST_JOY_ENABLED(envr, "xbios-joy1", XBIOS_JOY1);
}
}
Jul 10, 2006
Jul 10, 2006
238
239
240
241
242
243
244
/* Parallel port on any Atari, maybe clones */
if ((cookie_mch == MCH_ST << 16) || ((cookie_mch >> 16) == MCH_STE)
|| (cookie_mch == MCH_TT << 16)
|| (cookie_mch == MCH_F30 << 16)) {
TEST_JOY_ENABLED(envr, "para-joy0", PARA_JOY0);
TEST_JOY_ENABLED(envr, "para-joy1", PARA_JOY1);
}
245
#endif
Jul 10, 2006
Jul 10, 2006
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
}
/* Need to update joypad ports ? */
joypad_ports_enabled = SDL_FALSE;
for (i = PORTA_PAD; i <= PORTB_ANPAD; i++) {
if (atarijoysticks[i].enabled) {
joypad_ports_enabled = SDL_TRUE;
break;
}
}
SDL_numjoysticks = 0;
for (i = 0; i < MAX_JOYSTICKS; i++) {
if (atarijoysticks[i].enabled) {
++SDL_numjoysticks;
}
}
return (SDL_numjoysticks);
Jul 10, 2006
Jul 10, 2006
267
268
static int
GetEnabledAtariJoystick(int index)
Jul 10, 2006
Jul 10, 2006
270
int i, j;
Jul 10, 2006
Jul 10, 2006
272
273
274
275
276
277
/* Return the nth'index' enabled atari joystick */
j = 0;
for (i = 0; i < MAX_JOYSTICKS; i++) {
if (!atarijoysticks[i].enabled) {
continue;
}
Mar 10, 2002
Mar 10, 2002
278
Jul 10, 2006
Jul 10, 2006
279
280
281
if (j == index) {
break;
}
Mar 10, 2002
Mar 10, 2002
282
Jul 10, 2006
Jul 10, 2006
283
284
285
286
++j;
}
if (i == MAX_JOYSTICKS)
return -1;
Jul 10, 2006
Jul 10, 2006
288
return i;
Jul 10, 2006
Jul 10, 2006
291
292
const char *
SDL_SYS_JoystickName(int index)
Jul 10, 2006
Jul 10, 2006
294
int numjoystick;
Jul 10, 2006
Jul 10, 2006
296
297
298
numjoystick = GetEnabledAtariJoystick(index);
if (numjoystick == -1)
return NULL;
Jul 10, 2006
Jul 10, 2006
300
return (atarijoysticks[numjoystick].name);
Jul 10, 2006
Jul 10, 2006
303
304
int
SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
Jul 10, 2006
Jul 10, 2006
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
int numjoystick;
numjoystick = GetEnabledAtariJoystick(joystick->index);
if (numjoystick == -1)
return -1;
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);
Jul 10, 2006
Jul 10, 2006
337
338
void
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
Jul 10, 2006
Jul 10, 2006
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
int numjoystick;
Uint8 hatstate;
Uint32 curstate, prevstate;
numjoystick = GetEnabledAtariJoystick(joystick->index);
if (numjoystick == -1)
return;
prevstate = atarijoysticks[numjoystick].prevstate;
if (joypad_ports_enabled) {
Supexec(UpdateJoypads);
}
switch (numjoystick) {
case IKBD_JOY1:
case XBIOS_JOY1:
{
curstate = 0;
if (numjoystick == IKBD_JOY1) {
curstate = SDL_AtariIkbd_joystick & 0xff;
}
if (numjoystick == XBIOS_JOY1) {
curstate = SDL_AtariXbios_joystick & 0xff;
}
if (curstate != prevstate) {
hatstate = SDL_HAT_CENTERED;
if (curstate & IKBD_JOY_LEFT) {
hatstate |= SDL_HAT_LEFT;
}
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);
}
if (!(curstate & IKBD_JOY_FIRE)
&& (prevstate & IKBD_JOY_FIRE)) {
SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED);
}
}
atarijoysticks[numjoystick].prevstate = curstate;
}
break;
case PORTA_PAD:
case PORTB_PAD:
{
int numjoypad, i;
numjoypad = 0;
if (numjoystick == PORTB_PAD)
numjoypad = 1;
curstate = jp_joypads[numjoypad];
if (curstate != prevstate) {
hatstate = SDL_HAT_CENTERED;
if (curstate & (1 << JP_LEFT)) {
hatstate |= SDL_HAT_LEFT;
}
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;
button = 1 << jp_buttons[i];
if ((curstate & button) && !(prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_PRESSED);
}
if (!(curstate & button) && (prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_RELEASED);
}
}
}
atarijoysticks[numjoystick].prevstate = curstate;
}
break;
case PORTA_JOY0:
case PORTA_JOY1:
case PORTB_JOY0:
case PORTB_JOY1:
{
int fire_shift = 0, dir_shift = 0;
if (numjoystick == PORTA_JOY0) {
fire_shift = 0;
dir_shift = 0;
}
if (numjoystick == PORTA_JOY1) {
fire_shift = 1;
dir_shift = 4;
}
if (numjoystick == PORTB_JOY0) {
fire_shift = 2;
dir_shift = 8;
}
if (numjoystick == PORTB_JOY1) {
fire_shift = 3;
dir_shift = 12;
}
curstate = (jp_directions >> dir_shift) & 15;
curstate |= ((jp_fires >> fire_shift) & 1) << 4;
if (curstate != prevstate) {
hatstate = SDL_HAT_CENTERED;
if (curstate & PORT_JS_LEFT) {
hatstate |= SDL_HAT_LEFT;
}
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);
}
if (!(curstate & PORT_JS_FIRE)
&& (prevstate & PORT_JS_FIRE)) {
SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED);
}
}
atarijoysticks[numjoystick].prevstate = curstate;
}
break;
case PORTA_LP:
{
int i;
curstate = jp_lightpens[0] >> 1;
curstate |= (jp_lightpens[1] >> 1) << 15;
curstate |= (jp_fires & 3) << 30;
if (curstate != prevstate) {
/* X axis */
SDL_PrivateJoystickAxis(joystick, 0,
jp_lightpens[0] ^ 0x8000);
/* Y axis */
SDL_PrivateJoystickAxis(joystick, 1,
jp_lightpens[1] ^ 0x8000);
/* Buttons */
for (i = 0; i < 2; i++) {
int button;
button = 1 << (30 + i);
if ((curstate & button) && !(prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_PRESSED);
}
if (!(curstate & button) && (prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_RELEASED);
}
}
}
atarijoysticks[numjoystick].prevstate = curstate;
}
break;
case PORTA_ANPAD:
case PORTB_ANPAD:
{
int numpaddle, i;
numpaddle = 0 << 1;
if (numjoystick == PORTB_ANPAD)
numpaddle = 1 << 1;
curstate = jp_paddles[numpaddle] >> 1;
curstate |= (jp_paddles[numpaddle + 1] >> 1) << 15;
curstate |= ((jp_fires >> numpaddle) & 3) << 30;
if (curstate != prevstate) {
/* X axis */
SDL_PrivateJoystickAxis(joystick, 0,
jp_paddles[numpaddle] ^ 0x8000);
/* Y axis */
SDL_PrivateJoystickAxis(joystick, 1,
jp_paddles[numpaddle + 1] ^ 0x8000);
/* Buttons */
for (i = 0; i < 2; i++) {
int button;
button = 1 << (30 + i);
if ((curstate & button) && !(prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_PRESSED);
}
if (!(curstate & button) && (prevstate & button)) {
SDL_PrivateJoystickButton(joystick, i, SDL_RELEASED);
}
}
}
atarijoysticks[numjoystick].prevstate = curstate;
}
break;
Jul 10, 2006
Jul 10, 2006
565
566
567
case PARA_JOY0:
case PARA_JOY1:
break;
568
#endif
Jul 10, 2006
Jul 10, 2006
569
};
Jul 10, 2006
Jul 10, 2006
571
return;
Jul 10, 2006
Jul 10, 2006
574
575
void
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
Jul 10, 2006
Jul 10, 2006
577
return;
Jul 10, 2006
Jul 10, 2006
580
581
void
SDL_SYS_JoystickQuit(void)
Jul 10, 2006
Jul 10, 2006
583
584
SDL_numjoysticks = 0;
return;
585
586
587
588
589
}
/*--- Joypad I/O read/write interface ---*/
#define JOYPAD_IO_BASE (0xffff9200)
Jul 10, 2006
Jul 10, 2006
590
591
592
593
594
595
596
597
struct JOYPAD_IO_S
{
Uint16 fires;
Uint16 directions;
Uint16 dummy1[6];
Uint16 paddles[4];
Uint16 dummy2[4];
Uint16 lightpens[2];
598
599
600
};
#define JOYPAD_IO ((*(volatile struct JOYPAD_IO_S *)JOYPAD_IO_BASE))
Jul 10, 2006
Jul 10, 2006
601
602
static void
UpdateJoypads(void)
Jul 10, 2006
Jul 10, 2006
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
Uint16 tmp;
/*--- This function is called in supervisor mode ---*/
/* Update joysticks */
jp_fires = (~(JOYPAD_IO.fires)) & 15;
jp_directions = (~(JOYPAD_IO.directions));
/* Update lightpen */
tmp = JOYPAD_IO.lightpens[0] & 1023;
jp_lightpens[0] = (tmp << 6) | (tmp >> 4);
tmp = JOYPAD_IO.lightpens[1] & 1023;
jp_lightpens[1] = (tmp << 6) | (tmp >> 4);
/* Update paddles */
tmp = (JOYPAD_IO.paddles[0] & 255);
jp_paddles[0] = (tmp << 8) | tmp;
tmp = (JOYPAD_IO.paddles[1] & 255);
jp_paddles[1] = (tmp << 8) | tmp;
tmp = (JOYPAD_IO.paddles[2] & 255);
jp_paddles[2] = (tmp << 8) | tmp;
tmp = (JOYPAD_IO.paddles[3] & 255);
jp_paddles[3] = (tmp << 8) | tmp;
/* Update joypad 0 */
JOYPAD_IO.directions = 0xfffe;
jp_joypads[0] = ((~(JOYPAD_IO.fires)) & 3) << (16);
JOYPAD_IO.directions = 0xfffe;
jp_joypads[0] |= ((~(JOYPAD_IO.directions)) >> 8) & 15;
JOYPAD_IO.directions = 0xfffd;
jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3) << (16 + 2);
JOYPAD_IO.directions = 0xfffd;
jp_joypads[0] |= (((~(JOYPAD_IO.directions)) >> 8) & 15) << 4;
JOYPAD_IO.directions = 0xfffb;
jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3) << (16 + 4);
JOYPAD_IO.directions = 0xfffb;
jp_joypads[0] |= (((~(JOYPAD_IO.directions)) >> 8) & 15) << 8;
JOYPAD_IO.directions = 0xfff7;
jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3) << (16 + 6);
JOYPAD_IO.directions = 0xfff7;
jp_joypads[0] |= (((~(JOYPAD_IO.directions)) >> 8) & 15) << 12;
/* Update joypad 1 */
JOYPAD_IO.directions = 0xffef;
jp_joypads[1] = ((~(JOYPAD_IO.fires)) & (3 << 2)) << (16 - 2);
JOYPAD_IO.directions = 0xffef;
jp_joypads[1] |= ((~(JOYPAD_IO.directions)) >> 12) & 15;
JOYPAD_IO.directions = 0xffdf;
jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3 << 2)) << (16);
JOYPAD_IO.directions = 0xffdf;
jp_joypads[1] |= (((~(JOYPAD_IO.directions)) >> 12) & 15) << 4;
JOYPAD_IO.directions = 0xffbf;
jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3 << 2)) << (16 + 2);
JOYPAD_IO.directions = 0xffbf;
jp_joypads[1] |= (((~(JOYPAD_IO.directions)) >> 12) & 15) << 8;
JOYPAD_IO.directions = 0xff7f;
jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3 << 2)) << (16 + 4);
JOYPAD_IO.directions = 0xff7f;
jp_joypads[1] |= (((~(JOYPAD_IO.directions)) >> 12) & 15) << 12;
Apr 14, 2006
Apr 14, 2006
670
671
#endif /* SDL_JOYSTICK_MINT */
Jul 10, 2006
Jul 10, 2006
672
/* vi: set ts=4 sw=4 expandtab: */