Mercurial > molko
changeset 450:b26dd49f69ff
core: event -> mlk_event (and friends)
line wrap: on
line diff
--- a/libmlk-core/CMakeLists.txt Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/CMakeLists.txt Sat Feb 18 13:37:11 2023 +0100 @@ -20,10 +20,10 @@ set( SOURCES + ${libmlk-core_SOURCE_DIR}/mlk/core/action-stack.c + ${libmlk-core_SOURCE_DIR}/mlk/core/action-stack.h ${libmlk-core_SOURCE_DIR}/mlk/core/action.c ${libmlk-core_SOURCE_DIR}/mlk/core/action.h - ${libmlk-core_SOURCE_DIR}/mlk/core/action-stack.c - ${libmlk-core_SOURCE_DIR}/mlk/core/action-stack.h ${libmlk-core_SOURCE_DIR}/mlk/core/alloc.c ${libmlk-core_SOURCE_DIR}/mlk/core/alloc.h ${libmlk-core_SOURCE_DIR}/mlk/core/animation.c @@ -33,10 +33,12 @@ ${libmlk-core_SOURCE_DIR}/mlk/core/color.h ${libmlk-core_SOURCE_DIR}/mlk/core/core.c ${libmlk-core_SOURCE_DIR}/mlk/core/core.h + ${libmlk-core_SOURCE_DIR}/mlk/core/drawable-stack.c + ${libmlk-core_SOURCE_DIR}/mlk/core/drawable-stack.h ${libmlk-core_SOURCE_DIR}/mlk/core/drawable.c ${libmlk-core_SOURCE_DIR}/mlk/core/drawable.h - ${libmlk-core_SOURCE_DIR}/mlk/core/drawable-stack.c - ${libmlk-core_SOURCE_DIR}/mlk/core/drawable-stack.h + ${libmlk-core_SOURCE_DIR}/mlk/core/err.c + ${libmlk-core_SOURCE_DIR}/mlk/core/err.h ${libmlk-core_SOURCE_DIR}/mlk/core/error.c ${libmlk-core_SOURCE_DIR}/mlk/core/error.h ${libmlk-core_SOURCE_DIR}/mlk/core/event.c
--- a/libmlk-core/mlk/core/action-stack.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/action-stack.c Sat Feb 18 13:37:11 2023 +0100 @@ -55,7 +55,7 @@ } void -mlk_action_stack_handle(struct mlk_action_stack *st, const union event *ev) +mlk_action_stack_handle(struct mlk_action_stack *st, const union mlk_event *ev) { assert(st); assert(ev);
--- a/libmlk-core/mlk/core/action-stack.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/action-stack.h Sat Feb 18 13:37:11 2023 +0100 @@ -25,7 +25,7 @@ struct mlk_action; -union event; +union mlk_event; struct mlk_action_stack { struct mlk_action **actions; @@ -41,7 +41,7 @@ mlk_action_stack_add(struct mlk_action_stack *, struct mlk_action *); void -mlk_action_stack_handle(struct mlk_action_stack *, const union event *); +mlk_action_stack_handle(struct mlk_action_stack *, const union mlk_event *); int mlk_action_stack_update(struct mlk_action_stack *, unsigned int);
--- a/libmlk-core/mlk/core/action.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/action.c Sat Feb 18 13:37:11 2023 +0100 @@ -21,7 +21,7 @@ #include "action.h" void -mlk_action_handle(struct mlk_action *act, const union event *ev) +mlk_action_handle(struct mlk_action *act, const union mlk_event *ev) { assert(act); assert(ev);
--- a/libmlk-core/mlk/core/action.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/action.h Sat Feb 18 13:37:11 2023 +0100 @@ -21,11 +21,11 @@ #include "core.h" -union event; +union mlk_event; struct mlk_action { void *data; - void (*handle)(struct mlk_action *, const union event *); + void (*handle)(struct mlk_action *, const union mlk_event *); int (*update)(struct mlk_action *, unsigned int); void (*draw)(struct mlk_action *); void (*end)(struct mlk_action *); @@ -35,7 +35,7 @@ CORE_BEGIN_DECLS void -mlk_action_handle(struct mlk_action *, const union event *); +mlk_action_handle(struct mlk_action *, const union mlk_event *); int mlk_action_update(struct mlk_action *, unsigned int);
--- a/libmlk-core/mlk/core/event.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/event.c Sat Feb 18 13:37:11 2023 +0100 @@ -23,156 +23,156 @@ /* Maintain with enum key constants in key.h */ static const struct { SDL_Keycode key; - enum key value; + enum mlk_key value; } keymap[] = { - { SDLK_RETURN, KEY_ENTER }, - { SDLK_ESCAPE, KEY_ESCAPE }, - { SDLK_BACKSPACE, KEY_BACKSPACE }, - { SDLK_TAB, KEY_TAB }, - { SDLK_SPACE, KEY_SPACE }, - { SDLK_EXCLAIM, KEY_EXCLAIM }, - { SDLK_QUOTEDBL, KEY_DOUBLE_QUOTE }, - { SDLK_HASH, KEY_HASH }, - { SDLK_PERCENT, KEY_PERCENT }, - { SDLK_DOLLAR, KEY_DOLLAR }, - { SDLK_AMPERSAND, KEY_AMPERSAND }, - { SDLK_QUOTE, KEY_QUOTE }, - { SDLK_LEFTPAREN, KEY_LEFT_PAREN }, - { SDLK_RIGHTPAREN, KEY_RIGHT_PAREN }, - { SDLK_ASTERISK, KEY_ASTERISK }, - { SDLK_PLUS, KEY_PLUS }, - { SDLK_COMMA, KEY_COMMA }, - { SDLK_MINUS, KEY_MINUS }, - { SDLK_PERIOD, KEY_PERIOD }, - { SDLK_SLASH, KEY_SLASH }, - { SDLK_0, KEY_0 }, - { SDLK_1, KEY_1 }, - { SDLK_2, KEY_2 }, - { SDLK_3, KEY_3 }, - { SDLK_4, KEY_4 }, - { SDLK_5, KEY_5 }, - { SDLK_6, KEY_6 }, - { SDLK_7, KEY_7 }, - { SDLK_8, KEY_8 }, - { SDLK_9, KEY_9 }, - { SDLK_COLON, KEY_COLON }, - { SDLK_SEMICOLON, KEY_SEMICOLON }, - { SDLK_LESS, KEY_LESS }, - { SDLK_EQUALS, KEY_EQUALS }, - { SDLK_GREATER, KEY_GREATER }, - { SDLK_QUESTION, KEY_QUESTION }, - { SDLK_AT, KEY_AT }, - { SDLK_LEFTBRACKET, KEY_LEFT_BRACKET }, - { SDLK_BACKSLASH, KEY_BACKSLASH }, - { SDLK_RIGHTBRACKET, KEY_RIGHT_BRACKET }, - { SDLK_CARET, KEY_CARET }, - { SDLK_UNDERSCORE, KEY_UNDERSCORE }, - { SDLK_BACKQUOTE, KEY_BACKQUOTE }, - { SDLK_a, KEY_a }, - { SDLK_b, KEY_b }, - { SDLK_c, KEY_c }, - { SDLK_d, KEY_d }, - { SDLK_e, KEY_e }, - { SDLK_f, KEY_f }, - { SDLK_g, KEY_g }, - { SDLK_h, KEY_h }, - { SDLK_i, KEY_i }, - { SDLK_j, KEY_j }, - { SDLK_k, KEY_k }, - { SDLK_l, KEY_l }, - { SDLK_m, KEY_m }, - { SDLK_n, KEY_n }, - { SDLK_o, KEY_o }, - { SDLK_p, KEY_p }, - { SDLK_q, KEY_q }, - { SDLK_r, KEY_r }, - { SDLK_s, KEY_s }, - { SDLK_t, KEY_t }, - { SDLK_u, KEY_u }, - { SDLK_v, KEY_v }, - { SDLK_w, KEY_w }, - { SDLK_x, KEY_x }, - { SDLK_y, KEY_y }, - { SDLK_z, KEY_z }, - { SDLK_CAPSLOCK, KEY_CAPSLOCK }, - { SDLK_F1, KEY_F1 }, - { SDLK_F2, KEY_F2 }, - { SDLK_F3, KEY_F3 }, - { SDLK_F4, KEY_F4 }, - { SDLK_F5, KEY_F5 }, - { SDLK_F6, KEY_F6 }, - { SDLK_F7, KEY_F7 }, - { SDLK_F8, KEY_F8 }, - { SDLK_F9, KEY_F9 }, - { SDLK_F10, KEY_F10 }, - { SDLK_F11, KEY_F11 }, - { SDLK_F12, KEY_F12 }, - { SDLK_F13, KEY_F13 }, - { SDLK_F14, KEY_F14 }, - { SDLK_F15, KEY_F15 }, - { SDLK_F16, KEY_F16 }, - { SDLK_F17, KEY_F17 }, - { SDLK_F18, KEY_F18 }, - { SDLK_F19, KEY_F19 }, - { SDLK_F20, KEY_F20 }, - { SDLK_F21, KEY_F21 }, - { SDLK_F22, KEY_F22 }, - { SDLK_F23, KEY_F23 }, - { SDLK_F24, KEY_F24 }, - { SDLK_PRINTSCREEN, KEY_PRINTSCREEN }, - { SDLK_SCROLLLOCK, KEY_SCROLL_LOCK }, - { SDLK_PAUSE, KEY_PAUSE }, - { SDLK_INSERT, KEY_INSERT }, - { SDLK_HOME, KEY_HOME }, - { SDLK_PAGEUP, KEY_PAGEUP }, - { SDLK_DELETE, KEY_DELETE }, - { SDLK_END, KEY_END }, - { SDLK_PAGEDOWN, KEY_PAGEDOWN }, - { SDLK_RIGHT, KEY_RIGHT }, - { SDLK_LEFT, KEY_LEFT }, - { SDLK_DOWN, KEY_DOWN }, - { SDLK_UP, KEY_UP }, - { SDLK_KP_DIVIDE, KEY_KP_DIVIDE }, - { SDLK_KP_MULTIPLY, KEY_KP_MULTIPLY }, - { SDLK_KP_MINUS, KEY_KP_MINUS }, - { SDLK_KP_PLUS, KEY_KP_PLUS }, - { SDLK_KP_ENTER, KEY_KP_ENTER }, - { SDLK_KP_1, KEY_KP_1 }, - { SDLK_KP_2, KEY_KP_2 }, - { SDLK_KP_3, KEY_KP_3 }, - { SDLK_KP_4, KEY_KP_4 }, - { SDLK_KP_5, KEY_KP_5 }, - { SDLK_KP_6, KEY_KP_6 }, - { SDLK_KP_7, KEY_KP_7 }, - { SDLK_KP_8, KEY_KP_8 }, - { SDLK_KP_9, KEY_KP_9 }, - { SDLK_KP_0, KEY_KP_0 }, - { SDLK_KP_PERIOD, KEY_KP_PERIOD }, - { SDLK_KP_COMMA, KEY_KP_COMMA }, - { SDLK_MENU, KEY_MENU }, - { SDLK_MUTE, KEY_MUTE }, - { SDLK_VOLUMEUP, KEY_VOLUME_UP }, - { SDLK_VOLUMEDOWN, KEY_VOLUME_DOWN }, - { SDLK_LCTRL, KEY_LCTRL }, - { SDLK_LSHIFT, KEY_LSHIFT }, - { SDLK_LALT, KEY_LALT }, - { SDLK_LGUI, KEY_LSUPER }, - { SDLK_RCTRL, KEY_RCTRL }, - { SDLK_RSHIFT, KEY_RSHIFT }, - { SDLK_RALT, KEY_RALT }, - { SDLK_RGUI, KEY_RSUPER }, - { 0, -1 } + { SDLK_RETURN, MLK_KEY_ENTER }, + { SDLK_ESCAPE, MLK_KEY_ESCAPE }, + { SDLK_BACKSPACE, MLK_KEY_BACKSPACE }, + { SDLK_TAB, MLK_KEY_TAB }, + { SDLK_SPACE, MLK_KEY_SPACE }, + { SDLK_EXCLAIM, MLK_KEY_EXCLAIM }, + { SDLK_QUOTEDBL, MLK_KEY_DOUBLE_QUOTE }, + { SDLK_HASH, MLK_KEY_HASH }, + { SDLK_PERCENT, MLK_KEY_PERCENT }, + { SDLK_DOLLAR, MLK_KEY_DOLLAR }, + { SDLK_AMPERSAND, MLK_KEY_AMPERSAND }, + { SDLK_QUOTE, MLK_KEY_QUOTE }, + { SDLK_LEFTPAREN, MLK_KEY_LEFT_PAREN }, + { SDLK_RIGHTPAREN, MLK_KEY_RIGHT_PAREN }, + { SDLK_ASTERISK, MLK_KEY_ASTERISK }, + { SDLK_PLUS, MLK_KEY_PLUS }, + { SDLK_COMMA, MLK_KEY_COMMA }, + { SDLK_MINUS, MLK_KEY_MINUS }, + { SDLK_PERIOD, MLK_KEY_PERIOD }, + { SDLK_SLASH, MLK_KEY_SLASH }, + { SDLK_0, MLK_KEY_0 }, + { SDLK_1, MLK_KEY_1 }, + { SDLK_2, MLK_KEY_2 }, + { SDLK_3, MLK_KEY_3 }, + { SDLK_4, MLK_KEY_4 }, + { SDLK_5, MLK_KEY_5 }, + { SDLK_6, MLK_KEY_6 }, + { SDLK_7, MLK_KEY_7 }, + { SDLK_8, MLK_KEY_8 }, + { SDLK_9, MLK_KEY_9 }, + { SDLK_COLON, MLK_KEY_COLON }, + { SDLK_SEMICOLON, MLK_KEY_SEMICOLON }, + { SDLK_LESS, MLK_KEY_LESS }, + { SDLK_EQUALS, MLK_KEY_EQUALS }, + { SDLK_GREATER, MLK_KEY_GREATER }, + { SDLK_QUESTION, MLK_KEY_QUESTION }, + { SDLK_AT, MLK_KEY_AT }, + { SDLK_LEFTBRACKET, MLK_KEY_LEFT_BRACKET }, + { SDLK_BACKSLASH, MLK_KEY_BACKSLASH }, + { SDLK_RIGHTBRACKET, MLK_KEY_RIGHT_BRACKET }, + { SDLK_CARET, MLK_KEY_CARET }, + { SDLK_UNDERSCORE, MLK_KEY_UNDERSCORE }, + { SDLK_BACKQUOTE, MLK_KEY_BACKQUOTE }, + { SDLK_a, MLK_KEY_a }, + { SDLK_b, MLK_KEY_b }, + { SDLK_c, MLK_KEY_c }, + { SDLK_d, MLK_KEY_d }, + { SDLK_e, MLK_KEY_e }, + { SDLK_f, MLK_KEY_f }, + { SDLK_g, MLK_KEY_g }, + { SDLK_h, MLK_KEY_h }, + { SDLK_i, MLK_KEY_i }, + { SDLK_j, MLK_KEY_j }, + { SDLK_k, MLK_KEY_k }, + { SDLK_l, MLK_KEY_l }, + { SDLK_m, MLK_KEY_m }, + { SDLK_n, MLK_KEY_n }, + { SDLK_o, MLK_KEY_o }, + { SDLK_p, MLK_KEY_p }, + { SDLK_q, MLK_KEY_q }, + { SDLK_r, MLK_KEY_r }, + { SDLK_s, MLK_KEY_s }, + { SDLK_t, MLK_KEY_t }, + { SDLK_u, MLK_KEY_u }, + { SDLK_v, MLK_KEY_v }, + { SDLK_w, MLK_KEY_w }, + { SDLK_x, MLK_KEY_x }, + { SDLK_y, MLK_KEY_y }, + { SDLK_z, MLK_KEY_z }, + { SDLK_CAPSLOCK, MLK_KEY_CAPSLOCK }, + { SDLK_F1, MLK_KEY_F1 }, + { SDLK_F2, MLK_KEY_F2 }, + { SDLK_F3, MLK_KEY_F3 }, + { SDLK_F4, MLK_KEY_F4 }, + { SDLK_F5, MLK_KEY_F5 }, + { SDLK_F6, MLK_KEY_F6 }, + { SDLK_F7, MLK_KEY_F7 }, + { SDLK_F8, MLK_KEY_F8 }, + { SDLK_F9, MLK_KEY_F9 }, + { SDLK_F10, MLK_KEY_F10 }, + { SDLK_F11, MLK_KEY_F11 }, + { SDLK_F12, MLK_KEY_F12 }, + { SDLK_F13, MLK_KEY_F13 }, + { SDLK_F14, MLK_KEY_F14 }, + { SDLK_F15, MLK_KEY_F15 }, + { SDLK_F16, MLK_KEY_F16 }, + { SDLK_F17, MLK_KEY_F17 }, + { SDLK_F18, MLK_KEY_F18 }, + { SDLK_F19, MLK_KEY_F19 }, + { SDLK_F20, MLK_KEY_F20 }, + { SDLK_F21, MLK_KEY_F21 }, + { SDLK_F22, MLK_KEY_F22 }, + { SDLK_F23, MLK_KEY_F23 }, + { SDLK_F24, MLK_KEY_F24 }, + { SDLK_PRINTSCREEN, MLK_KEY_PRINTSCREEN }, + { SDLK_SCROLLLOCK, MLK_KEY_SCROLL_LOCK }, + { SDLK_PAUSE, MLK_KEY_PAUSE }, + { SDLK_INSERT, MLK_KEY_INSERT }, + { SDLK_HOME, MLK_KEY_HOME }, + { SDLK_PAGEUP, MLK_KEY_PAGEUP }, + { SDLK_DELETE, MLK_KEY_DELETE }, + { SDLK_END, MLK_KEY_END }, + { SDLK_PAGEDOWN, MLK_KEY_PAGEDOWN }, + { SDLK_RIGHT, MLK_KEY_RIGHT }, + { SDLK_LEFT, MLK_KEY_LEFT }, + { SDLK_DOWN, MLK_KEY_DOWN }, + { SDLK_UP, MLK_KEY_UP }, + { SDLK_KP_DIVIDE, MLK_KEY_KP_DIVIDE }, + { SDLK_KP_MULTIPLY, MLK_KEY_KP_MULTIPLY }, + { SDLK_KP_MINUS, MLK_KEY_KP_MINUS }, + { SDLK_KP_PLUS, MLK_KEY_KP_PLUS }, + { SDLK_KP_ENTER, MLK_KEY_KP_ENTER }, + { SDLK_KP_1, MLK_KEY_KP_1 }, + { SDLK_KP_2, MLK_KEY_KP_2 }, + { SDLK_KP_3, MLK_KEY_KP_3 }, + { SDLK_KP_4, MLK_KEY_KP_4 }, + { SDLK_KP_5, MLK_KEY_KP_5 }, + { SDLK_KP_6, MLK_KEY_KP_6 }, + { SDLK_KP_7, MLK_KEY_KP_7 }, + { SDLK_KP_8, MLK_KEY_KP_8 }, + { SDLK_KP_9, MLK_KEY_KP_9 }, + { SDLK_KP_0, MLK_KEY_KP_0 }, + { SDLK_KP_PERIOD, MLK_KEY_KP_PERIOD }, + { SDLK_KP_COMMA, MLK_KEY_KP_COMMA }, + { SDLK_MENU, MLK_KEY_MENU }, + { SDLK_MUTE, MLK_KEY_MUTE }, + { SDLK_VOLUMEUP, MLK_KEY_VOLUME_UP }, + { SDLK_VOLUMEDOWN, MLK_KEY_VOLUME_DOWN }, + { SDLK_LCTRL, MLK_KEY_LCTRL }, + { SDLK_LSHIFT, MLK_KEY_LSHIFT }, + { SDLK_LALT, MLK_KEY_LALT }, + { SDLK_LGUI, MLK_KEY_LSUPER }, + { SDLK_RCTRL, MLK_KEY_RCTRL }, + { SDLK_RSHIFT, MLK_KEY_RSHIFT }, + { SDLK_RALT, MLK_KEY_RALT }, + { SDLK_RGUI, MLK_KEY_RSUPER }, + { 0, -1 } }; /* Maintain with enum mouse_button constants in mouse.h */ static const struct { int key; - enum mouse_button value; + enum mlk_mouse_button value; } buttons[] = { - { SDL_BUTTON_LEFT, MOUSE_BUTTON_LEFT }, - { SDL_BUTTON_MIDDLE, MOUSE_BUTTON_MIDDLE }, - { SDL_BUTTON_RIGHT, MOUSE_BUTTON_RIGHT }, - { -1, MOUSE_BUTTON_NONE } + { SDL_BUTTON_LEFT, MLK_MOUSE_BUTTON_LEFT }, + { SDL_BUTTON_MIDDLE, MLK_MOUSE_BUTTON_MIDDLE }, + { SDL_BUTTON_RIGHT, MLK_MOUSE_BUTTON_RIGHT }, + { -1, MLK_MOUSE_BUTTON_NONE } }; /* Maintain with enum mlk_gamepad_button in gamepad.h */ @@ -199,10 +199,10 @@ }; static void -convert_key(const SDL_Event *event, union event *ev) +convert_key(const SDL_Event *event, union mlk_event *ev) { - ev->type = event->type == SDL_KEYDOWN ? EVENT_KEYDOWN : EVENT_KEYUP; - ev->key.key = KEY_UNKNOWN; + ev->type = event->type == SDL_KEYDOWN ? MLK_EVENT_KEYDOWN : MLK_EVENT_KEYUP; + ev->key.key = MLK_KEY_UNKNOWN; for (size_t i = 0; keymap[i].key != 0; ++i) { if (keymap[i].key == event->key.keysym.sym) { @@ -213,31 +213,31 @@ } static void -convert_mouse(const SDL_Event *event, union event *ev) +convert_mouse(const SDL_Event *event, union mlk_event *ev) { - ev->type = EVENT_MOUSE; + ev->type = MLK_EVENT_MOUSE; ev->mouse.buttons = 0; ev->mouse.x = event->motion.x; ev->mouse.y = event->motion.y; if (event->motion.state & SDL_BUTTON_LMASK) - ev->mouse.buttons |= MOUSE_BUTTON_LEFT; + ev->mouse.buttons |= MLK_MOUSE_BUTTON_LEFT; if (event->motion.state & SDL_BUTTON_MMASK) - ev->mouse.buttons |= MOUSE_BUTTON_MIDDLE; + ev->mouse.buttons |= MLK_MOUSE_BUTTON_MIDDLE; if (event->motion.state & SDL_BUTTON_RMASK) - ev->mouse.buttons |= MOUSE_BUTTON_RIGHT; + ev->mouse.buttons |= MLK_MOUSE_BUTTON_RIGHT; } static void -convert_click(const SDL_Event *event, union event *ev) +convert_click(const SDL_Event *event, union mlk_event *ev) { - ev->type = event->type == SDL_MOUSEBUTTONDOWN ? EVENT_CLICKDOWN : EVENT_CLICKUP; - ev->click.button = MOUSE_BUTTON_NONE; + ev->type = event->type == SDL_MOUSEBUTTONDOWN ? MLK_EVENT_CLICKDOWN : MLK_EVENT_CLICKUP; + ev->click.button = MLK_MOUSE_BUTTON_NONE; ev->click.x = event->button.x; ev->click.y = event->button.y; ev->click.clicks = event->button.clicks; - for (size_t i = 0; buttons[i].value != MOUSE_BUTTON_NONE; ++i) { + for (size_t i = 0; buttons[i].value != MLK_MOUSE_BUTTON_NONE; ++i) { if (buttons[i].key == event->button.button) { ev->click.button = buttons[i].value; break; @@ -246,9 +246,9 @@ } static void -convert_pad(const SDL_Event *event, union event *ev) +convert_pad(const SDL_Event *event, union mlk_event *ev) { - ev->type = event->type == SDL_CONTROLLERBUTTONDOWN ? EVENT_PADDOWN : EVENT_PADUP; + ev->type = event->type == SDL_CONTROLLERBUTTONDOWN ? MLK_EVENT_PADDOWN : MLK_EVENT_PADUP; for (size_t i = 0; pads[i].value != MLK_GAMEPAD_BUTTON_UNKNOWN; ++i) { if (pads[i].button == event->cbutton.button) { @@ -272,9 +272,9 @@ }; static void -convert_axis(const SDL_Event *event, union event *ev) +convert_axis(const SDL_Event *event, union mlk_event *ev) { - ev->type = EVENT_AXIS; + ev->type = MLK_EVENT_AXIS; ev->axis.value = event->caxis.value; for (size_t i = 0; axises[i].value != MLK_GAMEPAD_AXIS_UNKNOWN; ++i) { @@ -286,7 +286,7 @@ } int -event_poll(union event *ev) +mlk_event_poll(union mlk_event *ev) { SDL_Event event; @@ -299,7 +299,7 @@ while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_QUIT: - ev->type = EVENT_QUIT; + ev->type = MLK_EVENT_QUIT; return 1; case SDL_KEYDOWN: case SDL_KEYUP:
--- a/libmlk-core/mlk/core/event.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/event.h Sat Feb 18 13:37:11 2023 +0100 @@ -24,55 +24,55 @@ #include "mouse.h" #include "gamepad.h" -enum event_type { - EVENT_CLICKDOWN, - EVENT_CLICKUP, - EVENT_KEYDOWN, - EVENT_KEYUP, - EVENT_MOUSE, - EVENT_PADUP, - EVENT_PADDOWN, - EVENT_AXIS, - EVENT_QUIT, - EVENT_NUM +enum mlk_event_type { + MLK_EVENT_CLICKDOWN, + MLK_EVENT_CLICKUP, + MLK_EVENT_KEYDOWN, + MLK_EVENT_KEYUP, + MLK_EVENT_MOUSE, + MLK_EVENT_PADUP, + MLK_EVENT_PADDOWN, + MLK_EVENT_AXIS, + MLK_EVENT_QUIT, + MLK_EVENT_NUM }; -struct event_key { - enum event_type type; - enum key key; +struct mlk_event_key { + enum mlk_event_type type; + enum mlk_key key; }; -struct event_mouse { - enum event_type type; - enum mouse_button buttons; +struct mlk_event_mouse { + enum mlk_event_type type; + enum mlk_mouse_button buttons; int x; int y; }; -struct event_click { - enum event_type type; - enum mouse_button button; +struct mlk_event_click { + enum mlk_event_type type; + enum mlk_mouse_button button; int x; int y; unsigned int clicks; }; struct mlk_event_pad { - enum event_type type; + enum mlk_event_type type; enum mlk_gamepad_button button; }; struct mlk_event_axis { - enum event_type type; + enum mlk_event_type type; enum mlk_gamepad_axis axis; int value; }; -union event { - enum event_type type; - struct event_key key; - struct event_mouse mouse; - struct event_click click; +union mlk_event { + enum mlk_event_type type; + struct mlk_event_key key; + struct mlk_event_mouse mouse; + struct mlk_event_click click; struct mlk_event_pad pad; struct mlk_event_axis axis; }; @@ -80,7 +80,7 @@ CORE_BEGIN_DECLS int -event_poll(union event *); +mlk_event_poll(union mlk_event *); CORE_END_DECLS
--- a/libmlk-core/mlk/core/game.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/game.c Sat Feb 18 13:37:11 2023 +0100 @@ -73,7 +73,7 @@ } void -game_handle(const union event *ev) +game_handle(const union mlk_event *ev) { assert(ev); @@ -111,7 +111,7 @@ while (*game.state) { mlk_clock_start(&clock); - for (union event ev; event_poll(&ev); ) + for (union mlk_event ev; mlk_event_poll(&ev); ) game_handle(&ev); game_update(elapsed);
--- a/libmlk-core/mlk/core/game.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/game.h Sat Feb 18 13:37:11 2023 +0100 @@ -26,7 +26,7 @@ struct state; -union event; +union mlk_event; struct game { enum inhibit inhibit; @@ -49,7 +49,7 @@ game_pop(void); void -game_handle(const union event *); +game_handle(const union mlk_event *); void game_update(unsigned int);
--- a/libmlk-core/mlk/core/key.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/key.h Sat Feb 18 13:37:11 2023 +0100 @@ -19,158 +19,158 @@ #ifndef MLK_CORE_KEY_H #define MLK_CORE_KEY_H -enum key { - KEY_UNKNOWN, - KEY_ENTER, - KEY_ESCAPE, - KEY_BACKSPACE, - KEY_TAB, - KEY_SPACE, - KEY_EXCLAIM, - KEY_DOUBLE_QUOTE, - KEY_HASH, - KEY_PERCENT, - KEY_DOLLAR, - KEY_AMPERSAND, - KEY_QUOTE, - KEY_LEFT_PAREN, - KEY_RIGHT_PAREN, - KEY_ASTERISK, - KEY_PLUS, - KEY_COMMA, - KEY_MINUS, - KEY_PERIOD, - KEY_SLASH, - KEY_0, - KEY_1, - KEY_2, - KEY_3, - KEY_4, - KEY_5, - KEY_6, - KEY_7, - KEY_8, - KEY_9, - KEY_COLON, - KEY_SEMICOLON, - KEY_LESS, - KEY_EQUALS, - KEY_GREATER, - KEY_QUESTION, - KEY_AT, - KEY_LEFT_BRACKET, - KEY_BACKSLASH, - KEY_RIGHT_BRACKET, - KEY_CARET, - KEY_UNDERSCORE, - KEY_BACKQUOTE, - KEY_a, - KEY_b, - KEY_c, - KEY_d, - KEY_e, - KEY_f, - KEY_g, - KEY_h, - KEY_i, - KEY_j, - KEY_k, - KEY_l, - KEY_m, - KEY_n, - KEY_o, - KEY_p, - KEY_q, - KEY_r, - KEY_s, - KEY_t, - KEY_u, - KEY_v, - KEY_w, - KEY_x, - KEY_y, - KEY_z, - KEY_CAPSLOCK, - KEY_F1, - KEY_F2, - KEY_F3, - KEY_F4, - KEY_F5, - KEY_F6, - KEY_F7, - KEY_F8, - KEY_F9, - KEY_F10, - KEY_F11, - KEY_F12, - KEY_F13, - KEY_F14, - KEY_F15, - KEY_F16, - KEY_F17, - KEY_F18, - KEY_F19, - KEY_F20, - KEY_F21, - KEY_F22, - KEY_F23, - KEY_F24, - KEY_PRINTSCREEN, - KEY_SCROLL_LOCK, - KEY_PAUSE, - KEY_INSERT, - KEY_HOME, - KEY_PAGEUP, - KEY_DELETE, - KEY_END, - KEY_PAGEDOWN, - KEY_RIGHT, - KEY_LEFT, - KEY_DOWN, - KEY_UP, - KEY_NUMLOCKCLEAR, - KEY_KP_DIVIDE, - KEY_KP_MULTIPLY, - KEY_KP_MINUS, - KEY_KP_PLUS, - KEY_KP_ENTER, - KEY_KP_00, - KEY_KP_000, - KEY_KP_1, - KEY_KP_2, - KEY_KP_3, - KEY_KP_4, - KEY_KP_5, - KEY_KP_6, - KEY_KP_7, - KEY_KP_8, - KEY_KP_9, - KEY_KP_0, - KEY_KP_PERIOD, - KEY_KP_COMMA, - KEY_MENU, - KEY_MUTE, - KEY_VOLUME_UP, - KEY_VOLUME_DOWN, - KEY_LCTRL, - KEY_LSHIFT, - KEY_LALT, - KEY_LSUPER, - KEY_RCTRL, - KEY_RSHIFT, - KEY_RALT, - KEY_RSUPER, +enum mlk_key { + MLK_KEY_UNKNOWN, + MLK_KEY_ENTER, + MLK_KEY_ESCAPE, + MLK_KEY_BACKSPACE, + MLK_KEY_TAB, + MLK_KEY_SPACE, + MLK_KEY_EXCLAIM, + MLK_KEY_DOUBLE_QUOTE, + MLK_KEY_HASH, + MLK_KEY_PERCENT, + MLK_KEY_DOLLAR, + MLK_KEY_AMPERSAND, + MLK_KEY_QUOTE, + MLK_KEY_LEFT_PAREN, + MLK_KEY_RIGHT_PAREN, + MLK_KEY_ASTERISK, + MLK_KEY_PLUS, + MLK_KEY_COMMA, + MLK_KEY_MINUS, + MLK_KEY_PERIOD, + MLK_KEY_SLASH, + MLK_KEY_0, + MLK_KEY_1, + MLK_KEY_2, + MLK_KEY_3, + MLK_KEY_4, + MLK_KEY_5, + MLK_KEY_6, + MLK_KEY_7, + MLK_KEY_8, + MLK_KEY_9, + MLK_KEY_COLON, + MLK_KEY_SEMICOLON, + MLK_KEY_LESS, + MLK_KEY_EQUALS, + MLK_KEY_GREATER, + MLK_KEY_QUESTION, + MLK_KEY_AT, + MLK_KEY_LEFT_BRACKET, + MLK_KEY_BACKSLASH, + MLK_KEY_RIGHT_BRACKET, + MLK_KEY_CARET, + MLK_KEY_UNDERSCORE, + MLK_KEY_BACKQUOTE, + MLK_KEY_a, + MLK_KEY_b, + MLK_KEY_c, + MLK_KEY_d, + MLK_KEY_e, + MLK_KEY_f, + MLK_KEY_g, + MLK_KEY_h, + MLK_KEY_i, + MLK_KEY_j, + MLK_KEY_k, + MLK_KEY_l, + MLK_KEY_m, + MLK_KEY_n, + MLK_KEY_o, + MLK_KEY_p, + MLK_KEY_q, + MLK_KEY_r, + MLK_KEY_s, + MLK_KEY_t, + MLK_KEY_u, + MLK_KEY_v, + MLK_KEY_w, + MLK_KEY_x, + MLK_KEY_y, + MLK_KEY_z, + MLK_KEY_CAPSLOCK, + MLK_KEY_F1, + MLK_KEY_F2, + MLK_KEY_F3, + MLK_KEY_F4, + MLK_KEY_F5, + MLK_KEY_F6, + MLK_KEY_F7, + MLK_KEY_F8, + MLK_KEY_F9, + MLK_KEY_F10, + MLK_KEY_F11, + MLK_KEY_F12, + MLK_KEY_F13, + MLK_KEY_F14, + MLK_KEY_F15, + MLK_KEY_F16, + MLK_KEY_F17, + MLK_KEY_F18, + MLK_KEY_F19, + MLK_KEY_F20, + MLK_KEY_F21, + MLK_KEY_F22, + MLK_KEY_F23, + MLK_KEY_F24, + MLK_KEY_PRINTSCREEN, + MLK_KEY_SCROLL_LOCK, + MLK_KEY_PAUSE, + MLK_KEY_INSERT, + MLK_KEY_HOME, + MLK_KEY_PAGEUP, + MLK_KEY_DELETE, + MLK_KEY_END, + MLK_KEY_PAGEDOWN, + MLK_KEY_RIGHT, + MLK_KEY_LEFT, + MLK_KEY_DOWN, + MLK_KEY_UP, + MLK_KEY_NUMLOCKCLEAR, + MLK_KEY_KP_DIVIDE, + MLK_KEY_KP_MULTIPLY, + MLK_KEY_KP_MINUS, + MLK_KEY_KP_PLUS, + MLK_KEY_KP_ENTER, + MLK_KEY_KP_00, + MLK_KEY_KP_000, + MLK_KEY_KP_1, + MLK_KEY_KP_2, + MLK_KEY_KP_3, + MLK_KEY_KP_4, + MLK_KEY_KP_5, + MLK_KEY_KP_6, + MLK_KEY_KP_7, + MLK_KEY_KP_8, + MLK_KEY_KP_9, + MLK_KEY_KP_0, + MLK_KEY_KP_PERIOD, + MLK_KEY_KP_COMMA, + MLK_KEY_MENU, + MLK_KEY_MUTE, + MLK_KEY_VOLUME_UP, + MLK_KEY_VOLUME_DOWN, + MLK_KEY_LCTRL, + MLK_KEY_LSHIFT, + MLK_KEY_LALT, + MLK_KEY_LSUPER, + MLK_KEY_RCTRL, + MLK_KEY_RSHIFT, + MLK_KEY_RALT, + MLK_KEY_RSUPER, }; -enum keymod { - KEYMOD_LSHIFT = 1 << 0, - KEYMOD_LCTRL = 1 << 1, - KEYMOD_LALT = 1 << 2, - KEYMOD_LSUPER = 1 << 3, - KEYMOD_RSHIFT = 1 << 4, - KEYMOD_RCTRL = 1 << 5, - KEYMOD_RALT = 1 << 6, - KEYMOD_RSUPER = 1 << 7 +enum mlk_key_mod { + MLK_KEY_MOD_LSHIFT = 1 << 0, + MLK_KEY_MOD_LCTRL = 1 << 1, + MLK_KEY_MOD_LALT = 1 << 2, + MLK_KEY_MOD_LSUPER = 1 << 3, + MLK_KEY_MOD_RSHIFT = 1 << 4, + MLK_KEY_MOD_RCTRL = 1 << 5, + MLK_KEY_MOD_RALT = 1 << 6, + MLK_KEY_MOD_RSUPER = 1 << 7 }; #endif /* !MLK_CORE_KEY_H */
--- a/libmlk-core/mlk/core/mouse.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/mouse.h Sat Feb 18 13:37:11 2023 +0100 @@ -19,11 +19,11 @@ #ifndef MLK_CORE_MOUSE_H #define MLK_CORE_MOUSE_H -enum mouse_button { - MOUSE_BUTTON_NONE = 0, - MOUSE_BUTTON_LEFT = (1 << 0), - MOUSE_BUTTON_MIDDLE = (1 << 1), - MOUSE_BUTTON_RIGHT = (1 << 2) +enum mlk_mouse_button { + MLK_MOUSE_BUTTON_NONE = 0, + MLK_MOUSE_BUTTON_LEFT = (1 << 0), + MLK_MOUSE_BUTTON_MIDDLE = (1 << 1), + MLK_MOUSE_BUTTON_RIGHT = (1 << 2) }; #endif /* !MLK_CORE_MOUSE_H */
--- a/libmlk-core/mlk/core/script.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/script.c Sat Feb 18 13:37:11 2023 +0100 @@ -34,7 +34,7 @@ } static void -handle(struct mlk_action *a, const union event *ev) +handle(struct mlk_action *a, const union mlk_event *ev) { script_handle(a->data, ev); } @@ -80,7 +80,7 @@ } void -script_handle(struct script *s, const union event *ev) +script_handle(struct script *s, const union mlk_event *ev) { assert(s); assert(ev);
--- a/libmlk-core/mlk/core/script.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/script.h Sat Feb 18 13:37:11 2023 +0100 @@ -27,7 +27,7 @@ struct mlk_action; -union event; +union mlk_event; struct script { struct mlk_action *actions[SCRIPT_ACTION_MAX]; @@ -44,7 +44,7 @@ script_append(struct script *, struct mlk_action *); void -script_handle(struct script *, const union event *); +script_handle(struct script *, const union mlk_event *); int script_update(struct script *, unsigned int);
--- a/libmlk-core/mlk/core/state.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/state.c Sat Feb 18 13:37:11 2023 +0100 @@ -30,7 +30,7 @@ } void -state_handle(struct state *state, const union event *ev) +state_handle(struct state *state, const union mlk_event *ev) { assert(state); assert(ev);
--- a/libmlk-core/mlk/core/state.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-core/mlk/core/state.h Sat Feb 18 13:37:11 2023 +0100 @@ -21,12 +21,12 @@ #include "core.h" -union event; +union mlk_event; struct state { void *data; void (*start)(struct state *); - void (*handle)(struct state *, const union event *); + void (*handle)(struct state *, const union mlk_event *); void (*update)(struct state *, unsigned int); void (*draw)(struct state *); void (*suspend)(struct state *); @@ -41,7 +41,7 @@ state_start(struct state *); void -state_handle(struct state *, const union event *); +state_handle(struct state *, const union mlk_event *); void state_update(struct state *, unsigned int);
--- a/libmlk-rpg/mlk/rpg/battle-bar-default.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-bar-default.c Sat Feb 18 13:37:11 2023 +0100 @@ -394,24 +394,24 @@ * one of the Attack, Magic, Item and Special items. */ static void -handle_keydown_menu(struct battle_bar_default *bar, struct battle *bt, const union event *ev) +handle_keydown_menu(struct battle_bar_default *bar, struct battle *bt, const union mlk_event *ev) { (void)bt; switch (ev->key.key) { - case KEY_UP: + case MLK_KEY_UP: bar->menu = BATTLE_BAR_DEFAULT_MENU_ATTACK; break; - case KEY_RIGHT: + case MLK_KEY_RIGHT: bar->menu = BATTLE_BAR_DEFAULT_MENU_MAGIC; break; - case KEY_DOWN: + case MLK_KEY_DOWN: bar->menu = BATTLE_BAR_DEFAULT_MENU_ITEM; break; - case KEY_LEFT: + case MLK_KEY_LEFT: bar->menu = BATTLE_BAR_DEFAULT_MENU_SPECIAL; break; - case KEY_ENTER: + case MLK_KEY_ENTER: /* * At this step, attack does not require opening the sub menu so * we change selection state immediately if needed. @@ -440,10 +440,10 @@ * and Magic. */ static void -handle_keydown_grid(struct battle_bar_default *bar, struct battle *bt, const union event *ev) +handle_keydown_grid(struct battle_bar_default *bar, struct battle *bt, const union mlk_event *ev) { /* Go back to main menu if I press escape. */ - if (ev->key.key == KEY_ESCAPE) + if (ev->key.key == MLK_KEY_ESCAPE) bar->state = BATTLE_BAR_DEFAULT_STATE_MENU; else if (gridmenu_handle(&bar->grid, ev)) { switch (bar->menu) { @@ -460,11 +460,11 @@ } static void -handle_keydown(struct battle_bar_default *bar, struct battle *bt, const union event *ev) +handle_keydown(struct battle_bar_default *bar, struct battle *bt, const union mlk_event *ev) { - assert(ev->type == EVENT_KEYDOWN); + assert(ev->type == MLK_EVENT_KEYDOWN); - static void (*handlers[])(struct battle_bar_default *, struct battle *, const union event *) = { + static void (*handlers[])(struct battle_bar_default *, struct battle *, const union mlk_event *) = { [BATTLE_BAR_DEFAULT_STATE_MENU] = handle_keydown_menu, [BATTLE_BAR_DEFAULT_STATE_GRID] = handle_keydown_grid }; @@ -515,7 +515,7 @@ } static void -self_handle(struct battle_bar *bar, struct battle *bt, const union event *ev) +self_handle(struct battle_bar *bar, struct battle *bt, const union mlk_event *ev) { battle_bar_default_handle(bar->data, bt, ev); } @@ -622,15 +622,15 @@ } void -battle_bar_default_handle(struct battle_bar_default *bar, struct battle *bt, const union event *ev) +battle_bar_default_handle(struct battle_bar_default *bar, struct battle *bt, const union mlk_event *ev) { assert(bar); assert(bt); assert(ev); - static void (*handlers[])(struct battle_bar_default *, struct battle *, const union event *) = { - [EVENT_KEYDOWN] = handle_keydown, - [EVENT_NUM] = NULL + static void (*handlers[])(struct battle_bar_default *, struct battle *, const union mlk_event *) = { + [MLK_EVENT_KEYDOWN] = handle_keydown, + [MLK_EVENT_NUM] = NULL }; if (handlers[ev->type])
--- a/libmlk-rpg/mlk/rpg/battle-bar-default.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-bar-default.h Sat Feb 18 13:37:11 2023 +0100 @@ -29,7 +29,7 @@ struct selection; struct theme; -union event; +union mlk_event; enum battle_bar_default_menu { BATTLE_BAR_DEFAULT_MENU_ATTACK, @@ -77,7 +77,7 @@ battle_bar_default_select(struct battle_bar_default *, struct battle *, const struct selection *); void -battle_bar_default_handle(struct battle_bar_default *, struct battle *, const union event *); +battle_bar_default_handle(struct battle_bar_default *, struct battle *, const union mlk_event *); void battle_bar_default_draw(const struct battle_bar_default *, const struct battle *);
--- a/libmlk-rpg/mlk/rpg/battle-bar.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-bar.c Sat Feb 18 13:37:11 2023 +0100 @@ -43,7 +43,7 @@ } void -battle_bar_handle(struct battle_bar *bar, struct battle *bt, const union event *ev) +battle_bar_handle(struct battle_bar *bar, struct battle *bt, const union mlk_event *ev) { assert(bar); assert(bt);
--- a/libmlk-rpg/mlk/rpg/battle-bar.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-bar.h Sat Feb 18 13:37:11 2023 +0100 @@ -24,13 +24,13 @@ struct battle; struct selection; -union event; +union mlk_event; struct battle_bar { void *data; void (*start)(struct battle_bar *, struct battle *); void (*select)(struct battle_bar *, struct battle *, const struct selection *); - void (*handle)(struct battle_bar *, struct battle *, const union event *); + void (*handle)(struct battle_bar *, struct battle *, const union mlk_event *); void (*update)(struct battle_bar *, struct battle *, unsigned int); void (*draw)(const struct battle_bar *, const struct battle *); void (*finish)(struct battle_bar *, struct battle *); @@ -45,7 +45,7 @@ battle_bar_select(struct battle_bar *, struct battle *, const struct selection *); void -battle_bar_handle(struct battle_bar *, struct battle *, const union event *); +battle_bar_handle(struct battle_bar *, struct battle *, const union mlk_event *); void battle_bar_update(struct battle_bar *, struct battle *, unsigned int);
--- a/libmlk-rpg/mlk/rpg/battle-state-lost.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-lost.c Sat Feb 18 13:37:11 2023 +0100 @@ -34,7 +34,7 @@ }; static void -handle(struct battle_state *st, struct battle *bt, const union event *ev) +handle(struct battle_state *st, struct battle *bt, const union mlk_event *ev) { (void)bt; @@ -86,7 +86,7 @@ } void -battle_state_lost_handle(struct battle_state_lost *lost, const union event *ev) +battle_state_lost_handle(struct battle_state_lost *lost, const union mlk_event *ev) { assert(lost); assert(ev);
--- a/libmlk-rpg/mlk/rpg/battle-state-lost.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-lost.h Sat Feb 18 13:37:11 2023 +0100 @@ -21,7 +21,7 @@ #include <mlk/rpg/message.h> -union event; +union mlk_event; struct battle; @@ -34,7 +34,7 @@ battle_state_lost_init(struct battle_state_lost *, struct battle *); void -battle_state_lost_handle(struct battle_state_lost *, const union event *); +battle_state_lost_handle(struct battle_state_lost *, const union mlk_event *); int battle_state_lost_update(struct battle_state_lost *, struct battle *, unsigned int);
--- a/libmlk-rpg/mlk/rpg/battle-state-menu.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-menu.c Sat Feb 18 13:37:11 2023 +0100 @@ -27,7 +27,7 @@ #include "battle.h" static void -handle(struct battle_state *st, struct battle *bt, const union event *ev) +handle(struct battle_state *st, struct battle *bt, const union mlk_event *ev) { (void)st; @@ -61,7 +61,7 @@ } void -battle_state_menu_handle(struct battle *bt, const union event *ev) +battle_state_menu_handle(struct battle *bt, const union mlk_event *ev) { assert(bt); assert(ev);
--- a/libmlk-rpg/mlk/rpg/battle-state-menu.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-menu.h Sat Feb 18 13:37:11 2023 +0100 @@ -21,10 +21,10 @@ struct battle; -union event; +union mlk_event; void -battle_state_menu_handle(struct battle *, const union event *); +battle_state_menu_handle(struct battle *, const union mlk_event *); void battle_state_menu_update(struct battle *, unsigned int);
--- a/libmlk-rpg/mlk/rpg/battle-state-selection.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-selection.c Sat Feb 18 13:37:11 2023 +0100 @@ -78,32 +78,32 @@ } static void -handle_keydown(struct battle_state_selection *stl, struct battle *bt, const union event *ev) +handle_keydown(struct battle_state_selection *stl, struct battle *bt, const union mlk_event *ev) { - assert(ev->type == EVENT_KEYDOWN); + assert(ev->type == MLK_EVENT_KEYDOWN); switch (ev->key.key) { - case KEY_ESCAPE: + case MLK_KEY_ESCAPE: battle_state_menu(bt); break; - case KEY_ENTER: + case MLK_KEY_ENTER: battle_bar_select(bt->bar, bt, &stl->select); break; - case KEY_LEFT: + case MLK_KEY_LEFT: if (stl->select.allowed_sides & SELECTION_SIDE_ENEMY) stl->select.index_side = 0; break; - case KEY_RIGHT: + case MLK_KEY_RIGHT: if (stl->select.allowed_sides & SELECTION_SIDE_TEAM) stl->select.index_side = 1; break; - case KEY_UP: + case MLK_KEY_UP: select_adj(stl, bt, -1); break; - case KEY_DOWN: + case MLK_KEY_DOWN: select_adj(stl, bt, +1); break; - case KEY_TAB: + case MLK_KEY_TAB: if (stl->select.allowed_kinds == SELECTION_KIND_BOTH) stl->select.index_character = -1; break; @@ -145,7 +145,7 @@ } static void -handle(struct battle_state *st, struct battle *bt, const union event *ev) +handle(struct battle_state *st, struct battle *bt, const union mlk_event *ev) { battle_state_selection_handle(st->data, bt, ev); } @@ -174,14 +174,14 @@ } void -battle_state_selection_handle(struct battle_state_selection *stl, struct battle *bt, const union event *ev) +battle_state_selection_handle(struct battle_state_selection *stl, struct battle *bt, const union mlk_event *ev) { assert(stl); assert(bt); assert(ev); switch (ev->type) { - case EVENT_KEYDOWN: + case MLK_EVENT_KEYDOWN: handle_keydown(stl, bt, ev); break; default:
--- a/libmlk-rpg/mlk/rpg/battle-state-selection.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-selection.h Sat Feb 18 13:37:11 2023 +0100 @@ -23,7 +23,7 @@ struct battle; -union event; +union mlk_event; struct battle_state_selection { struct selection select; @@ -33,7 +33,7 @@ battle_state_selection_init(struct battle_state_selection *, const struct selection *); void -battle_state_selection_handle(struct battle_state_selection *, struct battle *, const union event *); +battle_state_selection_handle(struct battle_state_selection *, struct battle *, const union mlk_event *); void battle_state_selection_draw(const struct battle_state_selection *, const struct battle *);
--- a/libmlk-rpg/mlk/rpg/battle-state-victory.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-victory.c Sat Feb 18 13:37:11 2023 +0100 @@ -34,7 +34,7 @@ }; static void -handle(struct battle_state *st, struct battle *bt, const union event *ev) +handle(struct battle_state *st, struct battle *bt, const union mlk_event *ev) { (void)bt; @@ -87,7 +87,7 @@ } void -battle_state_victory_handle(struct battle_state_victory *vic, const union event *ev) +battle_state_victory_handle(struct battle_state_victory *vic, const union mlk_event *ev) { assert(vic);
--- a/libmlk-rpg/mlk/rpg/battle-state-victory.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state-victory.h Sat Feb 18 13:37:11 2023 +0100 @@ -23,7 +23,7 @@ struct battle; -union event; +union mlk_event; struct battle_state_victory { const char *text; @@ -34,7 +34,7 @@ battle_state_victory_init(struct battle_state_victory *, struct battle *); void -battle_state_victory_handle(struct battle_state_victory *, const union event *); +battle_state_victory_handle(struct battle_state_victory *, const union mlk_event *); int battle_state_victory_update(struct battle_state_victory *, struct battle *, unsigned int);
--- a/libmlk-rpg/mlk/rpg/battle-state.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state.c Sat Feb 18 13:37:11 2023 +0100 @@ -21,7 +21,7 @@ #include "battle-state.h" void -battle_state_handle(struct battle_state *st, struct battle *bt, const union event *ev) +battle_state_handle(struct battle_state *st, struct battle *bt, const union mlk_event *ev) { assert(st); assert(bt);
--- a/libmlk-rpg/mlk/rpg/battle-state.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle-state.h Sat Feb 18 13:37:11 2023 +0100 @@ -26,11 +26,11 @@ struct inventory_slot; struct selection; -union event; +union mlk_event; struct battle_state { void *data; - void (*handle)(struct battle_state *, struct battle *, const union event *); + void (*handle)(struct battle_state *, struct battle *, const union mlk_event *); int (*update)(struct battle_state *, struct battle *, unsigned int); void (*draw)(const struct battle_state *, const struct battle *); void (*finish)(struct battle_state *, struct battle *); @@ -39,7 +39,7 @@ CORE_BEGIN_DECLS void -battle_state_handle(struct battle_state *, struct battle *, const union event *); +battle_state_handle(struct battle_state *, struct battle *, const union mlk_event *); int battle_state_update(struct battle_state *, struct battle *, unsigned int);
--- a/libmlk-rpg/mlk/rpg/battle.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle.c Sat Feb 18 13:37:11 2023 +0100 @@ -413,7 +413,7 @@ } void -battle_handle_component(struct battle *bt, const union event *ev, enum battle_component comp) +battle_handle_component(struct battle *bt, const union mlk_event *ev, enum battle_component comp) { assert(bt); assert(ev); @@ -425,7 +425,7 @@ } void -battle_handle(struct battle *bt, const union event *ev) +battle_handle(struct battle *bt, const union mlk_event *ev) { assert(bt); assert(ev);
--- a/libmlk-rpg/mlk/rpg/battle.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/battle.h Sat Feb 18 13:37:11 2023 +0100 @@ -33,7 +33,7 @@ #include "selection.h" #include "spell.h" -union event; +union mlk_event; struct battle_bar; struct character; @@ -128,10 +128,10 @@ battle_indicator_hp(struct battle *, const struct character *, long); void -battle_handle_component(struct battle *, const union event *, enum battle_component); +battle_handle_component(struct battle *, const union mlk_event *, enum battle_component); void -battle_handle(struct battle *, const union event *); +battle_handle(struct battle *, const union mlk_event *); void battle_update_component(struct battle *, unsigned int, enum battle_component);
--- a/libmlk-rpg/mlk/rpg/map.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/map.c Sat Feb 18 13:37:11 2023 +0100 @@ -179,19 +179,19 @@ } static void -handle_keydown(struct map *map, const union event *event) +handle_keydown(struct map *map, const union mlk_event *event) { switch (event->key.key) { - case KEY_UP: + case MLK_KEY_UP: map->player_movement |= MOVING_UP; break; - case KEY_RIGHT: + case MLK_KEY_RIGHT: map->player_movement |= MOVING_RIGHT; break; - case KEY_DOWN: + case MLK_KEY_DOWN: map->player_movement |= MOVING_DOWN; break; - case KEY_LEFT: + case MLK_KEY_LEFT: map->player_movement |= MOVING_LEFT; break; default: @@ -202,22 +202,22 @@ } static void -handle_keyup(struct map *map, const union event *event) +handle_keyup(struct map *map, const union mlk_event *event) { switch (event->key.key) { - case KEY_TAB: + case MLK_KEY_TAB: map->flags ^= MAP_FLAGS_SHOW_GRID | MAP_FLAGS_SHOW_COLLIDE; break; - case KEY_UP: + case MLK_KEY_UP: map->player_movement &= ~(MOVING_UP); break; - case KEY_RIGHT: + case MLK_KEY_RIGHT: map->player_movement &= ~(MOVING_RIGHT); break; - case KEY_DOWN: + case MLK_KEY_DOWN: map->player_movement &= ~(MOVING_DOWN); break; - case KEY_LEFT: + case MLK_KEY_LEFT: map->player_movement &= ~(MOVING_LEFT); break; default: @@ -603,16 +603,16 @@ } void -map_handle(struct map *map, const union event *ev) +map_handle(struct map *map, const union mlk_event *ev) { assert(map); assert(ev); switch (ev->type) { - case EVENT_KEYDOWN: + case MLK_EVENT_KEYDOWN: handle_keydown(map, ev); break; - case EVENT_KEYUP: + case MLK_EVENT_KEYUP: handle_keyup(map, ev); break; default:
--- a/libmlk-rpg/mlk/rpg/map.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/map.h Sat Feb 18 13:37:11 2023 +0100 @@ -29,7 +29,7 @@ struct tileset; -union event; +union mlk_event; enum map_layer_type { MAP_LAYER_TYPE_BACKGROUND, @@ -104,7 +104,7 @@ map_init(struct map *map); void -map_handle(struct map *map, const union event *ev); +map_handle(struct map *map, const union mlk_event *ev); void map_update(struct map *map, unsigned int ticks);
--- a/libmlk-rpg/mlk/rpg/message.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/message.c Sat Feb 18 13:37:11 2023 +0100 @@ -40,7 +40,7 @@ #define THEME(msg) (msg->theme ? msg->theme : theme_default()) static void -handle(struct mlk_action *action, const union event *ev) +handle(struct mlk_action *action, const union mlk_event *ev) { assert(action); assert(ev); @@ -176,7 +176,7 @@ } void -message_handle(struct message *msg, const union event *ev) +message_handle(struct message *msg, const union mlk_event *ev) { assert(msg); assert(ev); @@ -186,19 +186,19 @@ return; /* Only keyboard event are valid. */ - if (ev->type != EVENT_KEYDOWN || msg->state == MESSAGE_STATE_NONE) + if (ev->type != MLK_EVENT_KEYDOWN || msg->state == MESSAGE_STATE_NONE) return; switch (ev->key.key) { - case KEY_UP: + case MLK_KEY_UP: if (msg->index > 0) msg->index--; break; - case KEY_DOWN: + case MLK_KEY_DOWN: if (msg->index + 1 < msg->linesz && msg->lines[msg->index + 1]) msg->index++; break; - case KEY_ENTER: + case MLK_KEY_ENTER: msg->state = msg->flags & MESSAGE_FLAGS_FADEOUT ? MESSAGE_STATE_HIDING : MESSAGE_STATE_NONE;
--- a/libmlk-rpg/mlk/rpg/message.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-rpg/mlk/rpg/message.h Sat Feb 18 13:37:11 2023 +0100 @@ -26,7 +26,7 @@ struct font; struct theme; -union event; +union mlk_event; #define MESSAGE_DELAY_DEFAULT (150) #define MESSAGE_TIMEOUT_DEFAULT (5000) @@ -72,7 +72,7 @@ message_query(const struct message *msg, unsigned int *w, unsigned int *h); void -message_handle(struct message *msg, const union event *ev); +message_handle(struct message *msg, const union mlk_event *ev); int message_update(struct message *msg, unsigned int ticks);
--- a/libmlk-ui/mlk/ui/button.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-ui/mlk/ui/button.c Sat Feb 18 13:37:11 2023 +0100 @@ -30,11 +30,11 @@ #include "theme.h" static int -is_boxed(const struct button *button, const struct event_click *click) +is_boxed(const struct button *button, const struct mlk_event_click *click) { assert(button); assert(click); - assert(click->type == EVENT_CLICKDOWN || click->type == EVENT_CLICKUP); + assert(click->type == MLK_EVENT_CLICKDOWN || click->type == MLK_EVENT_CLICKUP); return maths_is_boxed(button->x, button->y, button->w, button->h, click->x, click->y); @@ -70,17 +70,17 @@ } int -button_handle(struct button *button, const union event *ev) +button_handle(struct button *button, const union mlk_event *ev) { assert(button); assert(ev); switch (ev->type) { - case EVENT_CLICKDOWN: + case MLK_EVENT_CLICKDOWN: if (is_boxed(button, &ev->click)) button->state = BUTTON_STATE_PRESSED; break; - case EVENT_CLICKUP: + case MLK_EVENT_CLICKUP: /* * If the button was pressed, indicate that the button is * finally activated. This let the user to move the cursor
--- a/libmlk-ui/mlk/ui/button.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-ui/mlk/ui/button.h Sat Feb 18 13:37:11 2023 +0100 @@ -21,7 +21,7 @@ #include <mlk/core/core.h> -union event; +union mlk_event; struct theme; @@ -44,7 +44,7 @@ CORE_BEGIN_DECLS int -button_handle(struct button *, const union event *); +button_handle(struct button *, const union mlk_event *); void button_reset(struct button *);
--- a/libmlk-ui/mlk/ui/checkbox.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-ui/mlk/ui/checkbox.c Sat Feb 18 13:37:11 2023 +0100 @@ -28,10 +28,10 @@ #include "theme.h" static int -is_boxed(const struct checkbox *cb, const struct event_click *click) +is_boxed(const struct checkbox *cb, const struct mlk_event_click *click) { assert(cb); - assert(click && click->type == EVENT_CLICKDOWN); + assert(click && click->type == MLK_EVENT_CLICKDOWN); return maths_is_boxed(cb->x, cb->y, cb->w, cb->h, click->x, click->y); } @@ -55,13 +55,13 @@ } int -checkbox_handle(struct checkbox *cb, const union event *ev) +checkbox_handle(struct checkbox *cb, const union mlk_event *ev) { assert(cb); assert(ev); switch (ev->type) { - case EVENT_CLICKDOWN: + case MLK_EVENT_CLICKDOWN: if (is_boxed(cb, &ev->click)) return cb->checked = !cb->checked; break;
--- a/libmlk-ui/mlk/ui/checkbox.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-ui/mlk/ui/checkbox.h Sat Feb 18 13:37:11 2023 +0100 @@ -21,7 +21,7 @@ #include <mlk/core/core.h> -union event; +union mlk_event; struct theme; @@ -40,7 +40,7 @@ checkbox_draw_default(const struct theme *, const struct checkbox *); int -checkbox_handle(struct checkbox *, const union event *); +checkbox_handle(struct checkbox *, const union mlk_event *); void checkbox_draw(const struct checkbox *);
--- a/libmlk-ui/mlk/ui/gridmenu.c Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-ui/mlk/ui/gridmenu.c Sat Feb 18 13:37:11 2023 +0100 @@ -154,33 +154,33 @@ } static int -handle_keydown(struct gridmenu *menu, const struct event_key *key) +handle_keydown(struct gridmenu *menu, const struct mlk_event_key *key) { - assert(key->type == EVENT_KEYDOWN); + assert(key->type == MLK_EVENT_KEYDOWN); const struct index idx = get_index(menu); int validate = 0; switch (key->key) { - case KEY_UP: + case MLK_KEY_UP: if (idx.row > 0) menu->selected -= menu->ncols; break; - case KEY_RIGHT: + case MLK_KEY_RIGHT: if (menu->selected + 1U < menu->itemsz) menu->selected += 1; break; - case KEY_DOWN: + case MLK_KEY_DOWN: if (idx.row + 1U < menu->itemsz / menu->ncols) menu->selected += menu->ncols; else menu->selected = menu->itemsz - 1; break; - case KEY_LEFT: + case MLK_KEY_LEFT: if (idx.col > 0) menu->selected -= 1; break; - case KEY_ENTER: + case MLK_KEY_ENTER: validate = 1; break; default: @@ -191,9 +191,9 @@ } static int -handle_clickdown(struct gridmenu *menu, const struct event_click *click) +handle_clickdown(struct gridmenu *menu, const struct mlk_event_click *click) { - assert(click->type == EVENT_CLICKDOWN); + assert(click->type == MLK_EVENT_CLICKDOWN); const struct theme *theme = THEME(menu); size_t pagesz, pagenr, selected, c = 0, r = 0; @@ -258,16 +258,16 @@ } int -gridmenu_handle(struct gridmenu *menu, const union event *ev) +gridmenu_handle(struct gridmenu *menu, const union mlk_event *ev) { assert(menu); assert(ev); switch (ev->type) { - case EVENT_KEYDOWN: + case MLK_EVENT_KEYDOWN: return handle_keydown(menu, &ev->key); break; - case EVENT_CLICKDOWN: + case MLK_EVENT_CLICKDOWN: return handle_clickdown(menu, &ev->click); break; default:
--- a/libmlk-ui/mlk/ui/gridmenu.h Sat Feb 18 13:16:40 2023 +0100 +++ b/libmlk-ui/mlk/ui/gridmenu.h Sat Feb 18 13:37:11 2023 +0100 @@ -27,7 +27,7 @@ struct theme; -union event; +union mlk_event; struct gridmenu { int x; @@ -57,7 +57,7 @@ gridmenu_resize(struct gridmenu *, int, int, unsigned int, unsigned int); int -gridmenu_handle(struct gridmenu *, const union event *); +gridmenu_handle(struct gridmenu *, const union mlk_event *); void gridmenu_draw(const struct gridmenu *);