Class SdlGamecontroller


  • public final class SdlGamecontroller
    extends Object
    Definitions from file SDL_gamecontroller.h

    Function definitions for SDL game controller event handling.

    In order to use these functions, SDL_Init() must have been called with the SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system for game controllers, and load appropriate drivers.

    If you would like to receive controller updates while the application is in the background, you should set the following hint before calling SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS

    To count the number of game controllers in the system for the following:

      int nJoysticks = SDL_NumJoysticks();
      int nGameControllers = 0;
      for (int i = 0; i < nJoysticks; i++) {
          if (SDL_IsGameController(i)) {
              nGameControllers++;
          }
      }
     

    Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping() you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is: guid,name,mappings

    Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones. Under Windows there is a reserved GUID of "xinput" that covers any XInput devices.

    The mapping format for joystick is:

    • bX - a joystick button, index X
    • hX.Y - hat X with value Y
    • aX - axis X of the joystick

    Buttons can be used as a controller axis and vice versa.

    This string shows an example of a valid mapping for a controller

     "03000000341a00003608000000000000,PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
     
    • Method Detail

      • SDL_GameControllerAddMappingsFromRW

        public static int SDL_GameControllerAddMappingsFromRW​(SDL_RWops rw,
                                                              int freerw)
        Load a set of Game Controller mappings from a seekable SDL data stream.

        You can call this function several times, if needed, to load different database files.

        If a new mapping is loaded for an already known controller GUID, the later version will overwrite the one currently loaded.

        Mappings not belonging to the current platform or with no platform field specified will be ignored (i.e. mappings for Linux will be ignored in Windows, etc).

        This function will load the text database entirely in memory before processing it, so take this into consideration if you are in a memory constrained environment.

        Parameters:
        rw - the data stream for the mappings to be added
        freerw - non-zero to close the stream after being read
        Returns:
        the number of mappings added or -1 on error; call SDL_GetError() for more information.
        Since:
        This function is available since SDL 2.0.2.
        See Also:
        SDL_GameControllerAddMapping(String), SDL_GameControllerAddMappingsFromFile(String), SDL_GameControllerMappingForGUID(SDL_JoystickGUID)
      • SDL_GameControllerAddMappingsFromFile

        public static int SDL_GameControllerAddMappingsFromFile​(String file)
        Load a set of mappings from a file, filtered by the current SDL_GetPlatform()

        Convenience method.

      • SDL_GameControllerAddMapping

        public static int SDL_GameControllerAddMapping​(String mappingString)
        Add support for controllers that SDL is unaware of or to cause an existing controller to have a different binding.

        The mapping string has the format "GUID,name,mapping", where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones. Under Windows there is a reserved GUID of "xinput" that covers all XInput devices. The mapping format for joystick is: {| |bX |a joystick button, index X |- |hX.Y |hat X with value Y |- |aX |axis X of the joystick |} Buttons can be used as a controller axes and vice versa.

        This string shows an example of a valid mapping for a controller:

         "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7"
         
        Parameters:
        mappingString - the mapping string
        Returns:
        1 if a new mapping is added, 0 if an existing mapping is updated, -1 on error; call SDL_GetError() for more information.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerMapping(SDL_GameController), SDL_GameControllerMappingForGUID(SDL_JoystickGUID)
      • SDL_GameControllerNumMappings

        public static int SDL_GameControllerNumMappings()
        Get the number of mappings installed.
        Returns:
        the number of mappings.
        Since:
        This function is available since SDL 2.0.6.
      • SDL_GameControllerMappingForIndex

        public static String SDL_GameControllerMappingForIndex​(int mappingIndex)
        Get the mapping at a particular index.
        Returns:
        the mapping string. Returns null if the index is out of range.
        Since:
        This function is available since SDL 2.0.6.
      • SDL_GameControllerMapping

        public static String SDL_GameControllerMapping​(SDL_GameController gamecontroller)
        Get the current mapping of a Game Controller.

        Details about mappings are discussed with SDL_GameControllerAddMapping().

        Parameters:
        gamecontroller - the game controller you want to get the current mapping for
        Returns:
        a string that has the controller's mapping or null if no mapping is available; call SDL_GetError() for more information.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerAddMapping(String), SDL_GameControllerMappingForGUID(SDL_JoystickGUID)
      • SDL_IsGameController

        public static boolean SDL_IsGameController​(int joystickIndex)
        Check if the given joystick is supported by the game controller interface.

        joystick_index is the same as the device_index passed to SDL_JoystickOpen().

        Parameters:
        joystickIndex - the device_index of a device, up to SDL_NumJoysticks()
        Returns:
        true if the given joystick is supported by the game controller interface, false if it isn't or it's an invalid index.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerNameForIndex(int), SDL_GameControllerOpen(int)
      • SDL_GameControllerNameForIndex

        public static String SDL_GameControllerNameForIndex​(int joystickIndex)
        Get the implementation dependent name for the game controller.

        This function can be called before any controllers are opened.

        joystickIndex is the same as the deviceIndex passed to SDL_JoystickOpen().

        Parameters:
        joystickIndex - the device_index of a device, from zero to SDL_NumJoysticks()-1
        Returns:
        the implementation-dependent name for the game controller, or null if there is no name or the index is invalid.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerName(SDL_GameController), SDL_GameControllerOpen(int), SDL_IsGameController(int)
      • SDL_GameControllerPathForIndex

        public static String SDL_GameControllerPathForIndex​(int joystickIndex)
        Get the implementation dependent path for the game controller.

        This function can be called before any controllers are opened.

        joystickIndex is the same as the deviceIndex passed to SDL_JoystickOpen().

        Parameters:
        joystickIndex - the device_index of a device, from zero to SDL_NumJoysticks()-1
        Returns:
        the implementation-dependent path for the game controller, or NULL if there is no path or the index is invalid.
        Since:
        This function is available since SDL 2.24.0.
        See Also:
        SDL_GameControllerPath(SDL_GameController)
      • SDL_GameControllerTypeForIndex

        public static int SDL_GameControllerTypeForIndex​(int joystickIndex)
        Get the type of a game controller.

        This can be called before any controllers are opened.

        Parameters:
        joystickIndex - the device_index of a device, from zero to SDL_NumJoysticks()-1
        Returns:
        the controller type.
        Since:
        This function is available since SDL 2.0.12.
      • SDL_GameControllerMappingForDeviceIndex

        public static String SDL_GameControllerMappingForDeviceIndex​(int joystickIndex)
        Get the mapping of a game controller.

        This can be called before any controllers are opened.

        Parameters:
        joystickIndex - the device_index of a device, from zero to SDL_NumJoysticks()-1
        Returns:
        the mapping string. Returns null if no mapping is available.
        Since:
        This function is available since SDL 2.0.9.
      • SDL_GameControllerOpen

        public static SDL_GameController SDL_GameControllerOpen​(int joystickIndex)
        Open a game controller for use.

        joystick_index is the same as the device_index passed to SDL_JoystickOpen().

        The index passed as an argument refers to the N'th game controller on the system. This index is not the value which will identify this controller in future controller events. The joystick's instance id (SDL_JoystickID) will be used there instead.

        Parameters:
        joystickIndex - the device_index of a device, up to SDL_NumJoysticks()
        Returns:
        a gamecontroller identifier or null if an error occurred; call SDL_GetError() for more information.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerClose(SDL_GameController), SDL_GameControllerNameForIndex(int), SDL_IsGameController(int)
      • SDL_GameControllerFromInstanceID

        public static SDL_GameController SDL_GameControllerFromInstanceID​(SDL_JoystickID joyId)
        Get the SDL_GameController associated with an instance id.
        Parameters:
        joyId - the instance id to get the SDL_GameController for
        Returns:
        an SDL_GameController on success or null on failure; call SDL_GetError() for more information.
        Since:
        This function is available since SDL 2.0.4.
      • SDL_GameControllerName

        public static String SDL_GameControllerName​(SDL_GameController gamecontroller)
        Get the implementation-dependent name for an opened game controller.

        This is the same name as returned by SDL_GameControllerNameForIndex(), but it takes a controller identifier instead of the (unstable) device index.

        Parameters:
        gamecontroller - a game controller identifier previously returned by SDL_GameControllerOpen()
        Returns:
        the implementation dependent name for the game controller, or null if there is no name or the identifier passed is invalid.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerNameForIndex(int), SDL_GameControllerOpen(int)
      • SDL_GameControllerPath

        public static String SDL_GameControllerPath​(SDL_GameController gamecontroller)
        Get the implementation-dependent path for an opened game controller.

        This is the same path as returned by SDL_GameControllerNameForIndex(), but it takes a controller identifier instead of the (unstable) device index.

        Parameters:
        gamecontroller - a game controller identifier previously returned by SDL_GameControllerOpen()
        Returns:
        the implementation dependent path for the game controller, or NULL if there is no path or the identifier passed is invalid.
        Since:
        This function is available since SDL 2.24.0.
        See Also:
        SDL_GameControllerPathForIndex(int)
      • SDL_GameControllerGetType

        public static int SDL_GameControllerGetType​(SDL_GameController gamecontroller)
        Get the type of this currently opened controller

        This is the same name as returned by SDL_GameControllerTypeForIndex(), but it takes a controller identifier instead of the (unstable) device index.

        Parameters:
        gamecontroller - the game controller object to query.
        Returns:
        the controller type.
        Since:
        This function is available since SDL 2.0.12.
      • SDL_GameControllerGetPlayerIndex

        public static int SDL_GameControllerGetPlayerIndex​(SDL_GameController gamecontroller)
        Get the player index of an opened game controller.

        For XInput controllers this returns the XInput user index.

        Parameters:
        gamecontroller - the game controller object to query.
        Returns:
        the player index for controller, or -1 if it's not available.
        Since:
        This function is available since SDL 2.0.9.
      • SDL_GameControllerSetPlayerIndex

        public static void SDL_GameControllerSetPlayerIndex​(SDL_GameController gamecontroller,
                                                            int playerIndex)
        Set the player index of an opened game controller.
        Parameters:
        gamecontroller - the game controller object to adjust.
        playerIndex - Player index to assign to this controller, or -1 to clear the player index and turn off player LEDs.
        Since:
        This function is available since SDL 2.0.12.
      • SDL_GameControllerGetVendor

        public static short SDL_GameControllerGetVendor​(SDL_GameController gamecontroller)
        Get the USB vendor ID of an opened controller, if available.

        If the vendor ID isn't available this function returns 0.

        Parameters:
        gamecontroller - the game controller object to query.
        Returns:
        the USB vendor ID, or zero if unavailable.
        Since:
        This function is available since SDL 2.0.6.
      • SDL_GameControllerGetProduct

        public static short SDL_GameControllerGetProduct​(SDL_GameController gamecontroller)
        Get the USB product ID of an opened controller, if available.

        If the product ID isn't available this function returns 0.

        Parameters:
        gamecontroller - the game controller object to query.
        Returns:
        the USB product ID, or zero if unavailable.
        Since:
        This function is available since SDL 2.0.6.
      • SDL_GameControllerGetProductVersion

        public static short SDL_GameControllerGetProductVersion​(SDL_GameController gamecontroller)
        Get the product version of an opened controller, if available.

        If the product version isn't available this function returns 0.

        Parameters:
        gamecontroller - the game controller object to query.
        Returns:
        the USB product version, or zero if unavailable.
        Since:
        This function is available since SDL 2.0.6.
      • SDL_GameControllerGetFirmwareVersion

        public static short SDL_GameControllerGetFirmwareVersion​(SDL_GameController gamecontroller)
        Get the firmware version of an opened controller, if available.

        If the firmware version isn't available this function returns 0.

        Parameters:
        gamecontroller - the game controller object to query.
        Returns:
        the controller firmware version, or zero if unavailable.
        Since:
        This function is available since SDL 2.24.0.
      • SDL_GameControllerGetSerial

        public static String SDL_GameControllerGetSerial​(SDL_GameController gamecontroller)
        Get the serial number of an opened controller, if available.

        Returns the serial number of the controller, or NULL if it is not available.

        Parameters:
        gamecontroller - the game controller object to query.
        Returns:
        the serial number, or NULL if unavailable.
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerGetAttached

        public static boolean SDL_GameControllerGetAttached​(SDL_GameController gamecontroller)
        Check if a controller has been opened and is currently connected.
        Parameters:
        gamecontroller - a game controller identifier previously returned by SDL_GameControllerOpen()
        Returns:
        true if the controller has been opened and is currently connected, or false if not.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerClose(SDL_GameController), SDL_GameControllerOpen(int)
      • SDL_GameControllerGetJoystick

        public static SDL_Joystick SDL_GameControllerGetJoystick​(SDL_GameController gamecontroller)
        Get the Joystick ID from a Game Controller.

        This function will give you a SDL_Joystick object, which allows you to use the SDL_Joystick functions with a SDL_GameController object. This would be useful for getting a joystick's position at any given time, even if it hasn't moved (moving it would produce an event, which would have the axis' value).

        The pointer returned is owned by the SDL_GameController. You should not call SDL_JoystickClose() on it, for example, since doing so will likely cause SDL to crash.

        Parameters:
        gamecontroller - the game controller object that you want to get a joystick from
        Returns:
        a SDL_Joystick object; call SDL_GetError() for more information.
        Since:
        This function is available since SDL 2.0.0.
      • SDL_GameControllerEventState

        public static int SDL_GameControllerEventState​(int state)
        Query or change current state of Game Controller events.

        If controller events are disabled, you must call SDL_GameControllerUpdate() yourself and check the state of the controller when you want controller information.

        Any number can be passed to SDL_GameControllerEventState(), but only -1, 0, and 1 will have any effect. Other numbers will just be returned.

        Parameters:
        state - can be one of SDL_QUERY, SDL_IGNORE, or SDL_ENABLE
        Returns:
        the same value passed to the function, with exception to -1 (SDL_QUERY), which will return the current state.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SdlJoystick.SDL_JoystickEventState(int)
      • SDL_GameControllerUpdate

        public static void SDL_GameControllerUpdate()
        Manually pump game controller updates if not using the loop.

        This function is called automatically by the event loop if events are enabled. Under such circumstances, it will not be necessary to call this function.

        Since:
        This function is available since SDL 2.0.0.
      • SDL_GameControllerGetAxisFromString

        public static int SDL_GameControllerGetAxisFromString​(String str)
        Convert a string into SDL_GameControllerAxis enum.

        This function is called internally to translate SDL_GameController mapping strings for the underlying joystick device into the consistent SDL_GameController mapping. You do not normally need to call this function unless you are parsing SDL_GameController mappings in your own code.

        Note specially that "righttrigger" and "lefttrigger" map to SDL_CONTROLLER_AXIS_TRIGGERRIGHT and SDL_CONTROLLER_AXIS_TRIGGERLEFT, respectively.

        Parameters:
        str - string representing a SDL_GameController axis
        Returns:
        the SDL_GameControllerAxis enum corresponding to the input string, or SDL_CONTROLLER_AXIS_INVALID if no match was found.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerGetStringForAxis(int)
      • SDL_GameControllerGetStringForAxis

        public static String SDL_GameControllerGetStringForAxis​(int axis)
        Convert from an SDL_GameControllerAxis enum to a string.

        The caller should not SDL_free() the returned string.

        Parameters:
        axis - an enum value for a given SDL_GameControllerAxis
        Returns:
        a string for the given axis, or NULL if an invalid axis is specified. The string returned is of the format used by SDL_GameController mapping strings.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerGetAxisFromString(String)
      • SDL_GameControllerGetBindForAxis

        public static SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis​(SDL_GameController gamecontroller,
                                                                                    int axis)
        Get the SDL joystick layer binding for a controller axis mapping.
        Parameters:
        gamecontroller - a game controller
        axis - an axis enum value (one of the SDL_GameControllerAxis values)
        Returns:
        a SDL_GameControllerButtonBind describing the bind. On failure (like the given Controller axis doesn't exist on the device), its .bindType will be SDL_CONTROLLER_BINDTYPE_NONE.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerGetBindForButton(SDL_GameController, int)
      • SDL_GameControllerHasAxis

        public static boolean SDL_GameControllerHasAxis​(SDL_GameController gamecontroller,
                                                        int axis)
        Query whether a game controller has a given axis.

        This merely reports whether the controller's mapping defined this axis, as that is all the information SDL has about the physical device.

        Parameters:
        gamecontroller - a game controller
        axis - an axis enum value (an SDL_GameControllerAxis value)
        Returns:
        true if the controller has this axis, false otherwise.
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerGetAxis

        public static short SDL_GameControllerGetAxis​(SDL_GameController gamecontroller,
                                                      int axis)
        Get the current state of an axis control on a game controller.

        The axis indices start at index 0.

        The state is a value ranging from -32768 to 32767. Triggers, however, range from 0 to 32767 (they never return a negative value).

        Parameters:
        gamecontroller - a game controller
        axis - an axis index (one of the SDL_GameControllerAxis values)
        Returns:
        axis state (including 0) on success or 0 (also) on failure; call SDL_GetError() for more information.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerGetButton(SDL_GameController, int)
      • SDL_GameControllerGetButtonFromString

        public static int SDL_GameControllerGetButtonFromString​(String str)
        Convert a string into an SDL_GameControllerButton enum.

        This function is called internally to translate SDL_GameController mapping strings for the underlying joystick device into the consistent SDL_GameController mapping. You do not normally need to call this function unless you are parsing SDL_GameController mappings in your own code.

        Parameters:
        str - string representing a SDL_GameController axis
        Returns:
        the SDL_GameControllerButton enum corresponding to the input string, or SDL_CONTROLLER_AXIS_INVALID if no match was found.
        Since:
        This function is available since SDL 2.0.0.
      • SDL_GameControllerGetStringForButton

        public static String SDL_GameControllerGetStringForButton​(int button)
        Convert from an SDL_GameControllerButton enum to a string.

        The caller should not SDL_free() the returned string.

        Parameters:
        button - an enum value for a given SDL_GameControllerButton
        Returns:
        a string for the given button, or null if an invalid button is specified. The string returned is of the format used by SDL_GameController mapping strings.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerGetButtonFromString(String)
      • SDL_GameControllerGetBindForButton

        public static SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton​(SDL_GameController gamecontroller,
                                                                                      int button)
        Get the SDL joystick layer binding for a controller button mapping.
        Parameters:
        gamecontroller - a game controller
        button - an button enum value (an SDL_GameControllerButton value)
        Returns:
        a SDL_GameControllerButtonBind describing the bind. On failure (like the given Controller button doesn't exist on the device), its .bindType will be SDL_CONTROLLER_BINDTYPE_NONE.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerGetBindForAxis(SDL_GameController, int)
      • SDL_GameControllerHasButton

        public static boolean SDL_GameControllerHasButton​(SDL_GameController gamecontroller,
                                                          int button)
        Query whether a game controller has a given button.

        This merely reports whether the controller's mapping defined this button, as that is all the information SDL has about the physical device.

        Parameters:
        gamecontroller - a game controller
        button - a button enum value (an SDL_GameControllerButton value)
        Returns:
        true if the controller has this button, false otherwise.
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerGetButton

        public static byte SDL_GameControllerGetButton​(SDL_GameController gamecontroller,
                                                       int button)
        Get the current state of a button on a game controller.
        Parameters:
        gamecontroller - a game controller
        button - a button index (one of the SDL_GameControllerButton values)
        Returns:
        1 for pressed state or 0 for not pressed state or error; call SDL_GetError() for more information.
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerGetAxis(SDL_GameController, int)
      • SDL_GameControllerGetNumTouchpads

        public static int SDL_GameControllerGetNumTouchpads​(SDL_GameController gamecontroller)
        Get the number of touchpads on a game controller.
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerGetNumTouchpadFingers

        public static int SDL_GameControllerGetNumTouchpadFingers​(SDL_GameController gamecontroller,
                                                                  int touchpad)
        Get the number of supported simultaneous fingers on a touchpad on a game controller.
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerGetTouchpadFinger

        public static int SDL_GameControllerGetTouchpadFinger​(SDL_GameController gamecontroller,
                                                              int touchpad,
                                                              int finger,
                                                              com.sun.jna.ptr.ByteByReference state,
                                                              com.sun.jna.ptr.FloatByReference x,
                                                              com.sun.jna.ptr.FloatByReference y,
                                                              com.sun.jna.ptr.FloatByReference pressure)
        Get the current state of a finger on a touchpad on a game controller.
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerHasSensor

        public static boolean SDL_GameControllerHasSensor​(SDL_GameController gamecontroller,
                                                          int type)
        Return whether a game controller has a particular sensor.
        Parameters:
        gamecontroller - The controller to query
        type - The type of sensor to query
        Returns:
        true if the sensor exists, false otherwise.
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerSetSensorEnabled

        public static int SDL_GameControllerSetSensorEnabled​(SDL_GameController gamecontroller,
                                                             int type,
                                                             boolean enabled)
        Set whether data reporting for a game controller sensor is enabled.
        Parameters:
        gamecontroller - The controller to update
        type - The type of sensor to enable/disable
        enabled - Whether data reporting should be enabled
        Returns:
        0 or -1 if an error occurred.
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerIsSensorEnabled

        public static boolean SDL_GameControllerIsSensorEnabled​(SDL_GameController gamecontroller,
                                                                int type)
        Query whether sensor data reporting is enabled for a game controller.
        Parameters:
        gamecontroller - The controller to query
        type - The type of sensor to query
        Returns:
        true if the sensor is enabled, false otherwise.
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerGetSensorDataRate

        public static float SDL_GameControllerGetSensorDataRate​(SDL_GameController gamecontroller,
                                                                int type)
        Get the data rate (number of events per second) of a game controller sensor.
        Parameters:
        gamecontroller - The controller to query
        type - The type of sensor to query
        Returns:
        the data rate, or 0.0f if the data rate is not available.
        Since:
        This function is available since SDL 2.0.16.
      • SDL_GameControllerGetSensorData

        public static int SDL_GameControllerGetSensorData​(SDL_GameController gamecontroller,
                                                          int type,
                                                          com.sun.jna.Pointer data,
                                                          int numValues)
        Get the current state of a game controller sensor.

        The number of values and interpretation of the data is sensor dependent. See SDL_SensorType for the details for each type of sensor.

        Parameters:
        gamecontroller - The controller to query
        type - The type of sensor to query
        data - A pointer filled with the current sensor state
        numValues - The number of values to write to data
        Returns:
        0 or -1 if an error occurred.
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerGetSensorDataWithTimestamp

        public static int SDL_GameControllerGetSensorDataWithTimestamp​(SDL_GameController gamecontroller,
                                                                       int type,
                                                                       com.sun.jna.ptr.LongByReference timestamp,
                                                                       com.sun.jna.Pointer data,
                                                                       int numValues)
        Get the current state of a game controller sensor with the timestamp of the last update.

        The number of values and interpretation of the data is sensor dependent. See SDL_sensor.h for the details for each type of sensor.

        Parameters:
        gamecontroller - The controller to query
        type - The type of sensor to query
        timestamp - A pointer filled with the timestamp in microseconds of the current sensor reading if available, or 0 if not
        data - A pointer filled with the current sensor state
        numValues - The number of values to write to data
        Returns:
        0 or -1 if an error occurred.
        Since:
        This function is available since SDL 2.26.0.
      • SDL_GameControllerRumble

        public static int SDL_GameControllerRumble​(SDL_GameController gamecontroller,
                                                   short lowFrequencyRumble,
                                                   short highFrequencyRumble,
                                                   int durationMs)
        Start a rumble effect on a game controller.

        Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.

        Parameters:
        gamecontroller - The controller to vibrate
        lowFrequencyRumble - The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF
        highFrequencyRumble - The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF
        durationMs - The duration of the rumble effect, in milliseconds
        Returns:
        0, or -1 if rumble isn't supported on this controller
        Since:
        This function is available since SDL 2.0.9.
        See Also:
        SDL_GameControllerHasRumble(SDL_GameController)
      • SDL_GameControllerRumbleTriggers

        public static int SDL_GameControllerRumbleTriggers​(SDL_GameController gamecontroller,
                                                           short leftRumble,
                                                           short rightRumble,
                                                           int durationMs)
        Start a rumble effect in the game controller's triggers.

        Each call to this function cancels any previous trigger rumble effect, and calling it with 0 intensity stops any rumbling.

        Note that this is rumbling of the _triggers_ and not the game controller as a whole. This is currently only supported on Xbox One controllers. If you want the (more common) whole-controller rumble, use SDL_GameControllerRumble() instead.

        Parameters:
        gamecontroller - The controller to vibrate
        leftRumble - The intensity of the left trigger rumble motor, from 0 to 0xFFFF
        rightRumble - The intensity of the right trigger rumble motor, from 0 to 0xFFFF
        durationMs - The duration of the rumble effect, in milliseconds
        Returns:
        0, or -1 if trigger rumble isn't supported on this controller
        Since:
        This function is available since SDL 2.0.14.
        See Also:
        SDL_GameControllerHasRumbleTriggers(SDL_GameController)
      • SDL_GameControllerHasLED

        public static boolean SDL_GameControllerHasLED​(SDL_GameController gamecontroller)
        Query whether a game controller has an LED.
        Parameters:
        gamecontroller - The controller to query
        Returns:
        true if this controller has a modifiable LED, false otherwise
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerHasRumble

        public static boolean SDL_GameControllerHasRumble​(SDL_GameController gamecontroller)
        Query whether a game controller has rumble support.
        Parameters:
        gamecontroller - The controller to query
        Returns:
        true if this controller has rumble support, false otherwise
        Since:
        This function is available since SDL 2.0.18.
        See Also:
        SDL_GameControllerRumble(SDL_GameController, short, short, int)
      • SDL_GameControllerHasRumbleTriggers

        public static boolean SDL_GameControllerHasRumbleTriggers​(SDL_GameController gamecontroller)
        Query whether a game controller has rumble support on triggers.
        Parameters:
        gamecontroller - The controller to query
        Returns:
        true if this controller has trigger rumble support, false otherwise
        Since:
        This function is available since SDL 2.0.18.
        See Also:
        SDL_GameControllerRumbleTriggers(SDL_GameController, short, short, int)
      • SDL_GameControllerSetLED

        public static int SDL_GameControllerSetLED​(SDL_GameController gamecontroller,
                                                   byte red,
                                                   byte green,
                                                   byte blue)
        Update a game controller's LED color.
        Parameters:
        gamecontroller - The controller to update
        red - The intensity of the red LED
        green - The intensity of the green LED
        blue - The intensity of the blue LED
        Returns:
        0, or -1 if this controller does not have a modifiable LED
        Since:
        This function is available since SDL 2.0.14.
      • SDL_GameControllerSendEffect

        public static int SDL_GameControllerSendEffect​(SDL_GameController gamecontroller,
                                                       com.sun.jna.Pointer data,
                                                       int size)
        Send a controller specific effect packet
        Parameters:
        gamecontroller - The controller to affect
        data - The data to send to the controller
        size - The size of the data to send to the controller
        Returns:
        0, or -1 if this controller or driver doesn't support effect packets
        Since:
        This function is available since SDL 2.0.16.
      • SDL_GameControllerClose

        public static void SDL_GameControllerClose​(SDL_GameController gamecontroller)
        Close a game controller previously opened with SDL_GameControllerOpen().
        Parameters:
        gamecontroller - a game controller identifier previously returned by SDL_GameControllerOpen()
        Since:
        This function is available since SDL 2.0.0.
        See Also:
        SDL_GameControllerOpen(int)
      • SDL_GameControllerGetAppleSFSymbolsNameForButton

        public static String SDL_GameControllerGetAppleSFSymbolsNameForButton​(SDL_GameController gamecontroller,
                                                                              int button)
        Return the sfSymbolsName for a given button on a game controller on Apple platforms.
        Parameters:
        gamecontroller - the controller to query
        button - a button on the game controller
        Returns:
        the sfSymbolsName or null if the name can't be found
        Since:
        This function is available since SDL 2.0.18.
        See Also:
        SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController, int)
      • SDL_GameControllerGetAppleSFSymbolsNameForAxis

        public static String SDL_GameControllerGetAppleSFSymbolsNameForAxis​(SDL_GameController gamecontroller,
                                                                            int axis)
        Return the sfSymbolsName for a given axis on a game controller on Apple platforms.
        Parameters:
        gamecontroller - the controller to query
        axis - an axis on the game controller
        Returns:
        the sfSymbolsName or null if the name can't be found
        Since:
        This function is available since SDL 2.0.18.
        See Also:
        SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController, int)