Minor mouse fixes

This commit is contained in:
Michael Theall 2020-04-21 18:14:48 -05:00
parent 214ab229c6
commit a313c5c169
3 changed files with 17 additions and 4 deletions

View File

@ -20,6 +20,7 @@
#pragma once #pragma once
#ifndef CLASSIC
#include <deko3d.hpp> #include <deko3d.hpp>
namespace imgui namespace imgui
@ -74,3 +75,4 @@ constexpr inline std::uint32_t align (T const &size_, U const &align_)
} }
} }
} }
#endif

View File

@ -1226,8 +1226,6 @@ void moveMouse (ImGuiIO &io_, ImVec2 const &pos_, bool const force_ = false)
s_showMouse = true; s_showMouse = true;
s_lastMouseUpdate = now; s_lastMouseUpdate = now;
s_mousePos = pos_; s_mousePos = pos_;
io_.MousePos = s_mousePos;
} }
/// \brief Update mouse buttons /// \brief Update mouse buttons
@ -1254,8 +1252,15 @@ void updateMousePos (ImGuiIO &io_)
MousePosition pos; MousePosition pos;
hidMouseRead (&pos); hidMouseRead (&pos);
io_.MouseWheelH += pos.scrollVelocityX; if (pos.scrollVelocityX > 0)
io_.MouseWheel += pos.scrollVelocityY; io_.MouseWheel += 1;
else if (pos.scrollVelocityX < 0)
io_.MouseWheel -= 1;
if (pos.scrollVelocityY > 0)
io_.MouseWheelH += 1;
else if (pos.scrollVelocityY < 0)
io_.MouseWheelH -= 1;
moveMouse ( moveMouse (
io_, ImVec2 (s_mousePos.x + 2.0f * pos.velocityX, s_mousePos.y + 2.0f * pos.velocityY)); io_, ImVec2 (s_mousePos.x + 2.0f * pos.velocityX, s_mousePos.y + 2.0f * pos.velocityY));
@ -1504,6 +1509,7 @@ void imgui::nx::newFrame ()
// clamp mouse to screen // clamp mouse to screen
s_mousePos.x = std::clamp (s_mousePos.x, 0.0f, s_width); s_mousePos.x = std::clamp (s_mousePos.x, 0.0f, s_width);
s_mousePos.y = std::clamp (s_mousePos.y, 0.0f, s_height); s_mousePos.y = std::clamp (s_mousePos.y, 0.0f, s_height);
io.MousePos = s_mousePos;
} }
void imgui::nx::exit () void imgui::nx::exit ()

View File

@ -20,13 +20,18 @@
#pragma once #pragma once
#ifndef CLASSIC
namespace imgui namespace imgui
{ {
namespace nx namespace nx
{ {
/// \brief Initialize switch platform
bool init (); bool init ();
/// \brief Deinitialize switch platform
void exit (); void exit ();
/// \brief Prepare switch for a new frame
void newFrame (); void newFrame ();
} }
} }
#endif