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

29
app/src/control.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef CONTROL_H
#define CONTROL_H
#include "controlevent.h"
#include <SDL2/SDL_mutex.h>
#include <SDL2/SDL_net.h>
#include <SDL2/SDL_stdinc.h>
struct controller {
TCPsocket video_socket;
SDL_Thread *thread;
SDL_mutex *mutex;
SDL_cond *event_cond;
SDL_bool stopped;
struct control_event_queue queue;
};
SDL_bool controller_init(struct controller *controller, TCPsocket video_socket);
void controller_destroy(struct controller *controller);
SDL_bool controller_start(struct controller *controller);
void controller_stop(struct controller *controller);
void controller_join(struct controller *controller);
// expose simple API to hide control_event_queue
SDL_bool controller_push_event(struct controller *controller, struct control_event *event);
#endif