src/joystick/SDL_sysjoystick.h
author Sam Lantinga
Fri, 27 Jan 2017 21:23:27 -0800
changeset 10861 71d8f9afb690
parent 10855 fc18eb831c08
child 10966 a8f6d07da15a
permissions -rw-r--r--
Fixed bug 3569 - GL_UpdateViewport leaves PROJECTION matrix selected

Tom Seddon

GL_ActivateRenderer may call GL_UpdateViewport, which leaves the GL_PROJECTION matrix selected. But after GL_ResetState, the GL_MODELVIEW matrix is selected, suggesting that's the intended default state.

It seems at least like these should be consistent. Presumably GL_UpdateViewport should be doing a glMatrixMode(GL_MODELVIEW) before it finishes.
     1 /*
     2   Simple DirectMedia Layer
     3   Copyright (C) 1997-2017 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 #ifndef SDL_sysjoystick_h_
    24 #define SDL_sysjoystick_h_
    25 
    26 /* This is the system specific header for the SDL joystick API */
    27 
    28 #include "SDL_joystick.h"
    29 #include "SDL_joystick_c.h"
    30 
    31 /* The SDL joystick structure */
    32 typedef struct _SDL_JoystickAxisInfo
    33 {
    34     Sint16 initial_value;       /* Initial axis state */
    35     Sint16 value;               /* Current axis state */
    36     Sint16 zero;                /* Zero point on the axis (-32768 for triggers) */
    37     SDL_bool has_initial_value; /* Whether we've seen a value on the axis yet */
    38     SDL_bool sent_initial_value; /* Whether we've sent the initial axis value */
    39 } SDL_JoystickAxisInfo;
    40 
    41 struct _SDL_Joystick
    42 {
    43     SDL_JoystickID instance_id; /* Device instance, monotonically increasing from 0 */
    44     char *name;                 /* Joystick name - system dependent */
    45 
    46     int naxes;                  /* Number of axis controls on the joystick */
    47     SDL_JoystickAxisInfo *axes;
    48 
    49     int nhats;                  /* Number of hats on the joystick */
    50     Uint8 *hats;                /* Current hat states */
    51 
    52     int nballs;                 /* Number of trackballs on the joystick */
    53     struct balldelta {
    54         int dx;
    55         int dy;
    56     } *balls;                   /* Current ball motion deltas */
    57 
    58     int nbuttons;               /* Number of buttons on the joystick */
    59     Uint8 *buttons;             /* Current button states */
    60 
    61     struct joystick_hwdata *hwdata;     /* Driver dependent information */
    62 
    63     int ref_count;              /* Reference count for multiple opens */
    64 
    65     SDL_bool is_game_controller;
    66     SDL_bool force_recentering; /* SDL_TRUE if this device needs to have its state reset to 0 */
    67     SDL_JoystickPowerLevel epowerlevel; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */
    68     struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
    69 };
    70 
    71 /* Function to scan the system for joysticks.
    72  * Joystick 0 should be the system default joystick.
    73  * This function should return the number of available joysticks, or -1
    74  * on an unrecoverable fatal error.
    75  */
    76 extern int SDL_SYS_JoystickInit(void);
    77 
    78 /* Function to return the number of joystick devices plugged in right now */
    79 extern int SDL_SYS_NumJoysticks(void);
    80 
    81 /* Function to cause any queued joystick insertions to be processed */
    82 extern void SDL_SYS_JoystickDetect(void);
    83 
    84 /* Function to get the device-dependent name of a joystick */
    85 extern const char *SDL_SYS_JoystickNameForDeviceIndex(int device_index);
    86 
    87 /* Function to get the current instance id of the joystick located at device_index */
    88 extern SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index);
    89 
    90 /* Function to open a joystick for use.
    91    The joystick to open is specified by the device index.
    92    This should fill the nbuttons and naxes fields of the joystick structure.
    93    It returns 0, or -1 if there is an error.
    94  */
    95 extern int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index);
    96 
    97 /* Function to query if the joystick is currently attached
    98  * It returns SDL_TRUE if attached, SDL_FALSE otherwise.
    99  */
   100 extern SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick * joystick);
   101 
   102 /* Function to update the state of a joystick - called as a device poll.
   103  * This function shouldn't update the joystick structure directly,
   104  * but instead should call SDL_PrivateJoystick*() to deliver events
   105  * and update joystick device state.
   106  */
   107 extern void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick);
   108 
   109 /* Function to close a joystick after use */
   110 extern void SDL_SYS_JoystickClose(SDL_Joystick * joystick);
   111 
   112 /* Function to perform any system-specific joystick related cleanup */
   113 extern void SDL_SYS_JoystickQuit(void);
   114 
   115 /* Function to return the stable GUID for a plugged in device */
   116 extern SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index);
   117 
   118 /* Function to return the stable GUID for a opened joystick */
   119 extern SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick);
   120 
   121 #if SDL_JOYSTICK_XINPUT
   122 /* Function returns SDL_TRUE if this device is an XInput gamepad */
   123 extern SDL_bool SDL_SYS_IsXInputGamepad_DeviceIndex(int device_index);
   124 #endif
   125 
   126 #endif /* SDL_sysjoystick_h_ */
   127 
   128 /* vi: set ts=4 sw=4 expandtab: */