Browse Source
Adds a `REMAP_KEYBOARD_KEYS` CMake option. This remapping applies wherever Game or Menu controls apply. Uses it to map the Power button to the menu on RG350.pull/732/head
5 changed files with 42 additions and 1 deletions
@ -0,0 +1,32 @@
|
||||
#pragma once |
||||
|
||||
#include <cstddef> |
||||
|
||||
#include <SDL.h> |
||||
|
||||
#ifdef USE_SDL1 |
||||
#include "sdl2_to_1_2_backports.h" |
||||
#endif |
||||
|
||||
namespace dvl { |
||||
|
||||
// Re-maps a keyboard key as per the REMAP_KEYBOARD_KEYS define.
|
||||
inline void remap_keyboard_key(SDL_Keycode *sym) |
||||
{ |
||||
#ifdef REMAP_KEYBOARD_KEYS |
||||
|
||||
struct Mapping { |
||||
SDL_Keycode from; |
||||
SDL_Keycode to; |
||||
}; |
||||
constexpr Mapping kMappings[] = {REMAP_KEYBOARD_KEYS}; |
||||
for (std::size_t i = 0; i < sizeof(kMappings) / sizeof(kMappings[0]); ++i) { |
||||
if (*sym == kMappings[i].from) { |
||||
*sym = kMappings[i].to; |
||||
return; |
||||
} |
||||
} |
||||
#endif |
||||
} |
||||
|
||||
} // namespace dvl
|
||||
Loading…
Reference in new issue