cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

SDL_sysjoystick.c (3696B)


      1/*
      2  Simple DirectMedia Layer
      3  Copyright (C) 1997-2014 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/* Function to scan the system for joysticks.
     32 * It should return 0, or -1 on an unrecoverable fatal error.
     33 */
     34int
     35SDL_SYS_JoystickInit(void)
     36{
     37    return (0);
     38}
     39
     40int SDL_SYS_NumJoysticks()
     41{
     42    return 0;
     43}
     44
     45void SDL_SYS_JoystickDetect()
     46{
     47}
     48
     49/* Function to get the device-dependent name of a joystick */
     50const char *
     51SDL_SYS_JoystickNameForDeviceIndex(int device_index)
     52{
     53    SDL_SetError("Logic error: No joysticks available");
     54    return (NULL);
     55}
     56
     57/* Function to perform the mapping from device index to the instance id for this index */
     58SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
     59{
     60    return device_index;
     61}
     62
     63/* Function to open a joystick for use.
     64   The joystick to open is specified by the index field of the joystick.
     65   This should fill the nbuttons and naxes fields of the joystick structure.
     66   It returns 0, or -1 if there is an error.
     67 */
     68int
     69SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
     70{
     71    return SDL_SetError("Logic error: No joysticks available");
     72}
     73
     74/* Function to determine is this joystick is attached to the system right now */
     75SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
     76{
     77    return SDL_TRUE;
     78}
     79
     80/* Function to update the state of a joystick - called as a device poll.
     81 * This function shouldn't update the joystick structure directly,
     82 * but instead should call SDL_PrivateJoystick*() to deliver events
     83 * and update joystick device state.
     84 */
     85void
     86SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
     87{
     88    return;
     89}
     90
     91/* Function to close a joystick after use */
     92void
     93SDL_SYS_JoystickClose(SDL_Joystick * joystick)
     94{
     95    return;
     96}
     97
     98/* Function to perform any system-specific joystick related cleanup */
     99void
    100SDL_SYS_JoystickQuit(void)
    101{
    102    return;
    103}
    104
    105SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
    106{
    107    SDL_JoystickGUID guid;
    108    /* the GUID is just the first 16 chars of the name for now */
    109    const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
    110    SDL_zero( guid );
    111    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
    112    return guid;
    113}
    114
    115
    116SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
    117{
    118    SDL_JoystickGUID guid;
    119    /* the GUID is just the first 16 chars of the name for now */
    120    const char *name = joystick->name;
    121    SDL_zero( guid );
    122    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
    123    return guid;
    124}
    125
    126#endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
    127
    128/* vi: set ts=4 sw=4 expandtab: */