11
11
#include "config.h"
12
12
#include "compat.h"
13
13
#include "log.h"
14
+ #include "input_manager.h"
14
15
#include "recorder.h"
15
16
16
17
struct args {
@@ -67,6 +68,18 @@ static void usage(const char *arg0) {
67
68
" Set the TCP port the client listens on.\n"
68
69
" Default is %d.\n"
69
70
"\n"
71
+ " --prefer-text-events mode\n"
72
+ " Configure how key/text events are forwarded to the Android\n"
73
+ " device.\n"
74
+ " Possible values are:\n"
75
+ " always:\n"
76
+ " Every text is sent as text.\n"
77
+ " non-alpha:\n"
78
+ " Only letters are sent as a sequence of key events, other\n"
79
+ " characters are sent as text. (default)\n"
80
+ " never:\n"
81
+ " Every text is sent as a sequence of key events.\n"
82
+ "\n"
70
83
" --push-target path\n"
71
84
" Set the target directory for pushing files to the device by\n"
72
85
" drag & drop. It is passed as-is to \"adb push\".\n"
@@ -294,9 +307,33 @@ guess_record_format(const char *filename) {
294
307
return 0 ;
295
308
}
296
309
310
+ static bool
311
+ parse_prefer_text_events (const char * optarg ,
312
+ enum text_events_pref * pref ) {
313
+ if (!strcmp (optarg , "always" )) {
314
+ * pref = PREFER_TEXT_EVENTS_ALWAYS ;
315
+ return true;
316
+ }
317
+
318
+ if (!strcmp (optarg , "non-alpha" )) {
319
+ * pref = PREFER_TEXT_EVENTS_NON_ALPHA ;
320
+ return true;
321
+ }
322
+
323
+ if (!strcmp (optarg , "never" )) {
324
+ * pref = PREFER_TEXT_EVENTS_NEVER ;
325
+ return true;
326
+ }
327
+
328
+ LOGE ("Unsupported text events preference: %s"
329
+ "(expected 'always', 'non-alpha' or 'never')" , optarg );
330
+ return false;
331
+ }
332
+
297
333
#define OPT_RENDER_EXPIRED_FRAMES 1000
298
334
#define OPT_WINDOW_TITLE 1001
299
335
#define OPT_PUSH_TARGET 1002
336
+ #define OPT_PREFER_TEXT_EVENTS 1003
300
337
301
338
static bool
302
339
parse_args (struct args * args , int argc , char * argv []) {
@@ -319,6 +356,8 @@ parse_args(struct args *args, int argc, char *argv[]) {
319
356
{"serial" , required_argument , NULL , 's' },
320
357
{"show-touches" , no_argument , NULL , 't' },
321
358
{"turn-screen-off" , no_argument , NULL , 'S' },
359
+ {"prefer-text-events" , required_argument , NULL ,
360
+ OPT_PREFER_TEXT_EVENTS },
322
361
{"version" , no_argument , NULL , 'v' },
323
362
{"window-title" , required_argument , NULL ,
324
363
OPT_WINDOW_TITLE },
@@ -393,6 +432,12 @@ parse_args(struct args *args, int argc, char *argv[]) {
393
432
case OPT_PUSH_TARGET :
394
433
opts -> push_target = optarg ;
395
434
break ;
435
+ case OPT_PREFER_TEXT_EVENTS :
436
+ if (!parse_prefer_text_events (optarg ,
437
+ & opts -> text_events_pref )) {
438
+ return false;
439
+ }
440
+ break ;
396
441
default :
397
442
// getopt prints the error message on stderr
398
443
return false;
0 commit comments