You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
629 B
33 lines
629 B
|
6 years ago
|
#pragma once
|
||
|
|
|
||
|
|
#include <cstddef>
|
||
|
|
|
||
|
|
#include <SDL.h>
|
||
|
|
|
||
|
|
#ifdef USE_SDL1
|
||
|
5 years ago
|
#include "utils/sdl2_to_1_2_backports.h"
|
||
|
6 years ago
|
#endif
|
||
|
|
|
||
|
5 years ago
|
namespace devilution {
|
||
|
6 years ago
|
|
||
|
|
// 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;
|
||
|
|
};
|
||
|
5 years ago
|
constexpr Mapping kMappings[] = { REMAP_KEYBOARD_KEYS };
|
||
|
6 years ago
|
for (std::size_t i = 0; i < sizeof(kMappings) / sizeof(kMappings[0]); ++i) {
|
||
|
|
if (*sym == kMappings[i].from) {
|
||
|
|
*sym = kMappings[i].to;
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
}
|
||
|
|
|
||
|
5 years ago
|
} // namespace devilution
|