better cursor handling
parent
931ec082b8
commit
d45ae565a7
5
xormod.c
5
xormod.c
|
@ -5,6 +5,7 @@
|
|||
#include "platform.h"
|
||||
#include "types.h"
|
||||
|
||||
#include <SDL3/SDL_mouse.h>
|
||||
#include <SDL3/SDL_render.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
@ -87,18 +88,20 @@ int main() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
SDL_HideCursor();
|
||||
break;
|
||||
}
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP: {
|
||||
dragging = event.button.down;
|
||||
SDL_SetWindowRelativeMouseMode(window, dragging);
|
||||
break;
|
||||
}
|
||||
case SDL_EVENT_MOUSE_MOTION: {
|
||||
if (dragging) {
|
||||
f.offset.x -= event.motion.xrel;
|
||||
f.offset.y -= event.motion.yrel;
|
||||
} else {
|
||||
SDL_ShowCursor();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue