mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-14 07:21:51 +00:00
half keyboard is work
This commit is contained in:
parent
6a7335900f
commit
82562300ff
1 changed files with 7 additions and 4 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
#include <SDL3/SDL_keyboard.h>
|
#include <SDL3/SDL_keyboard.h>
|
||||||
#include <SDL3/SDL_keycode.h>
|
#include <SDL3/SDL_keycode.h>
|
||||||
#include <SDL3/SDL_mouse.h>
|
#include <SDL3/SDL_mouse.h>
|
||||||
|
#include <SDL3/SDL_scancode.h>
|
||||||
#include <SDL3/SDL_video.h>
|
#include <SDL3/SDL_video.h>
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
@ -17,13 +18,15 @@
|
||||||
static debug::Logger logger("input");
|
static debug::Logger logger("input");
|
||||||
|
|
||||||
std::string input_util::to_string(Keycode code) {
|
std::string input_util::to_string(Keycode code) {
|
||||||
int icode_repr = static_cast<int>(code);
|
auto icode_repr = static_cast<SDL_Scancode>(code);
|
||||||
const char* name = SDL_GetKeyName(icode_repr);
|
const char* name = SDL_GetKeyName(
|
||||||
|
SDL_GetKeyFromScancode(icode_repr, SDL_KMOD_NONE, false)
|
||||||
|
);
|
||||||
return std::string(name);
|
return std::string(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Keycode input_util::keycode_from(const std::string& name) {
|
Keycode input_util::keycode_from(const std::string& name) {
|
||||||
return static_cast<Keycode>(SDL_GetKeyFromName(name.c_str()));
|
return static_cast<Keycode>(SDL_GetScancodeFromName(name.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
input_sdl::input_sdl(window_sdl& window) : window(window) {
|
input_sdl::input_sdl(window_sdl& window) : window(window) {
|
||||||
|
|
@ -79,7 +82,7 @@ void input_sdl::pollEvents() {
|
||||||
break;
|
break;
|
||||||
case SDL_EVENT_MOUSE_MOTION:
|
case SDL_EVENT_MOUSE_MOTION:
|
||||||
if (cursorDrag) {
|
if (cursorDrag) {
|
||||||
delta += glm::vec2{event.motion.xrel, event.motion.yrel};
|
delta += glm::vec2 {event.motion.xrel, event.motion.yrel};
|
||||||
} else {
|
} else {
|
||||||
cursorDrag = true;
|
cursorDrag = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue