pass LDFLAGS to compiler at link time
[tennix.git] / input.h
blobf3f82136b64a04e5ef829d91d4b2a040693d8308
2 /**
4 * Tennix! SDL Port
5 * Copyright (C) 2003, 2007, 2008, 2009 Thomas Perl <thp@thpinfo.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
22 **/
24 #ifndef __INPUT_H
25 #define __INPUT_H
27 #include "archive.hh"
28 #include "graphics.h"
30 #ifdef TENNIX_PYTHON
31 #include <Python.h>
32 #endif
34 #define JOYSTICK_PERCENTIZE(x) ((float)(x)/(float)(32768))
36 #define MAX_INPUT_DEVICES 16
38 enum {
39 INPUT_COORD_TYPE_PLAYER,
40 INPUT_COORD_TYPE_BALL
43 enum {
44 INPUT_TYPE_KEYBOARD,
45 INPUT_TYPE_JOYSTICK,
46 INPUT_TYPE_MOUSE,
47 INPUT_TYPE_NETWORK,
48 #ifdef TENNIX_PYTHON
49 INPUT_TYPE_AI_PYTHON,
50 #endif
51 INPUT_TYPE_MAX
54 enum {
55 INPUT_AXIS_X,
56 INPUT_AXIS_Y
59 enum {
60 INPUT_KEY_HIT,
61 INPUT_KEY_TOPSPIN,
62 INPUT_KEY_SMASH,
63 INPUT_KEY_COUNT
66 enum {
67 NET_KEY_HIT = 1 << INPUT_KEY_HIT,
68 NET_KEY_TOPSPIN = 1 << INPUT_KEY_TOPSPIN,
69 NET_KEY_SMASH = 1 << INPUT_KEY_SMASH
72 #define INPUT_DEVICE_NAME_MAX 100
74 typedef struct {
75 unsigned char type;
76 char name[INPUT_DEVICE_NAME_MAX];
78 /* Joystick-specific items */
79 SDL_Joystick* joystick;
80 int x_axis;
81 int y_axis;
83 /* Joystick, keyboard and mouse */
84 int input_keys[INPUT_KEY_COUNT];
86 /* Keyboard-specific items */
87 int up_key;
88 int down_key;
89 int left_key;
90 int right_key;
92 /* Mouse-specific items */
93 int mx;
94 int my;
95 int player_x;
96 int player_y;
98 /* Network-specific items */
99 NetworkInputData net;
101 #ifdef TENNIX_PYTHON
102 /* Python-specific items */
103 PyObject* py_bot_class;
104 PyObject* py_bot;
105 #endif
107 /* The picture for this input device */
108 image_id icon;
110 /* If nonzero, be exclusive to this player ID */
111 int exclusive_to_player;
112 } InputDevice;
114 void init_input(TennixArchive& tnxar);
115 void uninit_input();
117 #ifdef TENNIX_PYTHON
118 void input_add_python_bot(PyObject* pyclass);
119 #endif
121 InputDevice* find_input_devices(unsigned int*);
123 const char* input_device_get_name(InputDevice*);
124 float input_device_get_axis(InputDevice*, unsigned const char);
125 char input_device_get_key(InputDevice*, unsigned const char);
127 void input_device_join_game(InputDevice* device, void* gamestate, int player_id);
128 void input_device_part_game(InputDevice*);
131 #endif