Implement keyboard/mouse control

To control the device from the computer:
 - retrieve mouse and keyboard SDL events;
 - convert them to Android events;
 - serialize them;
 - send them on the same socket used by the video stream (but in the
 opposite direction);
 - deserialize the events on the Android side;
 - inject them using the InputManager.
This commit is contained in:
Romain Vimont
2017-12-14 11:38:44 +01:00
parent 6605ab8e23
commit cabb102a04
23 changed files with 2999 additions and 101 deletions

20
app/src/convert.h Normal file
View File

@@ -0,0 +1,20 @@
#ifndef CONVERT_H
#define CONVERT_H
#include <SDL2/SDL_stdinc.h>
#include <SDL2/SDL_events.h>
#include "controlevent.h"
// on Android, a scroll event requires the current mouse position
struct complete_mouse_wheel_event {
SDL_MouseWheelEvent *mouse_wheel_event;
Sint32 x;
Sint32 y;
};
SDL_bool input_key_from_sdl_to_android(SDL_KeyboardEvent *from, struct control_event *to);
SDL_bool mouse_button_from_sdl_to_android(SDL_MouseButtonEvent *from, struct control_event *to);
SDL_bool mouse_motion_from_sdl_to_android(SDL_MouseMotionEvent *from, struct control_event *to);
SDL_bool mouse_wheel_from_sdl_to_android(struct complete_mouse_wheel_event *from, struct control_event *to);
#endif