mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-27 09:13:03 +02:00
Implement bindings for keyboard and controller button input in libretro builds
This commit is contained in:
parent
c9e7c4d02d
commit
df1dbccf5a
3 changed files with 910 additions and 102 deletions
12
src/core.cpp
12
src/core.cpp
|
@ -30,6 +30,7 @@
|
|||
#include "mkxp-polyfill.h" // std::mutex
|
||||
#include "git-hash.h"
|
||||
|
||||
#include "core.h"
|
||||
#include "binding-sandbox.h"
|
||||
|
||||
#include "al-util.h"
|
||||
|
@ -158,6 +159,7 @@ namespace mkxp_retro {
|
|||
retro_input_state_t input_state;
|
||||
struct retro_perf_callback perf;
|
||||
retro_hw_render_callback hw_render;
|
||||
bool keyboard_state[RETROK_LAST];
|
||||
bool input_polled;
|
||||
|
||||
uint64_t get_ticks_ms() noexcept {
|
||||
|
@ -427,6 +429,16 @@ extern "C" RETRO_API void retro_set_environment(retro_environment_t cb) {
|
|||
log_printf = fallback_log;
|
||||
}
|
||||
|
||||
static const struct retro_keyboard_callback keyboard = {
|
||||
.callback = [](bool down, unsigned int keycode, uint32_t character, uint16_t key_modifiers) {
|
||||
if (keycode < RETROK_LAST) {
|
||||
keyboard_state[keycode] = down;
|
||||
}
|
||||
}
|
||||
};
|
||||
std::memset(keyboard_state, 0, sizeof keyboard_state);
|
||||
cb(RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK, (void *)&keyboard);
|
||||
|
||||
perf = {
|
||||
.get_time_usec = nullptr,
|
||||
.get_cpu_features = nullptr,
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace mkxp_retro {
|
|||
extern retro_input_state_t input_state;
|
||||
extern struct retro_perf_callback perf;
|
||||
extern struct retro_hw_render_callback hw_render;
|
||||
extern bool keyboard_state[RETROK_LAST];
|
||||
extern bool input_polled;
|
||||
|
||||
uint64_t get_ticks_ms() noexcept;
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue