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