src/joystick/dummy/SDL_sysjoystick.c
author Ryan C. Gordon <icculus@icculus.org>
Wed, 24 Dec 2014 22:22:35 -0500
changeset 9289 5f857c00d25d
parent 8860 c4133d635375
child 9380 07b7c1005a23
permissions -rw-r--r--
Maybe actually patched to compile this time?
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@8149
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
icculus@8093
    21
#include "../../SDL_internal.h"
slouken@0
    22
slouken@1635
    23
#if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED)
slouken@1635
    24
philipp@8138
    25
/* This is the dummy implementation of the SDL joystick API */
slouken@0
    26
slouken@0
    27
#include "SDL_joystick.h"
slouken@1361
    28
#include "../SDL_sysjoystick.h"
slouken@1361
    29
#include "../SDL_joystick_c.h"
slouken@0
    30
slouken@0
    31
/* Function to scan the system for joysticks.
slouken@0
    32
 * It should return 0, or -1 on an unrecoverable fatal error.
slouken@0
    33
 */
slouken@1895
    34
int
slouken@1895
    35
SDL_SYS_JoystickInit(void)
slouken@0
    36
{
slouken@1895
    37
    return (0);
slouken@0
    38
}
slouken@0
    39
slouken@6707
    40
int SDL_SYS_NumJoysticks()
slouken@6707
    41
{
slouken@6707
    42
    return 0;
slouken@6707
    43
}
slouken@6707
    44
slouken@6707
    45
void SDL_SYS_JoystickDetect()
slouken@6707
    46
{
slouken@6707
    47
}
slouken@6707
    48
slouken@0
    49
/* Function to get the device-dependent name of a joystick */
slouken@1895
    50
const char *
slouken@6707
    51
SDL_SYS_JoystickNameForDeviceIndex(int device_index)
slouken@0
    52
{
slouken@1895
    53
    SDL_SetError("Logic error: No joysticks available");
slouken@1895
    54
    return (NULL);
slouken@0
    55
}
slouken@0
    56
slouken@6707
    57
/* Function to perform the mapping from device index to the instance id for this index */
slouken@6707
    58
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
slouken@6707
    59
{
slouken@6707
    60
    return device_index;
slouken@6707
    61
}
slouken@6707
    62
slouken@0
    63
/* Function to open a joystick for use.
slouken@0
    64
   The joystick to open is specified by the index field of the joystick.
slouken@0
    65
   This should fill the nbuttons and naxes fields of the joystick structure.
slouken@0
    66
   It returns 0, or -1 if there is an error.
slouken@0
    67
 */
slouken@1895
    68
int
slouken@6698
    69
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
slouken@0
    70
{
icculus@7037
    71
    return SDL_SetError("Logic error: No joysticks available");
slouken@0
    72
}
slouken@0
    73
slouken@6707
    74
/* Function to determine is this joystick is attached to the system right now */
slouken@6707
    75
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
slouken@6707
    76
{
slouken@6707
    77
    return SDL_TRUE;
slouken@6707
    78
}
slouken@6707
    79
slouken@0
    80
/* Function to update the state of a joystick - called as a device poll.
slouken@0
    81
 * This function shouldn't update the joystick structure directly,
slouken@0
    82
 * but instead should call SDL_PrivateJoystick*() to deliver events
slouken@0
    83
 * and update joystick device state.
slouken@0
    84
 */
slouken@1895
    85
void
slouken@1895
    86
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
slouken@0
    87
{
slouken@1895
    88
    return;
slouken@0
    89
}
slouken@0
    90
slouken@0
    91
/* Function to close a joystick after use */
slouken@1895
    92
void
slouken@1895
    93
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
slouken@0
    94
{
slouken@1895
    95
    return;
slouken@0
    96
}
slouken@0
    97
slouken@0
    98
/* Function to perform any system-specific joystick related cleanup */
slouken@1895
    99
void
slouken@1895
   100
SDL_SYS_JoystickQuit(void)
slouken@0
   101
{
slouken@1895
   102
    return;
slouken@0
   103
}
slouken@0
   104
slouken@6744
   105
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
slouken@6698
   106
{
slouken@6744
   107
    SDL_JoystickGUID guid;
slouken@7191
   108
    /* the GUID is just the first 16 chars of the name for now */
slouken@6707
   109
    const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
slouken@6698
   110
    SDL_zero( guid );
slouken@6698
   111
    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
slouken@6698
   112
    return guid;
slouken@6698
   113
}
slouken@6698
   114
slouken@6698
   115
slouken@6744
   116
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
slouken@6698
   117
{
slouken@6744
   118
    SDL_JoystickGUID guid;
slouken@7191
   119
    /* the GUID is just the first 16 chars of the name for now */
slouken@6698
   120
    const char *name = joystick->name;
slouken@6698
   121
    SDL_zero( guid );
slouken@6698
   122
    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
slouken@6698
   123
    return guid;
slouken@6698
   124
}
slouken@6698
   125
slouken@1635
   126
#endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
slouken@3104
   127
slouken@1895
   128
/* vi: set ts=4 sw=4 expandtab: */