raw_mouse: center cursors on init

This commit is contained in:
Megamouse 2024-02-13 22:52:48 +01:00
parent c91bc03532
commit d71f4b33d7
2 changed files with 15 additions and 1 deletions

View File

@ -69,6 +69,12 @@ void raw_mouse::update_window_handle()
m_window_height = 0;
}
void raw_mouse::center_cursor()
{
m_pos_x = m_window_width / 2;
m_pos_y = m_window_height / 2;
}
#ifdef _WIN32
void raw_mouse::update_values(const RAWMOUSE& state)
{
@ -226,9 +232,15 @@ void raw_mouse_handler::Init(const u32 max_connect)
#ifdef _WIN32
if (max_connect && !m_raw_mice.empty())
{
// Initialize and center all mice
for (auto& [handle, mouse] : m_raw_mice)
{
mouse.update_window_handle();
mouse.center_cursor();
}
// Get the window handle of the first mouse
raw_mouse& mouse = m_raw_mice.begin()->second;
mouse.update_window_handle();
std::vector<RAWINPUTDEVICE> raw_input_devices;
raw_input_devices.push_back(RAWINPUTDEVICE {

View File

@ -19,6 +19,8 @@ public:
void update_window_handle();
display_handle_t window_handle() const { return m_window_handle; }
void center_cursor();
#ifdef _WIN32
void update_values(const RAWMOUSE& state);
#endif