diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-12-14 23:31:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-14 23:31:52 +0100 |
commit | 57c3f6a94ba547cfb4c3bcfd7a3e2e784239fd4e (patch) | |
tree | 2d86291ab8b732297206b28cad8cfdea3e38f0a0 /platform/windows | |
parent | 46f73c366df4377a69c26ee295db26956a90531b (diff) | |
parent | bd9c592c528034a58f4ede0bd2ba06760dd360b5 (diff) |
Merge pull request #20063 from moiman100/fix-button-mask
Unified button mask behavior across platforms
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/os_windows.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 55d2bb2153..e1cbbcc66b 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -496,15 +496,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) mm->set_shift((wParam & MK_SHIFT) != 0); mm->set_alt(alt_mem); - int bmask = 0; - bmask |= (wParam & MK_LBUTTON) ? (1 << 0) : 0; - bmask |= (wParam & MK_RBUTTON) ? (1 << 1) : 0; - bmask |= (wParam & MK_MBUTTON) ? (1 << 2) : 0; - bmask |= (wParam & MK_XBUTTON1) ? (1 << 7) : 0; - bmask |= (wParam & MK_XBUTTON2) ? (1 << 8) : 0; - mm->set_button_mask(bmask); - - last_button_state = mm->get_button_mask(); + mm->set_button_mask(last_button_state); mm->set_position(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); mm->set_global_position(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); @@ -673,15 +665,12 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) mb->set_shift((wParam & MK_SHIFT) != 0); mb->set_alt(alt_mem); //mb->get_alt()=(wParam&MK_MENU)!=0; - int bmask = 0; - bmask |= (wParam & MK_LBUTTON) ? (1 << 0) : 0; - bmask |= (wParam & MK_RBUTTON) ? (1 << 1) : 0; - bmask |= (wParam & MK_MBUTTON) ? (1 << 2) : 0; - bmask |= (wParam & MK_XBUTTON1) ? (1 << 7) : 0; - bmask |= (wParam & MK_XBUTTON2) ? (1 << 8) : 0; - mb->set_button_mask(bmask); - - last_button_state = mb->get_button_mask(); + if (mb->is_pressed()) + last_button_state |= (1 << (mb->get_button_index() - 1)); + else + last_button_state &= ~(1 << (mb->get_button_index() - 1)); + mb->set_button_mask(last_button_state); + mb->set_position(Vector2(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); if (mouse_mode == MOUSE_MODE_CAPTURED && !use_raw_input) { @@ -721,6 +710,8 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (mb->is_pressed() && mb->get_button_index() > 3 && mb->get_button_index() < 8) { //send release for mouse wheel Ref<InputEventMouseButton> mbd = mb->duplicate(); + last_button_state &= ~(1 << (mbd->get_button_index() - 1)); + mbd->set_button_mask(last_button_state); mbd->set_pressed(false); input->parse_input_event(mbd); } |