| 1 | /* |
|---|
| 2 | SDL - Simple DirectMedia Layer |
|---|
| 3 | Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga |
|---|
| 4 | |
|---|
| 5 | This library is free software; you can redistribute it and/or |
|---|
| 6 | modify it under the terms of the GNU Library General Public |
|---|
| 7 | License as published by the Free Software Foundation; either |
|---|
| 8 | version 2 of the License, or (at your option) any later version. |
|---|
| 9 | |
|---|
| 10 | This library is distributed in the hope that it will be useful, |
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 13 | Library General Public License for more details. |
|---|
| 14 | |
|---|
| 15 | You should have received a copy of the GNU Library General Public |
|---|
| 16 | License along with this library; if not, write to the Free |
|---|
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | |
|---|
| 19 | Sam Lantinga |
|---|
| 20 | slouken@devolution.com |
|---|
| 21 | */ |
|---|
| 22 | |
|---|
| 23 | /* Include file for SDL joystick event handling */ |
|---|
| 24 | |
|---|
| 25 | import SDL_types; |
|---|
| 26 | |
|---|
| 27 | extern(C): |
|---|
| 28 | |
|---|
| 29 | /* In order to use these functions, SDL_Init() must have been called |
|---|
| 30 | with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system |
|---|
| 31 | for joysticks, and load appropriate drivers. |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | /* The joystick structure used to identify an SDL joystick */ |
|---|
| 35 | struct SDL_Joystick { } |
|---|
| 36 | |
|---|
| 37 | /* Function prototypes */ |
|---|
| 38 | /* |
|---|
| 39 | * Count the number of joysticks attached to the system |
|---|
| 40 | */ |
|---|
| 41 | int SDL_NumJoysticks(); |
|---|
| 42 | |
|---|
| 43 | /* |
|---|
| 44 | * Get the implementation dependent name of a joystick. |
|---|
| 45 | * This can be called before any joysticks are opened. |
|---|
| 46 | * If no name can be found, this function returns NULL. |
|---|
| 47 | */ |
|---|
| 48 | char *SDL_JoystickName(int device_index); |
|---|
| 49 | |
|---|
| 50 | /* |
|---|
| 51 | * Open a joystick for use - the index passed as an argument refers to |
|---|
| 52 | * the N'th joystick on the system. This index is the value which will |
|---|
| 53 | * identify this joystick in future joystick events. |
|---|
| 54 | * |
|---|
| 55 | * This function returns a joystick identifier, or NULL if an error occurred. |
|---|
| 56 | */ |
|---|
| 57 | SDL_Joystick *SDL_JoystickOpen(int device_index); |
|---|
| 58 | |
|---|
| 59 | /* |
|---|
| 60 | * Returns 1 if the joystick has been opened, or 0 if it has not. |
|---|
| 61 | */ |
|---|
| 62 | int SDL_JoystickOpened(int device_index); |
|---|
| 63 | |
|---|
| 64 | /* |
|---|
| 65 | * Get the device index of an opened joystick. |
|---|
| 66 | */ |
|---|
| 67 | int SDL_JoystickIndex(SDL_Joystick *joystick); |
|---|
| 68 | |
|---|
| 69 | /* |
|---|
| 70 | * Get the number of general axis controls on a joystick |
|---|
| 71 | */ |
|---|
| 72 | int SDL_JoystickNumAxes(SDL_Joystick *joystick); |
|---|
| 73 | |
|---|
| 74 | /* |
|---|
| 75 | * Get the number of trackballs on a joystick |
|---|
| 76 | * Joystick trackballs have only relative motion events associated |
|---|
| 77 | * with them and their state cannot be polled. |
|---|
| 78 | */ |
|---|
| 79 | int SDL_JoystickNumBalls(SDL_Joystick *joystick); |
|---|
| 80 | |
|---|
| 81 | /* |
|---|
| 82 | * Get the number of POV hats on a joystick |
|---|
| 83 | */ |
|---|
| 84 | int SDL_JoystickNumHats(SDL_Joystick *joystick); |
|---|
| 85 | |
|---|
| 86 | /* |
|---|
| 87 | * Get the number of buttons on a joystick |
|---|
| 88 | */ |
|---|
| 89 | int SDL_JoystickNumButtons(SDL_Joystick *joystick); |
|---|
| 90 | |
|---|
| 91 | /* |
|---|
| 92 | * Update the current state of the open joysticks. |
|---|
| 93 | * This is called automatically by the event loop if any joystick |
|---|
| 94 | * events are enabled. |
|---|
| 95 | */ |
|---|
| 96 | void SDL_JoystickUpdate(); |
|---|
| 97 | |
|---|
| 98 | /* |
|---|
| 99 | * Enable/disable joystick event polling. |
|---|
| 100 | * If joystick events are disabled, you must call SDL_JoystickUpdate() |
|---|
| 101 | * yourself and check the state of the joystick when you want joystick |
|---|
| 102 | * information. |
|---|
| 103 | * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. |
|---|
| 104 | */ |
|---|
| 105 | int SDL_JoystickEventState(int state); |
|---|
| 106 | |
|---|
| 107 | /* |
|---|
| 108 | * Get the current state of an axis control on a joystick |
|---|
| 109 | * The state is a value ranging from -32768 to 32767. |
|---|
| 110 | * The axis indices start at index 0. |
|---|
| 111 | */ |
|---|
| 112 | Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis); |
|---|
| 113 | |
|---|
| 114 | /* |
|---|
| 115 | * Get the current state of a POV hat on a joystick |
|---|
| 116 | * The return value is one of the following positions: |
|---|
| 117 | */ |
|---|
| 118 | const uint SDL_HAT_CENTERED = 0x00; |
|---|
| 119 | const uint SDL_HAT_UP = 0x01; |
|---|
| 120 | const uint SDL_HAT_RIGHT = 0x02; |
|---|
| 121 | const uint SDL_HAT_DOWN = 0x04; |
|---|
| 122 | const uint SDL_HAT_LEFT = 0x08; |
|---|
| 123 | const uint SDL_HAT_RIGHTUP = (SDL_HAT_RIGHT|SDL_HAT_UP); |
|---|
| 124 | const uint SDL_HAT_RIGHTDOWN = (SDL_HAT_RIGHT|SDL_HAT_DOWN); |
|---|
| 125 | const uint SDL_HAT_LEFTUP = (SDL_HAT_LEFT|SDL_HAT_UP); |
|---|
| 126 | const uint SDL_HAT_LEFTDOWN = (SDL_HAT_LEFT|SDL_HAT_DOWN); |
|---|
| 127 | /* |
|---|
| 128 | * The hat indices start at index 0. |
|---|
| 129 | */ |
|---|
| 130 | Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat); |
|---|
| 131 | |
|---|
| 132 | /* |
|---|
| 133 | * Get the ball axis change since the last poll |
|---|
| 134 | * This returns 0, or -1 if you passed it invalid parameters. |
|---|
| 135 | * The ball indices start at index 0. |
|---|
| 136 | */ |
|---|
| 137 | int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); |
|---|
| 138 | |
|---|
| 139 | /* |
|---|
| 140 | * Get the current state of a button on a joystick |
|---|
| 141 | * The button indices start at index 0. |
|---|
| 142 | */ |
|---|
| 143 | Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button); |
|---|
| 144 | |
|---|
| 145 | /* |
|---|
| 146 | * Close a joystick previously opened with SDL_JoystickOpen() |
|---|
| 147 | */ |
|---|
| 148 | void SDL_JoystickClose(SDL_Joystick *joystick); |
|---|