quakeforge/include/QF/in_event.h
Bill Currie fed8f66824 [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 09:16:31 +09:00

93 lines
1.9 KiB
C

/*
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"
typedef struct {
int x, y;
unsigned buttons;
} IE_mouse_event_t;
typedef struct {
int key_code;
qboolean pressed;
} IE_key_event_t;
typedef struct {
int devid;
int axis;
int value;
} IE_axis_event_t;
typedef struct {
int devid;
int button;
int state;
} IE_button_event_t;
typedef struct {
int devid;
} IE_device_event_t;
typedef enum {
ie_none,
ie_gain_focus,
ie_lose_focus,
ie_add_device,
ie_remove_device,
ie_mouse,
ie_key,
ie_axis,
ie_button,
} IE_event_type;
typedef struct {
IE_event_type type;
uint64_t when;
union {
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;
};
} IE_event_t;
typedef int ie_handler_t (const IE_event_t *, void *data);
int IE_Send_Event (const IE_event_t *event);
int IE_Add_Handler (ie_handler_t *event_handler, void *data);
void IE_Remove_Handler (int handle);
void IE_Set_Focus (int handle);
#endif//__QF_in_event_h