annotate src/joystick/mint/SDL_sysjoystick.c @ 2029:8640d90b0406

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