| 1 | package SDL2::joystick 0.01 { | ||
| 2 | use SDL2::Utils; | ||
| 3 | use experimental 'signatures'; | ||
| 4 | # | ||
| 5 | use SDL2::stdinc; | ||
| 6 | use SDL2::error; | ||
| 7 | |||
| 8 | package SDL2::Joystick { | ||
| 9 | use SDL2::Utils; | ||
| 10 | our $TYPE = has(); | ||
| 11 | }; | ||
| 12 | |||
| 13 | package SDL2::JoystickGUID { | ||
| 14 | use SDL2::Utils; | ||
| 15 | our $TYPE = has data => 'uint8[16]'; | ||
| 16 | }; | ||
| 17 | # | ||
| 18 | ffi->type( 'sint32' => 'SDL_JoystickID' ); | ||
| 19 | enum SDL_JoystickType => [ | ||
| 20 | qw[ | ||
| 21 | SDL_JOYSTICK_TYPE_UNKNOWN | ||
| 22 | SDL_JOYSTICK_TYPE_GAMECONTROLLER | ||
| 23 | SDL_JOYSTICK_TYPE_WHEEL | ||
| 24 | SDL_JOYSTICK_TYPE_ARCADE_STICK | ||
| 25 | SDL_JOYSTICK_TYPE_FLIGHT_STICK | ||
| 26 | SDL_JOYSTICK_TYPE_DANCE_PAD | ||
| 27 | SDL_JOYSTICK_TYPE_GUITAR | ||
| 28 | SDL_JOYSTICK_TYPE_DRUM_KIT | ||
| 29 | SDL_JOYSTICK_TYPE_ARCADE_PAD | ||
| 30 | SDL_JOYSTICK_TYPE_THROTTLE | ||
| 31 | ] | ||
| 32 | ], | ||
| 33 | SDL_JoystickPowerLevel => [ | ||
| 34 | [ SDL_JOYSTICK_POWER_UNKNOWN => -1 ], qw[SDL_JOYSTICK_POWER_EMPTY | ||
| 35 | SDL_JOYSTICK_POWER_LOW | ||
| 36 | SDL_JOYSTICK_POWER_MEDIUM | ||
| 37 | SDL_JOYSTICK_POWER_FULL | ||
| 38 | SDL_JOYSTICK_POWER_WIRED | ||
| 39 | SDL_JOYSTICK_POWER_MAX | ||
| 40 | ] | ||
| 41 | ]; | ||
| 42 | # | ||
| 43 | define joystick => [ | ||
| 44 | [ SDL_IPHONE_MAX_GFORCE => 5.0 ], | ||
| 45 | [ SDL_JOYSTICK_AXIS_MAX => 32767 ], | ||
| 46 | [ SDL_JOYSTICK_AXIS_MIN => -32768 ], | ||
| 47 | [ SDL_HAT_CENTERED => 0x00 ], | ||
| 48 | [ SDL_HAT_UP => 0x01 ], | ||
| 49 | [ SDL_HAT_RIGHT => 0x02 ], | ||
| 50 | [ SDL_HAT_DOWN => 0x04 ], | ||
| 51 | [ SDL_HAT_LEFT => 0x08 ], | ||
| 52 | [ SDL_HAT_RIGHTUP => sub () { ( SDL_HAT_RIGHT | SDL_HAT_UP ) } ], | ||
| 53 | [ SDL_HAT_RIGHTDOWN => sub () { ( SDL_HAT_RIGHT | SDL_HAT_DOWN ) } ], | ||
| 54 | [ SDL_HAT_LEFTUP => sub () { ( SDL_HAT_LEFT | SDL_HAT_UP ) } ], | ||
| 55 | [ SDL_HAT_LEFTDOWN => sub () { ( SDL_HAT_LEFT | SDL_HAT_DOWN ) } ], | ||
| 56 | ]; | ||
| 57 | # | ||
| 58 | attach joystick => { | ||
| 59 | SDL_LockJoysticks => [ [] ], | ||
| 60 | SDL_UnlockJoysticks => [ [] ], | ||
| 61 | SDL_NumJoysticks => [ [], 'int' ], | ||
| 62 | SDL_JoystickNameForIndex => [ ['int'], 'string' ], | ||
| 63 | SDL_JoystickGetDevicePlayerIndex => [ ['int'], 'int' ], | ||
| 64 | SDL_JoystickGetDeviceGUID => [ ['int'], 'SDL_JoystickGUID' ], | ||
| 65 | SDL_JoystickGetDeviceVendor => [ ['int'], 'uint16' ], | ||
| 66 | SDL_JoystickGetDeviceProduct => [ ['int'], 'uint16' ], | ||
| 67 | SDL_JoystickGetDeviceProductVersion => [ ['int'], 'uint16' ], | ||
| 68 | SDL_JoystickGetDeviceType => [ ['int'], 'SDL_JoystickType' ], | ||
| 69 | SDL_JoystickGetDeviceInstanceID => [ ['int'], 'SDL_JoystickID' ], | ||
| 70 | SDL_JoystickOpen => [ ['int'], 'SDL_Joystick' ], | ||
| 71 | SDL_JoystickFromInstanceID => [ ['SDL_JoystickID'], 'SDL_Joystick' ], | ||
| 72 | SDL_JoystickFromPlayerIndex => [ ['int'], 'SDL_Joystick' ], | ||
| 73 | SDL_JoystickAttachVirtual => [ [ 'int', 'int', 'int' ], 'int' ], | ||
| 74 | SDL_JoystickDetachVirtual => [ ['int'], 'int' ], | ||
| 75 | SDL_JoystickIsVirtual => [ ['int'], 'SDL_bool' ], | ||
| 76 | SDL_JoystickSetVirtualAxis => [ [ 'SDL_Joystick', 'int', 'sint16' ], 'int' ], | ||
| 77 | SDL_JoystickSetVirtualButton => [ [ 'SDL_Joystick', 'int', 'uint8' ], 'int' ], | ||
| 78 | SDL_JoystickSetVirtualHat => [ [ 'SDL_Joystick', 'int', 'uint8' ], 'int' ], | ||
| 79 | SDL_JoystickName => [ ['SDL_Joystick'], 'string' ], | ||
| 80 | SDL_JoystickGetPlayerIndex => [ ['SDL_Joystick'], 'int' ], | ||
| 81 | SDL_JoystickSetPlayerIndex => [ [ 'SDL_Joystick', 'int' ] ], | ||
| 82 | SDL_JoystickGetGUID => [ ['SDL_Joystick'], 'SDL_JoystickGUID' ], | ||
| 83 | SDL_JoystickGetVendor => [ ['SDL_Joystick'], 'uint16' ], | ||
| 84 | SDL_JoystickGetProduct => [ ['SDL_Joystick'], 'uint16' ], | ||
| 85 | SDL_JoystickGetProductVersion => [ ['SDL_Joystick'], 'uint16' ], | ||
| 86 | SDL_JoystickGetSerial => [ ['SDL_Joystick'], 'string' ], | ||
| 87 | SDL_JoystickGetType => [ ['SDL_Joystick'], 'SDL_JoystickType' ], | ||
| 88 | SDL_JoystickGetGUIDString => [ [ 'SDL_JoystickGUID', 'string', 'int' ] ], | ||
| 89 | SDL_JoystickGetGUIDFromString => [ ['string'], 'SDL_JoystickGUID' ], | ||
| 90 | SDL_JoystickGetAttached => [ ['SDL_Joystick'], 'SDL_bool' ], | ||
| 91 | SDL_JoystickInstanceID => [ ['SDL_Joystick'], 'SDL_JoystickID' ], | ||
| 92 | SDL_JoystickNumAxes => [ ['SDL_Joystick'], 'int' ], | ||
| 93 | SDL_JoystickNumBalls => [ ['SDL_Joystick'], 'int' ], | ||
| 94 | SDL_JoystickNumHats => [ ['SDL_Joystick'], 'int' ], | ||
| 95 | SDL_JoystickNumButtons => [ ['SDL_Joystick'], 'int' ], | ||
| 96 | SDL_JoystickUpdate => [ [] ], | ||
| 97 | SDL_JoystickEventState => [ ['int'], 'int' ], | ||
| 98 | SDL_JoystickGetAxis => [ [ 'SDL_Joystick', 'int' ], 'sint16' ], | ||
| 99 | SDL_JoystickGetAxisInitialState => [ [ 'SDL_Joystick', 'int', 'sint16' ], 'SDL_bool' ], | ||
| 100 | SDL_JoystickGetHat => [ [ 'SDL_Joystick', 'int' ], 'uint8' ], | ||
| 101 | SDL_JoystickGetBall => [ [ 'SDL_Joystick', 'int', 'int*', 'int*' ], 'int' ], | ||
| 102 | SDL_JoystickGetButton => [ [ 'SDL_Joystick', 'int' ], 'uint8' ], | ||
| 103 | SDL_JoystickRumble => [ [ 'SDL_Joystick', 'uint16', 'uint16', 'uint32' ], 'int' ], | ||
| 104 | SDL_JoystickRumbleTriggers => [ [ 'SDL_Joystick', 'uint16', 'uint16', 'uint32' ], 'int' ], | ||
| 105 | SDL_JoystickHasLED => [ ['SDL_Joystick'], 'SDL_bool' ], | ||
| 106 | SDL_JoystickSetLED => [ [ 'SDL_Joystick', 'uint8', 'uint8', 'uint8' ], 'int' ], | ||
| 107 | SDL_JoystickClose => [ ['SDL_Joystick'] ], | ||
| 108 | SDL_JoystickCurrentPowerLevel => [ ['SDL_Joystick'], 'SDL_JoystickPowerLevel' ] | ||
| 109 | }; | ||
| 110 | |||
| 111 | =encoding utf-8 | ||
| 112 | |||
| 113 | =head1 NAME | ||
| 114 | |||
| 115 | SDL2::joystick - SDL Joystick Event Handling | ||
| 116 | |||
| 117 | =head1 SYNOPSIS | ||
| 118 | |||
| 119 | use SDL2 qw[:joystick]; | ||
| 120 | |||
| 121 | =head1 DESCRIPTION | ||
| 122 | |||
| 123 | The term "device_index" identifies currently plugged in joystick devices | ||
| 124 | between 0 and L<< C<SDL_NumJoysticks( )>|/C<SDL_NumJoysticks( )> >>, with the | ||
| 125 | exact joystick behind a C<device_index> changing as joysticks are plugged and | ||
| 126 | unplugged. | ||
| 127 | |||
| 128 | The term "instance_id" is the current instantiation of a joystick device in the | ||
| 129 | system, if the joystick is removed and then re-inserted then it will get a new | ||
| 130 | C<instance_id>, C<instance_id>'s are monotonically increasing identifiers of a | ||
| 131 | joystick plugged in. | ||
| 132 | |||
| 133 | The term "C<player_index>" is the number assigned to a player on a specific | ||
| 134 | controller. For XInput controllers this returns the XInput user index. Many | ||
| 135 | joysticks will not be able to supply this information. | ||
| 136 | |||
| 137 | The term JoystickGUID is a stable 128-bit identifier for a joystick device that | ||
| 138 | does not change over time, it identifies class of the device (a X360 wired | ||
| 139 | controller for example). This identifier is platform dependent. | ||
| 140 | |||
| 141 | |||
| 142 | =head1 Functions | ||
| 143 | |||
| 144 | These functions may be imported with the C<:joystick> tag or by name. | ||
| 145 | |||
| 146 | =head2 C<SDL_LockJoysticks( )> | ||
| 147 | |||
| 148 | Locking for multi-threaded access to the joystick API. | ||
| 149 | |||
| 150 | If you are using the joystick API or handling events from multiple threads you | ||
| 151 | should use these locking functions to protect access to the joysticks. | ||
| 152 | |||
| 153 | In particular, you are guaranteed that the joystick list won't change, so the | ||
| 154 | API functions that take a joystick index will be valid, and joystick and game | ||
| 155 | controller events will not be delivered. | ||
| 156 | |||
| 157 | =head2 C<SDL_UnlockJoysticks( )> | ||
| 158 | |||
| 159 | Unlocking for multi-threaded access to the joystick API | ||
| 160 | |||
| 161 | If you are using the joystick API or handling events from multiple threads you | ||
| 162 | should use these locking functions to protect access to the joysticks. | ||
| 163 | |||
| 164 | In particular, you are guaranteed that the joystick list won't change, so the | ||
| 165 | API functions that take a joystick index will be valid, and joystick and game | ||
| 166 | controller events will not be delivered. | ||
| 167 | |||
| 168 | =head2 C<SDL_NumJoysticks( )> | ||
| 169 | |||
| 170 | Count the number of joysticks attached to the system. | ||
| 171 | |||
| 172 | my $count = SDL_NumJoysticks( ); | ||
| 173 | |||
| 174 | Returns the number of attached joysticks on success or a negative error code on | ||
| 175 | failure; call C<SDL_GetError( )> for more information. | ||
| 176 | |||
| 177 | =head2 C<SDL_JoystickNameForIndex( ... )> | ||
| 178 | |||
| 179 | Get the implementation dependent name of a joystick. | ||
| 180 | |||
| 181 | This can be called before any joysticks are opened. | ||
| 182 | |||
| 183 | Expected parameters include: | ||
| 184 | |||
| 185 | =over | ||
| 186 | |||
| 187 | =item C<device_index> - the index of the joystick to query (the N'th joystick on the system) | ||
| 188 | |||
| 189 | =back | ||
| 190 | |||
| 191 | Returns the name of the selected joystick. If no name can be found, this | ||
| 192 | function returns C<undef>; call C<SDL_GetError( )> for more information. | ||
| 193 | |||
| 194 | =head2 C<SDL_JoystickGetDevicePlayerIndex( ... )> | ||
| 195 | |||
| 196 | Get the player index of a joystick, or C<-1> if it's not available This can be | ||
| 197 | called before any joysticks are opened. | ||
| 198 | |||
| 199 | my $p_id = SDL_JoystickGetDevicePlayerIndex( 1 ); | ||
| 200 | |||
| 201 | Expected parameters include: | ||
| 202 | |||
| 203 | =over | ||
| 204 | |||
| 205 | =item C<device_index> | ||
| 206 | |||
| 207 | =back | ||
| 208 | |||
| 209 | Returns the player index or C<-1> on error; call C<SDL_GetError( )> for more | ||
| 210 | information. | ||
| 211 | |||
| 212 | =head2 C<SDL_JoystickGetDeviceGUID( ... )> | ||
| 213 | |||
| 214 | Get the implementation-dependent GUID for the joystick at a given device index. | ||
| 215 | |||
| 216 | This function can be called before any joysticks are opened. | ||
| 217 | |||
| 218 | Expected parameters include: | ||
| 219 | |||
| 220 | =over | ||
| 221 | |||
| 222 | =item C<device_index> - the index of the joystick to query (the N'th joystick on the system | ||
| 223 | |||
| 224 | =back | ||
| 225 | |||
| 226 | Returns the GUID of the selected joystick. If called on an invalid index, this | ||
| 227 | function returns a zero GUID. | ||
| 228 | |||
| 229 | =head2 C<SDL_JoystickGetDeviceVendor( ... )> | ||
| 230 | |||
| 231 | Get the USB vendor ID of a joystick, if available. | ||
| 232 | |||
| 233 | This can be called before any joysticks are opened. If the vendor ID isn't | ||
| 234 | available this function returns C<0>. | ||
| 235 | |||
| 236 | Expected parameters include: | ||
| 237 | |||
| 238 | =over | ||
| 239 | |||
| 240 | =item C<device_index> - the index of the joystick to query (the N'th joystick on the system | ||
| 241 | |||
| 242 | =back | ||
| 243 | |||
| 244 | Returns the USB vendor ID of the selected joystick. If called on an invalid | ||
| 245 | index, this function returns zero. | ||
| 246 | |||
| 247 | =head2 C<SDL_JoystickGetDeviceProduct( ... )> | ||
| 248 | |||
| 249 | Get the USB product ID of a joystick, if available. | ||
| 250 | |||
| 251 | This can be called before any joysticks are opened. If the product ID isn't | ||
| 252 | available this function returns 0. | ||
| 253 | |||
| 254 | Expected parameters include: | ||
| 255 | |||
| 256 | =over | ||
| 257 | |||
| 258 | =item C<device_index> - the index of the joystick to query (the N'th joystick on the system | ||
| 259 | |||
| 260 | =back | ||
| 261 | |||
| 262 | Returns the USB product ID of the selected joystick. If called on an invalid | ||
| 263 | index, this function returns zero. | ||
| 264 | |||
| 265 | =head2 C<SDL_JoystickGetDeviceProductVersion( ... )> | ||
| 266 | |||
| 267 | Get the product version of a joystick, if available. | ||
| 268 | |||
| 269 | This can be called before any joysticks are opened. If the product version | ||
| 270 | isn't available this function returns C<0>. | ||
| 271 | |||
| 272 | Expected parameters include: | ||
| 273 | |||
| 274 | =over | ||
| 275 | |||
| 276 | =item C<device_index> - the index of the joystick to query (the N'th joystick on the system | ||
| 277 | |||
| 278 | =back | ||
| 279 | |||
| 280 | Returns the product version of the selected joystick. If called on an invalid | ||
| 281 | index, this function returns zero. | ||
| 282 | |||
| 283 | =head2 C<SDL_JoystickGetDeviceType( ... )> | ||
| 284 | |||
| 285 | Get the type of a joystick, if available. | ||
| 286 | |||
| 287 | This can be called before any joysticks are opened. | ||
| 288 | |||
| 289 | Expected parameters include: | ||
| 290 | |||
| 291 | =over | ||
| 292 | |||
| 293 | =item C<device_index> - the index of the joystick to query (the N'th joystick on the system | ||
| 294 | |||
| 295 | =back | ||
| 296 | |||
| 297 | Returns the C<SDL_JoystickType> of the selected joystick. If called on an | ||
| 298 | invalid index, this function returns C<SDL_JOYSTICK_TYPE_UNKNOWN>. | ||
| 299 | |||
| 300 | =head2 C<SDL_JoystickGetDeviceInstanceID( ... )> | ||
| 301 | |||
| 302 | Get the instance ID of a joystick. | ||
| 303 | |||
| 304 | This can be called before any joysticks are opened. If the index is out of | ||
| 305 | range, this function will return C<-1>. | ||
| 306 | |||
| 307 | Expected parameters include: | ||
| 308 | |||
| 309 | =over | ||
| 310 | |||
| 311 | =item C<device_index> - the index of the joystick to query (the N'th joystick on the system | ||
| 312 | |||
| 313 | =back | ||
| 314 | |||
| 315 | Returns the instance id of the selected joystick. If called on an invalid | ||
| 316 | index, this function returns zero. | ||
| 317 | |||
| 318 | =head2 C<SDL_JoystickOpen( ... )> | ||
| 319 | |||
| 320 | Open a joystick for use. | ||
| 321 | |||
| 322 | # Initialize the joystick subsystem | ||
| 323 | SDL_InitSubSystem( SDL_INIT_JOYSTICK ); | ||
| 324 | |||
| 325 | # Check for joystick | ||
| 326 | if (SDL_NumJoysticks( ) > 0) { | ||
| 327 | # Open joystick | ||
| 328 | my $joy = SDL_JoystickOpen( 0 ); | ||
| 329 | |||
| 330 | if (joy) { | ||
| 331 | printf( "Opened Joystick 0\n" ); | ||
| 332 | printf( "Name: %s\n", SDL_JoystickNameForIndex( 0 ) ); | ||
| 333 | printf( "Number of Axes: %d\n", SDL_JoystickNumAxes($joy) ); | ||
| 334 | printf( "Number of Buttons: %d\n", SDL_JoystickNumButtons( $joy ) ); | ||
| 335 | printf( "Number of Balls: %d\n", SDL_JoystickNumBalls( $joy ) ); | ||
| 336 | } | ||
| 337 | else { | ||
| 338 | printf( "Couldn't open Joystick 0\n" ); | ||
| 339 | } | ||
| 340 | |||
| 341 | # Close if opened | ||
| 342 | if ( SDL_JoystickGetAttached( $joy ) ) { | ||
| 343 | SDL_JoystickClose( $joy ); | ||
| 344 | } | ||
| 345 | } | ||
| 346 | |||
| 347 | The C<device_index> argument refers to the N'th joystick presently recognized | ||
| 348 | by SDL on the system. It is B<NOT> the same as the instance ID used to identify | ||
| 349 | the joystick in future events. See L<< C<SDL_JoystickInstanceID( ... | ||
| 350 | )>|/C<SDL_JoystickInstanceID( ... )> >> for more details about instance IDs. | ||
| 351 | |||
| 352 | The joystick subsystem must be initialized before a joystick can be opened for | ||
| 353 | use. | ||
| 354 | |||
| 355 | Expected parameters include: | ||
| 356 | |||
| 357 | =over | ||
| 358 | |||
| 359 | =item C<device_index> - the index of the joystick to query | ||
| 360 | |||
| 361 | =back | ||
| 362 | |||
| 363 | Returns a joystick identifier or C<undef> if an error occurred; call | ||
| 364 | C<SDL_GetError( )> for more information. | ||
| 365 | |||
| 366 | =head2 C<SDL_JoystickFromInstanceID( ... )> | ||
| 367 | |||
| 368 | Get the L<SDL2::Joystick> associated with an instance id. | ||
| 369 | |||
| 370 | Expected parameters include: | ||
| 371 | |||
| 372 | =over | ||
| 373 | |||
| 374 | =item C<instance_id> - the instance id to get the SDL_Joystick for | ||
| 375 | |||
| 376 | =back | ||
| 377 | |||
| 378 | Returns an L<SDL2::Joystick> on success or C<undef> on failure; call | ||
| 379 | C<SDL_GetError( )> for more information. | ||
| 380 | |||
| 381 | =head2 C<SDL_JoystickFromPlayerIndex( ... )> | ||
| 382 | |||
| 383 | Get the L<SDL2::Joystick> associated with a player index. | ||
| 384 | |||
| 385 | Expected parameters include: | ||
| 386 | |||
| 387 | =over | ||
| 388 | |||
| 389 | =item C<player_index> - the player index to get the L<SDL2::Joystick> for | ||
| 390 | |||
| 391 | =back | ||
| 392 | |||
| 393 | Returns an L<SDL2::Joystick> on success or C<undef> on failure; call | ||
| 394 | C<SDL_GetError( )> for more information. | ||
| 395 | |||
| 396 | =head2 C<SDL_JoystickAttachVirtual( ... )> | ||
| 397 | |||
| 398 | Attach a new virtual joystick. | ||
| 399 | |||
| 400 | Expected parameters include: | ||
| 401 | |||
| 402 | =over | ||
| 403 | |||
| 404 | =item C<type> - C<SDL_JoystickType> | ||
| 405 | |||
| 406 | =item C<naxes> - number of axes | ||
| 407 | |||
| 408 | =item C<nbuttons> - number of buttons | ||
| 409 | |||
| 410 | =item C<nhats> - number of hats | ||
| 411 | |||
| 412 | =back | ||
| 413 | |||
| 414 | Returns the joystick's device index, or C<-1> if an error occurred. | ||
| 415 | |||
| 416 | =head2 C<SDL_JoystickDetachVirtual( ... )> | ||
| 417 | |||
| 418 | Detach a virtual joystick. | ||
| 419 | |||
| 420 | Expected parameters include: | ||
| 421 | |||
| 422 | =over | ||
| 423 | |||
| 424 | =item C<device_index> - a value previously returned from L<< C<SDL_JoystickAttachVirtual( ... )>|/C<SDL_JoystickAttachVirtual( ... )> >> | ||
| 425 | |||
| 426 | =back | ||
| 427 | |||
| 428 | Returns C<0> on success, or C<-1> if an error occurred. | ||
| 429 | |||
| 430 | =head2 C<SDL_JoystickIsVirtual( ... )> | ||
| 431 | |||
| 432 | Query whether or not the joystick at a given device index is virtual. | ||
| 433 | |||
| 434 | Expected parameters include: | ||
| 435 | |||
| 436 | =over | ||
| 437 | |||
| 438 | =item C<device_index> - a joystick device index | ||
| 439 | |||
| 440 | =back | ||
| 441 | |||
| 442 | Returns C<SDL_TRUE> if the joystick is virtual, C<SDL_FALSE> otherwise. | ||
| 443 | |||
| 444 | =head2 C<SDL_JoystickSetVirtualAxis( ... )> | ||
| 445 | |||
| 446 | Set values on an opened, virtual-joystick's axis. | ||
| 447 | |||
| 448 | Please note that values set here will not be applied until the next call to | ||
| 449 | SDL_JoystickUpdate, which can either be called directly, or can be called | ||
| 450 | indirectly through various other SDL APIs, including, but not limited to the | ||
| 451 | following: C<SDL_PollEvent>, C<SDL_PumpEvents>, C<SDL_WaitEventTimeout>, | ||
| 452 | C<SDL_WaitEvent>. | ||
| 453 | |||
| 454 | Expected parameters include: | ||
| 455 | |||
| 456 | =over | ||
| 457 | |||
| 458 | =item C<joystick> - the virtual joystick on which to set state | ||
| 459 | |||
| 460 | =item C<axis> - the specific axis on the virtual joystick to set | ||
| 461 | |||
| 462 | =item C<value> - the new value for the specified axis | ||
| 463 | |||
| 464 | =back | ||
| 465 | |||
| 466 | Returns C<0> on success, C<-1> on error. | ||
| 467 | |||
| 468 | =head2 C<SDL_JoystickSetVirtualButton( ... )> | ||
| 469 | |||
| 470 | Set values on an opened, virtual-joystick's button. | ||
| 471 | |||
| 472 | Please note that values set here will not be applied until the next call to | ||
| 473 | SDL_JoystickUpdate, which can either be called directly, or can be called | ||
| 474 | indirectly through various other SDL APIs, including, but not limited to the | ||
| 475 | following: C<SDL_PollEvent>, C<SDL_PumpEvents>, C<SDL_WaitEventTimeout>, | ||
| 476 | C<SDL_WaitEvent>. | ||
| 477 | |||
| 478 | Expected parameters include: | ||
| 479 | |||
| 480 | =over | ||
| 481 | |||
| 482 | =item C<joystick> - the virtual joystick on which to set state | ||
| 483 | |||
| 484 | =item C<button> - the specific button on the virtual joystick to set | ||
| 485 | |||
| 486 | =item C<value> - the new value for the specified button | ||
| 487 | |||
| 488 | =back | ||
| 489 | |||
| 490 | Returns C<0> on success, C<-1> on error. | ||
| 491 | |||
| 492 | =head2 C<SDL_JoystickSetVirtualHat( ... )> | ||
| 493 | |||
| 494 | Set values on an opened, virtual-joystick's hat. | ||
| 495 | |||
| 496 | Please note that values set here will not be applied until the next call to | ||
| 497 | C<SDL_JoystickUpdate>, which can either be called directly, or can be called | ||
| 498 | indirectly through various other SDL APIs, including, but not limited to the | ||
| 499 | following: C<SDL_PollEvent>, C<SDL_PumpEvents>, C<SDL_WaitEventTimeout>, | ||
| 500 | C<SDL_WaitEvent>. | ||
| 501 | |||
| 502 | Expected parameters include: | ||
| 503 | |||
| 504 | =over | ||
| 505 | |||
| 506 | =item C<joystick> - the virtual joystick on which to set state | ||
| 507 | |||
| 508 | =item C<hat> - the specific hat on the virtual joystick to set | ||
| 509 | |||
| 510 | =item C<value> - the new value for the specified hat | ||
| 511 | |||
| 512 | =back | ||
| 513 | |||
| 514 | Returns C<0> on success, C<-1> on error. | ||
| 515 | |||
| 516 | =head2 C<SDL_JoystickName( ... )> | ||
| 517 | |||
| 518 | Get the implementation dependent name of a joystick. | ||
| 519 | |||
| 520 | Expected parameters include: | ||
| 521 | |||
| 522 | =over | ||
| 523 | |||
| 524 | =item C<joystick> - the L<SDL2::Joystick> obtained from L<< C<SDL_JoystickOpen( ... )>|/C<SDL_JoystickOpen( ... )> >> | ||
| 525 | |||
| 526 | =back | ||
| 527 | |||
| 528 | Returns the name of the selected joystick. If no name can be found, this | ||
| 529 | function returns C<undef>; call C<SDL_GetError( )> for more information. | ||
| 530 | |||
| 531 | =head2 C<SDL_JoystickGetPlayerIndex( ... )> | ||
| 532 | |||
| 533 | Get the player index of an opened joystick. | ||
| 534 | |||
| 535 | For XInput controllers this returns the XInput user index. Many joysticks will | ||
| 536 | not be able to supply this information. | ||
| 537 | |||
| 538 | Expected parameters include: | ||
| 539 | |||
| 540 | =over | ||
| 541 | |||
| 542 | =item C<joystick> - the L<SDL2::Joystick> obtained from L<< C<SDL_JoystickOpen( ... )>|/C<SDL_JoystickOpen( ... )> >> | ||
| 543 | |||
| 544 | =back | ||
| 545 | |||
| 546 | Returns the player index, or C<-1> if it's not available. | ||
| 547 | |||
| 548 | =head2 C<SDL_JoystickSetPlayerIndex( ... )> | ||
| 549 | |||
| 550 | Set the player index of an opened joystick. | ||
| 551 | |||
| 552 | Expected parameters include: | ||
| 553 | |||
| 554 | =over | ||
| 555 | |||
| 556 | =item C<joystick> - the L<SDL2::Joystick> obtained from L<< C<SDL_JoystickOpen( ... )>|/C<SDL_JoystickOpen( ... )> >> | ||
| 557 | |||
| 558 | =item C<player_index> - the player index to set | ||
| 559 | |||
| 560 | =back | ||
| 561 | |||
| 562 | =head2 C<SDL_JoystickGetGUID( ... )> | ||
| 563 | |||
| 564 | Get the implementation-dependent GUID for the joystick. | ||
| 565 | |||
| 566 | This function requires an open joystick. | ||
| 567 | |||
| 568 | Expected parameters include: | ||
| 569 | |||
| 570 | =over | ||
| 571 | |||
| 572 | =item C<joystick> - the L<SDL2::Joystick> obtained from L<< C<SDL_JoystickOpen( ... )>|/C<SDL_JoystickOpen( ... )> >> | ||
| 573 | |||
| 574 | =back | ||
| 575 | |||
| 576 | Returns the GUID of the given joystick. If called on an invalid index, this | ||
| 577 | function returns a zero GUID; call C<SDL_GetError( )> for more information. | ||
| 578 | |||
| 579 | =head2 C<SDL_JoystickGetVendor( ... )> | ||
| 580 | |||
| 581 | Get the USB vendor ID of an opened joystick, if available. | ||
| 582 | |||
| 583 | If the vendor ID isn't available this function returns C<0>. | ||
| 584 | |||
| 585 | Expected parameters include: | ||
| 586 | |||
| 587 | =over | ||
| 588 | |||
| 589 | =item C<joystick> - the L<SDL2::Joystick> obtained from L<< C<SDL_JoystickOpen( ... )>|/C<SDL_JoystickOpen( ... )> >> | ||
| 590 | |||
| 591 | =back | ||
| 592 | |||
| 593 | Returns the USB vendor ID of the selected joystick, or C<0> if unavailable. | ||
| 594 | |||
| 595 | =head2 C<SDL_JoystickGetProduct( ... )> | ||
| 596 | |||
| 597 | Get the USB product ID of an opened joystick, if available. | ||
| 598 | |||
| 599 | If the product ID isn't available this function returns C<0>. | ||
| 600 | |||
| 601 | Expected parameters include: | ||
| 602 | |||
| 603 | =over | ||
| 604 | |||
| 605 | =item C<joystick> - the L<SDL2::Joystick> obtained from L<< C<SDL_JoystickOpen( ... )>|/C<SDL_JoystickOpen( ... )> >> | ||
| 606 | |||
| 607 | =back | ||
| 608 | |||
| 609 | Returns the USB product ID of the selected joystick, or C<0> if unavailable. | ||
| 610 | |||
| 611 | =head2 C<SDL_JoystickGetProductVersion( ... )> | ||
| 612 | |||
| 613 | Get the product version of an opened joystick, if available. If the product | ||
| 614 | version isn't available this function returns C<0>. | ||
| 615 | |||
| 616 | Expected parameters include: | ||
| 617 | |||
| 618 | =over | ||
| 619 | |||
| 620 | =item C<joystick> - the L<SDL2::Joystick> obtained from L<< C<SDL_JoystickOpen( ... )>|/C<SDL_JoystickOpen( ... )> >> | ||
| 621 | |||
| 622 | =back | ||
| 623 | |||
| 624 | Returns the product version of the selected joystick, or C<0> if unavailable. | ||
| 625 | |||
| 626 | =head2 C<SDL_JoystickGetSerial( ... )> | ||
| 627 | |||
| 628 | Get the serial number of an opened joystick, if available. | ||
| 629 | |||
| 630 | =over | ||
| 631 | |||
| 632 | =item C<joystick> - the L<SDL2::Joystick> obtained from L<< C<SDL_JoystickOpen( ... )>|/C<SDL_JoystickOpen( ... )> >> | ||
| 633 | |||
| 634 | =back | ||
| 635 | |||
| 636 | Returns the serial number of the joystick, or C<undef> if it is not available. | ||
| 637 | |||
| 638 | =head2 C<SDL_JoystickGetType( ... )> | ||
| 639 | |||
| 640 | Get the type of an opened joystick. | ||
| 641 | |||
| 642 | Expected parameters include: | ||
| 643 | |||
| 644 | =over | ||
| 645 | |||
| 646 | =item C<joystick> - the L<SDL2::Joystick> obtained from L<< C<SDL_JoystickOpen( ... )>|/C<SDL_JoystickOpen( ... )> >> | ||
| 647 | |||
| 648 | =back | ||
| 649 | |||
| 650 | Returns the C<SDL_JoystickType> of the selected joystick. | ||
| 651 | |||
| 652 | =head2 C<SDL_JoystickGetGUIDString( ... )> | ||
| 653 | |||
| 654 | Get an ASCII string representation for a given C<SDL_JoystickGUID>. | ||
| 655 | |||
| 656 | You should supply at least 33 bytes for pszGUID. | ||
| 657 | |||
| 658 | Expected parameters include: | ||
| 659 | |||
| 660 | =over | ||
| 661 | |||
| 662 | =item C<guid> - the C<SDL_JoystickGUID> you wish to convert to string | ||
| 663 | |||
| 664 | =item C<pszGUID> - buffer in which to write the ASCII string | ||
| 665 | |||
| 666 | =item C<cbGUID> - the size of pszGUID | ||
| 667 | |||
| 668 | =back | ||
| 669 | |||
| 670 | =head2 C<SDL_JoystickGetGUIDFromString( ... )> | ||
| 671 | |||
| 672 | Convert a GUID string into a C<SDL_JoystickGUID> structure. | ||
| 673 | |||
| 674 | Performs no error checking. If this function is given a string containing an | ||
| 675 | invalid GUID, the function will silently succeed, but the GUID generated will | ||
| 676 | not be useful. | ||
| 677 | |||
| 678 | Expected parameters include: | ||
| 679 | |||
| 680 | =over | ||
| 681 | |||
| 682 | =item C<pchGUID> - string containing an ASCII representation of a GUID | ||
| 683 | |||
| 684 | =back | ||
| 685 | |||
| 686 | Returns a C<SDL_JoystickGUID> structure. | ||
| 687 | |||
| 688 | =head2 C<SDL_JoystickGetAttached( ... )> | ||
| 689 | |||
| 690 | Get the status of a specified joystick. | ||
| 691 | |||
| 692 | Expected parameters include: | ||
| 693 | |||
| 694 | =over | ||
| 695 | |||
| 696 | =item C<joystick> - the L<joystick|SDL2::Joystick> to query | ||
| 697 | |||
| 698 | =back | ||
| 699 | |||
| 700 | Returns C<SDL_TRUE> if the joystick has been opened, C<SDL_FALSE> if it has | ||
| 701 | not; call C<SDL_GetError( )> for more information. | ||
| 702 | |||
| 703 | =head2 C<SDL_JoystickInstanceID( ... )> | ||
| 704 | |||
| 705 | Get the instance ID of an opened joystick. | ||
| 706 | |||
| 707 | Expected parameters include: | ||
| 708 | |||
| 709 | =over | ||
| 710 | |||
| 711 | =item C<joystick> - an L<SDL2::Joystick> structure containing joystick information | ||
| 712 | |||
| 713 | =back | ||
| 714 | |||
| 715 | Returns the instance ID of the specified joystick on success or a negative | ||
| 716 | error code on failure; call C<SDL_GetError( )> for more information. | ||
| 717 | |||
| 718 | =head2 C<SDL_JoystickNumAxes( ... )> | ||
| 719 | |||
| 720 | Get the number of general axis controls on a joystick. | ||
| 721 | |||
| 722 | Often, the directional pad on a game controller will either look like 4 | ||
| 723 | separate buttons or a POV hat, and not axes, but all of this is up to the | ||
| 724 | device and platform. | ||
| 725 | |||
| 726 | Expected parameters include: | ||
| 727 | |||
| 728 | =over | ||
| 729 | |||
| 730 | =item C<joystick> - an L<SDL2::Joystick> structure containing joystick information | ||
| 731 | |||
| 732 | =back | ||
| 733 | |||
| 734 | Returns the number of axis controls/number of axes on success or a negative | ||
| 735 | error code on failure; call C<SDL_GetError( )> for more information. | ||
| 736 | |||
| 737 | =head2 C<SDL_JoystickNumBalls( ... )> | ||
| 738 | |||
| 739 | Get the number of trackballs on a joystick. | ||
| 740 | |||
| 741 | Joystick trackballs have only relative motion events associated with them and | ||
| 742 | their state cannot be polled. | ||
| 743 | |||
| 744 | Most joysticks do not have trackballs. | ||
| 745 | |||
| 746 | Expected parameters include: | ||
| 747 | |||
| 748 | =over | ||
| 749 | |||
| 750 | =item C<joystick> - an L<SDL2::Joystick> structure containing joystick information | ||
| 751 | |||
| 752 | =back | ||
| 753 | |||
| 754 | Returns the number of trackballs on success or a negative error code on | ||
| 755 | failure; call C<SDL_GetError( )> for more information. | ||
| 756 | |||
| 757 | =head2 C<SDL_JoystickNumHats( ... )> | ||
| 758 | |||
| 759 | Get the number of POV hats on a joystick. | ||
| 760 | |||
| 761 | Expected parameters include: | ||
| 762 | |||
| 763 | =over | ||
| 764 | |||
| 765 | =item C<joystick> - an L<SDL2::Joystick> structure containing joystick information | ||
| 766 | |||
| 767 | =back | ||
| 768 | |||
| 769 | Returns the number of POV hats on success or a negative error code on failure; | ||
| 770 | call C<SDL_GetError( )> for more information. | ||
| 771 | |||
| 772 | =head2 C<SDL_JoystickNumButtons( ... )> | ||
| 773 | |||
| 774 | Get the number of buttons on a joystick. | ||
| 775 | |||
| 776 | Expected parameters include: | ||
| 777 | |||
| 778 | =over | ||
| 779 | |||
| 780 | =item C<joystick> - an L<SDL2::Joystick> structure containing joystick information | ||
| 781 | |||
| 782 | =back | ||
| 783 | |||
| 784 | Returns the number of buttons on success or a negative error code on failure; | ||
| 785 | call C<SDL_GetError( )> for more information. | ||
| 786 | |||
| 787 | =head2 C<SDL_JoystickUpdate( )> | ||
| 788 | |||
| 789 | Update the current state of the open joysticks. | ||
| 790 | |||
| 791 | This is called automatically by the event loop if any joystick events are | ||
| 792 | enabled. | ||
| 793 | |||
| 794 | =head2 C<SDL_JoystickEventState( ... )> | ||
| 795 | |||
| 796 | Enable/disable joystick event polling. | ||
| 797 | |||
| 798 | If joystick events are disabled, you must call L<< C<SDL_JoystickUpdate( | ||
| 799 | )>|/C<SDL_JoystickUpdate( )> >> yourself and manually check the state of the | ||
| 800 | joystick when you want joystick information. | ||
| 801 | |||
| 802 | It is recommended that you leave joystick event handling enabled. | ||
| 803 | |||
| 804 | B<WARNING>: Calling this function may delete all events currently in SDL's | ||
| 805 | event queue. | ||
| 806 | |||
| 807 | Expected parameters include: | ||
| 808 | |||
| 809 | =over | ||
| 810 | |||
| 811 | =item C<state> - can be one of C<SDL_QUERY>, C<SDL_IGNORE>, or C<SDL_ENABLE> | ||
| 812 | |||
| 813 | =back | ||
| 814 | |||
| 815 | Returns C<1> if enabled, C<0> if disabled, or a negative error code on failure; | ||
| 816 | call C<SDL_GetError( )> for more information. | ||
| 817 | |||
| 818 | If C<state> is C<SDL_QUERY> then the current state is returned, otherwise the | ||
| 819 | new processing state is returned. | ||
| 820 | |||
| 821 | =head2 C<SDL_JoystickGetAxis( ... )> | ||
| 822 | |||
| 823 | Get the current state of an axis control on a joystick. | ||
| 824 | |||
| 825 | SDL makes no promises about what part of the joystick any given axis refers to. | ||
| 826 | Your game should have some sort of configuration UI to let users specify what | ||
| 827 | each axis should be bound to. Alternately, SDL's higher-level Game Controller | ||
| 828 | API makes a great effort to apply order to this lower-level interface, so you | ||
| 829 | know that a specific axis is the "left thumb stick," etc. | ||
| 830 | |||
| 831 | The value returned by L<< C<SDL_JoystickGetAxis( ... )>|/C<SDL_JoystickGetAxis( | ||
| 832 | ... )> >> is a signed integer (C<-32768> to C<32767>) representing the current | ||
| 833 | position of the axis. It may be necessary to impose certain tolerances on these | ||
| 834 | values to account for jitter. | ||
| 835 | |||
| 836 | Expected parameters include: | ||
| 837 | |||
| 838 | =over | ||
| 839 | |||
| 840 | =item C<joystick> - an L<SDL2::Joystick> structure containing joystick information | ||
| 841 | |||
| 842 | =item C<axis> - the axis to query; the axis indices start at index C<0> | ||
| 843 | |||
| 844 | =back | ||
| 845 | |||
| 846 | Returns a 16-bit signed integer representing the current position of the axis | ||
| 847 | or 0 on failure; call C<SDL_GetError( )> for more information. | ||
| 848 | |||
| 849 | =head2 C<SDL_JoystickGetAxisInitialState( ... )> | ||
| 850 | |||
| 851 | Get the initial state of an axis control on a joystick. | ||
| 852 | |||
| 853 | The state is a value ranging from C<-32768> to C<32767>. | ||
| 854 | |||
| 855 | The axis indices start at index C<0>. | ||
| 856 | |||
| 857 | Expected parameters include: | ||
| 858 | |||
| 859 | =over | ||
| 860 | |||
| 861 | =item C<joystick> - an L<SDL2::Joystick> structure containing joystick information | ||
| 862 | |||
| 863 | =item C<axis> - the axis to query; the axis indices start at index C<0> | ||
| 864 | |||
| 865 | =item C<state> - upon return, the initial value is supplied here | ||
| 866 | |||
| 867 | =back | ||
| 868 | |||
| 869 | Return C<SDL_TRUE> if this axis has any initial value, or C<SDL_FALSE> if not. | ||
| 870 | |||
| 871 | =head2 C<SDL_JoystickGetHat> | ||
| 872 | |||
| 873 | Get the current state of a POV hat on a joystick. | ||
| 874 | |||
| 875 | The returned value will be one of the following positions: | ||
| 876 | |||
| 877 | =over | ||
| 878 | |||
| 879 | =item C<SDL_HAT_CENTERED> | ||
| 880 | |||
| 881 | =item C<SDL_HAT_UP> | ||
| 882 | |||
| 883 | =item C<SDL_HAT_RIGHT> | ||
| 884 | |||
| 885 | =item C<SDL_HAT_DOWN> | ||
| 886 | |||
| 887 | =item C<SDL_HAT_LEFT> | ||
| 888 | |||
| 889 | =item C<SDL_HAT_RIGHTUP> | ||
| 890 | |||
| 891 | =item C<SDL_HAT_RIGHTDOWN> | ||
| 892 | |||
| 893 | =item C<SDL_HAT_LEFTUP> | ||
| 894 | |||
| 895 | =item C<SDL_HAT_LEFTDOWN> | ||
| 896 | |||
| 897 | =back | ||
| 898 | |||
| 899 | Expected parameters include: | ||
| 900 | |||
| 901 | =over | ||
| 902 | |||
| 903 | =item C<joystick> - an L<SDL2::Joystick> structure containing joystick information | ||
| 904 | |||
| 905 | =item C<hat> - the hat index to get the state from; indices start at index C<0> | ||
| 906 | |||
| 907 | =back | ||
| 908 | |||
| 909 | Returns the current hat position. | ||
| 910 | |||
| 911 | =head2 C<SDL_JoystickGetBall( ... )> | ||
| 912 | |||
| 913 | Get the ball axis change since the last poll. | ||
| 914 | |||
| 915 | Trackballs can only return relative motion since the last call to L<< | ||
| 916 | C<SDL_JoystickGetBall( ... )>|/C<SDL_JoystickGetBall( ... )> >>, these motion | ||
| 917 | deltas are placed into C<dx> and C<dy>. | ||
| 918 | |||
| 919 | Most joysticks do not have trackballs. | ||
| 920 | |||
| 921 | Expected parameters include: | ||
| 922 | |||
| 923 | =over | ||
| 924 | |||
| 925 | =item C<joystick> - the L<SDL2::Joystick> to query | ||
| 926 | |||
| 927 | =item C<ball> - the ball index to query; ball indices start at index C<0> | ||
| 928 | |||
| 929 | =item C<dx> - stores the difference in the x axis position since the last poll | ||
| 930 | |||
| 931 | =item C<dy> - stores the difference in the y axis position since the last poll | ||
| 932 | |||
| 933 | =back | ||
| 934 | |||
| 935 | Returns C<0> on success or a negative error code on failure; call | ||
| 936 | C<SDL_GetError( )> for more information. | ||
| 937 | |||
| 938 | =head2 C<SDL_JoystickGetButton( ... )> | ||
| 939 | |||
| 940 | Get the current state of a button on a joystick. | ||
| 941 | |||
| 942 | Expected parameters include: | ||
| 943 | |||
| 944 | =over | ||
| 945 | |||
| 946 | =item C<joystick> - an L<SDL2::Joystick> structure containing joystick information | ||
| 947 | |||
| 948 | =item C<button> - the button index to get the state from; indices start at index C<0> | ||
| 949 | |||
| 950 | =back | ||
| 951 | |||
| 952 | Returns C<1> if the specified button is pressed, C<0> otherwise. | ||
| 953 | |||
| 954 | =head2 C<SDL_JoystickRumble( ... )> | ||
| 955 | |||
| 956 | Start a rumble effect. | ||
| 957 | |||
| 958 | Each call to this function cancels any previous rumble effect, and calling it | ||
| 959 | with C<0> intensity stops any rumbling. | ||
| 960 | |||
| 961 | Expected parameters include: | ||
| 962 | |||
| 963 | =over | ||
| 964 | |||
| 965 | =item C<joystick> - the joystick to vibrate | ||
| 966 | |||
| 967 | =item C<low_frequency_rumble> - the intensity of the low frequency (left) rumble motor, from C<0> to C<0xFFFF> | ||
| 968 | |||
| 969 | =item C<high_frequency_rumble> - the intensity of the high frequency (right) rumble motor, from C<0> to C<0xFFFF> | ||
| 970 | |||
| 971 | =item C<duration_ms> - the duration of the rumble effect, in milliseconds | ||
| 972 | |||
| 973 | =back | ||
| 974 | |||
| 975 | Returns C<0>, or C<-1> if rumble isn't supported on this joystick. | ||
| 976 | |||
| 977 | =head2 C<SDL_JoystickRumbleTriggers( ... )> | ||
| 978 | |||
| 979 | Start a rumble effect in the joystick's triggers | ||
| 980 | |||
| 981 | Each call to this function cancels any previous trigger rumble effect, and | ||
| 982 | calling it with 0 intensity stops any rumbling. | ||
| 983 | |||
| 984 | Note that this function is for _trigger_ rumble; the first joystick to support | ||
| 985 | this was the PlayStation 5's DualShock 5 controller. If you want the (more | ||
| 986 | common) whole-controller rumble, use SDL_JoystickRumble() instead. | ||
| 987 | |||
| 988 | Expected parameters include: | ||
| 989 | |||
| 990 | =over | ||
| 991 | |||
| 992 | =item C<joystick> - the joystick to vibrate | ||
| 993 | |||
| 994 | =item C<left_rumble> - the intensity of the left trigger rumble motor, from C<0> to C<0xFFFF> | ||
| 995 | |||
| 996 | =item C<right_rumble> - the intensity of the right trigger rumble motor, from C<0> to C<0xFFFF> | ||
| 997 | |||
| 998 | =item C<duration_ms> - the duration of the rumble effect, in milliseconds | ||
| 999 | |||
| 1000 | =back | ||
| 1001 | |||
| 1002 | Returns C<0>, or C<-1> if trigger rumble isn't supported on this joystick. | ||
| 1003 | |||
| 1004 | =head2 C<SDL_JoystickHasLED( ... )> | ||
| 1005 | |||
| 1006 | Query whether a joystick has an LED. | ||
| 1007 | |||
| 1008 | An example of a joystick LED is the light on the back of a PlayStation 4's | ||
| 1009 | DualShock 4 controller. | ||
| 1010 | |||
| 1011 | Expected parameters include: | ||
| 1012 | |||
| 1013 | =over | ||
| 1014 | |||
| 1015 | =item C<joystick> - the joystick to query | ||
| 1016 | |||
| 1017 | =back | ||
| 1018 | |||
| 1019 | Return C<SDL_TRUE> if the joystick has a modifiable LED, C<SDL_FALSE> | ||
| 1020 | otherwise. | ||
| 1021 | |||
| 1022 | =head2 C<SDL_JoystickSetLED( ... )> | ||
| 1023 | |||
| 1024 | Update a joystick's LED color. | ||
| 1025 | |||
| 1026 | An example of a joystick LED is the light on the back of a PlayStation 4's | ||
| 1027 | DualShock 4 controller. | ||
| 1028 | |||
| 1029 | Expected parameters include: | ||
| 1030 | |||
| 1031 | =over | ||
| 1032 | |||
| 1033 | =item C<joystick> - the joystick to update | ||
| 1034 | |||
| 1035 | =item C<red> - the intensity of the red LED | ||
| 1036 | |||
| 1037 | =item C<green> - the intensity of the green LED | ||
| 1038 | |||
| 1039 | =item C<blue> - the intensity of the blue LED | ||
| 1040 | |||
| 1041 | =back | ||
| 1042 | |||
| 1043 | Returns C<0> on success, C<-1> if this joystick does not have a modifiable LED. | ||
| 1044 | |||
| 1045 | =head2 C<SDL_JoystickClose( ... )> | ||
| 1046 | |||
| 1047 | Close a joystick previously opened with L<< CC<SDL_JoystickOpen( ... | ||
| 1048 | )>|/C<SDL_JoystickOpen( ... )> >>. | ||
| 1049 | |||
| 1050 | Expected parameters include: | ||
| 1051 | |||
| 1052 | =over | ||
| 1053 | |||
| 1054 | =item C<joystick> - the joystick device to close | ||
| 1055 | |||
| 1056 | =back | ||
| 1057 | |||
| 1058 | =head2 C<SDL_JoystickCurrentPowerLevel( ... )> | ||
| 1059 | |||
| 1060 | Get the battery level of a joystick as C<SDL_JoystickPowerLevel>. | ||
| 1061 | |||
| 1062 | Expected parameters include: | ||
| 1063 | |||
| 1064 | =over | ||
| 1065 | |||
| 1066 | =item C<joystick> - the L<SDL2::Joystick> to query | ||
| 1067 | |||
| 1068 | =back | ||
| 1069 | |||
| 1070 | Returns the current battery level as C<SDL_JoystickPowerLevel> on success or | ||
| 1071 | C<SDL_JOYSTICK_POWER_UNKNOWN> if it is unknown | ||
| 1072 | |||
| 1073 | =head1 Defined Values and Enumerations | ||
| 1074 | |||
| 1075 | You may import these values by name or, unless another tag is given, with the | ||
| 1076 | C<:joystick> tag. | ||
| 1077 | |||
| 1078 | =head2 C<SDL_JoystickType> | ||
| 1079 | |||
| 1080 | These values may be imported with the C<:joystickType> tag. | ||
| 1081 | |||
| 1082 | =over | ||
| 1083 | |||
| 1084 | =item C<SDL_JOYSTICK_TYPE_UNKNOWN> | ||
| 1085 | |||
| 1086 | =item C<SDL_JOYSTICK_TYPE_GAMECONTROLLER> | ||
| 1087 | |||
| 1088 | =item C<SDL_JOYSTICK_TYPE_WHEEL> | ||
| 1089 | |||
| 1090 | =item C<SDL_JOYSTICK_TYPE_ARCADE_STICK> | ||
| 1091 | |||
| 1092 | =item C<SDL_JOYSTICK_TYPE_FLIGHT_STICK> | ||
| 1093 | |||
| 1094 | =item C<SDL_JOYSTICK_TYPE_DANCE_PAD> | ||
| 1095 | |||
| 1096 | =item C<SDL_JOYSTICK_TYPE_GUITAR> | ||
| 1097 | |||
| 1098 | =item C<SDL_JOYSTICK_TYPE_DRUM_KIT> | ||
| 1099 | |||
| 1100 | =item C<SDL_JOYSTICK_TYPE_ARCADE_PAD> | ||
| 1101 | |||
| 1102 | =item C<SDL_JOYSTICK_TYPE_THROTTLE> | ||
| 1103 | |||
| 1104 | =back | ||
| 1105 | |||
| 1106 | =head2 C<SDL_JoystickPowerLevel> | ||
| 1107 | |||
| 1108 | These values by me imported with the C<:joystickPowerLevel> tag. | ||
| 1109 | |||
| 1110 | =over | ||
| 1111 | |||
| 1112 | =item C<SDL_JOYSTICK_POWER_UNKNOWN> | ||
| 1113 | |||
| 1114 | =item C<SDL_JOYSTICK_POWER_EMPTY> - C<< <= 5% >> | ||
| 1115 | |||
| 1116 | =item C<SDL_JOYSTICK_POWER_LOW> - C<< <= 20% >> | ||
| 1117 | |||
| 1118 | =item C<SDL_JOYSTICK_POWER_MEDIUM> - C<< <= 70% >> | ||
| 1119 | |||
| 1120 | =item C<SDL_JOYSTICK_POWER_FULL> - C<< <= 100% >> | ||
| 1121 | |||
| 1122 | =item C<SDL_JOYSTICK_POWER_WIRED> | ||
| 1123 | |||
| 1124 | =item C<SDL_JOYSTICK_POWER_MAX> | ||
| 1125 | |||
| 1126 | =back | ||
| 1127 | |||
| 1128 | =head2 C<SDL_IPHONE_MAX_GFORCE> | ||
| 1129 | |||
| 1130 | Set max recognized G-force from accelerometer. See | ||
| 1131 | C<src/joystick/uikit/SDL_sysjoystick.m> for notes on why this is needed. | ||
| 1132 | |||
| 1133 | =head2 Axis limits | ||
| 1134 | |||
| 1135 | These may be imported with the C<:joystick> tag. | ||
| 1136 | |||
| 1137 | =over | ||
| 1138 | |||
| 1139 | =item C<SDL_JOYSTICK_AXIS_MAX> | ||
| 1140 | |||
| 1141 | =item C<SDL_JOYSTICK_AXIS_MIN> | ||
| 1142 | |||
| 1143 | =back | ||
| 1144 | |||
| 1145 | =head2 Hat Positions | ||
| 1146 | |||
| 1147 | These may be imported by name or with the C<:joystick> tag. | ||
| 1148 | |||
| 1149 | =over | ||
| 1150 | |||
| 1151 | =item C<SDL_HAT_CENTERED> | ||
| 1152 | |||
| 1153 | =item C<SDL_HAT_UP> | ||
| 1154 | |||
| 1155 | =item C<SDL_HAT_RIGHT> | ||
| 1156 | |||
| 1157 | =item C<SDL_HAT_DOWN> | ||
| 1158 | |||
| 1159 | =item C<SDL_HAT_LEFT> | ||
| 1160 | |||
| 1161 | =item C<SDL_HAT_RIGHTUP> | ||
| 1162 | |||
| 1163 | =item C<SDL_HAT_RIGHTDOWN> | ||
| 1164 | |||
| 1165 | =item C<SDL_HAT_LEFTUP> | ||
| 1166 | |||
| 1167 | =item C<SDL_HAT_LEFTDOWN> | ||
| 1168 | |||
| 1169 | =back | ||
| 1170 | |||
| 1171 | |||
| 1172 | =head1 LICENSE | ||
| 1173 | |||
| 1174 | Copyright (C) Sanko Robinson. | ||
| 1175 | |||
| 1176 | This library is free software; you can redistribute it and/or modify it under | ||
| 1177 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||
| 1178 | conditions may apply to data transmitted through this module. | ||
| 1179 | |||
| 1180 | =head1 AUTHOR | ||
| 1181 | |||
| 1182 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||
| 1183 | |||
| 1184 | =begin stopwords | ||
| 1185 | |||
| 1186 | bitwise scancoded scancodes N'th XInput JoystickGUID pszGUID | ||
| 1187 | |||
| 1188 | =end stopwords | ||
| 1189 | |||
| 1190 | =cut | ||
| 1191 | |||
| 1192 | }; | ||
| 1193 | 1; |