comparison src/joystick/nds/SDL_sysjoystick.c @ 2749:1c5f440a60fe

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