Skip to content

Commit

Permalink
Improve m_ctrl_pressed detection in Editor::event
Browse files Browse the repository at this point in the history
  • Loading branch information
Vankata453 authored Nov 8, 2024
1 parent 1e5d753 commit 95af078
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/editor/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,16 +858,14 @@ Editor::event(const SDL_Event& ev)
{
if (ev.type == SDL_KEYDOWN)
{
if (ev.key.keysym.mod & KMOD_CTRL)
m_ctrl_pressed = ev.key.keysym.mod & KMOD_CTRL;

if (m_ctrl_pressed)
m_scroll_speed = 16.0f;
else if (ev.key.keysym.mod & KMOD_RSHIFT)
m_scroll_speed = 96.0f;

if (ev.key.keysym.sym == SDLK_LCTRL)
{
m_ctrl_pressed = true;
}
else if (ev.key.keysym.sym == SDLK_F6)
if (ev.key.keysym.sym == SDLK_F6)
{
Compositor::s_render_lighting = !Compositor::s_render_lighting;
return;
Expand Down Expand Up @@ -904,11 +902,10 @@ Editor::event(const SDL_Event& ev)
}
else if (ev.type == SDL_KEYUP)
{
if (!(ev.key.keysym.mod & KMOD_CTRL) && !(ev.key.keysym.mod & KMOD_RSHIFT))
m_scroll_speed = 32.0f;
m_ctrl_pressed = ev.key.keysym.mod & KMOD_CTRL;

if (ev.key.keysym.sym == SDLK_LCTRL)
m_ctrl_pressed = false;
if (!m_ctrl_pressed && !(ev.key.keysym.mod & KMOD_RSHIFT))
m_scroll_speed = 32.0f;
}
else if (ev.type == SDL_MOUSEMOTION)
{
Expand Down

0 comments on commit 95af078

Please sign in to comment.