1 /*
2 JOYSTICK.H
3 
4         Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
5         and the "Aleph One" developers.
6 
7         This program is free software; you can redistribute it and/or modify
8         it under the terms of the GNU General Public License as published by
9         the Free Software Foundation; either version 3 of the License, or
10         (at your option) any later version.
11 
12         This program is distributed in the hope that it will be useful,
13         but WITHOUT ANY WARRANTY; without even the implied warranty of
14         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15         GNU General Public License for more details.
16 
17         This license is contained in the file "COPYING",
18         which is included with this source code; it is available online at
19         http://www.gnu.org/licenses/gpl.html
20 
21 May 18, 2009 (Eric Peterson):
22     Initial revision.
23 
24 */
25 
26 #ifndef JOYSTICK_H
27 #define JOYSTICK_H
28 
29 #include "cstypes.h"
30 
31 // this is where we start stuffing button presses into the big keymap array,
32 // comfortably past SDL2's defined scancodes
33 const int AO_SCANCODE_BASE_JOYSTICK_BUTTON = 415;
34 const int AO_SCANCODE_BASE_JOYSTICK_AXIS_POSITIVE = AO_SCANCODE_BASE_JOYSTICK_BUTTON + SDL_CONTROLLER_BUTTON_MAX;
35 const int AO_SCANCODE_BASE_JOYSTICK_AXIS_NEGATIVE = AO_SCANCODE_BASE_JOYSTICK_AXIS_POSITIVE + SDL_CONTROLLER_AXIS_MAX;
36 const int NUM_SDL_JOYSTICK_BUTTONS = SDL_CONTROLLER_BUTTON_MAX + 2*SDL_CONTROLLER_AXIS_MAX;
37 
38 const SDL_Scancode AO_SCANCODE_JOYSTICK_ESCAPE = static_cast<SDL_Scancode>(AO_SCANCODE_BASE_JOYSTICK_BUTTON + SDL_CONTROLLER_BUTTON_START);
39 
40 void initialize_joystick(void);
41 void enter_joystick(void);
42 void exit_joystick(void);
43 void joystick_buttons_become_keypresses(Uint8* ioKeyMap);
44 int process_joystick_axes(int flags, int tick);
45 void joystick_axis_moved(int instance_id, int axis, int value);
46 void joystick_button_pressed(int instance_id, int button, bool down);
47 void joystick_added(int device_index);
48 void joystick_removed(int instance_id);
49 
50 #endif // JOYSTICK_H
51