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