Add GET_CLIPBOARD device event

Add the first device event, used to forward the device clipboard to the
computer.
This commit is contained in:
Romain Vimont
2019-05-30 00:24:26 +02:00
parent ec71a3f66a
commit f9d2d99166
5 changed files with 141 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
#include <assert.h>
#include <string.h>
#include "device_event.h"
#include <stdio.h>
static void test_deserialize_clipboard_event(void) {
const unsigned char input[] = {
0x00, // DEVICE_EVENT_TYPE_CLIPBOARD
0x00, 0x03, // text length
0x41, 0x42, 0x43, // "ABC"
};
struct device_event event;
ssize_t r = device_event_deserialize(input, sizeof(input), &event);
assert(r == 6);
assert(event.type == DEVICE_EVENT_TYPE_GET_CLIPBOARD);
assert(event.clipboard_event.text);
assert(!strcmp("ABC", event.clipboard_event.text));
device_event_destroy(&event);
}
int main(void) {
test_deserialize_clipboard_event();
return 0;
}