Skip to content

Commit

Permalink
fix sdl2 keyboard event
Browse files Browse the repository at this point in the history
  • Loading branch information
K1ngst0m committed Jan 14, 2024
1 parent 5dcd6f4 commit 48355a5
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions engine/wsi/wsi_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ using namespace aph;
static Key SDL2KeyCast(int key)
{
#define k(sdlk, aph) \
case SDLK_##sdlk: \
return Key::aph
case SDLK_##sdlk: \
return Key::aph
switch(key)
{
k(a, A);
Expand Down Expand Up @@ -125,27 +125,30 @@ bool WSI::update()
case SDL_KEYDOWN:
{
state = KeyState::Pressed;
}
break;
case SDL_KEYUP:
{
CM_LOG_DEBUG("key down: %s", KeyToStr(gkey));
if(gkey == Key::Escape)
{
close();
return false;
}
else if(gkey == Key::_1)

if(gkey == Key::_1)
{
// TODO cursor visible
static bool visible = false;
visible = !visible;
visible = !visible;
}
else
{
EventManager::GetInstance().pushEvent(KeyboardEvent{gkey, state});
}
}
break;
case SDL_KEYUP:
{
state = KeyState::Released;
break;
}
break;
}

if(windowEvent.key.repeat)
Expand Down Expand Up @@ -223,7 +226,6 @@ bool WSI::update()
};

void WSI::close(){

// glfwSetWindowShouldClose((GLFWwindow*)m_window, true);
};

Expand Down

0 comments on commit 48355a5

Please sign in to comment.