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
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2020-02-24 03:21:20 +00:00
|
|
|
#ifndef __QF_joystick_h
|
|
|
|
#define __QF_joystick_h
|
2001-05-19 23:24:20 +00:00
|
|
|
|
|
|
|
#include <QF/qtypes.h>
|
2013-01-25 19:27:38 +00:00
|
|
|
#include "QF/quakeio.h"
|
2001-04-10 21:01:29 +00:00
|
|
|
|
2014-08-17 02:35:40 +00:00
|
|
|
#define JOY_MAX_AXES 32
|
|
|
|
#define JOY_MAX_BUTTONS 64
|
2001-04-10 21:01:29 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
extern char *joy_device;
|
|
|
|
extern int joy_enable;
|
2001-04-10 21:01:29 +00:00
|
|
|
|
2013-01-27 05:05:24 +00:00
|
|
|
struct joy_axis_button {
|
2013-01-19 13:37:02 +00:00
|
|
|
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 {
|
2013-01-27 05:05:24 +00:00
|
|
|
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 {
|
2013-01-27 05:05:24 +00:00
|
|
|
int current;
|
|
|
|
float amp;
|
|
|
|
float pre_amp;
|
|
|
|
int deadzone;
|
|
|
|
float offset;
|
2013-01-19 13:37:02 +00:00
|
|
|
js_dest_t dest;
|
2013-01-27 05:05:24 +00:00
|
|
|
int axis; // if linear delta
|
|
|
|
int num_buttons; // if axis button
|
2013-01-19 13:37:02 +00:00
|
|
|
struct joy_axis_button *axis_buttons; // if axis button
|
2001-04-11 19:56:01 +00:00
|
|
|
};
|
|
|
|
|
2013-01-27 05:05:24 +00:00
|
|
|
extern qboolean joy_found; // Joystick present?
|
|
|
|
extern qboolean joy_active; // Joystick in use?
|
2013-01-19 13:37:02 +00:00
|
|
|
|
2001-04-11 19:56:01 +00:00
|
|
|
struct joy_button {
|
2013-01-27 05:05:24 +00:00
|
|
|
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
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
joy_enable are zero.
|
2001-04-10 21:01:29 +00:00
|
|
|
*/
|
|
|
|
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
|
|
|
|
|
|
|
/*
|
2001-04-11 07:57:08 +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
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
joy_enable are zero.
|
2001-04-10 21:01:29 +00:00
|
|
|
*/
|
2001-04-11 07:57:08 +00:00
|
|
|
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
|
|
|
|
2018-10-09 03:35:01 +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
|
|
|
|
2018-10-09 03:35:01 +00:00
|
|
|
const char *JOY_GetDest_c (int i) __attribute__((pure));
|
|
|
|
int JOY_GetDest_i (const char *c) __attribute__((pure));
|
2013-01-28 12:09:21 +00:00
|
|
|
int JOY_GetAxis_i (int dest, const char *c);
|
2013-01-25 18:02:52 +00:00
|
|
|
|
2013-01-25 19:27:38 +00:00
|
|
|
|
|
|
|
void Joy_WriteBindings (QFile *f);
|
|
|
|
|
2020-02-24 03:21:20 +00:00
|
|
|
#endif//__QF_joystick_h
|