AntiMicroX
xbox360wireless.h
Go to the documentation of this file.
1 /* antimicrox Gamepad to KB+M event mapper
2  * Copyright (C) 2015 Travis Nickles <nickles.travis@gmail.com>
3  * Copyright (C) 2020 Jagoda Górska <juliagoda.pl@protonmail>
4  * Copyright (C) 2020 Paweł Kotiuk <kotiuk@zohomail.eu>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15 
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef XBOX360WIRELESS_H
21 #define XBOX360WIRELESS_H
22 
23 #include <SDL2/SDL_joystick.h>
24 
25 typedef struct _SDL_JoystickAxisInfo
26 {
27  Sint16 initial_value; /* Initial axis state */
28  Sint16 value; /* Current axis state */
29  Sint16 zero; /* Zero point on the axis (-32768 for triggers) */
30  SDL_bool has_initial_value; /* Whether we've seen a value on the axis yet */
31  SDL_bool sent_initial_value; /* Whether we've sent the initial axis value */
33 
35 {
36  SDL_JoystickID instance_id; /* Device instance, monotonically increasing from 0 */
37  char *name; /* Joystick name - system dependent */
38  int player_index; /* Joystick player index, or -1 if unavailable */
39  SDL_JoystickGUID guid; /* Joystick guid */
40 
41  int naxes; /* Number of axis controls on the joystick */
43 
44  int nhats; /* Number of hats on the joystick */
45  Uint8 *hats; /* Current hat states */
46 
47  int nballs; /* Number of trackballs on the joystick */
48  struct balldelta
49  {
50  int dx;
51  int dy;
52  } * balls; /* Current ball motion deltas */
53 
54  int nbuttons; /* Number of buttons on the joystick */
55  Uint8 *buttons; /* Current button states */
56 
57  SDL_bool attached;
59  SDL_bool delayed_guide_button; /* SDL_TRUE if this device has the guide button event delayed */
60  SDL_bool force_recentering; /* SDL_TRUE if this device needs to have its state reset to 0 */
61  SDL_JoystickPowerLevel epowerlevel; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */
62  struct _SDL_JoystickDriver *driver;
63 
64  struct joystick_hwdata *hwdata; /* Driver dependent information */
65 
66  int ref_count; /* Reference count for multiple opens */
67 
68  struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
69 };
70 
72 {
73  public:
76 
77  char *GUID();
78  char *name();
79  unsigned int deviceId();
80  int controllerType();
81  SDL_JoystickType joystickType();
82  SDL_JoystickGUID joyGUID();
83  SDL_Joystick *getResult();
84 
85  private:
86  SDL_Joystick *result;
87 };
88 
89 #endif
xbox360wireless.h
_SDL_JoystickAxisInfo::has_initial_value
SDL_bool has_initial_value
Definition: xbox360wireless.h:30
_SDL_Joystick::nhats
int nhats
Definition: xbox360wireless.h:44
_SDL_Joystick::delayed_guide_button
SDL_bool delayed_guide_button
Definition: xbox360wireless.h:59
_SDL_Joystick::epowerlevel
SDL_JoystickPowerLevel epowerlevel
Definition: xbox360wireless.h:61
Xbox360Wireless::getResult
SDL_Joystick * getResult()
Definition: xbox360wireless.cpp:92
_SDL_Joystick::instance_id
SDL_JoystickID instance_id
Definition: xbox360wireless.h:36
_SDL_Joystick::driver
struct _SDL_JoystickDriver * driver
Definition: xbox360wireless.h:62
_SDL_Joystick::buttons
Uint8 * buttons
Definition: xbox360wireless.h:55
_SDL_Joystick::next
struct _SDL_Joystick * next
Definition: xbox360wireless.h:68
Xbox360Wireless::GUID
char * GUID()
Definition: xbox360wireless.cpp:77
Xbox360Wireless::name
char * name()
Definition: xbox360wireless.cpp:79
_SDL_Joystick::balldelta::dx
int dx
Definition: xbox360wireless.h:50
_SDL_Joystick::balls
struct _SDL_Joystick::balldelta * balls
Xbox360Wireless::joyGUID
SDL_JoystickGUID joyGUID()
Definition: xbox360wireless.cpp:90
_SDL_JoystickAxisInfo::sent_initial_value
SDL_bool sent_initial_value
Definition: xbox360wireless.h:31
_SDL_Joystick::naxes
int naxes
Definition: xbox360wireless.h:41
_SDL_Joystick::attached
SDL_bool attached
Definition: xbox360wireless.h:57
_SDL_JoystickAxisInfo::value
Sint16 value
Definition: xbox360wireless.h:28
_SDL_JoystickAxisInfo
Definition: xbox360wireless.h:25
_SDL_Joystick::balldelta::dy
int dy
Definition: xbox360wireless.h:51
Xbox360Wireless::deviceId
unsigned int deviceId()
Definition: xbox360wireless.cpp:81
_SDL_Joystick::name
char * name
Definition: xbox360wireless.h:37
_SDL_Joystick
Definition: xbox360wireless.h:34
_SDL_Joystick::hwdata
struct joystick_hwdata * hwdata
Definition: xbox360wireless.h:64
_SDL_JoystickAxisInfo::initial_value
Sint16 initial_value
Definition: xbox360wireless.h:27
Xbox360Wireless::result
SDL_Joystick * result
Definition: xbox360wireless.h:86
_SDL_Joystick::axes
SDL_JoystickAxisInfo * axes
Definition: xbox360wireless.h:42
_SDL_Joystick::nballs
int nballs
Definition: xbox360wireless.h:47
_SDL_Joystick::ref_count
int ref_count
Definition: xbox360wireless.h:66
_SDL_Joystick::hats
Uint8 * hats
Definition: xbox360wireless.h:45
_SDL_Joystick::balldelta
Definition: xbox360wireless.h:48
Xbox360Wireless::controllerType
int controllerType()
Definition: xbox360wireless.cpp:83
SDL_JoystickAxisInfo
struct _SDL_JoystickAxisInfo SDL_JoystickAxisInfo
_SDL_Joystick::nbuttons
int nbuttons
Definition: xbox360wireless.h:54
_SDL_Joystick::is_game_controller
SDL_bool is_game_controller
Definition: xbox360wireless.h:58
Xbox360Wireless::~Xbox360Wireless
~Xbox360Wireless()
Definition: xbox360wireless.cpp:65
_SDL_Joystick::guid
SDL_JoystickGUID guid
Definition: xbox360wireless.h:39
MAKE_CONTROLLER_ID
#define MAKE_CONTROLLER_ID(nVID, nPID)
Definition: xbox360wireless.cpp:20
Xbox360Wireless::Xbox360Wireless
Xbox360Wireless()
Definition: xbox360wireless.cpp:25
_SDL_Joystick::force_recentering
SDL_bool force_recentering
Definition: xbox360wireless.h:60
_SDL_Joystick::player_index
int player_index
Definition: xbox360wireless.h:38
Xbox360Wireless
Definition: xbox360wireless.h:71
_SDL_JoystickAxisInfo::zero
Sint16 zero
Definition: xbox360wireless.h:29
Xbox360Wireless::joystickType
SDL_JoystickType joystickType()
Definition: xbox360wireless.cpp:88