comparison rvinterf/asyncshell/keypress.c @ 398:8c7e86bc137e

fc-shell: added key commands for sending keystrokes via MMI CONFIG sysprims
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Mar 2018 00:52:40 +0000
parents
children
comparison
equal deleted inserted replaced
397:4477d28c77bc 398:8c7e86bc137e
1 /*
2 * Functions for sending simulated keystrokes via GPF MMI CONFIG sysprims.
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <ctype.h>
8 #include <string.h>
9 #include <strings.h>
10 #include <stdlib.h>
11 #include "pktmux.h"
12 #include "limits.h"
13 #include "exitcodes.h"
14
15 send_mmi_config_pair(key, value)
16 char *key, *value;
17 {
18 unsigned intlen;
19 u_char sendpkt[MAX_PKT_TO_TARGET+1];
20 unsigned pktlen;
21
22 intlen = 12 + 7 + strlen(key) + 1 + strlen(value);
23 pktlen = intlen + 4;
24 if (pktlen > MAX_PKT_TO_TARGET) {
25 printf("error: max pkt to target limit exceeded\n");
26 return(ERROR_USAGE);
27 }
28 /* fill out the packet */
29 sendpkt[0] = RVT_L23_HEADER;
30 sendpkt[1] = 0xB7; /* system prim */
31 sendpkt[2] = intlen;
32 sendpkt[3] = intlen >> 8;
33 /* send zeros for the timestamp */
34 sendpkt[4] = 0;
35 sendpkt[5] = 0;
36 sendpkt[6] = 0;
37 sendpkt[7] = 0;
38 /* as far as TI's sw is concerned, we are PCO */
39 sprintf(sendpkt + 8, "PCO MMI CONFIG %s=%s", key, value);
40 /* send it! */
41 send_pkt_to_target(sendpkt, pktlen);
42 return(0);
43 }
44
45 void
46 cmd_key_interactive(arg)
47 char *arg;
48 {
49 while (isspace(*arg))
50 arg++;
51 if (!*arg) {
52 printf("error: missing string argument\n");
53 return;
54 }
55 send_mmi_config_pair("KEY_SEQUENCE", arg);
56 }
57
58 cmd_key_oneshot(argc, argv)
59 char **argv;
60 {
61 return send_mmi_config_pair("KEY_SEQUENCE", argv[1]);
62 }
63
64 void
65 cmd_keydown_interactive(arg)
66 char *arg;
67 {
68 while (isspace(*arg))
69 arg++;
70 if (!*arg) {
71 printf("error: missing string argument\n");
72 return;
73 }
74 send_mmi_config_pair("KEY_PRESS", arg);
75 }
76
77 cmd_keydown_oneshot(argc, argv)
78 char **argv;
79 {
80 return send_mmi_config_pair("KEY_PRESS", argv[1]);
81 }
82
83 void
84 cmd_keyup_interactive(arg)
85 char *arg;
86 {
87 while (isspace(*arg))
88 arg++;
89 if (!*arg) {
90 printf("error: missing string argument\n");
91 return;
92 }
93 send_mmi_config_pair("KEY_RELEASE", arg);
94 }
95
96 cmd_keyup_oneshot(argc, argv)
97 char **argv;
98 {
99 return send_mmi_config_pair("KEY_RELEASE", argv[1]);
100 }