src/joystick/dummy/SDL_sysjoystick.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Wed, 16 Nov 2016 22:08:51 +0100
changeset 10617 346c02ff71b6
parent 9998 f67cf37e9cd4
child 10737 3406a0f8b041
permissions -rw-r--r--
Fixed empty parameter list in signatures of internal functions.
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@9998
     3
  Copyright (C) 1997-2016 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
{
icculus@9433
    37
    return 0;
slouken@0
    38
}
slouken@0
    39
philipp@10617
    40
int
philipp@10617
    41
SDL_SYS_NumJoysticks(void)
slouken@6707
    42
{
slouken@6707
    43
    return 0;
slouken@6707
    44
}
slouken@6707
    45
philipp@10617
    46
void
philipp@10617
    47
SDL_SYS_JoystickDetect(void)
slouken@6707
    48
{
slouken@6707
    49
}
slouken@6707
    50
slouken@0
    51
/* Function to get the device-dependent name of a joystick */
slouken@1895
    52
const char *
slouken@6707
    53
SDL_SYS_JoystickNameForDeviceIndex(int device_index)
slouken@0
    54
{
slouken@1895
    55
    SDL_SetError("Logic error: No joysticks available");
slouken@1895
    56
    return (NULL);
slouken@0
    57
}
slouken@0
    58
slouken@6707
    59
/* Function to perform the mapping from device index to the instance id for this index */
slouken@6707
    60
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
slouken@6707
    61
{
slouken@6707
    62
    return device_index;
slouken@6707
    63
}
slouken@6707
    64
slouken@0
    65
/* Function to open a joystick for use.
philipp@9380
    66
   The joystick to open is specified by the device index.
slouken@0
    67
   This should fill the nbuttons and naxes fields of the joystick structure.
slouken@0
    68
   It returns 0, or -1 if there is an error.
slouken@0
    69
 */
slouken@1895
    70
int
slouken@6698
    71
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
slouken@0
    72
{
icculus@7037
    73
    return SDL_SetError("Logic error: No joysticks available");
slouken@0
    74
}
slouken@0
    75
philipp@9561
    76
/* Function to determine if this joystick is attached to the system right now */
slouken@6707
    77
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
slouken@6707
    78
{
slouken@6707
    79
    return SDL_TRUE;
slouken@6707
    80
}
slouken@6707
    81
slouken@0
    82
/* Function to update the state of a joystick - called as a device poll.
slouken@0
    83
 * This function shouldn't update the joystick structure directly,
slouken@0
    84
 * but instead should call SDL_PrivateJoystick*() to deliver events
slouken@0
    85
 * and update joystick device state.
slouken@0
    86
 */
slouken@1895
    87
void
slouken@1895
    88
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
slouken@0
    89
{
slouken@0
    90
}
slouken@0
    91
slouken@0
    92
/* Function to close a joystick after use */
slouken@1895
    93
void
slouken@1895
    94
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
slouken@0
    95
{
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@0
   102
}
slouken@0
   103
slouken@6744
   104
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
slouken@6698
   105
{
slouken@6744
   106
    SDL_JoystickGUID guid;
slouken@7191
   107
    /* the GUID is just the first 16 chars of the name for now */
slouken@6707
   108
    const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
slouken@6698
   109
    SDL_zero( guid );
slouken@6698
   110
    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
slouken@6698
   111
    return guid;
slouken@6698
   112
}
slouken@6698
   113
slouken@6698
   114
slouken@6744
   115
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
slouken@6698
   116
{
slouken@6744
   117
    SDL_JoystickGUID guid;
slouken@7191
   118
    /* the GUID is just the first 16 chars of the name for now */
slouken@6698
   119
    const char *name = joystick->name;
slouken@6698
   120
    SDL_zero( guid );
slouken@6698
   121
    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
slouken@6698
   122
    return guid;
slouken@6698
   123
}
slouken@6698
   124
slouken@1635
   125
#endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
slouken@3104
   126
slouken@1895
   127
/* vi: set ts=4 sw=4 expandtab: */