~ubuntu-branches/debian/stretch/opentyrian/stretch

« back to all changes in this revision

Viewing changes to src/joystick.h

  • Committer: Package Import Robot
  • Author(s): Etienne Millon
  • Date: 2015-03-31 08:48:54 UTC
  • Revision ID: package-import@ubuntu.com-20150331084854-f5a4uoz7uv3vopk6
Tags: upstream-2.1.20130907+dfsg
ImportĀ upstreamĀ versionĀ 2.1.20130907+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 * OpenTyrian: A modern cross-platform port of Tyrian
 
3
 * Copyright (C) 2007-2009  The OpenTyrian Development Team
 
4
 *
 
5
 * This program is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU General Public License
 
7
 * as published by the Free Software Foundation; either version 2
 
8
 * of the License, or (at your option) any later version.
 
9
 *
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License
 
16
 * along with this program; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
#ifndef JOYSTICK_H
 
20
#define JOYSTICK_H
 
21
 
 
22
#include "opentyr.h"
 
23
 
 
24
#include "SDL.h"
 
25
 
 
26
typedef enum
 
27
{
 
28
        NONE,
 
29
        AXIS,
 
30
        BUTTON,
 
31
        HAT
 
32
}
 
33
Joystick_assignment_types;
 
34
 
 
35
typedef struct
 
36
{
 
37
        Joystick_assignment_types type;
 
38
        int num;
 
39
        
 
40
        // if hat
 
41
        bool x_axis; // else y_axis
 
42
        
 
43
        // if hat or axis
 
44
        bool negative_axis; // else positive
 
45
}
 
46
Joystick_assignment;
 
47
 
 
48
typedef struct
 
49
{
 
50
        SDL_Joystick *handle;
 
51
        
 
52
        Joystick_assignment assignment[10][2]; // 0-3: directions, 4-9: actions
 
53
        
 
54
        bool analog;
 
55
        int sensitivity, threshold;
 
56
        
 
57
        signed int x, y;
 
58
        int analog_direction[4];
 
59
        bool direction[4], direction_pressed[4]; // up, right, down, left  (_pressed, for emulating key presses)
 
60
        
 
61
        bool confirm, cancel;
 
62
        bool action[6], action_pressed[6]; // fire, mode swap, left fire, right fire, menu, pause
 
63
        
 
64
        Uint32 joystick_delay;
 
65
        bool input_pressed;
 
66
}
 
67
Joystick;
 
68
 
 
69
extern int joystick_repeat_delay;
 
70
extern bool joydown;
 
71
extern bool ignore_joystick;
 
72
extern int joysticks;
 
73
extern Joystick *joystick;
 
74
 
 
75
int joystick_axis_reduce( int j, int value );
 
76
bool joystick_analog_angle( int j, float *angle );
 
77
 
 
78
void poll_joystick( int j );
 
79
void poll_joysticks( void );
 
80
 
 
81
void push_key( SDLKey key );
 
82
void push_joysticks_as_keyboard( void );
 
83
 
 
84
void init_joysticks( void );
 
85
void deinit_joysticks( void );
 
86
 
 
87
void reset_joystick_assignments( int j );
 
88
bool load_joystick_assignments( int j );
 
89
bool save_joystick_assignments( int j );
 
90
 
 
91
void joystick_assignments_to_string( char *buffer, size_t buffer_len, const Joystick_assignment *assignments );
 
92
 
 
93
bool detect_joystick_assignment( int j, Joystick_assignment *assignment );
 
94
bool joystick_assignment_cmp( const Joystick_assignment *, const Joystick_assignment * );
 
95
 
 
96
#endif /* JOYSTICK_H */
 
97