2001-08-09 22:35:41 +00:00
|
|
|
/*
|
|
|
|
in_event.h
|
|
|
|
|
|
|
|
input event handling
|
|
|
|
|
|
|
|
Copyright (C) 2001 Bill Currie <bill@taniwha.org>
|
|
|
|
|
|
|
|
Author: Bill Currie <bill@taniwha.org>
|
|
|
|
Date: 2001/8/9
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __QF_in_event_h
|
|
|
|
#define __QF_in_event_h
|
|
|
|
|
|
|
|
#include "QF/qtypes.h"
|
|
|
|
|
2022-04-12 12:01:41 +00:00
|
|
|
/** \defgroup input_events Input Events
|
|
|
|
\ingroup input
|
|
|
|
*/
|
|
|
|
///@{
|
|
|
|
|
2021-11-22 04:06:08 +00:00
|
|
|
typedef struct {
|
|
|
|
int xpos, ypos;
|
|
|
|
int xlen, ylen;
|
|
|
|
} IE_app_window_event_t;
|
|
|
|
|
2021-11-05 04:26:44 +00:00
|
|
|
typedef enum {
|
|
|
|
ies_shift = 1,
|
|
|
|
ies_capslock = 2,
|
|
|
|
ies_control = 4,
|
|
|
|
ies_alt = 8,
|
2023-07-01 16:23:28 +00:00
|
|
|
ies_numlock = 16,
|
2021-11-05 04:26:44 +00:00
|
|
|
} IE_shift;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ie_mousedown,
|
|
|
|
ie_mouseup,
|
|
|
|
ie_mouseclick,
|
|
|
|
ie_mousemove,
|
|
|
|
ie_mouseauto,
|
|
|
|
} IE_mouse_type;
|
|
|
|
|
2001-08-09 22:35:41 +00:00
|
|
|
typedef struct {
|
2021-11-05 04:26:44 +00:00
|
|
|
IE_mouse_type type;
|
|
|
|
unsigned shift; ///< ored bit pattern of IE_shift
|
[input] Rework logical buttons
kbutton_t is now in_button_t and has been moved to input.h. Also, a
button registration function has been added to take care of +button and
-button command creation and, eventually, direct binding of "physical"
buttons to logical buttons. "Physical" buttons are those coming in from
the OS (keyboard, mouse, joystick...), logical buttons are what the code
looks at for button state.
Additionally, the button edge detection code has been cleaned up such
that it no longer uses magic numbers, and the conversion to a float is
cleaner. Interestingly, I found that the handling is extremely
frame-rate dependent (eg, +forward will accelerate the player to full
speed much faster at 72fps than it does at 20fps). This may be a factor
in why gamers are frame rate obsessed: other games doing the same thing
would certainly feel different under varying frame rates.
2021-10-01 00:16:31 +00:00
|
|
|
int x, y;
|
|
|
|
unsigned buttons;
|
2021-11-05 04:26:44 +00:00
|
|
|
int click;
|
2001-08-09 22:35:41 +00:00
|
|
|
} IE_mouse_event_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2021-11-05 04:26:44 +00:00
|
|
|
int code;
|
|
|
|
int unicode;
|
|
|
|
unsigned shift; ///< ored bit pattern of IE_shift
|
2001-08-09 22:35:41 +00:00
|
|
|
} IE_key_event_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2021-11-09 13:31:09 +00:00
|
|
|
void *data;
|
2021-08-30 05:40:19 +00:00
|
|
|
int devid;
|
|
|
|
int axis;
|
|
|
|
int value;
|
|
|
|
} IE_axis_event_t;
|
|
|
|
|
|
|
|
typedef struct {
|
2021-11-09 13:31:09 +00:00
|
|
|
void *data;
|
2021-08-30 05:40:19 +00:00
|
|
|
int devid;
|
|
|
|
int button;
|
|
|
|
int state;
|
|
|
|
} IE_button_event_t;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int devid;
|
|
|
|
} IE_device_event_t;
|
2001-08-09 22:35:41 +00:00
|
|
|
|
2021-11-22 05:07:30 +00:00
|
|
|
#define IE_EVENT(event) ie_##event,
|
2001-08-09 22:35:41 +00:00
|
|
|
typedef enum {
|
2021-11-22 05:07:30 +00:00
|
|
|
#include "QF/input/event_names.h"
|
2021-11-08 02:20:04 +00:00
|
|
|
ie_event_count
|
2001-08-09 22:35:41 +00:00
|
|
|
} IE_event_type;
|
|
|
|
|
2021-11-22 05:07:30 +00:00
|
|
|
extern const char *ie_event_names[];
|
|
|
|
|
2021-11-03 05:08:41 +00:00
|
|
|
#define IE_broadcast_events (0 \
|
|
|
|
| (1 << ie_add_device) \
|
|
|
|
| (1 << ie_remove_device) \
|
2021-11-22 04:23:17 +00:00
|
|
|
| (1 << ie_app_gain_focus) \
|
|
|
|
| (1 << ie_app_lose_focus) \
|
2021-11-22 04:06:08 +00:00
|
|
|
| (1 << ie_app_window) \
|
2021-11-03 05:08:41 +00:00
|
|
|
)
|
|
|
|
|
2021-11-16 00:37:39 +00:00
|
|
|
typedef struct IE_event_s {
|
2021-08-30 05:40:19 +00:00
|
|
|
IE_event_type type;
|
|
|
|
uint64_t when;
|
2001-08-09 22:35:41 +00:00
|
|
|
union {
|
2021-11-22 04:06:08 +00:00
|
|
|
IE_app_window_event_t app_window;
|
2021-08-30 05:40:19 +00:00
|
|
|
IE_mouse_event_t mouse;
|
|
|
|
IE_key_event_t key;
|
|
|
|
IE_axis_event_t axis;
|
|
|
|
IE_button_event_t button;
|
|
|
|
IE_device_event_t device;
|
|
|
|
};
|
2001-08-09 22:35:41 +00:00
|
|
|
} IE_event_t;
|
2003-04-08 19:20:48 +00:00
|
|
|
|
2021-08-30 05:40:19 +00:00
|
|
|
typedef int ie_handler_t (const IE_event_t *, void *data);
|
|
|
|
|
2001-08-09 23:16:54 +00:00
|
|
|
int IE_Send_Event (const IE_event_t *event);
|
2021-08-30 05:40:19 +00:00
|
|
|
int IE_Add_Handler (ie_handler_t *event_handler, void *data);
|
2001-08-09 22:35:41 +00:00
|
|
|
void IE_Remove_Handler (int handle);
|
|
|
|
void IE_Set_Focus (int handle);
|
2021-11-11 06:43:07 +00:00
|
|
|
int IE_Get_Focus (void) __attribute__ ((pure));
|
2001-08-09 22:35:41 +00:00
|
|
|
|
2022-04-12 12:01:41 +00:00
|
|
|
///@}
|
|
|
|
|
2001-08-09 22:35:41 +00:00
|
|
|
#endif//__QF_in_event_h
|