mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-13 13:28:49 +00:00
Add RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. An interface for allowing keyboard event data to be sent to the core.
This commit is contained in:
parent
efa78bded7
commit
e60bb1d168
@ -482,6 +482,15 @@ static bool environment_cb(unsigned cmd, void *data)
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK:
|
||||
{
|
||||
const struct retro_keyboard_callback *info = (const struct retro_keyboard_callback*)data;
|
||||
|
||||
g_extern.system.key_event = info->callback;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd);
|
||||
|
@ -320,6 +320,8 @@ struct global
|
||||
bool force_nonblock;
|
||||
|
||||
const char *input_desc_btn[MAX_PLAYERS][RARCH_FIRST_CUSTOM_BIND];
|
||||
|
||||
retro_keyboard_event_t key_event;
|
||||
} system;
|
||||
|
||||
struct
|
||||
|
@ -254,6 +254,24 @@ static void gfx_ctx_check_window(bool *quit,
|
||||
*width = event.resize.w;
|
||||
*height = event.resize.h;
|
||||
break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP:
|
||||
if(g_extern.system.key_event)
|
||||
{
|
||||
static bool unicodeOn = false;
|
||||
|
||||
if(!unicodeOn)
|
||||
{
|
||||
unicodeOn = true;
|
||||
SDL_EnableUNICODE(true);
|
||||
}
|
||||
|
||||
// For now it seems that all RETROK_* constant values match the SDLK_* values.
|
||||
// Ultimately the table in sdl_input.c should be used in case this changes.
|
||||
g_extern.system.key_event(event.type == SDL_KEYDOWN, event.key.keysym.sym, event.key.keysym.unicode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
14
libretro.h
14
libretro.h
@ -388,8 +388,22 @@ enum retro_key
|
||||
// It is up to the frontend to present this in a usable way.
|
||||
// The array is terminated by retro_input_descriptor::description being set to NULL.
|
||||
// This function can be called at any time, but it is recommended to call it as early as possible.
|
||||
#define RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK 12
|
||||
// const struct retro_keyboard_callback * --
|
||||
// Sets a callback function used to notify core about keyboard events.
|
||||
|
||||
|
||||
// Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. Called by the frontend in response to keyboard events.
|
||||
// down is set if the key is being pressed, or false if it is being released.
|
||||
// keycode is the RETROK value of the char.
|
||||
// character is the text character of the pressed key. (UTF?)
|
||||
typedef void (*retro_keyboard_event_t)(bool down, unsigned keycode, unsigned character);
|
||||
|
||||
struct retro_keyboard_callback
|
||||
{
|
||||
retro_keyboard_event_t callback;
|
||||
};
|
||||
|
||||
enum retro_pixel_format
|
||||
{
|
||||
// 0RGB1555, native endian. 0 bit must be set to 0.
|
||||
|
Loading…
Reference in New Issue
Block a user