1 /*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "../../SDL_internal.h"
22
23 #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED)
24
25 /* This is the dummy implementation of the SDL joystick API */
26
27 #include "SDL_joystick.h"
28 #include "../SDL_sysjoystick.h"
29 #include "../SDL_joystick_c.h"
30
31
32 static int
DUMMY_JoystickInit(void)33 DUMMY_JoystickInit(void)
34 {
35 return 0;
36 }
37
38 static int
DUMMY_JoystickGetCount(void)39 DUMMY_JoystickGetCount(void)
40 {
41 return 0;
42 }
43
44 static void
DUMMY_JoystickDetect(void)45 DUMMY_JoystickDetect(void)
46 {
47 }
48
49 static const char *
DUMMY_JoystickGetDeviceName(int device_index)50 DUMMY_JoystickGetDeviceName(int device_index)
51 {
52 return NULL;
53 }
54
55 static int
DUMMY_JoystickGetDevicePlayerIndex(int device_index)56 DUMMY_JoystickGetDevicePlayerIndex(int device_index)
57 {
58 return -1;
59 }
60
61 static void
DUMMY_JoystickSetDevicePlayerIndex(int device_index,int player_index)62 DUMMY_JoystickSetDevicePlayerIndex(int device_index, int player_index)
63 {
64 }
65
66 static SDL_JoystickGUID
DUMMY_JoystickGetDeviceGUID(int device_index)67 DUMMY_JoystickGetDeviceGUID(int device_index)
68 {
69 SDL_JoystickGUID guid;
70 SDL_zero(guid);
71 return guid;
72 }
73
74 static SDL_JoystickID
DUMMY_JoystickGetDeviceInstanceID(int device_index)75 DUMMY_JoystickGetDeviceInstanceID(int device_index)
76 {
77 return -1;
78 }
79
80 static int
DUMMY_JoystickOpen(SDL_Joystick * joystick,int device_index)81 DUMMY_JoystickOpen(SDL_Joystick *joystick, int device_index)
82 {
83 return SDL_SetError("Logic error: No joysticks available");
84 }
85
86 static int
DUMMY_JoystickRumble(SDL_Joystick * joystick,Uint16 low_frequency_rumble,Uint16 high_frequency_rumble)87 DUMMY_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
88 {
89 return SDL_Unsupported();
90 }
91
92 static int
DUMMY_JoystickRumbleTriggers(SDL_Joystick * joystick,Uint16 left_rumble,Uint16 right_rumble)93 DUMMY_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
94 {
95 return SDL_Unsupported();
96 }
97
98 static Uint32
DUMMY_JoystickGetCapabilities(SDL_Joystick * joystick)99 DUMMY_JoystickGetCapabilities(SDL_Joystick *joystick)
100 {
101 return 0;
102 }
103
104 static int
DUMMY_JoystickSetLED(SDL_Joystick * joystick,Uint8 red,Uint8 green,Uint8 blue)105 DUMMY_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
106 {
107 return SDL_Unsupported();
108 }
109
110 static int
DUMMY_JoystickSendEffect(SDL_Joystick * joystick,const void * data,int size)111 DUMMY_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size)
112 {
113 return SDL_Unsupported();
114 }
115
116 static int
DUMMY_JoystickSetSensorsEnabled(SDL_Joystick * joystick,SDL_bool enabled)117 DUMMY_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled)
118 {
119 return SDL_Unsupported();
120 }
121
122 static void
DUMMY_JoystickUpdate(SDL_Joystick * joystick)123 DUMMY_JoystickUpdate(SDL_Joystick *joystick)
124 {
125 }
126
127 static void
DUMMY_JoystickClose(SDL_Joystick * joystick)128 DUMMY_JoystickClose(SDL_Joystick *joystick)
129 {
130 }
131
132 static void
DUMMY_JoystickQuit(void)133 DUMMY_JoystickQuit(void)
134 {
135 }
136
137 static SDL_bool
DUMMY_JoystickGetGamepadMapping(int device_index,SDL_GamepadMapping * out)138 DUMMY_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
139 {
140 return SDL_FALSE;
141 }
142
143 SDL_JoystickDriver SDL_DUMMY_JoystickDriver =
144 {
145 DUMMY_JoystickInit,
146 DUMMY_JoystickGetCount,
147 DUMMY_JoystickDetect,
148 DUMMY_JoystickGetDeviceName,
149 DUMMY_JoystickGetDevicePlayerIndex,
150 DUMMY_JoystickSetDevicePlayerIndex,
151 DUMMY_JoystickGetDeviceGUID,
152 DUMMY_JoystickGetDeviceInstanceID,
153 DUMMY_JoystickOpen,
154 DUMMY_JoystickRumble,
155 DUMMY_JoystickRumbleTriggers,
156 DUMMY_JoystickGetCapabilities,
157 DUMMY_JoystickSetLED,
158 DUMMY_JoystickSendEffect,
159 DUMMY_JoystickSetSensorsEnabled,
160 DUMMY_JoystickUpdate,
161 DUMMY_JoystickClose,
162 DUMMY_JoystickQuit,
163 DUMMY_JoystickGetGamepadMapping
164 };
165
166 #endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
167
168 /* vi: set ts=4 sw=4 expandtab: */
169