zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_sysjoystick.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2013 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_config.h"
22 
23 #if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED)
24 
25 /* This is the system specific header for the SDL joystick API */
26 
27 #include "SDL_joystick.h"
28 #include "../SDL_sysjoystick.h"
29 #include "../SDL_joystick_c.h"
30 
31 /* Function to scan the system for joysticks.
32  * It should return 0, or -1 on an unrecoverable fatal error.
33  */
34 int
36 {
37  return (0);
38 }
39 
41 {
42  return 0;
43 }
44 
46 {
47 }
48 
50 {
51  return SDL_FALSE;
52 }
53 
54 /* Function to get the device-dependent name of a joystick */
55 const char *
56 SDL_SYS_JoystickNameForDeviceIndex(int device_index)
57 {
58  SDL_SetError("Logic error: No joysticks available");
59  return (NULL);
60 }
61 
62 /* Function to perform the mapping from device index to the instance id for this index */
64 {
65  return device_index;
66 }
67 
68 /* Function to open a joystick for use.
69  The joystick to open is specified by the index field of the joystick.
70  This should fill the nbuttons and naxes fields of the joystick structure.
71  It returns 0, or -1 if there is an error.
72  */
73 int
74 SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
75 {
76  return SDL_SetError("Logic error: No joysticks available");
77 }
78 
79 /* Function to determine is this joystick is attached to the system right now */
81 {
82  return SDL_TRUE;
83 }
84 
85 /* Function to update the state of a joystick - called as a device poll.
86  * This function shouldn't update the joystick structure directly,
87  * but instead should call SDL_PrivateJoystick*() to deliver events
88  * and update joystick device state.
89  */
90 void
92 {
93  return;
94 }
95 
96 /* Function to close a joystick after use */
97 void
99 {
100  return;
101 }
102 
103 /* Function to perform any system-specific joystick related cleanup */
104 void
106 {
107  return;
108 }
109 
111 {
112  SDL_JoystickGUID guid;
113  /* the GUID is just the first 16 chars of the name for now */
114  const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
115  SDL_zero( guid );
116  SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
117  return guid;
118 }
119 
120 
122 {
123  SDL_JoystickGUID guid;
124  /* the GUID is just the first 16 chars of the name for now */
125  const char *name = joystick->name;
126  SDL_zero( guid );
127  SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
128  return guid;
129 }
130 
131 #endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
132 
133 /* vi: set ts=4 sw=4 expandtab: */
int SDL_SYS_NumJoysticks()
#define NULL
Definition: ftobjs.h:61
SDL_bool
Definition: SDL_stdinc.h:116
Sint32 SDL_JoystickID
Definition: SDL_joystick.h:72
EGLImageKHR EGLint * name
Definition: eglext.h:284
void SDL_SYS_JoystickQuit(void)
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
void SDL_SYS_JoystickDetect()
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
Definition: SDL_error.c:53
const char * SDL_SYS_JoystickNameForDeviceIndex(int device_index)
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick *joystick)
SDL_bool SDL_SYS_JoystickNeedsPolling()
DECLSPEC size_t SDLCALL SDL_strlen(const char *str)
Definition: SDL_string.c:389
int SDL_SYS_JoystickInit(void)
DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, size_t len)
Definition: SDL_string.c:293
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
int SDL_SYS_JoystickOpen(SDL_Joystick *joystick, int device_index)
#define SDL_zero(x)
Definition: SDL_stdinc.h:254
#define SDL_min(x, y)
Definition: SDL_stdinc.h:244
void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index)