'Mouse.RelX' and 'Mouse.RelY' are two new properties that return how much the mouse cursor has moved.

[GB.SDL2]
* NEW: 'Mouse.RelX' and 'Mouse.RelY' are two new properties that return how much the mouse cursor has moved.
This commit is contained in:
Benoît Minisini 2023-08-23 02:47:14 +02:00
parent 69f7b31d67
commit 91887f926b
2 changed files with 23 additions and 0 deletions

View file

@ -47,11 +47,16 @@ static void update_event()
_info = info = &window->mouse;
info->xrel = 0;
info->yrel = 0;
switch (_current->type)
{
case SDL_MOUSEMOTION:
info->x = _current->motion.x;
info->y = _current->motion.y;
info->xrel = _current->motion.xrel;
info->yrel = _current->motion.yrel;
info->wheel_x = 0;
info->wheel_y = 0;
info->state = _current->motion.state;
@ -137,6 +142,20 @@ BEGIN_PROPERTY(Mouse_Y)
END_PROPERTY
BEGIN_PROPERTY(Mouse_RelX)
CHECK_EVENT();
GB.ReturnInteger(_info->xrel);
END_PROPERTY
BEGIN_PROPERTY(Mouse_RelY)
CHECK_EVENT();
GB.ReturnInteger(_info->yrel);
END_PROPERTY
BEGIN_PROPERTY(Mouse_WheelX)
CHECK_EVENT();
@ -259,6 +278,8 @@ GB_DESC MouseDesc[] =
GB_STATIC_PROPERTY_READ("StartY", "i", Mouse_StartY),
GB_STATIC_PROPERTY_READ("X", "i", Mouse_X),
GB_STATIC_PROPERTY_READ("Y", "i", Mouse_Y),
GB_STATIC_PROPERTY_READ("RelX", "i", Mouse_RelX),
GB_STATIC_PROPERTY_READ("RelY", "i", Mouse_RelY),
GB_STATIC_PROPERTY_READ("WheelX", "i", Mouse_WheelX),
GB_STATIC_PROPERTY_READ("WheelY", "i", Mouse_WheelY),

View file

@ -34,6 +34,8 @@ typedef
struct {
int x;
int y;
int xrel;
int yrel;
int wheel_x;
int wheel_y;
int state;