Use sc_ prefix for input_manager

This commit is contained in:
Romain Vimont 2022-01-14 22:17:30 +01:00
parent 2a0c2e5e99
commit 5f7ddff8ae
4 changed files with 32 additions and 32 deletions

View file

@ -106,7 +106,7 @@ to_sdl_mod(unsigned shortcut_mod) {
} }
static bool static bool
is_shortcut_mod(struct input_manager *im, uint16_t sdl_mod) { is_shortcut_mod(struct sc_input_manager *im, uint16_t sdl_mod) {
// keep only the relevant modifier keys // keep only the relevant modifier keys
sdl_mod &= SC_SDL_SHORTCUT_MODS_MASK; sdl_mod &= SC_SDL_SHORTCUT_MODS_MASK;
@ -122,8 +122,8 @@ is_shortcut_mod(struct input_manager *im, uint16_t sdl_mod) {
} }
void void
input_manager_init(struct input_manager *im, sc_input_manager_init(struct sc_input_manager *im,
const struct input_manager_params *params) { const struct sc_input_manager_params *params) {
assert(!params->control || (params->kp && params->kp->ops)); assert(!params->control || (params->kp && params->kp->ops));
assert(!params->control || (params->mp && params->mp->ops)); assert(!params->control || (params->mp && params->mp->ops));
@ -381,8 +381,8 @@ rotate_client_right(struct sc_screen *screen) {
} }
static void static void
input_manager_process_text_input(struct input_manager *im, sc_input_manager_process_text_input(struct sc_input_manager *im,
const SDL_TextInputEvent *event) { const SDL_TextInputEvent *event) {
if (!im->kp->ops->process_text) { if (!im->kp->ops->process_text) {
// The key processor does not support text input // The key processor does not support text input
return; return;
@ -401,7 +401,7 @@ input_manager_process_text_input(struct input_manager *im,
} }
static bool static bool
simulate_virtual_finger(struct input_manager *im, simulate_virtual_finger(struct sc_input_manager *im,
enum android_motionevent_action action, enum android_motionevent_action action,
struct sc_point point) { struct sc_point point) {
bool up = action == AMOTION_EVENT_ACTION_UP; bool up = action == AMOTION_EVENT_ACTION_UP;
@ -431,8 +431,8 @@ inverse_point(struct sc_point point, struct sc_size size) {
} }
static void static void
input_manager_process_key(struct input_manager *im, sc_input_manager_process_key(struct sc_input_manager *im,
const SDL_KeyboardEvent *event) { const SDL_KeyboardEvent *event) {
// control: indicates the state of the command-line option --no-control // control: indicates the state of the command-line option --no-control
bool control = im->control; bool control = im->control;
@ -629,8 +629,8 @@ input_manager_process_key(struct input_manager *im,
} }
static void static void
input_manager_process_mouse_motion(struct input_manager *im, sc_input_manager_process_mouse_motion(struct sc_input_manager *im,
const SDL_MouseMotionEvent *event) { const SDL_MouseMotionEvent *event) {
if (event->which == SDL_TOUCH_MOUSEID) { if (event->which == SDL_TOUCH_MOUSEID) {
// simulated from touch events, so it's a duplicate // simulated from touch events, so it's a duplicate
@ -668,8 +668,8 @@ input_manager_process_mouse_motion(struct input_manager *im,
} }
static void static void
input_manager_process_touch(struct input_manager *im, sc_input_manager_process_touch(struct sc_input_manager *im,
const SDL_TouchFingerEvent *event) { const SDL_TouchFingerEvent *event) {
if (!im->mp->ops->process_touch) { if (!im->mp->ops->process_touch) {
// The mouse processor does not support touch events // The mouse processor does not support touch events
return; return;
@ -698,8 +698,8 @@ input_manager_process_touch(struct input_manager *im,
} }
static void static void
input_manager_process_mouse_button(struct input_manager *im, sc_input_manager_process_mouse_button(struct sc_input_manager *im,
const SDL_MouseButtonEvent *event) { const SDL_MouseButtonEvent *event) {
bool control = im->control; bool control = im->control;
if (event->which == SDL_TOUCH_MOUSEID) { if (event->which == SDL_TOUCH_MOUSEID) {
@ -807,8 +807,8 @@ input_manager_process_mouse_button(struct input_manager *im,
} }
static void static void
input_manager_process_mouse_wheel(struct input_manager *im, sc_input_manager_process_mouse_wheel(struct sc_input_manager *im,
const SDL_MouseWheelEvent *event) { const SDL_MouseWheelEvent *event) {
if (!im->mp->ops->process_mouse_scroll) { if (!im->mp->ops->process_mouse_scroll) {
// The mouse processor does not support scroll events // The mouse processor does not support scroll events
return; return;
@ -835,42 +835,42 @@ input_manager_process_mouse_wheel(struct input_manager *im,
} }
bool bool
input_manager_handle_event(struct input_manager *im, SDL_Event *event) { sc_input_manager_handle_event(struct sc_input_manager *im, SDL_Event *event) {
switch (event->type) { switch (event->type) {
case SDL_TEXTINPUT: case SDL_TEXTINPUT:
if (!im->control) { if (!im->control) {
return true; return true;
} }
input_manager_process_text_input(im, &event->text); sc_input_manager_process_text_input(im, &event->text);
return true; return true;
case SDL_KEYDOWN: case SDL_KEYDOWN:
case SDL_KEYUP: case SDL_KEYUP:
// some key events do not interact with the device, so process the // some key events do not interact with the device, so process the
// event even if control is disabled // event even if control is disabled
input_manager_process_key(im, &event->key); sc_input_manager_process_key(im, &event->key);
return true; return true;
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
if (!im->control) { if (!im->control) {
break; break;
} }
input_manager_process_mouse_motion(im, &event->motion); sc_input_manager_process_mouse_motion(im, &event->motion);
return true; return true;
case SDL_MOUSEWHEEL: case SDL_MOUSEWHEEL:
if (!im->control) { if (!im->control) {
break; break;
} }
input_manager_process_mouse_wheel(im, &event->wheel); sc_input_manager_process_mouse_wheel(im, &event->wheel);
return true; return true;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
// some mouse events do not interact with the device, so process // some mouse events do not interact with the device, so process
// the event even if control is disabled // the event even if control is disabled
input_manager_process_mouse_button(im, &event->button); sc_input_manager_process_mouse_button(im, &event->button);
return true; return true;
case SDL_FINGERMOTION: case SDL_FINGERMOTION:
case SDL_FINGERDOWN: case SDL_FINGERDOWN:
case SDL_FINGERUP: case SDL_FINGERUP:
input_manager_process_touch(im, &event->tfinger); sc_input_manager_process_touch(im, &event->tfinger);
return true; return true;
} }

View file

@ -13,7 +13,7 @@
#include "trait/key_processor.h" #include "trait/key_processor.h"
#include "trait/mouse_processor.h" #include "trait/mouse_processor.h"
struct input_manager { struct sc_input_manager {
struct controller *controller; struct controller *controller;
struct sc_screen *screen; struct sc_screen *screen;
@ -42,7 +42,7 @@ struct input_manager {
uint64_t next_sequence; // used for request acknowledgements uint64_t next_sequence; // used for request acknowledgements
}; };
struct input_manager_params { struct sc_input_manager_params {
struct controller *controller; struct controller *controller;
struct sc_screen *screen; struct sc_screen *screen;
struct sc_key_processor *kp; struct sc_key_processor *kp;
@ -56,10 +56,10 @@ struct input_manager_params {
}; };
void void
input_manager_init(struct input_manager *im, sc_input_manager_init(struct sc_input_manager *im,
const struct input_manager_params *params); const struct sc_input_manager_params *params);
bool bool
input_manager_handle_event(struct input_manager *im, SDL_Event *event); sc_input_manager_handle_event(struct sc_input_manager *im, SDL_Event *event);
#endif #endif

View file

@ -484,7 +484,7 @@ sc_screen_init(struct sc_screen *screen,
goto error_destroy_texture; goto error_destroy_texture;
} }
struct input_manager_params im_params = { struct sc_input_manager_params im_params = {
.controller = params->controller, .controller = params->controller,
.screen = screen, .screen = screen,
.kp = params->kp, .kp = params->kp,
@ -496,7 +496,7 @@ sc_screen_init(struct sc_screen *screen,
.shortcut_mods = params->shortcut_mods, .shortcut_mods = params->shortcut_mods,
}; };
input_manager_init(&screen->im, &im_params); sc_input_manager_init(&screen->im, &im_params);
// Reset the window size to trigger a SIZE_CHANGED event, to workaround // Reset the window size to trigger a SIZE_CHANGED event, to workaround
// HiDPI issues with some SDL renderers when several displays having // HiDPI issues with some SDL renderers when several displays having
@ -866,7 +866,7 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) {
} }
} }
return input_manager_handle_event(&screen->im, event); return sc_input_manager_handle_event(&screen->im, event);
} }
struct sc_point struct sc_point

View file

@ -24,7 +24,7 @@ struct sc_screen {
bool open; // track the open/close state to assert correct behavior bool open; // track the open/close state to assert correct behavior
#endif #endif
struct input_manager im; struct sc_input_manager im;
struct sc_video_buffer vb; struct sc_video_buffer vb;
struct fps_counter fps_counter; struct fps_counter fps_counter;