taisei/src/events.h

76 lines
1.5 KiB
C
Raw Normal View History

2012-08-13 17:50:28 +02:00
/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
2012-08-13 17:50:28 +02:00
* ---
2017-09-12 03:28:15 +02:00
* Copyright (c) 2011-2017, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
2012-08-13 17:50:28 +02:00
*/
2017-09-27 14:14:53 +02:00
#pragma once
2012-08-13 17:50:28 +02:00
#include "config.h"
2012-08-13 17:50:28 +02:00
typedef enum {
EF_Keyboard = 1,
EF_Text = 2,
EF_Menu = 4,
EF_Game = 8,
EF_Gamepad = 16,
EF_Video = 32,
2012-08-13 17:50:28 +02:00
} EventFlags;
typedef enum {
// EF_Keyboard
E_KeyDown,
E_KeyUp,
2012-08-13 17:50:28 +02:00
// EF_Text
E_CharTyped,
E_CharErased,
E_SubmitText,
E_CancelText,
2012-08-13 17:50:28 +02:00
// EF_Menu
E_CursorUp,
E_CursorDown,
E_CursorLeft,
E_CursorRight,
E_MenuAccept,
E_MenuAbort,
2012-08-13 17:50:28 +02:00
// EF_Game
E_PlrKeyDown,
E_PlrKeyUp,
2012-08-15 16:36:39 +02:00
E_PlrAxisUD,
E_PlrAxisLR,
E_Pause,
// EF_Gamepad
E_GamepadKeyDown,
2017-02-27 23:58:47 +01:00
E_GamepadKeyUp,
E_GamepadAxis,
E_GamepadAxisValue,
// EF_Video
E_VideoModeChanged,
2012-08-13 17:50:28 +02:00
} EventType;
extern struct sdl_custom_events_s {
uint32_t resource_load_finished;
uint32_t video_mode_changed;
} sdl_custom_events;
#define NUM_CUSTOM_EVENTS (sizeof(struct sdl_custom_events_s)/sizeof(uint32_t))
#define FIRST_CUSTOM_EVENT (((uint32_t*)&sdl_custom_events)[0])
#define LAST_CUSTOM_EVENT (((uint32_t*)&sdl_custom_events)[NUM_CUSTOM_EVENTS - 1])
#define IS_CUSTOM_EVENT(e) ((e) >= FIRST_CUSTOM_EVENT && (e) <= LAST_CUSTOM_EVENT)
2012-08-13 17:50:28 +02:00
typedef void(*EventHandler)(EventType, int, void*);
void events_init(void);
2017-09-19 14:13:04 +02:00
void events_pause_keyrepeat(void);
2012-08-13 17:50:28 +02:00
void handle_events(EventHandler handler, EventFlags flags, void *arg);
bool gamekeypressed(KeyIndex key);
2012-08-13 17:50:28 +02:00
2017-09-27 14:14:53 +02:00