FreeCalypso > hg > freecalypso-tools
annotate rvinterf/asyncshell/keypress.c @ 661:fd7b447b99e3
libserial rename
The version that was previously named libserial-newlnx is now libserial-linux,
and the version that was previosly named libserial-orig is now libserial-posix.
This new naming is more in line with the objective reality of the difference,
moving away from naming based on our project history.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 05 Mar 2020 19:54:31 +0000 |
parents | 8c7e86bc137e |
children |
rev | line source |
---|---|
398
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * Functions for sending simulated keystrokes via GPF MMI CONFIG sysprims. |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <ctype.h> |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <string.h> |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <strings.h> |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdlib.h> |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "pktmux.h" |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "limits.h" |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "exitcodes.h" |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 send_mmi_config_pair(key, value) |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 char *key, *value; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 { |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 unsigned intlen; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 u_char sendpkt[MAX_PKT_TO_TARGET+1]; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 unsigned pktlen; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 intlen = 12 + 7 + strlen(key) + 1 + strlen(value); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 pktlen = intlen + 4; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (pktlen > MAX_PKT_TO_TARGET) { |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 printf("error: max pkt to target limit exceeded\n"); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 return(ERROR_USAGE); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 /* fill out the packet */ |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 sendpkt[0] = RVT_L23_HEADER; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 sendpkt[1] = 0xB7; /* system prim */ |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 sendpkt[2] = intlen; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 sendpkt[3] = intlen >> 8; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 /* send zeros for the timestamp */ |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 sendpkt[4] = 0; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 sendpkt[5] = 0; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 sendpkt[6] = 0; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 sendpkt[7] = 0; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 /* as far as TI's sw is concerned, we are PCO */ |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 sprintf(sendpkt + 8, "PCO MMI CONFIG %s=%s", key, value); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 /* send it! */ |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 send_pkt_to_target(sendpkt, pktlen); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 return(0); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 } |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 void |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 cmd_key_interactive(arg) |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 char *arg; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 { |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 while (isspace(*arg)) |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 arg++; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 if (!*arg) { |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 printf("error: missing string argument\n"); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 return; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 send_mmi_config_pair("KEY_SEQUENCE", arg); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 } |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 cmd_key_oneshot(argc, argv) |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 char **argv; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 { |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 return send_mmi_config_pair("KEY_SEQUENCE", argv[1]); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 void |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 cmd_keydown_interactive(arg) |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 char *arg; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 { |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 while (isspace(*arg)) |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 arg++; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 if (!*arg) { |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 printf("error: missing string argument\n"); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 return; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 send_mmi_config_pair("KEY_PRESS", arg); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 } |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 cmd_keydown_oneshot(argc, argv) |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 char **argv; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 { |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 return send_mmi_config_pair("KEY_PRESS", argv[1]); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 } |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 void |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 cmd_keyup_interactive(arg) |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 char *arg; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 { |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 while (isspace(*arg)) |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 arg++; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 if (!*arg) { |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 printf("error: missing string argument\n"); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 return; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 } |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 send_mmi_config_pair("KEY_RELEASE", arg); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 } |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 cmd_keyup_oneshot(argc, argv) |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 char **argv; |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 { |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 return send_mmi_config_pair("KEY_RELEASE", argv[1]); |
8c7e86bc137e
fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 } |