2019-05-30 06:25:37 +08:00
|
|
|
#ifndef RECEIVER_H
|
|
|
|
#define RECEIVER_H
|
|
|
|
|
2021-01-09 02:24:51 +08:00
|
|
|
#include "common.h"
|
|
|
|
|
2019-05-30 06:25:37 +08:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <SDL2/SDL_mutex.h>
|
|
|
|
#include <SDL2/SDL_thread.h>
|
|
|
|
|
2019-11-24 18:53:00 +08:00
|
|
|
#include "util/net.h"
|
2019-05-30 06:25:37 +08:00
|
|
|
|
|
|
|
// receive events from the device
|
|
|
|
// managed by the controller
|
|
|
|
struct receiver {
|
|
|
|
socket_t control_socket;
|
|
|
|
SDL_Thread *thread;
|
|
|
|
SDL_mutex *mutex;
|
|
|
|
};
|
|
|
|
|
|
|
|
bool
|
|
|
|
receiver_init(struct receiver *receiver, socket_t control_socket);
|
|
|
|
|
|
|
|
void
|
|
|
|
receiver_destroy(struct receiver *receiver);
|
|
|
|
|
|
|
|
bool
|
|
|
|
receiver_start(struct receiver *receiver);
|
|
|
|
|
|
|
|
// no receiver_stop(), it will automatically stop on control_socket shutdown
|
|
|
|
|
|
|
|
void
|
|
|
|
receiver_join(struct receiver *receiver);
|
|
|
|
|
|
|
|
#endif
|