quakeforge/include/QF/joystick.h

158 lines
3.6 KiB
C
Raw Normal View History

2001-04-10 21:01:29 +00:00
/*
joystick.h
QuakeForge joystick DPI (driver programming interface)
Copyright (C) 1996-1997 Jeff Teunissen <deek@dusknet.dhs.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to:
Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/
2001-05-19 23:24:20 +00:00
#ifndef __QF_joystick_h_
#define __QF_joystick_h_
#include <QF/qtypes.h>
#include "QF/quakeio.h"
2001-04-10 21:01:29 +00:00
#define JOY_MAX_AXES 32
#define JOY_MAX_BUTTONS 64
2001-04-10 21:01:29 +00:00
2001-05-19 23:24:20 +00:00
extern struct cvar_s *joy_device; // Joystick device name
extern struct cvar_s *joy_enable; // Joystick enabling flag
2001-04-10 21:01:29 +00:00
struct joy_axis_button {
float threshold;
int key;
int state;
};
typedef enum {
js_none, // ignore axis
js_position, // linear delta
js_angles, // linear delta
js_button, // axis button
} js_dest_t;
2001-04-10 21:01:29 +00:00
2013-01-25 18:02:52 +00:00
typedef enum {
js_clear,
js_amp,
js_pre_amp,
js_deadzone,
js_offset,
js_type,
js_axis_button,
2013-01-25 18:02:52 +00:00
} js_opt_t;
2001-04-11 19:56:01 +00:00
struct joy_axis {
int current;
float amp;
float pre_amp;
int deadzone;
float offset;
js_dest_t dest;
int axis; // if linear delta
int num_buttons; // if axis button
struct joy_axis_button *axis_buttons; // if axis button
2001-04-11 19:56:01 +00:00
};
extern qboolean joy_found; // Joystick present?
extern qboolean joy_active; // Joystick in use?
2001-04-11 19:56:01 +00:00
struct joy_button {
int old;
int current;
2001-04-11 19:56:01 +00:00
};
extern struct joy_axis joy_axes[JOY_MAX_AXES];
extern struct joy_button joy_buttons[JOY_MAX_BUTTONS];
2001-04-10 21:01:29 +00:00
/*
JOY_Command ()
Use this function to process joystick button presses and generate key
events. It is called inside the IN_Commands () input function, once each
frame.
You should exit this function immediately if either joy_active or
joy_enable->int_val are zero.
*/
void JOY_Command (void);
2013-01-26 19:34:53 +00:00
void joy_clear_axis (int i);
2001-04-10 21:01:29 +00:00
/*
JOY_Move (usercmd_t *) // FIXME: Not anymore!
2001-04-10 21:01:29 +00:00
Use this function to process joystick movements to move the player around.
You should exit this function immediately if either joy_active or
joy_enable->int_val are zero.
*/
void JOY_Move (void);
2001-04-10 21:01:29 +00:00
/*
JOY_Init ()
Use this function to initialize the joystick Cvars, open your joystick
device, and get it ready for use. You MUST obey the value of the
joy_enable Cvar. Set joy_found if there is a device, and joy_active if
you have successfully enabled it.
*/
void JOY_Init (void);
void JOY_Init_Cvars (void);
/*
JOY_Shutdown ()
Use this function to close the joystick device and tell QuakeForge that it
is no longer available. It is called from IN_Init (), but may be called
elsewhere to disable the device.
*/
void JOY_Shutdown (void);
2001-04-11 19:56:01 +00:00
/*
JOY_Open ()
JOY_Close ()
2001-05-19 23:24:20 +00:00
OS-specific joystick init/deinit
2001-04-11 19:56:01 +00:00
*/
int JOY_Open (void);
void JOY_Close (void);
/*
JOY_Read ()
2001-05-19 23:24:20 +00:00
OS-specific joystick reading
2001-04-11 19:56:01 +00:00
*/
void JOY_Read (void);
2001-05-19 23:24:20 +00:00
2013-01-25 18:02:52 +00:00
const char *JOY_GetOption_c (int i) __attribute__((pure));
int JOY_GetOption_i (const char *c) __attribute__((pure));
2013-01-25 18:02:52 +00:00
const char *JOY_GetDest_c (int i) __attribute__((pure));
int JOY_GetDest_i (const char *c) __attribute__((pure));
int JOY_GetAxis_i (int dest, const char *c);
2013-01-25 18:02:52 +00:00
void Joy_WriteBindings (QFile *f);
2001-05-19 23:24:20 +00:00
#endif // __QF_joystick_h_