Display and control your Android device
Make process_text() optional
Romain Vimontbc674721dcc9
diff --git a/app/src/hid_keyboard.c b/app/src/hid_keyboard.cindex be5f8a19..4a0e64ba 100644--- a/app/src/hid_keyboard.c+++ b/app/src/hid_keyboard.c@@ -387,15 +387,6 @@ sc_key_processor_process_key(struct sc_key_processor *kp,}}-static void-sc_key_processor_process_text(struct sc_key_processor *kp,- const struct sc_text_event *event) {- (void) kp;- (void) event;-- // Never forward text input via HID (all the keys are injected separately)-}-boolsc_hid_keyboard_init(struct sc_hid_keyboard *kb, struct sc_aoa *aoa) {kb->aoa = aoa;@@ -415,7 +406,9 @@ sc_hid_keyboard_init(struct sc_hid_keyboard *kb, struct sc_aoa *aoa) {static const struct sc_key_processor_ops ops = {.process_key = sc_key_processor_process_key,- .process_text = sc_key_processor_process_text,+ // Never forward text input via HID (all the keys are injected+ // separately)+ .process_text = NULL,};// Clipboard synchronization is requested over the control socket, while HIDdiff --git a/app/src/input_manager.c b/app/src/input_manager.cindex 4dc8c4eb..aa0708c0 100644--- a/app/src/input_manager.c+++ b/app/src/input_manager.c@@ -384,6 +384,11 @@ rotate_client_right(struct screen *screen) {static voidinput_manager_process_text_input(struct input_manager *im,const SDL_TextInputEvent *event) {+ if (!im->kp->ops->process_text) {+ // The key processor does not support text input+ return;+ }+if (is_shortcut_mod(im, SDL_GetModState())) {// A shortcut must never generate text eventsreturn;@@ -620,6 +625,7 @@ input_manager_process_key(struct input_manager *im,.mods_state = sc_mods_state_from_sdl(event->keysym.mod),};+ assert(im->kp->ops->process_key);im->kp->ops->process_key(im->kp, &evt, ack_to_wait);}diff --git a/app/src/trait/key_processor.h b/app/src/trait/key_processor.hindex 045e5e7b..8c51b11d 100644--- a/app/src/trait/key_processor.h+++ b/app/src/trait/key_processor.h@@ -29,17 +29,24 @@ struct sc_key_processor {struct sc_key_processor_ops {/**- * Process the keyboard event+ * Process a keyboard event** The `sequence` number (if different from `SC_SEQUENCE_INVALID`) indicates* the acknowledgement number to wait for before injecting this event.* This allows to ensure that the device clipboard is set before injecting* Ctrl+v on the device.+ *+ * This function is mandatory.*/void(*process_key)(struct sc_key_processor *kp,const struct sc_key_event *event, uint64_t ack_to_wait);+ /**+ * Process an input text+ *+ * This function is optional.+ */void(*process_text)(struct sc_key_processor *kp,const struct sc_text_event *event);