diff --git a/include/QF/input/event.h b/include/QF/input/event.h index 413685fc9..97902029d 100644 --- a/include/QF/input/event.h +++ b/include/QF/input/event.h @@ -85,23 +85,14 @@ typedef struct { int devid; } IE_device_event_t; +#define IE_EVENT(event) ie_##event, typedef enum { - ie_none, - 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, - +#include "QF/input/event_names.h" ie_event_count } IE_event_type; +extern const char *ie_event_names[]; + #define IE_broadcast_events (0 \ | (1 << ie_add_device) \ | (1 << ie_remove_device) \ diff --git a/include/QF/input/event_names.h b/include/QF/input/event_names.h new file mode 100644 index 000000000..9e2e5f150 --- /dev/null +++ b/include/QF/input/event_names.h @@ -0,0 +1,45 @@ +/* + event_names.h + + Input event enum names + + Copyright (C) 2021 Bill Currie + + 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 diff --git a/libs/input/in_event.c b/libs/input/in_event.c index 0fdfa0f9b..caa9e9ccb 100644 --- a/libs/input/in_event.c +++ b/libs/input/in_event.c @@ -43,6 +43,12 @@ #include "QF/input/event.h" +#define IE_EVENT(event) #event, +const char *ie_event_names[] = { +#include "QF/input/event_names.h" + 0 +}; + typedef struct { ie_handler_t *handler; void *data;