src/joystick/nds/SDL_sysjoystick.c
branchgsoc2008_nds
changeset 2698 e1da92da346c
parent 2676 082cc3ffd7d8
equal deleted inserted replaced
2697:c9121b04cffa 2698:e1da92da346c
    18 
    18 
    19     Sam Lantinga
    19     Sam Lantinga
    20     slouken@devolution.com
    20     slouken@devolution.com
    21 */
    21 */
    22 
    22 
    23 #ifdef SAVE_RCSID
       
    24 static char rcsid =
       
    25     "@(#) $Id: SDL_sysjoystick.c,v 1.2 2001/04/26 16:50:17 hercules Exp $";
       
    26 #endif
       
    27 
       
    28 #include "SDL_config.h"
    23 #include "SDL_config.h"
    29 
    24 
    30 #ifdef SDL_JOYSTICK_NDS
    25 #ifdef SDL_JOYSTICK_NDS
    31 
    26 
    32 /* This is the system specific header for the SDL joystick API */
    27 /* This is the system specific header for the SDL joystick API */
    33 #include <nds.h>
    28 #include <nds.h>
    34 //#include <nds/registers_alt.h>
       
    35 #include <stdio.h>              /* For the definition of NULL */
    29 #include <stdio.h>              /* For the definition of NULL */
    36 
    30 
    37 #include "SDL_error.h"
    31 #include "SDL_error.h"
    38 #include "SDL_events.h"
    32 #include "SDL_events.h"
    39 #include "SDL_joystick.h"
    33 #include "SDL_joystick.h"
    49  */
    43  */
    50 int
    44 int
    51 SDL_SYS_JoystickInit(void)
    45 SDL_SYS_JoystickInit(void)
    52 {
    46 {
    53     SDL_numjoysticks = 1;
    47     SDL_numjoysticks = 1;
    54     /* keysInit();*/
    48     
    55     return (1);
    49 return (1);
    56 }
    50 }
    57 
    51 
    58 /* Function to get the device-dependent name of a joystick */
    52 /* Function to get the device-dependent name of a joystick */
    59 const char *
    53 const char *
    60 SDL_SYS_JoystickName(int index)
    54 SDL_SYS_JoystickName(int index)
    84 /* 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.
    85  * This function shouldn't update the joystick structure directly,
    79  * This function shouldn't update the joystick structure directly,
    86  * but instead should call SDL_PrivateJoystick*() to deliver events
    80  * but instead should call SDL_PrivateJoystick*() to deliver events
    87  * and update joystick device state.
    81  * and update joystick device state.
    88  */
    82  */
    89 void
    83     void
    90 SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
    84 SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
    91 {
    85 {
    92     u32 keysd, keysu;
    86     u32 keysd, keysu;
    93     int magnitude = 16384;
    87     int magnitude = 16384;
    94     /*scanKeys();*/
    88     
    95     keysd = keysDown();
    89         /*scanKeys(); */ 
       
    90         keysd = keysDown();
    96     keysu = keysUp();
    91     keysu = keysUp();
    97 
    92 
    98     if ((keysd & KEY_UP)) {
    93     if ((keysd & KEY_UP)) {
    99         SDL_PrivateJoystickAxis(joystick, 1, -magnitude);
    94         SDL_PrivateJoystickAxis(joystick, 1, -magnitude);
   100     }
    95     }
   105         SDL_PrivateJoystickAxis(joystick, 0, -magnitude);
   100         SDL_PrivateJoystickAxis(joystick, 0, -magnitude);
   106     }
   101     }
   107     if ((keysd & KEY_RIGHT)) {
   102     if ((keysd & KEY_RIGHT)) {
   108         SDL_PrivateJoystickAxis(joystick, 0, magnitude);
   103         SDL_PrivateJoystickAxis(joystick, 0, magnitude);
   109     }
   104     }
   110 
   105     
   111     if ((keysu & (KEY_UP|KEY_DOWN))) {
   106 if ((keysu & (KEY_UP | KEY_DOWN))) {
   112         SDL_PrivateJoystickAxis(joystick, 1, 0);
   107         SDL_PrivateJoystickAxis(joystick, 1, 0);
   113     }
   108     }
   114     if ((keysu & (KEY_LEFT|KEY_RIGHT))) {
   109     
       
   110 if ((keysu & (KEY_LEFT | KEY_RIGHT))) {
   115         SDL_PrivateJoystickAxis(joystick, 0, 0);
   111         SDL_PrivateJoystickAxis(joystick, 0, 0);
   116     }
   112     }
   117 
   113     
   118     if ((keysd & KEY_A)) {
   114 if ((keysd & KEY_A)) {
   119         SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED);
   115         SDL_PrivateJoystickButton(joystick, 0, SDL_PRESSED);
   120     }
   116     }
   121     if ((keysd & KEY_B)) {
   117     
       
   118 if ((keysd & KEY_B)) {
   122         SDL_PrivateJoystickButton(joystick, 1, SDL_PRESSED);
   119         SDL_PrivateJoystickButton(joystick, 1, SDL_PRESSED);
   123     }
   120     }
   124     if ((keysd & KEY_X)) {
   121     
       
   122 if ((keysd & KEY_X)) {
   125         SDL_PrivateJoystickButton(joystick, 2, SDL_PRESSED);
   123         SDL_PrivateJoystickButton(joystick, 2, SDL_PRESSED);
   126     }
   124     }
   127     if ((keysd & KEY_Y)) {
   125     
       
   126 if ((keysd & KEY_Y)) {
   128         SDL_PrivateJoystickButton(joystick, 3, SDL_PRESSED);
   127         SDL_PrivateJoystickButton(joystick, 3, SDL_PRESSED);
   129     }
   128     }
   130 
   129     
   131     if ((keysd & KEY_L)) {
   130 if ((keysd & KEY_L)) {
   132         SDL_PrivateJoystickButton(joystick, 4, SDL_PRESSED);
   131         SDL_PrivateJoystickButton(joystick, 4, SDL_PRESSED);
   133     }
   132     }
   134     if ((keysd & KEY_R)) {
   133     
       
   134 if ((keysd & KEY_R)) {
   135         SDL_PrivateJoystickButton(joystick, 5, SDL_PRESSED);
   135         SDL_PrivateJoystickButton(joystick, 5, SDL_PRESSED);
   136     }
   136     }
   137 
   137     
   138     if ((keysd & KEY_SELECT)) {
   138 if ((keysd & KEY_SELECT)) {
   139         SDL_PrivateJoystickButton(joystick, 6, SDL_PRESSED);
   139         SDL_PrivateJoystickButton(joystick, 6, SDL_PRESSED);
   140     }
   140     }
   141     if ((keysd & KEY_START)) {
   141     
       
   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     if ((keysu & KEY_B)) {
   149     
       
   150 if ((keysu & KEY_B)) {
   149         SDL_PrivateJoystickButton(joystick, 1, SDL_RELEASED);
   151         SDL_PrivateJoystickButton(joystick, 1, SDL_RELEASED);
   150     }
   152     }
   151     if ((keysu & KEY_X)) {
   153     
       
   154 if ((keysu & KEY_X)) {
   152         SDL_PrivateJoystickButton(joystick, 2, SDL_RELEASED);
   155         SDL_PrivateJoystickButton(joystick, 2, SDL_RELEASED);
   153     }
   156     }
   154     if ((keysu & KEY_Y)) {
   157     
       
   158 if ((keysu & KEY_Y)) {
   155         SDL_PrivateJoystickButton(joystick, 3, SDL_RELEASED);
   159         SDL_PrivateJoystickButton(joystick, 3, SDL_RELEASED);
   156     }
   160     }
   157 
   161     
   158     if ((keysu & KEY_L)) {
   162 if ((keysu & KEY_L)) {
   159         SDL_PrivateJoystickButton(joystick, 4, SDL_RELEASED);
   163         SDL_PrivateJoystickButton(joystick, 4, SDL_RELEASED);
   160     }
   164     }
   161     if ((keysu & KEY_R)) {
   165     
       
   166 if ((keysu & KEY_R)) {
   162         SDL_PrivateJoystickButton(joystick, 5, SDL_RELEASED);
   167         SDL_PrivateJoystickButton(joystick, 5, SDL_RELEASED);
   163     }
   168     }
   164 
   169     
   165     if ((keysu & KEY_SELECT)) {
   170 if ((keysu & KEY_SELECT)) {
   166         SDL_PrivateJoystickButton(joystick, 6, SDL_RELEASED);
   171         SDL_PrivateJoystickButton(joystick, 6, SDL_RELEASED);
   167     }
   172     }
   168     if ((keysu & KEY_START)) {
   173     
       
   174 if ((keysu & KEY_START)) {
   169         SDL_PrivateJoystickButton(joystick, 7, SDL_RELEASED);
   175         SDL_PrivateJoystickButton(joystick, 7, SDL_RELEASED);
   170     }
   176     }
       
   177 
   171 }
   178 }
   172 
   179 
   173 /* Function to close a joystick after use */
   180 /* Function to close a joystick after use */
   174 void
   181 void
   175 SDL_SYS_JoystickClose(SDL_Joystick * joystick)
   182 SDL_SYS_JoystickClose(SDL_Joystick * joystick)
   179 /* Function to perform any system-specific joystick related cleanup */
   186 /* Function to perform any system-specific joystick related cleanup */
   180 void
   187 void
   181 SDL_SYS_JoystickQuit(void)
   188 SDL_SYS_JoystickQuit(void)
   182 {
   189 {
   183 }
   190 }
       
   191 
   184 #endif /* SDL_JOYSTICK_NDS */
   192 #endif /* SDL_JOYSTICK_NDS */
   185