mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2025-08-18 01:15:59 +00:00
Simple keyboard support for SDL
This commit is contained in:
parent
a92d215151
commit
be83130820
14
src/sdl.c
14
src/sdl.c
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#ifdef HAVE_SDL
|
#ifdef HAVE_SDL
|
||||||
|
|
||||||
|
#include "sdl.h"
|
||||||
|
|
||||||
#include "limelight-common/Limelight.h"
|
#include "limelight-common/Limelight.h"
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -56,9 +58,19 @@ void sdl_loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (button != 0)
|
if (button != 0)
|
||||||
LiSendMouseButtonEvent(event.button.state==SDL_PRESSED?BUTTON_ACTION_PRESS:BUTTON_ACTION_RELEASE, button);
|
LiSendMouseButtonEvent(event.type==SDL_MOUSEBUTTONDOWN?BUTTON_ACTION_PRESS:BUTTON_ACTION_RELEASE, button);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
case SDL_KEYDOWN:
|
||||||
|
case SDL_KEYUP:
|
||||||
|
button = event.key.keysym.sym;
|
||||||
|
if (button >= (0x40000000 + 0x39) && button < (0x40000000 + sizeof(keyCodes)))
|
||||||
|
button = keyCodes[button - 0x40000039];
|
||||||
|
if (button >= 0x61)
|
||||||
|
button -= 0x20;
|
||||||
|
|
||||||
|
LiSendKeyboardEvent(0x80 << 8 | button, event.type==SDL_KEYDOWN?KEY_ACTION_DOWN:KEY_ACTION_UP, 0);
|
||||||
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
|
28
src/sdl.h
28
src/sdl.h
@ -19,6 +19,34 @@
|
|||||||
|
|
||||||
#ifdef HAVE_SDL
|
#ifdef HAVE_SDL
|
||||||
|
|
||||||
|
static const short keyCodes[] = {
|
||||||
|
0x14, //SDLK_CAPSLOCK
|
||||||
|
0x70, //SDLK_F1
|
||||||
|
0x71, //SDLK_F2
|
||||||
|
0x72, //SDLK_F3
|
||||||
|
0x73, //SDLK_F4
|
||||||
|
0x74, //SDLK_F5
|
||||||
|
0x75, //SDLK_F6
|
||||||
|
0x76, //SDLK_F7
|
||||||
|
0x77, //SDLK_F8
|
||||||
|
0x78, //SDLK_F9
|
||||||
|
0x79, //SDLK_F10
|
||||||
|
0x7A, //SDLK_F11
|
||||||
|
0x7B, //SDLK_F12
|
||||||
|
0, //SDLK_PRINTSCREEN
|
||||||
|
0x91, //SDLK_SCROLLLOCK
|
||||||
|
0x13, //SDLK_PAUSE
|
||||||
|
0x9B, //SDLK_INSERT
|
||||||
|
0x24, //SDLK_HOME
|
||||||
|
0x21, //SDLK_PAGEUP
|
||||||
|
0x23, //SDLK_END
|
||||||
|
0x22, //SDLK_PAGEDOWN
|
||||||
|
0x27, //SDLK_RIGHT
|
||||||
|
0x25, //SDLK_LEFT
|
||||||
|
0x28, //SDLK_DOWN
|
||||||
|
0x26, //SDLK_UP
|
||||||
|
};
|
||||||
|
|
||||||
void sdl_loop();
|
void sdl_loop();
|
||||||
|
|
||||||
#endif /* HAVE_SDL */
|
#endif /* HAVE_SDL */
|
||||||
|
@ -101,9 +101,6 @@ static int sdl_submit_decode_unit(PDECODE_UNIT decodeUnit) {
|
|||||||
fprintf(stderr, "Video decode buffer too small");
|
fprintf(stderr, "Video decode buffer too small");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Event event;
|
|
||||||
SDL_PollEvent(&event);
|
|
||||||
|
|
||||||
return DR_OK;
|
return DR_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user