mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-08-18 01:15:59 +00:00
Mouse support for SDL
This commit is contained in:
parent
676f39e197
commit
a92d215151
30
src/sdl.c
30
src/sdl.c
@ -19,16 +19,46 @@
|
||||
|
||||
#ifdef HAVE_SDL
|
||||
|
||||
#include "limelight-common/Limelight.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <SDL.h>
|
||||
|
||||
static bool done;
|
||||
|
||||
void sdl_loop() {
|
||||
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
|
||||
SDL_Event event;
|
||||
|
||||
while(!done && SDL_WaitEvent(&event)) {
|
||||
int button = 0;
|
||||
switch (event.type) {
|
||||
case SDL_MOUSEMOTION:
|
||||
LiSendMouseMoveEvent(event.motion.xrel, event.motion.yrel);
|
||||
break;
|
||||
case SDL_MOUSEWHEEL:
|
||||
LiSendScrollEvent(event.wheel.y);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
switch (event.button.button) {
|
||||
case SDL_BUTTON_LEFT:
|
||||
button = BUTTON_LEFT;
|
||||
break;
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
button = BUTTON_MIDDLE;
|
||||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
button = BUTTON_RIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (button != 0)
|
||||
LiSendMouseButtonEvent(event.button.state==SDL_PRESSED?BUTTON_ACTION_PRESS:BUTTON_ACTION_RELEASE, button);
|
||||
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
done = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user