[input] Make event names easy to print

Handy for debugging and testing.
This commit is contained in:
Bill Currie 2021-11-22 14:07:30 +09:00
parent e8a7e8218e
commit 67483eea37
3 changed files with 55 additions and 13 deletions

View file

@ -85,23 +85,14 @@ typedef struct {
int devid; int devid;
} IE_device_event_t; } IE_device_event_t;
#define IE_EVENT(event) ie_##event,
typedef enum { typedef enum {
ie_none, #include "QF/input/event_names.h"
ie_gain_focus,
ie_lose_focus,
ie_app_gain_focus,
ie_app_lose_focus,
ie_app_window,
ie_add_device,
ie_remove_device,
ie_mouse,
ie_key,
ie_axis,
ie_button,
ie_event_count ie_event_count
} IE_event_type; } IE_event_type;
extern const char *ie_event_names[];
#define IE_broadcast_events (0 \ #define IE_broadcast_events (0 \
| (1 << ie_add_device) \ | (1 << ie_add_device) \
| (1 << ie_remove_device) \ | (1 << ie_remove_device) \

View file

@ -0,0 +1,45 @@
/*
event_names.h
Input event enum names
Copyright (C) 2021 Bill Currie <bill@taniwha.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
*/
#ifndef IE_EVENT
#define IE_EVENT(event)
#endif
IE_EVENT (none)
IE_EVENT (gain_focus)
IE_EVENT (lose_focus)
IE_EVENT (app_gain_focus)
IE_EVENT (app_lose_focus)
IE_EVENT (app_window)
IE_EVENT (add_device)
IE_EVENT (remove_device)
IE_EVENT (mouse)
IE_EVENT (key)
IE_EVENT (axis)
IE_EVENT (button)
#undef IE_EVENT

View file

@ -43,6 +43,12 @@
#include "QF/input/event.h" #include "QF/input/event.h"
#define IE_EVENT(event) #event,
const char *ie_event_names[] = {
#include "QF/input/event_names.h"
0
};
typedef struct { typedef struct {
ie_handler_t *handler; ie_handler_t *handler;
void *data; void *data;