Mercurial > sdl-ios-xcode
comparison src/joystick/nds/SDL_sysjoystick.c @ 2750:e3affc66d963
Fixes to the NDS sprite2 test. Illustrates partially working texture-as-sprite functionality.
author | Darren Alton <dalton@stevens.edu> |
---|---|
date | Sat, 06 Sep 2008 04:31:34 +0000 |
parents | 1c5f440a60fe |
children | 99210400e8b9 |
comparison
equal
deleted
inserted
replaced
2749:1c5f440a60fe | 2750:e3affc66d963 |
---|---|
43 */ | 43 */ |
44 int | 44 int |
45 SDL_SYS_JoystickInit(void) | 45 SDL_SYS_JoystickInit(void) |
46 { | 46 { |
47 SDL_numjoysticks = 1; | 47 SDL_numjoysticks = 1; |
48 return (1); | 48 |
49 return (1); | |
49 } | 50 } |
50 | 51 |
51 /* Function to get the device-dependent name of a joystick */ | 52 /* Function to get the device-dependent name of a joystick */ |
52 const char * | 53 const char * |
53 SDL_SYS_JoystickName(int index) | 54 SDL_SYS_JoystickName(int index) |
77 /* Function to update the state of a joystick - called as a device poll. | 78 /* Function to update the state of a joystick - called as a device poll. |
78 * This function shouldn't update the joystick structure directly, | 79 * This function shouldn't update the joystick structure directly, |
79 * but instead should call SDL_PrivateJoystick*() to deliver events | 80 * but instead should call SDL_PrivateJoystick*() to deliver events |
80 * and update joystick device state. | 81 * and update joystick device state. |
81 */ | 82 */ |
82 void | 83 void |
83 SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) | 84 SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) |
84 { | 85 { |
85 u32 keysd, keysu; | 86 u32 keysd, keysu; |
86 int magnitude = 16384; | 87 int magnitude = 16384; |
87 | 88 |
88 /*scanKeys(); - this is done in PumpEvents, because touch uses it too */ | 89 /*scanKeys(); - this is done in PumpEvents, because touch uses it too */ |
89 keysd = keysDown(); | 90 keysd = keysDown(); |
90 keysu = keysUp(); | 91 keysu = keysUp(); |
91 | 92 |
92 if ((keysd & KEY_UP)) { | 93 if ((keysd & KEY_UP)) { |
93 SDL_PrivateJoystickAxis(joystick, 1, -magnitude); | 94 SDL_PrivateJoystickAxis(joystick, 1, -magnitude); |
94 } | 95 } |
99 SDL_PrivateJoystickAxis(joystick, 0, -magnitude); | 100 SDL_PrivateJoystickAxis(joystick, 0, -magnitude); |
100 } | 101 } |
101 if ((keysd & KEY_RIGHT)) { | 102 if ((keysd & KEY_RIGHT)) { |
102 SDL_PrivateJoystickAxis(joystick, 0, magnitude); | 103 SDL_PrivateJoystickAxis(joystick, 0, magnitude); |
103 } | 104 } |
104 | 105 |
105 if ((keysu & (KEY_UP | KEY_DOWN))) { | 106 if ((keysu & (KEY_UP | KEY_DOWN))) { |
106 SDL_PrivateJoystickAxis(joystick, 1, 0); | 107 SDL_PrivateJoystickAxis(joystick, 1, 0); |
107 } | 108 } |
108 | 109 |
109 if ((keysu & (KEY_LEFT | KEY_RIGHT))) { | 110 if ((keysu & (KEY_LEFT | KEY_RIGHT))) { |
110 SDL_PrivateJoystickAxis(joystick, 0, 0); | 111 SDL_PrivateJoystickAxis(joystick, 0, 0); |
111 } | 112 } |
112 | 113 |
113 if ((keysd & KEY_A)) { | 114 if ((keysd & KEY_A)) { |
114 SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED); | 115 SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED); |
115 } | 116 } |
116 | 117 |
117 if ((keysd & KEY_B)) { | 118 if ((keysd & KEY_B)) { |
118 SDL_PrivateJoystickButton(joystick, 1, SDL_PRESSED); | 119 SDL_PrivateJoystickButton(joystick, 1, SDL_PRESSED); |
119 } | 120 } |
120 | 121 |
121 if ((keysd & KEY_X)) { | 122 if ((keysd & KEY_X)) { |
122 SDL_PrivateJoystickButton(joystick, 2, SDL_PRESSED); | 123 SDL_PrivateJoystickButton(joystick, 2, SDL_PRESSED); |
123 } | 124 } |
124 | 125 |
125 if ((keysd & KEY_Y)) { | 126 if ((keysd & KEY_Y)) { |
126 SDL_PrivateJoystickButton(joystick, 3, SDL_PRESSED); | 127 SDL_PrivateJoystickButton(joystick, 3, SDL_PRESSED); |
127 } | 128 } |
128 | 129 |
129 if ((keysd & KEY_L)) { | 130 if ((keysd & KEY_L)) { |
130 SDL_PrivateJoystickButton(joystick, 4, SDL_PRESSED); | 131 SDL_PrivateJoystickButton(joystick, 4, SDL_PRESSED); |
131 } | 132 } |
132 | 133 |
133 if ((keysd & KEY_R)) { | 134 if ((keysd & KEY_R)) { |
134 SDL_PrivateJoystickButton(joystick, 5, SDL_PRESSED); | 135 SDL_PrivateJoystickButton(joystick, 5, SDL_PRESSED); |
135 } | 136 } |
136 | 137 |
137 if ((keysd & KEY_SELECT)) { | 138 if ((keysd & KEY_SELECT)) { |
138 SDL_PrivateJoystickButton(joystick, 6, SDL_PRESSED); | 139 SDL_PrivateJoystickButton(joystick, 6, SDL_PRESSED); |
139 } | 140 } |
140 | 141 |
141 if ((keysd & KEY_START)) { | 142 if ((keysd & KEY_START)) { |
142 SDL_PrivateJoystickButton(joystick, 7, SDL_PRESSED); | 143 SDL_PrivateJoystickButton(joystick, 7, SDL_PRESSED); |
143 } | 144 } |
144 | 145 |
145 if ((keysu & KEY_A)) { | 146 if ((keysu & KEY_A)) { |
146 SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED); | 147 SDL_PrivateJoystickButton(joystick, 0, SDL_RELEASED); |
147 } | 148 } |
148 | 149 |
149 if ((keysu & KEY_B)) { | 150 if ((keysu & KEY_B)) { |
150 SDL_PrivateJoystickButton(joystick, 1, SDL_RELEASED); | 151 SDL_PrivateJoystickButton(joystick, 1, SDL_RELEASED); |
151 } | 152 } |
152 | 153 |
153 if ((keysu & KEY_X)) { | 154 if ((keysu & KEY_X)) { |
154 SDL_PrivateJoystickButton(joystick, 2, SDL_RELEASED); | 155 SDL_PrivateJoystickButton(joystick, 2, SDL_RELEASED); |
155 } | 156 } |
156 | 157 |
157 if ((keysu & KEY_Y)) { | 158 if ((keysu & KEY_Y)) { |
158 SDL_PrivateJoystickButton(joystick, 3, SDL_RELEASED); | 159 SDL_PrivateJoystickButton(joystick, 3, SDL_RELEASED); |
159 } | 160 } |
160 | 161 |
161 if ((keysu & KEY_L)) { | 162 if ((keysu & KEY_L)) { |
162 SDL_PrivateJoystickButton(joystick, 4, SDL_RELEASED); | 163 SDL_PrivateJoystickButton(joystick, 4, SDL_RELEASED); |
163 } | 164 } |
164 | 165 |
165 if ((keysu & KEY_R)) { | 166 if ((keysu & KEY_R)) { |
166 SDL_PrivateJoystickButton(joystick, 5, SDL_RELEASED); | 167 SDL_PrivateJoystickButton(joystick, 5, SDL_RELEASED); |
167 } | 168 } |
168 | 169 |
169 if ((keysu & KEY_SELECT)) { | 170 if ((keysu & KEY_SELECT)) { |
170 SDL_PrivateJoystickButton(joystick, 6, SDL_RELEASED); | 171 SDL_PrivateJoystickButton(joystick, 6, SDL_RELEASED); |
171 } | 172 } |
172 | 173 |
173 if ((keysu & KEY_START)) { | 174 if ((keysu & KEY_START)) { |
174 SDL_PrivateJoystickButton(joystick, 7, SDL_RELEASED); | 175 SDL_PrivateJoystickButton(joystick, 7, SDL_RELEASED); |
175 } | 176 } |
176 | 177 |
177 } | 178 } |
178 | 179 |
187 SDL_SYS_JoystickQuit(void) | 188 SDL_SYS_JoystickQuit(void) |
188 { | 189 { |
189 } | 190 } |
190 | 191 |
191 #endif /* SDL_JOYSTICK_NDS */ | 192 #endif /* SDL_JOYSTICK_NDS */ |
192 |