better cursor handling

main
Henri Vasserman 2025-01-10 17:46:30 +02:00
parent 931ec082b8
commit d45ae565a7
1 changed files with 4 additions and 1 deletions

View File

@ -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;
}