14#ifndef INPUT_GP_EVENT_H
15#define INPUT_GP_EVENT_H
20#include <input/gp_types.h>
107 uint32_t pressure, pressure_max;
128#define GP_EVENT_KEY_BITMAP_BYTES 56
191 return ev->
utf.
ch < 0x20 && ev->
utf.
ch != 0x7f;
202 if (key >= GP_EVENT_KEY_BITMAP_BYTES * 8)
218 if (key >= GP_EVENT_KEY_BITMAP_BYTES * 8)
221 return !!(self->
keys_pressed[(key)/8] & (1<<((key)%8)));
232 if (key >= GP_EVENT_KEY_BITMAP_BYTES * 8)
272#define gp_ev_any_key_pressed(ev, ...) gp_ev_any_key_pressed_(ev, __VA_ARGS__, 0)
273int gp_ev_any_key_pressed_(
gp_event *ev, ...);
282#define gp_ev_all_keys_pressed(ev, ...) gp_ev_all_keys_pressed_(ev, __VA_ARGS__, 0)
283int gp_ev_all_keys_pressed_(
gp_event *ev, ...);
static void gp_events_state_press(gp_events_state *self, uint32_t key)
Helper to set key bit in the event state.
gp_ev_key_code
A key event type.
@ GP_EV_KEY_UP
Key released.
@ GP_EV_KEY_REPEAT
Key repeated.
@ GP_EV_KEY_DOWN
Key pressed.
static void gp_events_state_release(gp_events_state *self, uint32_t key)
Helper to reset key bit in the event state.
gp_ev_sys_code
System events.
@ GP_EV_SYS_CLIPBOARD
Clipboard request is ready.
@ GP_EV_SYS_RESIZE
User resized the applicaton window.
@ GP_EV_SYS_QUIT
User requested application to quit.
void gp_ev_dump(gp_event *ev)
Dumps event into a stdout.
gp_ev_rel_code
A relative event type.
@ GP_EV_REL_WHEEL
A mouse wheel.
@ GP_EV_REL_POS
A relative position.
static int gp_ev_utf_is_ctrl(gp_event *ev)
Checks if a character is not printable.
static int gp_ev_key_pressed(gp_event *ev, uint32_t key)
Checks if key is being pressed.
@ GP_EV_SYS
A system events, window close, resize, etc.
@ GP_EV_UTF
An unicode character typed on a keyboard.
@ GP_EV_ABS
An absolute event, e.g. touchscreen touch.
@ GP_EV_REL
A relative event, e.g. mouse cursor movement.
@ GP_EV_MAX
Last used event type.
@ GP_EV_KEY
A key or button press event.
@ GP_EV_TMR
A timer expired.
static void gp_events_state_release_all(gp_events_state *self)
Helper to reset all key bits in the event state.
static int gp_events_state_pressed(gp_events_state *self, uint32_t key)
Helper to get key bit from the event state.
gp_ev_abs_code
An absolute event type.
@ GP_EV_ABS_POS
An absolute position.
An absolute cursor position.
A relative cursor position change.
uint32_t w
New width for a window resize event.
uint32_t h
New height for a window resize event.
uint32_t ch
An unicode character.
struct gp_ev_pos_abs abs
An absolute position.
gp_timer * tmr
A timer expired event.
int32_t val
A generic integer value.
uint16_t code
enum gp_event_*_code
struct gp_ev_key key
A keyboard or mouse key.
struct gp_ev_utf utf
An unicode input event.
struct gp_events_state * st
Pointer to overall state, pressed keys, cursor position etc.
struct gp_ev_sys sys
A system event.
uint16_t type
enum gp_event_type
struct gp_ev_pos_rel rel
A relative change in position.
uint64_t time
An event timestamp.
uint32_t saved_cursor_x
Saved cursor x coordinate.
uint8_t keys_pressed[56]
Bitmap of pressed keys including mouse buttons.
uint32_t saved_cursor_y
Saved cursor y coordinate.
uint32_t cursor_y
Current cursor y coordinate.
uint32_t cursor_x
Current cursor x coordinate.