1 /*
2  * Triplane Classic - a side-scrolling dogfighting game.
3  * Copyright (C) 1996,1997,2009  Dodekaedron Software Creations Oy
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (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, see <http://www.gnu.org/licenses/>.
17  *
18  * tjt@users.sourceforge.net
19  */
20 
21 #ifndef JOYSTICK_H
22 #define JOYSTICK_H
23 
24 // Vakiom��rittelyt eri tietojen bittimaskeille
25 #define JOY1X 0x01              // Akselibitit ovat aina 1 jos joystick
26 #define JOY1Y 0x02              // ei ole kytkettyn�.
27 #define JOY2X 0x04
28 #define JOY2Y 0x08
29 
30 struct joystick_action {
31     char type;                  /* 0 = none, 1 = button, 2 = axis */
32     char n;                     /* nth button or axis */
33     Sint16 threshold;           /* threshold for axis */
34     char threshold_dir;         /* 0 = lower bound, 1 = upper bound */
35 };
36 
37 struct joystick_configuration {
38     /* "brake" action presses up and down simultaneously */
39     /* if roll.type = 0, use autoroll */
40     joystick_action up, down, roll, power, guns, bombs, brake;
41 };
42 extern joystick_configuration joystick_config[2];
43 
44 short init_joysticks(void);
45 int load_joysticks_data(const char *filename);
46 void save_joysticks_data(const char *filename);
47 void open_close_joysticks(int joy1, int joy2);
48 int joystick_has_roll_button(int t);
49 void get_joystick_action(int t, int inmenu, int *down, int *up, int *power, int *roll, int *guns, int *bombs);
50 Sint16 *allocate_axis_state(int joy);
51 void save_axis_state(Sint16 * axes, int joy);
52 void find_changed_axis(struct joystick_action *act, Sint16 * idle, Sint16 * current, int joy);
53 int find_changed_button(struct joystick_action *act, int joy);
54 void set_disabled_action(struct joystick_action *act);
55 char *get_joy_action_string(struct joystick_action *act);
56 
57 #endif
58