Imported Upstream version 2.0.14
[platform/upstream/SDL.git] / src / joystick / dummy / SDL_sysjoystick.c
index 10fda10..a51fb20 100644 (file)
@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
+  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
 #include "../SDL_sysjoystick.h"
 #include "../SDL_joystick_c.h"
 
-/* Function to scan the system for joysticks.
- * It should return 0, or -1 on an unrecoverable fatal error.
- */
-int
-SDL_SYS_JoystickInit(void)
+
+static int
+DUMMY_JoystickInit(void)
 {
     return 0;
 }
 
-int SDL_SYS_NumJoysticks()
+static int
+DUMMY_JoystickGetCount(void)
 {
     return 0;
 }
 
-void SDL_SYS_JoystickDetect()
+static void
+DUMMY_JoystickDetect(void)
+{
+}
+
+static const char *
+DUMMY_JoystickGetDeviceName(int device_index)
 {
+    return NULL;
 }
 
-/* Function to get the device-dependent name of a joystick */
-const char *
-SDL_SYS_JoystickNameForDeviceIndex(int device_index)
+static int
+DUMMY_JoystickGetDevicePlayerIndex(int device_index)
 {
-    SDL_SetError("Logic error: No joysticks available");
-    return (NULL);
+    return -1;
 }
 
-/* Function to perform the mapping from device index to the instance id for this index */
-SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
+static void
+DUMMY_JoystickSetDevicePlayerIndex(int device_index, int player_index)
 {
-    return device_index;
 }
 
-/* Function to open a joystick for use.
-   The joystick to open is specified by the device index.
-   This should fill the nbuttons and naxes fields of the joystick structure.
-   It returns 0, or -1 if there is an error.
- */
-int
-SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
+static SDL_JoystickGUID
+DUMMY_JoystickGetDeviceGUID(int device_index)
+{
+    SDL_JoystickGUID guid;
+    SDL_zero(guid);
+    return guid;
+}
+
+static SDL_JoystickID
+DUMMY_JoystickGetDeviceInstanceID(int device_index)
+{
+    return -1;
+}
+
+static int
+DUMMY_JoystickOpen(SDL_Joystick *joystick, int device_index)
 {
     return SDL_SetError("Logic error: No joysticks available");
 }
 
-/* Function to determine if this joystick is attached to the system right now */
-SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
+static int
+DUMMY_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
 {
-    return SDL_TRUE;
+    return SDL_Unsupported();
 }
 
-/* Function to update the state of a joystick - called as a device poll.
- * This function shouldn't update the joystick structure directly,
- * but instead should call SDL_PrivateJoystick*() to deliver events
- * and update joystick device state.
- */
-void
-SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
+static int
+DUMMY_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
 {
+    return SDL_Unsupported();
 }
 
-/* Function to close a joystick after use */
-void
-SDL_SYS_JoystickClose(SDL_Joystick * joystick)
+static SDL_bool
+DUMMY_JoystickHasLED(SDL_Joystick *joystick)
 {
+    return SDL_FALSE;
 }
 
-/* Function to perform any system-specific joystick related cleanup */
-void
-SDL_SYS_JoystickQuit(void)
+static int
+DUMMY_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
 {
+    return SDL_Unsupported();
 }
 
-SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
+static int
+DUMMY_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled)
 {
-    SDL_JoystickGUID guid;
-    /* the GUID is just the first 16 chars of the name for now */
-    const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
-    SDL_zero( guid );
-    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
-    return guid;
+    return SDL_Unsupported();
 }
 
+static void
+DUMMY_JoystickUpdate(SDL_Joystick *joystick)
+{
+}
 
-SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
+static void
+DUMMY_JoystickClose(SDL_Joystick *joystick)
 {
-    SDL_JoystickGUID guid;
-    /* the GUID is just the first 16 chars of the name for now */
-    const char *name = joystick->name;
-    SDL_zero( guid );
-    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
-    return guid;
 }
 
+static void
+DUMMY_JoystickQuit(void)
+{
+}
+
+static SDL_bool
+DUMMY_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
+{
+    return SDL_FALSE;
+}
+
+SDL_JoystickDriver SDL_DUMMY_JoystickDriver =
+{
+    DUMMY_JoystickInit,
+    DUMMY_JoystickGetCount,
+    DUMMY_JoystickDetect,
+    DUMMY_JoystickGetDeviceName,
+    DUMMY_JoystickGetDevicePlayerIndex,
+    DUMMY_JoystickSetDevicePlayerIndex,
+    DUMMY_JoystickGetDeviceGUID,
+    DUMMY_JoystickGetDeviceInstanceID,
+    DUMMY_JoystickOpen,
+    DUMMY_JoystickRumble,
+    DUMMY_JoystickRumbleTriggers,
+    DUMMY_JoystickHasLED,
+    DUMMY_JoystickSetLED,
+    DUMMY_JoystickSetSensorsEnabled,
+    DUMMY_JoystickUpdate,
+    DUMMY_JoystickClose,
+    DUMMY_JoystickQuit,
+    DUMMY_JoystickGetGamepadMapping
+};
+
 #endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
 
 /* vi: set ts=4 sw=4 expandtab: */