src/joystick/android/SDL_sysjoystick.c
author Gabriel Jacobo <gabomdq@gmail.com>
Mon, 01 Apr 2013 13:21:23 -0300
changeset 7041 eb0b541c9722
child 7191 75360622e65f
child 8460 f483e8bdae3c
permissions -rw-r--r--
Backed out changeset: a500a9dbfb41
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7041
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     1
/*
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     2
  Simple DirectMedia Layer
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     4
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     7
  arising from the use of this software.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     8
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    12
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    16
     appreciated but is not required.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    18
     misrepresented as being the original software.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    20
*/
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    21
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    22
#include "SDL_config.h"
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    23
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    24
#ifdef SDL_JOYSTICK_ANDROID
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    25
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    26
/* This is the system specific header for the SDL joystick API */
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    27
#include <stdio.h>              /* For the definition of NULL */
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    28
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    29
#include "SDL_error.h"
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    30
#include "SDL_events.h"
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    31
#include "SDL_joystick.h"
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    32
#include "../SDL_sysjoystick.h"
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    33
#include "../SDL_joystick_c.h"
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    34
#include "../../core/android/SDL_android.h"
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    35
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    36
static const char *accelerometerName = "Android accelerometer";
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    37
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    38
/* Function to scan the system for joysticks.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    39
 * This function should set SDL_numjoysticks to the number of available
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    40
 * joysticks.  Joystick 0 should be the system default joystick.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    41
 * It should return 0, or -1 on an unrecoverable fatal error.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    42
 */
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    43
int
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    44
SDL_SYS_JoystickInit(void)
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    45
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    46
    return (1);
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    47
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    48
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    49
int SDL_SYS_NumJoysticks()
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    50
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    51
    return 1;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    52
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    53
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    54
void SDL_SYS_JoystickDetect()
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    55
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    56
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    57
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    58
SDL_bool SDL_SYS_JoystickNeedsPolling()
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    59
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    60
    return SDL_FALSE;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    61
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    62
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    63
/* Function to get the device-dependent name of a joystick */
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    64
const char *
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    65
SDL_SYS_JoystickNameForDeviceIndex(int device_index)
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    66
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    67
    return accelerometerName;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    68
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    69
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    70
/* Function to perform the mapping from device index to the instance id for this index */
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    71
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    72
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    73
    return device_index;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    74
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    75
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    76
/* Function to open a joystick for use.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    77
   The joystick to open is specified by the index field of the joystick.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    78
   This should fill the nbuttons and naxes fields of the joystick structure.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    79
   It returns 0, or -1 if there is an error.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    80
 */
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    81
int
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    82
SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    83
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    84
    if (device_index == 0) {
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    85
        joystick->nbuttons = 0;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    86
        joystick->nhats = 0;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    87
        joystick->nballs = 0;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    88
        joystick->naxes = 3;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    89
        return 0;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    90
	} else {
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    91
		SDL_SetError("No joystick available with that index");
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    92
		return (-1);
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    93
	}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    94
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    95
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    96
/* Function to determine is this joystick is attached to the system right now */
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    97
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    98
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
    99
    return SDL_TRUE;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   100
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   101
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   102
/* Function to update the state of a joystick - called as a device poll.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   103
 * This function shouldn't update the joystick structure directly,
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   104
 * but instead should call SDL_PrivateJoystick*() to deliver events
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   105
 * and update joystick device state.
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   106
 */
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   107
void
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   108
SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   109
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   110
    int i;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   111
    Sint16 value;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   112
    float values[3];
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   113
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   114
    if (Android_JNI_GetAccelerometerValues(values)) {
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   115
        for ( i = 0; i < 3; i++ ) {
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   116
            value = (Sint16)(values[i] * 32767.0f);
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   117
            SDL_PrivateJoystickAxis(joystick, i, value);
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   118
        }
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   119
    }
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   120
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   121
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   122
/* Function to close a joystick after use */
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   123
void
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   124
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   125
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   126
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   127
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   128
/* Function to perform any system-specific joystick related cleanup */
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   129
void
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   130
SDL_SYS_JoystickQuit(void)
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   131
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   132
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   133
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   134
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   135
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   136
    SDL_JoystickGUID guid;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   137
    // the GUID is just the first 16 chars of the name for now
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   138
    const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   139
    SDL_zero( guid );
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   140
    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   141
    return guid;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   142
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   143
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   144
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   145
{
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   146
    SDL_JoystickGUID guid;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   147
    // the GUID is just the first 16 chars of the name for now
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   148
    const char *name = joystick->name;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   149
    SDL_zero( guid );
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   150
    SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   151
    return guid;
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   152
}
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   153
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   154
#endif /* SDL_JOYSTICK_ANDROID */
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   155
eb0b541c9722 Backed out changeset: a500a9dbfb41
Gabriel Jacobo <gabomdq@gmail.com>
parents:
diff changeset
   156
/* vi: set ts=4 sw=4 expandtab: */