annotate src/joystick/mint/SDL_sysjoystick.c @ 1402:d910939febfa

Use consistent identifiers for the various platforms we support. Make sure every source file includes SDL_config.h, so the proper system headers are chosen.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 21 Feb 2006 08:46:50 +0000
parents 19418e4422cb
children a8181c4040b8
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
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 /*
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 * Atari Joystick/Joypad drivers
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 * Patrice Mandin
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
557
0ce5a68278fd Updated Atari port for new system headers (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents: 507
diff changeset
30 #include <mint/cookie.h>
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include <mint/osbind.h>
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32
1350
adc8ff3c9597 Fixes for new SDL embedded libc stuff
Patrice Mandin <patmandin@gmail.com>
parents: 1338
diff changeset
33 #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
34 #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
35 #include "../SDL_joystick_c.h"
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
37 #include "SDL_ikbdinterrupt_s.h"
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
38 #include "SDL_xbiosevents_c.h"
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
39 #include "SDL_xbiosinterrupt_s.h"
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 /*--- Const ---*/
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 /* We can have:
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
44 1 joystick on IKBD port 1, read via hardware I/O
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
45 or same joystick on IKBD port 1, read via xbios
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 2 joypads on ports A,B
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 or 4 joysticks on joypads ports A,B
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 or 1 lightpen on joypad port A
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 or 2 analog paddles on joypads ports A,B
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 2 joysticks on parallel port
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 enum {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 IKBD_JOY1=0,
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
55 XBIOS_JOY1,
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 PORTA_PAD,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 PORTB_PAD,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 PORTA_JOY0,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 PORTA_JOY1,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 PORTB_JOY0,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 PORTB_JOY1,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 PORTA_LP,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 PORTA_ANPAD,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 PORTB_ANPAD,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 #if 0
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 PARA_JOY0,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 PARA_JOY1,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 #endif
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 MAX_JOYSTICKS
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 };
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 enum {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 MCH_ST=0,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 MCH_STE,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 MCH_TT,
1054
e89d7f826b4a Add support for ARAnyM Atari emulator
Patrice Mandin <patmandin@gmail.com>
parents: 963
diff changeset
76 MCH_F30,
1079
39b5606fa543 Forgot enumeration value for Atari clones
Patrice Mandin <patmandin@gmail.com>
parents: 1054
diff changeset
77 MCH_CLONE,
1054
e89d7f826b4a Add support for ARAnyM Atari emulator
Patrice Mandin <patmandin@gmail.com>
parents: 963
diff changeset
78 MCH_ARANYM
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 };
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 /* Joypad buttons
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 * Procontroller note:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 * L,R are connected to 4,6
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 * X,Y,Z are connected to 7,8,9
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 enum {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 JP_UP=0, JP_DOWN, JP_LEFT, JP_RIGHT,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 JP_KPMULT, JP_KP7, JP_KP4, JP_KP1,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 JP_KP0, JP_KP8, JP_KP5, JP_KP2,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 JP_KPNUM, JP_KP9, JP_KP6, JP_KP3,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 JP_PAUSE, JP_FIRE0, JP_UNDEF0, JP_FIRE1,
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 JP_UNDEF1, JP_FIRE2, JP_UNDEF2, JP_OPTION
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 };
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 #define JP_NUM_BUTTONS 17
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 #define PORT_JS_RIGHT (1<<0)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 #define PORT_JS_LEFT (1<<1)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 #define PORT_JS_DOWN (1<<2)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 #define PORT_JS_UP (1<<3)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 #define PORT_JS_FIRE (1<<4)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 /*--- Types ---*/
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 typedef struct {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 SDL_bool enabled;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 unsigned char *name;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 Uint32 prevstate;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 } atarijoy_t;
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 /*--- Variables ---*/
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 static atarijoy_t atarijoysticks[MAX_JOYSTICKS]={
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 {SDL_FALSE,"IKBD joystick port 1",0},
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
116 {SDL_FALSE,"Xbios joystick port 1",0},
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 {SDL_FALSE,"Joypad port A",0},
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 {SDL_FALSE,"Joypad port B",0},
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 {SDL_FALSE,"Joystick 0 port A",0},
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 {SDL_FALSE,"Joystick 1 port A",0},
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 {SDL_FALSE,"Joystick 0 port B",0},
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 {SDL_FALSE,"Joystick 1 port B",0},
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 {SDL_FALSE,"Lightpen port A",0},
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 {SDL_FALSE,"Analog paddle port A",0},
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 {SDL_FALSE,"Analog paddle port B",0}
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 #if 0
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 ,{SDL_FALSE,"Joystick 0 parallel port",0},
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 {SDL_FALSE,"Joystick 1 parallel port",0}
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 #endif
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 };
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 static const int jp_buttons[JP_NUM_BUTTONS]={
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
133 JP_FIRE0, JP_FIRE1, JP_FIRE2, JP_PAUSE,
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
134 JP_OPTION, JP_KPMULT, JP_KPNUM, JP_KP0,
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
135 JP_KP1, JP_KP2, JP_KP3, JP_KP4,
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
136 JP_KP5, JP_KP6, JP_KP7, JP_KP8,
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
137 JP_KP9
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 };
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 static SDL_bool joypad_ports_enabled=SDL_FALSE;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 /* Updated joypad ports */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 static Uint16 jp_paddles[4];
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 static Uint16 jp_lightpens[2];
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 static Uint16 jp_directions;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 static Uint16 jp_fires;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 static Uint32 jp_joypads[2];
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 /*--- Functions prototypes ---*/
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 static int GetEnabledAtariJoystick(int index);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 static void UpdateJoypads(void);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 /*--- Functions ---*/
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 int SDL_SYS_JoystickInit(void)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 int i;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 unsigned long cookie_mch;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
160 const char *envr=SDL_getenv("SDL_JOYSTICK_ATARI");
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 #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
163 if (SDL_strstr(env,idstring"-off")) { \
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 atarijoysticks[num].enabled=SDL_FALSE; \
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 } \
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
166 if (SDL_strstr(env,idstring"-on")) { \
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 atarijoysticks[num].enabled=SDL_TRUE; \
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 }
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 /* Cookie _MCH present ? if not, assume ST machine */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 if (Getcookie(C__MCH, &cookie_mch) != C_FOUND) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 cookie_mch = MCH_ST << 16;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 }
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 /* Enable some default joysticks */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 if ((cookie_mch == MCH_ST<<16) || ((cookie_mch>>16) == MCH_STE) ||
1054
e89d7f826b4a Add support for ARAnyM Atari emulator
Patrice Mandin <patmandin@gmail.com>
parents: 963
diff changeset
177 (cookie_mch == MCH_TT<<16) || (cookie_mch == MCH_F30<<16) ||
e89d7f826b4a Add support for ARAnyM Atari emulator
Patrice Mandin <patmandin@gmail.com>
parents: 963
diff changeset
178 (cookie_mch == MCH_ARANYM<<16)) {
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
179 atarijoysticks[IKBD_JOY1].enabled=(SDL_AtariIkbd_enabled!=0);
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 if ((cookie_mch == MCH_STE<<16) || (cookie_mch == MCH_F30<<16)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 atarijoysticks[PORTA_PAD].enabled=SDL_TRUE;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 atarijoysticks[PORTB_PAD].enabled=SDL_TRUE;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 }
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
185 if (!atarijoysticks[IKBD_JOY1].enabled) {
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
186 atarijoysticks[XBIOS_JOY1].enabled=(SDL_AtariXbios_enabled!=0);
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
187 }
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 /* Read environment for joysticks to enable */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 if (envr) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 /* IKBD on any Atari, maybe clones */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 if ((cookie_mch == MCH_ST<<16) || ((cookie_mch>>16) == MCH_STE) ||
1054
e89d7f826b4a Add support for ARAnyM Atari emulator
Patrice Mandin <patmandin@gmail.com>
parents: 963
diff changeset
193 (cookie_mch == MCH_TT<<16) || (cookie_mch == MCH_F30<<16) ||
e89d7f826b4a Add support for ARAnyM Atari emulator
Patrice Mandin <patmandin@gmail.com>
parents: 963
diff changeset
194 (cookie_mch == MCH_ARANYM<<16)) {
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
195 if (SDL_AtariIkbd_enabled!=0) {
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
196 TEST_JOY_ENABLED(envr, "ikbd-joy1", IKBD_JOY1);
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 /* Joypads ports only on STE and Falcon */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 if ((cookie_mch == MCH_STE<<16) || (cookie_mch == MCH_F30<<16)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 TEST_JOY_ENABLED(envr, "porta-pad", PORTA_PAD);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 if (!atarijoysticks[PORTA_PAD].enabled) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 TEST_JOY_ENABLED(envr, "porta-joy0", PORTA_JOY0);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 TEST_JOY_ENABLED(envr, "porta-joy1", PORTA_JOY1);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 if (!(atarijoysticks[PORTA_JOY0].enabled) && !(atarijoysticks[PORTA_JOY1].enabled)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 TEST_JOY_ENABLED(envr, "porta-lp", PORTA_LP);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 if (!atarijoysticks[PORTA_LP].enabled) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 TEST_JOY_ENABLED(envr, "porta-anpad", PORTA_ANPAD);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 TEST_JOY_ENABLED(envr, "portb-pad", PORTB_PAD);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 if (!atarijoysticks[PORTB_PAD].enabled) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 TEST_JOY_ENABLED(envr, "portb-joy0", PORTB_JOY0);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 TEST_JOY_ENABLED(envr, "portb-joy1", PORTB_JOY1);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 if (!(atarijoysticks[PORTB_JOY0].enabled) && !(atarijoysticks[PORTB_JOY1].enabled)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 TEST_JOY_ENABLED(envr, "portb-anpad", PORTB_ANPAD);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 }
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
222
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
223 if (!atarijoysticks[IKBD_JOY1].enabled) {
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
224 if (SDL_AtariXbios_enabled!=0) {
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
225 TEST_JOY_ENABLED(envr, "xbios-joy1", XBIOS_JOY1);
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
226 }
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
227 }
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 #if 0
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 /* Parallel port on any Atari, maybe clones */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 if ((cookie_mch == MCH_ST<<16) || ((cookie_mch>>16) == MCH_STE) ||
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 (cookie_mch == MCH_TT<<16) || (cookie_mch == MCH_F30<<16)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 TEST_JOY_ENABLED(envr, "para-joy0", PARA_JOY0);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 TEST_JOY_ENABLED(envr, "para-joy1", PARA_JOY1);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 #endif
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 /* Need to update joypad ports ? */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 joypad_ports_enabled=SDL_FALSE;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 for (i=PORTA_PAD;i<=PORTB_ANPAD;i++) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 if (atarijoysticks[i].enabled) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 joypad_ports_enabled=SDL_TRUE;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 break;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 SDL_numjoysticks = 0;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 for (i=0;i<MAX_JOYSTICKS;i++) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 if (atarijoysticks[i].enabled) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 ++SDL_numjoysticks;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 return(SDL_numjoysticks);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 static int GetEnabledAtariJoystick(int index)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 int i,j;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 /* Return the nth'index' enabled atari joystick */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 j=0;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 for (i=0;i<MAX_JOYSTICKS;i++) {
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
264 if (!atarijoysticks[i].enabled) {
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
265 continue;
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 }
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
267
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
268 if (j==index) {
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
269 break;
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
270 }
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
271
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
272 ++j;
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 if (i==MAX_JOYSTICKS)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 return -1;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 return i;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 const char *SDL_SYS_JoystickName(int index)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 int numjoystick;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 numjoystick=GetEnabledAtariJoystick(index);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 if (numjoystick==-1)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 return NULL;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 return(atarijoysticks[numjoystick].name);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 int numjoystick;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 numjoystick=GetEnabledAtariJoystick(joystick->index);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 if (numjoystick==-1)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 return -1;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298
963
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
299 joystick->naxes=0;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
300 joystick->nhats=0;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
301 joystick->nballs=0;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
302
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
303 switch(numjoystick) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
304 case PORTA_PAD:
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
305 case PORTB_PAD:
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
306 joystick->nhats=1;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
307 joystick->nbuttons=JP_NUM_BUTTONS;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
308 break;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
309 case PORTA_LP:
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
310 case PORTA_ANPAD:
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
311 case PORTB_ANPAD:
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
312 joystick->naxes=2;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
313 joystick->nbuttons=2;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
314 break;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
315 default:
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
316 joystick->nhats=1;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
317 joystick->nbuttons=1;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
318 break;
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 return(0);
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
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 int numjoystick;
963
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
327 Uint8 hatstate;
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 Uint32 curstate,prevstate;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 numjoystick=GetEnabledAtariJoystick(joystick->index);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331 if (numjoystick==-1)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 return;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 prevstate = atarijoysticks[numjoystick].prevstate;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 if (joypad_ports_enabled) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 Supexec(UpdateJoypads);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 switch (numjoystick) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 case IKBD_JOY1:
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
342 case XBIOS_JOY1:
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 {
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
344 curstate = 0;
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
345
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
346 if (numjoystick==IKBD_JOY1) {
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
347 curstate = SDL_AtariIkbd_joystick & 0xff;
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
348 }
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
349 if (numjoystick==XBIOS_JOY1) {
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
350 curstate = SDL_AtariXbios_joystick & 0xff;
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
351 }
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
352
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
353 if (curstate != prevstate) {
963
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
354 hatstate = SDL_HAT_CENTERED;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
355 if (curstate & IKBD_JOY_LEFT) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
356 hatstate |= SDL_HAT_LEFT;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
357 }
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
358 if (curstate & IKBD_JOY_RIGHT) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
359 hatstate |= SDL_HAT_RIGHT;
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
360 }
963
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
361 if (curstate & IKBD_JOY_UP) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
362 hatstate |= SDL_HAT_UP;
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
363 }
963
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
364 if (curstate & IKBD_JOY_DOWN) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
365 hatstate |= SDL_HAT_DOWN;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
366 }
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
367 SDL_PrivateJoystickHat(joystick, 0, hatstate);
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
368
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
369 /* Button */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
370 if ((curstate & IKBD_JOY_FIRE) && !(prevstate & IKBD_JOY_FIRE)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
371 SDL_PrivateJoystickButton(joystick,0,SDL_PRESSED);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
372 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
373 if (!(curstate & IKBD_JOY_FIRE) && (prevstate & IKBD_JOY_FIRE)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
374 SDL_PrivateJoystickButton(joystick,0,SDL_RELEASED);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
375 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
376 }
305
9c6613983e85 Atari port cleanups from Patrice
Sam Lantinga <slouken@libsdl.org>
parents: 302
diff changeset
377 atarijoysticks[numjoystick].prevstate = curstate;
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
378 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
379 break;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
380 case PORTA_PAD:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
381 case PORTB_PAD:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
382 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
383 int numjoypad,i;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
384
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
385 numjoypad=0;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
386 if (numjoystick==PORTB_PAD) numjoypad=1;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
387
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
388 curstate=jp_joypads[numjoypad];
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
389 if (curstate!=prevstate) {
963
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
390 hatstate = SDL_HAT_CENTERED;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
391 if (curstate & (1<<JP_LEFT)) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
392 hatstate |= SDL_HAT_LEFT;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
393 }
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
394 if (curstate & (1<<JP_RIGHT)) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
395 hatstate |= SDL_HAT_RIGHT;
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
396 }
963
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
397 if (curstate & (1<<JP_UP)) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
398 hatstate |= SDL_HAT_UP;
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
399 }
963
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
400 if (curstate & (1<<JP_DOWN)) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
401 hatstate |= SDL_HAT_DOWN;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
402 }
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
403 SDL_PrivateJoystickHat(joystick, 0, hatstate);
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
404
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
405 /* Buttons */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
406 for (i=0;i<JP_NUM_BUTTONS;i++) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
407 int button;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
408
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
409 button=1<<jp_buttons[i];
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
410
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
411 if ((curstate & button) && !(prevstate & button)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
412 SDL_PrivateJoystickButton(joystick,i,SDL_PRESSED);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
413 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
414 if (!(curstate & button) && (prevstate & button)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
415 SDL_PrivateJoystickButton(joystick,i,SDL_RELEASED);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
416 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
417 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
418 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
419 atarijoysticks[numjoystick].prevstate = curstate;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
420 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
421 break;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
422 case PORTA_JOY0:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
423 case PORTA_JOY1:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
424 case PORTB_JOY0:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
425 case PORTB_JOY1:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
426 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
427 int fire_shift=0,dir_shift=0;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
428
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
429 if (numjoystick==PORTA_JOY0) { fire_shift=0; dir_shift=0; }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
430 if (numjoystick==PORTA_JOY1) { fire_shift=1; dir_shift=4; }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
431 if (numjoystick==PORTB_JOY0) { fire_shift=2; dir_shift=8; }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
432 if (numjoystick==PORTB_JOY1) { fire_shift=3; dir_shift=12; }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
433
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
434 curstate = (jp_directions>>dir_shift) & 15;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
435 curstate |= ((jp_fires>>fire_shift) & 1)<<4;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
436
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
437 if (curstate != prevstate) {
963
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
438 hatstate = SDL_HAT_CENTERED;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
439 if (curstate & PORT_JS_LEFT) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
440 hatstate |= SDL_HAT_LEFT;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
441 }
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
442 if (curstate & PORT_JS_RIGHT) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
443 hatstate |= SDL_HAT_RIGHT;
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
444 }
963
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
445 if (curstate & PORT_JS_UP) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
446 hatstate |= SDL_HAT_UP;
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
447 }
963
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
448 if (curstate & PORT_JS_DOWN) {
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
449 hatstate |= SDL_HAT_DOWN;
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
450 }
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
451 SDL_PrivateJoystickHat(joystick, 0, hatstate);
92c247cec42d No need to try to emulate analog axis when SDL support digital hats
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
452
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
453 /* Button */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
454 if ((curstate & PORT_JS_FIRE) && !(prevstate & PORT_JS_FIRE)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
455 SDL_PrivateJoystickButton(joystick,0,SDL_PRESSED);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
456 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
457 if (!(curstate & PORT_JS_FIRE) && (prevstate & PORT_JS_FIRE)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
458 SDL_PrivateJoystickButton(joystick,0,SDL_RELEASED);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
459 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
460 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
461 atarijoysticks[numjoystick].prevstate = curstate;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
462 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
463 break;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
464 case PORTA_LP:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
465 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
466 int i;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
467
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
468 curstate = jp_lightpens[0]>>1;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
469 curstate |= (jp_lightpens[1]>>1)<<15;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
470 curstate |= (jp_fires & 3)<<30;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
471
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
472 if (curstate != prevstate) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
473 /* X axis */
507
7853b6af5957 Atari joystick fixes contributed by Patrice Mandin
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
474 SDL_PrivateJoystickAxis(joystick,0,jp_lightpens[0] ^ 0x8000);
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
475 /* Y axis */
507
7853b6af5957 Atari joystick fixes contributed by Patrice Mandin
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
476 SDL_PrivateJoystickAxis(joystick,1,jp_lightpens[1] ^ 0x8000);
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
477 /* Buttons */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
478 for (i=0;i<2;i++) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
479 int button;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
480
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
481 button=1<<(30+i);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
482
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
483 if ((curstate & button) && !(prevstate & button)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
484 SDL_PrivateJoystickButton(joystick,i,SDL_PRESSED);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
485 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
486 if (!(curstate & button) && (prevstate & button)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
487 SDL_PrivateJoystickButton(joystick,i,SDL_RELEASED);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
488 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
489 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
490 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
491 atarijoysticks[numjoystick].prevstate = curstate;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
492 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
493 break;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
494 case PORTA_ANPAD:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
495 case PORTB_ANPAD:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
496 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
497 int numpaddle, i;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
498
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
499 numpaddle=0<<1;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
500 if (numjoystick==PORTB_ANPAD) numpaddle=1<<1;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
501
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
502 curstate = jp_paddles[numpaddle]>>1;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
503 curstate |= (jp_paddles[numpaddle+1]>>1)<<15;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
504 curstate |= ((jp_fires>>numpaddle) & 3)<<30;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
505
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
506 if (curstate != prevstate) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
507 /* X axis */
507
7853b6af5957 Atari joystick fixes contributed by Patrice Mandin
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
508 SDL_PrivateJoystickAxis(joystick,0,jp_paddles[numpaddle] ^ 0x8000);
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
509 /* Y axis */
507
7853b6af5957 Atari joystick fixes contributed by Patrice Mandin
Sam Lantinga <slouken@libsdl.org>
parents: 305
diff changeset
510 SDL_PrivateJoystickAxis(joystick,1,jp_paddles[numpaddle+1] ^ 0x8000);
302
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
511 /* Buttons */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
512 for (i=0;i<2;i++) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
513 int button;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
514
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
515 button=1<<(30+i);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
516
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
517 if ((curstate & button) && !(prevstate & button)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
518 SDL_PrivateJoystickButton(joystick,i,SDL_PRESSED);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
519 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
520 if (!(curstate & button) && (prevstate & button)) {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
521 SDL_PrivateJoystickButton(joystick,i,SDL_RELEASED);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
522 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
523 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
524 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
525 atarijoysticks[numjoystick].prevstate = curstate;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
526 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
527 break;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
528 #if 0
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
529 case PARA_JOY0:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
530 case PARA_JOY1:
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
531 break;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
532 #endif
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
533 };
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
534
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
535 return;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
536 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
537
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
538 void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
539 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
540 return;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
541 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
542
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
543 void SDL_SYS_JoystickQuit(void)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
544 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
545 SDL_numjoysticks=0;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
546 return;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
547 }
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
548
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
549 /*--- Joypad I/O read/write interface ---*/
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
550
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
551 #define JOYPAD_IO_BASE (0xffff9200)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
552 struct JOYPAD_IO_S {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
553 Uint16 fires;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
554 Uint16 directions;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
555 Uint16 dummy1[6];
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
556 Uint16 paddles[4];
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
557 Uint16 dummy2[4];
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
558 Uint16 lightpens[2];
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
559 };
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
560 #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
561
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
562 static void UpdateJoypads(void)
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
563 {
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
564 Uint16 tmp;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
565
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
566 /*--- This function is called in supervisor mode ---*/
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
567
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
568 /* Update joysticks */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
569 jp_fires = (~(JOYPAD_IO.fires)) & 15;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
570 jp_directions = (~(JOYPAD_IO.directions));
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
571
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
572 /* Update lightpen */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
573 tmp = JOYPAD_IO.lightpens[0] & 1023;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574 jp_lightpens[0] = (tmp<<6) | (tmp>>4);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
575 tmp = JOYPAD_IO.lightpens[1] & 1023;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
576 jp_lightpens[1] = (tmp<<6) | (tmp>>4);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
577
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
578 /* Update paddles */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
579 tmp = (JOYPAD_IO.paddles[0] & 255);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
580 jp_paddles[0] = (tmp<<8) | tmp;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
581 tmp = (JOYPAD_IO.paddles[1] & 255);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
582 jp_paddles[1] = (tmp<<8) | tmp;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
583 tmp = (JOYPAD_IO.paddles[2] & 255);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
584 jp_paddles[2] = (tmp<<8) | tmp;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
585 tmp = (JOYPAD_IO.paddles[3] & 255);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
586 jp_paddles[3] = (tmp<<8) | tmp;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
587
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
588 /* Update joypad 0 */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
589 JOYPAD_IO.directions=0xfffe;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
590 jp_joypads[0]=((~(JOYPAD_IO.fires)) & 3)<<(16);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
591 JOYPAD_IO.directions=0xfffe;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
592 jp_joypads[0] |= ((~(JOYPAD_IO.directions))>>8) & 15;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
593
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
594 JOYPAD_IO.directions=0xfffd;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
595 jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3)<<(16+2);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
596 JOYPAD_IO.directions=0xfffd;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
597 jp_joypads[0] |= (((~(JOYPAD_IO.directions))>>8) & 15)<<4;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
598
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
599 JOYPAD_IO.directions=0xfffb;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
600 jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3)<<(16+4);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
601 JOYPAD_IO.directions=0xfffb;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
602 jp_joypads[0] |= (((~(JOYPAD_IO.directions))>>8) & 15)<<8;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
603
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
604 JOYPAD_IO.directions=0xfff7;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
605 jp_joypads[0] |= ((~(JOYPAD_IO.fires)) & 3)<<(16+6);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
606 JOYPAD_IO.directions=0xfff7;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
607 jp_joypads[0] |= (((~(JOYPAD_IO.directions))>>8) & 15)<<12;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
608
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
609 /* Update joypad 1 */
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
610 JOYPAD_IO.directions=0xffef;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
611 jp_joypads[1]=((~(JOYPAD_IO.fires)) & (3<<2))<<(16-2);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612 JOYPAD_IO.directions=0xffef;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 jp_joypads[1] |= ((~(JOYPAD_IO.directions))>>12) & 15;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
614
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
615 JOYPAD_IO.directions=0xffdf;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
616 jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3<<2))<<(16);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
617 JOYPAD_IO.directions=0xffdf;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
618 jp_joypads[1] |= (((~(JOYPAD_IO.directions))>>12) & 15)<<4;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
619
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
620 JOYPAD_IO.directions=0xffbf;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
621 jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3<<2))<<(16+2);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
622 JOYPAD_IO.directions=0xffbf;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
623 jp_joypads[1] |= (((~(JOYPAD_IO.directions))>>12) & 15)<<8;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
624
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
625 JOYPAD_IO.directions=0xff7f;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
626 jp_joypads[1] |= ((~(JOYPAD_IO.fires)) & (3<<2))<<(16+4);
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 JOYPAD_IO.directions=0xff7f;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628 jp_joypads[1] |= (((~(JOYPAD_IO.directions))>>12) & 15)<<12;
8a86bdf34f0f Added Atari joystick support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 }