Use sc_ prefix for control_msg

This commit is contained in:
Romain Vimont 2022-01-14 22:17:30 +01:00
parent 3a4d5c7f18
commit afa4a1b728
9 changed files with 67 additions and 66 deletions

View file

@ -89,7 +89,7 @@ to_fixed_point_16(float f) {
} }
size_t size_t
control_msg_serialize(const struct control_msg *msg, unsigned char *buf) { sc_control_msg_serialize(const struct sc_control_msg *msg, unsigned char *buf) {
buf[0] = msg->type; buf[0] = msg->type;
switch (msg->type) { switch (msg->type) {
case CONTROL_MSG_TYPE_INJECT_KEYCODE: case CONTROL_MSG_TYPE_INJECT_KEYCODE:
@ -151,7 +151,7 @@ control_msg_serialize(const struct control_msg *msg, unsigned char *buf) {
} }
void void
control_msg_log(const struct control_msg *msg) { sc_control_msg_log(const struct sc_control_msg *msg) {
#define LOG_CMSG(fmt, ...) LOGV("input: " fmt, ## __VA_ARGS__) #define LOG_CMSG(fmt, ...) LOGV("input: " fmt, ## __VA_ARGS__)
switch (msg->type) { switch (msg->type) {
case CONTROL_MSG_TYPE_INJECT_KEYCODE: case CONTROL_MSG_TYPE_INJECT_KEYCODE:
@ -237,7 +237,7 @@ control_msg_log(const struct control_msg *msg) {
} }
void void
control_msg_destroy(struct control_msg *msg) { sc_control_msg_destroy(struct sc_control_msg *msg) {
switch (msg->type) { switch (msg->type) {
case CONTROL_MSG_TYPE_INJECT_TEXT: case CONTROL_MSG_TYPE_INJECT_TEXT:
free(msg->inject_text.text); free(msg->inject_text.text);

View file

@ -20,7 +20,7 @@
#define POINTER_ID_MOUSE UINT64_C(-1) #define POINTER_ID_MOUSE UINT64_C(-1)
#define POINTER_ID_VIRTUAL_FINGER UINT64_C(-2) #define POINTER_ID_VIRTUAL_FINGER UINT64_C(-2)
enum control_msg_type { enum sc_control_msg_type {
CONTROL_MSG_TYPE_INJECT_KEYCODE, CONTROL_MSG_TYPE_INJECT_KEYCODE,
CONTROL_MSG_TYPE_INJECT_TEXT, CONTROL_MSG_TYPE_INJECT_TEXT,
CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT, CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT,
@ -47,8 +47,8 @@ enum get_clipboard_copy_key {
GET_CLIPBOARD_COPY_KEY_CUT, GET_CLIPBOARD_COPY_KEY_CUT,
}; };
struct control_msg { struct sc_control_msg {
enum control_msg_type type; enum sc_control_msg_type type;
union { union {
struct { struct {
enum android_keyevent_action action; enum android_keyevent_action action;
@ -93,12 +93,12 @@ struct control_msg {
// buf size must be at least CONTROL_MSG_MAX_SIZE // buf size must be at least CONTROL_MSG_MAX_SIZE
// return the number of bytes written // return the number of bytes written
size_t size_t
control_msg_serialize(const struct control_msg *msg, unsigned char *buf); sc_control_msg_serialize(const struct sc_control_msg *msg, unsigned char *buf);
void void
control_msg_log(const struct control_msg *msg); sc_control_msg_log(const struct sc_control_msg *msg);
void void
control_msg_destroy(struct control_msg *msg); sc_control_msg_destroy(struct sc_control_msg *msg);
#endif #endif

View file

@ -38,9 +38,9 @@ sc_controller_destroy(struct sc_controller *controller) {
sc_cond_destroy(&controller->msg_cond); sc_cond_destroy(&controller->msg_cond);
sc_mutex_destroy(&controller->mutex); sc_mutex_destroy(&controller->mutex);
struct control_msg msg; struct sc_control_msg msg;
while (cbuf_take(&controller->queue, &msg)) { while (cbuf_take(&controller->queue, &msg)) {
control_msg_destroy(&msg); sc_control_msg_destroy(&msg);
} }
receiver_destroy(&controller->receiver); receiver_destroy(&controller->receiver);
@ -48,9 +48,9 @@ sc_controller_destroy(struct sc_controller *controller) {
bool bool
sc_controller_push_msg(struct sc_controller *controller, sc_controller_push_msg(struct sc_controller *controller,
const struct control_msg *msg) { const struct sc_control_msg *msg) {
if (sc_get_log_level() <= SC_LOG_LEVEL_VERBOSE) { if (sc_get_log_level() <= SC_LOG_LEVEL_VERBOSE) {
control_msg_log(msg); sc_control_msg_log(msg);
} }
sc_mutex_lock(&controller->mutex); sc_mutex_lock(&controller->mutex);
@ -64,9 +64,10 @@ sc_controller_push_msg(struct sc_controller *controller,
} }
static bool static bool
process_msg(struct sc_controller *controller, const struct control_msg *msg) { process_msg(struct sc_controller *controller,
const struct sc_control_msg *msg) {
static unsigned char serialized_msg[CONTROL_MSG_MAX_SIZE]; static unsigned char serialized_msg[CONTROL_MSG_MAX_SIZE];
size_t length = control_msg_serialize(msg, serialized_msg); size_t length = sc_control_msg_serialize(msg, serialized_msg);
if (!length) { if (!length) {
return false; return false;
} }
@ -89,14 +90,14 @@ run_controller(void *data) {
sc_mutex_unlock(&controller->mutex); sc_mutex_unlock(&controller->mutex);
break; break;
} }
struct control_msg msg; struct sc_control_msg msg;
bool non_empty = cbuf_take(&controller->queue, &msg); bool non_empty = cbuf_take(&controller->queue, &msg);
assert(non_empty); assert(non_empty);
(void) non_empty; (void) non_empty;
sc_mutex_unlock(&controller->mutex); sc_mutex_unlock(&controller->mutex);
bool ok = process_msg(controller, &msg); bool ok = process_msg(controller, &msg);
control_msg_destroy(&msg); sc_control_msg_destroy(&msg);
if (!ok) { if (!ok) {
LOGD("Could not write msg to socket"); LOGD("Could not write msg to socket");
break; break;

View file

@ -12,7 +12,7 @@
#include "util/net.h" #include "util/net.h"
#include "util/thread.h" #include "util/thread.h"
struct sc_control_msg_queue CBUF(struct control_msg, 64); struct sc_control_msg_queue CBUF(struct sc_control_msg, 64);
struct sc_controller { struct sc_controller {
sc_socket control_socket; sc_socket control_socket;
@ -42,6 +42,6 @@ sc_controller_join(struct sc_controller *controller);
bool bool
sc_controller_push_msg(struct sc_controller *controller, sc_controller_push_msg(struct sc_controller *controller,
const struct control_msg *msg); const struct sc_control_msg *msg);
#endif #endif

View file

@ -160,7 +160,7 @@ static void
send_keycode(struct sc_controller *controller, enum android_keycode keycode, send_keycode(struct sc_controller *controller, enum android_keycode keycode,
enum sc_action action, const char *name) { enum sc_action action, const char *name) {
// send DOWN event // send DOWN event
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_INJECT_KEYCODE; msg.type = CONTROL_MSG_TYPE_INJECT_KEYCODE;
msg.inject_keycode.action = action == SC_ACTION_DOWN msg.inject_keycode.action = action == SC_ACTION_DOWN
? AKEY_EVENT_ACTION_DOWN ? AKEY_EVENT_ACTION_DOWN
@ -214,7 +214,7 @@ action_menu(struct sc_controller *controller, enum sc_action action) {
static void static void
press_back_or_turn_screen_on(struct sc_controller *controller, press_back_or_turn_screen_on(struct sc_controller *controller,
enum sc_action action) { enum sc_action action) {
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_BACK_OR_SCREEN_ON; msg.type = CONTROL_MSG_TYPE_BACK_OR_SCREEN_ON;
msg.back_or_screen_on.action = action == SC_ACTION_DOWN msg.back_or_screen_on.action = action == SC_ACTION_DOWN
? AKEY_EVENT_ACTION_DOWN ? AKEY_EVENT_ACTION_DOWN
@ -227,7 +227,7 @@ press_back_or_turn_screen_on(struct sc_controller *controller,
static void static void
expand_notification_panel(struct sc_controller *controller) { expand_notification_panel(struct sc_controller *controller) {
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL; msg.type = CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL;
if (!sc_controller_push_msg(controller, &msg)) { if (!sc_controller_push_msg(controller, &msg)) {
@ -237,7 +237,7 @@ expand_notification_panel(struct sc_controller *controller) {
static void static void
expand_settings_panel(struct sc_controller *controller) { expand_settings_panel(struct sc_controller *controller) {
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_EXPAND_SETTINGS_PANEL; msg.type = CONTROL_MSG_TYPE_EXPAND_SETTINGS_PANEL;
if (!sc_controller_push_msg(controller, &msg)) { if (!sc_controller_push_msg(controller, &msg)) {
@ -247,7 +247,7 @@ expand_settings_panel(struct sc_controller *controller) {
static void static void
collapse_panels(struct sc_controller *controller) { collapse_panels(struct sc_controller *controller) {
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_COLLAPSE_PANELS; msg.type = CONTROL_MSG_TYPE_COLLAPSE_PANELS;
if (!sc_controller_push_msg(controller, &msg)) { if (!sc_controller_push_msg(controller, &msg)) {
@ -258,7 +258,7 @@ collapse_panels(struct sc_controller *controller) {
static bool static bool
get_device_clipboard(struct sc_controller *controller, get_device_clipboard(struct sc_controller *controller,
enum get_clipboard_copy_key copy_key) { enum get_clipboard_copy_key copy_key) {
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_GET_CLIPBOARD; msg.type = CONTROL_MSG_TYPE_GET_CLIPBOARD;
msg.get_clipboard.copy_key = copy_key; msg.get_clipboard.copy_key = copy_key;
@ -286,7 +286,7 @@ set_device_clipboard(struct sc_controller *controller, bool paste,
return false; return false;
} }
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_SET_CLIPBOARD; msg.type = CONTROL_MSG_TYPE_SET_CLIPBOARD;
msg.set_clipboard.sequence = sequence; msg.set_clipboard.sequence = sequence;
msg.set_clipboard.text = text_dup; msg.set_clipboard.text = text_dup;
@ -304,7 +304,7 @@ set_device_clipboard(struct sc_controller *controller, bool paste,
static void static void
set_screen_power_mode(struct sc_controller *controller, set_screen_power_mode(struct sc_controller *controller,
enum screen_power_mode mode) { enum screen_power_mode mode) {
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE; msg.type = CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE;
msg.set_screen_power_mode.mode = mode; msg.set_screen_power_mode.mode = mode;
@ -349,7 +349,7 @@ clipboard_paste(struct sc_controller *controller) {
return; return;
} }
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_INJECT_TEXT; msg.type = CONTROL_MSG_TYPE_INJECT_TEXT;
msg.inject_text.text = text_dup; msg.inject_text.text = text_dup;
if (!sc_controller_push_msg(controller, &msg)) { if (!sc_controller_push_msg(controller, &msg)) {
@ -360,7 +360,7 @@ clipboard_paste(struct sc_controller *controller) {
static void static void
rotate_device(struct sc_controller *controller) { rotate_device(struct sc_controller *controller) {
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_ROTATE_DEVICE; msg.type = CONTROL_MSG_TYPE_ROTATE_DEVICE;
if (!sc_controller_push_msg(controller, &msg)) { if (!sc_controller_push_msg(controller, &msg)) {
@ -406,7 +406,7 @@ simulate_virtual_finger(struct sc_input_manager *im,
struct sc_point point) { struct sc_point point) {
bool up = action == AMOTION_EVENT_ACTION_UP; bool up = action == AMOTION_EVENT_ACTION_UP;
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT; msg.type = CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT;
msg.inject_touch_event.action = action; msg.inject_touch_event.action = action;
msg.inject_touch_event.position.screen_size = im->screen->frame_size; msg.inject_touch_event.position.screen_size = im->screen->frame_size;

View file

@ -246,7 +246,7 @@ convert_meta_state(uint16_t mod) {
} }
static bool static bool
convert_input_key(const struct sc_key_event *event, struct control_msg *msg, convert_input_key(const struct sc_key_event *event, struct sc_control_msg *msg,
enum sc_key_inject_mode key_inject_mode, uint32_t repeat) { enum sc_key_inject_mode key_inject_mode, uint32_t repeat) {
msg->type = CONTROL_MSG_TYPE_INJECT_KEYCODE; msg->type = CONTROL_MSG_TYPE_INJECT_KEYCODE;
@ -282,7 +282,7 @@ sc_key_processor_process_key(struct sc_key_processor *kp,
ki->repeat = 0; ki->repeat = 0;
} }
struct control_msg msg; struct sc_control_msg msg;
if (convert_input_key(event, &msg, ki->key_inject_mode, ki->repeat)) { if (convert_input_key(event, &msg, ki->key_inject_mode, ki->repeat)) {
if (!sc_controller_push_msg(ki->controller, &msg)) { if (!sc_controller_push_msg(ki->controller, &msg)) {
LOGW("Could not request 'inject keycode'"); LOGW("Could not request 'inject keycode'");
@ -309,7 +309,7 @@ sc_key_processor_process_text(struct sc_key_processor *kp,
} }
} }
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_INJECT_TEXT; msg.type = CONTROL_MSG_TYPE_INJECT_TEXT;
msg.inject_text.text = strdup(event->text); msg.inject_text.text = strdup(event->text);
if (!msg.inject_text.text) { if (!msg.inject_text.text) {

View file

@ -65,7 +65,7 @@ sc_mouse_processor_process_mouse_motion(struct sc_mouse_processor *mp,
struct sc_mouse_inject *mi = DOWNCAST(mp); struct sc_mouse_inject *mi = DOWNCAST(mp);
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT, .type = CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT,
.inject_touch_event = { .inject_touch_event = {
.action = AMOTION_EVENT_ACTION_MOVE, .action = AMOTION_EVENT_ACTION_MOVE,
@ -86,7 +86,7 @@ sc_mouse_processor_process_mouse_click(struct sc_mouse_processor *mp,
const struct sc_mouse_click_event *event) { const struct sc_mouse_click_event *event) {
struct sc_mouse_inject *mi = DOWNCAST(mp); struct sc_mouse_inject *mi = DOWNCAST(mp);
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT, .type = CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT,
.inject_touch_event = { .inject_touch_event = {
.action = convert_mouse_action(event->action), .action = convert_mouse_action(event->action),
@ -107,7 +107,7 @@ sc_mouse_processor_process_mouse_scroll(struct sc_mouse_processor *mp,
const struct sc_mouse_scroll_event *event) { const struct sc_mouse_scroll_event *event) {
struct sc_mouse_inject *mi = DOWNCAST(mp); struct sc_mouse_inject *mi = DOWNCAST(mp);
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT, .type = CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT,
.inject_scroll_event = { .inject_scroll_event = {
.position = event->position, .position = event->position,
@ -127,7 +127,7 @@ sc_mouse_processor_process_touch(struct sc_mouse_processor *mp,
const struct sc_touch_event *event) { const struct sc_touch_event *event) {
struct sc_mouse_inject *mi = DOWNCAST(mp); struct sc_mouse_inject *mi = DOWNCAST(mp);
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT, .type = CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT,
.inject_touch_event = { .inject_touch_event = {
.action = convert_touch_action(event->action), .action = convert_touch_action(event->action),

View file

@ -558,7 +558,7 @@ aoa_hid_end:
controller_started = true; controller_started = true;
if (options->turn_screen_off) { if (options->turn_screen_off) {
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE; msg.type = CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE;
msg.set_screen_power_mode.mode = SCREEN_POWER_MODE_OFF; msg.set_screen_power_mode.mode = SCREEN_POWER_MODE_OFF;

View file

@ -6,7 +6,7 @@
#include "control_msg.h" #include "control_msg.h"
static void test_serialize_inject_keycode(void) { static void test_serialize_inject_keycode(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_INJECT_KEYCODE, .type = CONTROL_MSG_TYPE_INJECT_KEYCODE,
.inject_keycode = { .inject_keycode = {
.action = AKEY_EVENT_ACTION_UP, .action = AKEY_EVENT_ACTION_UP,
@ -17,7 +17,7 @@ static void test_serialize_inject_keycode(void) {
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 14); assert(size == 14);
const unsigned char expected[] = { const unsigned char expected[] = {
@ -31,7 +31,7 @@ static void test_serialize_inject_keycode(void) {
} }
static void test_serialize_inject_text(void) { static void test_serialize_inject_text(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_INJECT_TEXT, .type = CONTROL_MSG_TYPE_INJECT_TEXT,
.inject_text = { .inject_text = {
.text = "hello, world!", .text = "hello, world!",
@ -39,7 +39,7 @@ static void test_serialize_inject_text(void) {
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 18); assert(size == 18);
const unsigned char expected[] = { const unsigned char expected[] = {
@ -51,7 +51,7 @@ static void test_serialize_inject_text(void) {
} }
static void test_serialize_inject_text_long(void) { static void test_serialize_inject_text_long(void) {
struct control_msg msg; struct sc_control_msg msg;
msg.type = CONTROL_MSG_TYPE_INJECT_TEXT; msg.type = CONTROL_MSG_TYPE_INJECT_TEXT;
char text[CONTROL_MSG_INJECT_TEXT_MAX_LENGTH + 1]; char text[CONTROL_MSG_INJECT_TEXT_MAX_LENGTH + 1];
memset(text, 'a', CONTROL_MSG_INJECT_TEXT_MAX_LENGTH); memset(text, 'a', CONTROL_MSG_INJECT_TEXT_MAX_LENGTH);
@ -59,7 +59,7 @@ static void test_serialize_inject_text_long(void) {
msg.inject_text.text = text; msg.inject_text.text = text;
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 5 + CONTROL_MSG_INJECT_TEXT_MAX_LENGTH); assert(size == 5 + CONTROL_MSG_INJECT_TEXT_MAX_LENGTH);
unsigned char expected[5 + CONTROL_MSG_INJECT_TEXT_MAX_LENGTH]; unsigned char expected[5 + CONTROL_MSG_INJECT_TEXT_MAX_LENGTH];
@ -74,7 +74,7 @@ static void test_serialize_inject_text_long(void) {
} }
static void test_serialize_inject_touch_event(void) { static void test_serialize_inject_touch_event(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT, .type = CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT,
.inject_touch_event = { .inject_touch_event = {
.action = AMOTION_EVENT_ACTION_DOWN, .action = AMOTION_EVENT_ACTION_DOWN,
@ -95,7 +95,7 @@ static void test_serialize_inject_touch_event(void) {
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 28); assert(size == 28);
const unsigned char expected[] = { const unsigned char expected[] = {
@ -111,7 +111,7 @@ static void test_serialize_inject_touch_event(void) {
} }
static void test_serialize_inject_scroll_event(void) { static void test_serialize_inject_scroll_event(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT, .type = CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT,
.inject_scroll_event = { .inject_scroll_event = {
.position = { .position = {
@ -131,7 +131,7 @@ static void test_serialize_inject_scroll_event(void) {
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 25); assert(size == 25);
const unsigned char expected[] = { const unsigned char expected[] = {
@ -146,7 +146,7 @@ static void test_serialize_inject_scroll_event(void) {
} }
static void test_serialize_back_or_screen_on(void) { static void test_serialize_back_or_screen_on(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_BACK_OR_SCREEN_ON, .type = CONTROL_MSG_TYPE_BACK_OR_SCREEN_ON,
.back_or_screen_on = { .back_or_screen_on = {
.action = AKEY_EVENT_ACTION_UP, .action = AKEY_EVENT_ACTION_UP,
@ -154,7 +154,7 @@ static void test_serialize_back_or_screen_on(void) {
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 2); assert(size == 2);
const unsigned char expected[] = { const unsigned char expected[] = {
@ -165,12 +165,12 @@ static void test_serialize_back_or_screen_on(void) {
} }
static void test_serialize_expand_notification_panel(void) { static void test_serialize_expand_notification_panel(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL, .type = CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL,
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 1); assert(size == 1);
const unsigned char expected[] = { const unsigned char expected[] = {
@ -180,12 +180,12 @@ static void test_serialize_expand_notification_panel(void) {
} }
static void test_serialize_expand_settings_panel(void) { static void test_serialize_expand_settings_panel(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_EXPAND_SETTINGS_PANEL, .type = CONTROL_MSG_TYPE_EXPAND_SETTINGS_PANEL,
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 1); assert(size == 1);
const unsigned char expected[] = { const unsigned char expected[] = {
@ -195,12 +195,12 @@ static void test_serialize_expand_settings_panel(void) {
} }
static void test_serialize_collapse_panels(void) { static void test_serialize_collapse_panels(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_COLLAPSE_PANELS, .type = CONTROL_MSG_TYPE_COLLAPSE_PANELS,
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 1); assert(size == 1);
const unsigned char expected[] = { const unsigned char expected[] = {
@ -210,7 +210,7 @@ static void test_serialize_collapse_panels(void) {
} }
static void test_serialize_get_clipboard(void) { static void test_serialize_get_clipboard(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_GET_CLIPBOARD, .type = CONTROL_MSG_TYPE_GET_CLIPBOARD,
.get_clipboard = { .get_clipboard = {
.copy_key = GET_CLIPBOARD_COPY_KEY_COPY, .copy_key = GET_CLIPBOARD_COPY_KEY_COPY,
@ -218,7 +218,7 @@ static void test_serialize_get_clipboard(void) {
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 2); assert(size == 2);
const unsigned char expected[] = { const unsigned char expected[] = {
@ -229,7 +229,7 @@ static void test_serialize_get_clipboard(void) {
} }
static void test_serialize_set_clipboard(void) { static void test_serialize_set_clipboard(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_SET_CLIPBOARD, .type = CONTROL_MSG_TYPE_SET_CLIPBOARD,
.set_clipboard = { .set_clipboard = {
.sequence = UINT64_C(0x0102030405060708), .sequence = UINT64_C(0x0102030405060708),
@ -239,7 +239,7 @@ static void test_serialize_set_clipboard(void) {
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 27); assert(size == 27);
const unsigned char expected[] = { const unsigned char expected[] = {
@ -253,7 +253,7 @@ static void test_serialize_set_clipboard(void) {
} }
static void test_serialize_set_clipboard_long(void) { static void test_serialize_set_clipboard_long(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_SET_CLIPBOARD, .type = CONTROL_MSG_TYPE_SET_CLIPBOARD,
.set_clipboard = { .set_clipboard = {
.sequence = UINT64_C(0x0102030405060708), .sequence = UINT64_C(0x0102030405060708),
@ -268,7 +268,7 @@ static void test_serialize_set_clipboard_long(void) {
msg.set_clipboard.text = text; msg.set_clipboard.text = text;
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == CONTROL_MSG_MAX_SIZE); assert(size == CONTROL_MSG_MAX_SIZE);
unsigned char expected[CONTROL_MSG_MAX_SIZE] = { unsigned char expected[CONTROL_MSG_MAX_SIZE] = {
@ -287,7 +287,7 @@ static void test_serialize_set_clipboard_long(void) {
} }
static void test_serialize_set_screen_power_mode(void) { static void test_serialize_set_screen_power_mode(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE, .type = CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE,
.set_screen_power_mode = { .set_screen_power_mode = {
.mode = SCREEN_POWER_MODE_NORMAL, .mode = SCREEN_POWER_MODE_NORMAL,
@ -295,7 +295,7 @@ static void test_serialize_set_screen_power_mode(void) {
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 2); assert(size == 2);
const unsigned char expected[] = { const unsigned char expected[] = {
@ -306,12 +306,12 @@ static void test_serialize_set_screen_power_mode(void) {
} }
static void test_serialize_rotate_device(void) { static void test_serialize_rotate_device(void) {
struct control_msg msg = { struct sc_control_msg msg = {
.type = CONTROL_MSG_TYPE_ROTATE_DEVICE, .type = CONTROL_MSG_TYPE_ROTATE_DEVICE,
}; };
unsigned char buf[CONTROL_MSG_MAX_SIZE]; unsigned char buf[CONTROL_MSG_MAX_SIZE];
size_t size = control_msg_serialize(&msg, buf); size_t size = sc_control_msg_serialize(&msg, buf);
assert(size == 1); assert(size == 1);
const unsigned char expected[] = { const unsigned char expected[] = {