win32 and SDL2: capture the mouse when the button is pressed
This commit is contained in:
parent
cb315e4f0c
commit
b184a75c9e
@ -1299,11 +1299,17 @@ int Get_input(int sleep_time)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
#ifdef USE_SDL2
|
||||||
|
SDL_CaptureMouse(SDL_TRUE);
|
||||||
|
#endif
|
||||||
Handle_mouse_click(&event.button);
|
Handle_mouse_click(&event.button);
|
||||||
user_feedback_required = 1;
|
user_feedback_required = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
|
#ifdef USE_SDL2
|
||||||
|
SDL_CaptureMouse(SDL_FALSE);
|
||||||
|
#endif
|
||||||
Handle_mouse_release(&event.button);
|
Handle_mouse_release(&event.button);
|
||||||
user_feedback_required = 1;
|
user_feedback_required = 1;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
|
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <windowsx.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
@ -208,32 +209,38 @@ static LRESULT CALLBACK Win32_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LP
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
|
SetCapture(hwnd); // capture mouse when the button is pressed
|
||||||
Input_new_mouse_K |= 1;
|
Input_new_mouse_K |= 1;
|
||||||
Move_cursor_with_constraints(0);
|
Move_cursor_with_constraints(0);
|
||||||
user_feedback_required = 1;
|
user_feedback_required = 1;
|
||||||
return 0;
|
return 0;
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
|
ReleaseCapture(); // Release mouse when the button is released
|
||||||
Input_new_mouse_K &= ~1;
|
Input_new_mouse_K &= ~1;
|
||||||
Move_cursor_with_constraints(0);
|
Move_cursor_with_constraints(0);
|
||||||
user_feedback_required = 1;
|
user_feedback_required = 1;
|
||||||
return 0;
|
return 0;
|
||||||
// WM_LBUTTONDBLCLK
|
// WM_LBUTTONDBLCLK
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
|
SetCapture(hwnd); // capture mouse when the button is pressed
|
||||||
Input_new_mouse_K |= 2;
|
Input_new_mouse_K |= 2;
|
||||||
Move_cursor_with_constraints(0);
|
Move_cursor_with_constraints(0);
|
||||||
user_feedback_required = 1;
|
user_feedback_required = 1;
|
||||||
return 0;
|
return 0;
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP:
|
||||||
|
ReleaseCapture(); // Release mouse when the button is released
|
||||||
Input_new_mouse_K &= ~2;
|
Input_new_mouse_K &= ~2;
|
||||||
Move_cursor_with_constraints(0);
|
Move_cursor_with_constraints(0);
|
||||||
user_feedback_required = 1;
|
user_feedback_required = 1;
|
||||||
return 0;
|
return 0;
|
||||||
// WM_RBUTTONDBLCLK
|
// WM_RBUTTONDBLCLK
|
||||||
case WM_MBUTTONDOWN:
|
case WM_MBUTTONDOWN:
|
||||||
//case WM_MBUTTONUP:
|
|
||||||
Key = KEY_MOUSEMIDDLE|Get_Key_modifiers();
|
Key = KEY_MOUSEMIDDLE|Get_Key_modifiers();
|
||||||
user_feedback_required = 1;
|
user_feedback_required = 1;
|
||||||
return 0;
|
return 0;
|
||||||
|
case WM_MBUTTONUP:
|
||||||
|
return 0;
|
||||||
|
// WM_MBUTTONDBLCLK
|
||||||
case WM_MOUSEWHEEL:
|
case WM_MOUSEWHEEL:
|
||||||
{
|
{
|
||||||
short delta = HIWORD(wParam);
|
short delta = HIWORD(wParam);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user