Extract keyboard processor trait

This will allow to provide alternative key processors.
This commit is contained in:
Romain Vimont
2021-10-03 17:11:20 +02:00
parent 2f6d7b371d
commit 353e440ace
9 changed files with 335 additions and 227 deletions

View File

@@ -0,0 +1,29 @@
#ifndef SC_KEY_PROCESSOR_H
#define SC_KEY_PROCESSOR_H
#include "common.h"
#include <assert.h>
#include <stdbool.h>
#include <SDL2/SDL_events.h>
/**
* Key processor trait.
*
* Component able to process and inject keys should implement this trait.
*/
struct sc_key_processor {
const struct sc_key_processor_ops *ops;
};
struct sc_key_processor_ops {
void
(*process_key)(struct sc_key_processor *kp, const SDL_KeyboardEvent *event);
void
(*process_text)(struct sc_key_processor *kp,
const SDL_TextInputEvent *event);
};
#endif