Andrew Duggan | 052556f | 2014-04-16 11:32:30 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 - 2014 Andrew Duggan |
| 3 | * Copyright (C) 2013 - 2014 Synaptics Inc |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 18 | #include <stdio.h> |
| 19 | #include <sys/types.h> |
| 20 | #include <sys/stat.h> |
| 21 | #include <fcntl.h> |
| 22 | #include <errno.h> |
| 23 | #include <string.h> |
| 24 | #include <unistd.h> |
| 25 | #include <sys/ioctl.h> |
| 26 | #include <sys/select.h> |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 27 | #include <getopt.h> |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 28 | |
| 29 | #include <linux/types.h> |
| 30 | #include <linux/input.h> |
| 31 | #include <linux/hidraw.h> |
| 32 | #include <signal.h> |
| 33 | #include <stdlib.h> |
| 34 | |
| 35 | #include "hiddevice.h" |
| 36 | |
Andrew Duggan | 2c24adb | 2015-05-06 18:18:06 -0700 | [diff] [blame^] | 37 | #define RMI4UPDATE_GETOPTS "hp:ir:w:foambd" |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 38 | |
| 39 | enum rmihidtool_cmd { |
| 40 | RMIHIDTOOL_CMD_INTERACTIVE, |
| 41 | RMIHIDTOOL_CMD_READ, |
| 42 | RMIHIDTOOL_CMD_WRITE, |
| 43 | RMIHIDTOOL_CMD_FW_ID, |
| 44 | RMIHIDTOOL_CMD_PROPS, |
| 45 | RMIHIDTOOL_CMD_ATTN, |
| 46 | RMIHIDTOOL_CMD_PRINT_FUNCTIONS, |
Andrew Duggan | 161c83c | 2015-05-06 18:06:03 -0700 | [diff] [blame] | 47 | RMIHIDTOOL_CMD_REBIND_DRIVER, |
Andrew Duggan | 2c24adb | 2015-05-06 18:18:06 -0700 | [diff] [blame^] | 48 | RMIHIDTOOL_CMD_PRINT_DEVICE_INFO, |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 49 | }; |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 50 | |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 51 | static int report_attn = 0; |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 52 | static RMIDevice * g_device = NULL; |
| 53 | |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 54 | void print_help(const char *prog_name) |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 55 | { |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 56 | fprintf(stdout, "Usage: %s [OPTIONS] DEVICEFILE\n", prog_name); |
| 57 | fprintf(stdout, "\t-h, --help\t\t\t\tPrint this message\n"); |
| 58 | fprintf(stdout, "\t-p, --protocol [protocol]\t\tSet which transport prototocl to use.\n"); |
| 59 | fprintf(stdout, "\t-i, --interactive\t\t\tRun in interactive mode.\n"); |
| 60 | fprintf(stdout, "\t-r, --read [address] [length]\t\tRead registers starting at the address.\n"); |
| 61 | fprintf(stdout, "\t-r, --write [address] [length] [data]\tWrite registers starting at the address.\n"); |
| 62 | fprintf(stdout, "\t-f, --firmware-id\t\t\tPrint the firmware id\n"); |
| 63 | fprintf(stdout, "\t-o, --props\t\t\t\tPrint device properties\n"); |
| 64 | fprintf(stdout, "\t-a, --attention\t\t\t\tPrint attention reports until control + c\n"); |
| 65 | fprintf(stdout, "\t-m, --print-functions\t\t\tPrint RMI4 functions for the device.\n"); |
Andrew Duggan | 161c83c | 2015-05-06 18:06:03 -0700 | [diff] [blame] | 66 | fprintf(stdout, "\t-b, --rebind-driver\t\t\tRebind the driver to force an update of device properties.\n"); |
Andrew Duggan | 2c24adb | 2015-05-06 18:18:06 -0700 | [diff] [blame^] | 67 | fprintf(stdout, "\t-d, --device-info\t\t\tPrint protocol specific information about the device.\n"); |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 68 | } |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 69 | |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 70 | void print_cmd_usage() |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 71 | { |
| 72 | fprintf(stdout, "Commands:\n"); |
| 73 | fprintf(stdout, "s [0,1,2]: Set RMIMode\n"); |
| 74 | fprintf(stdout, "r address size: read size bytes from address\n"); |
| 75 | fprintf(stdout, "w address { values }: write bytes to address\n"); |
| 76 | fprintf(stdout, "a: Wait for attention\n"); |
| 77 | fprintf(stdout, "q: quit\n"); |
| 78 | } |
| 79 | |
| 80 | int find_token(char * input, char * result, char ** endpp) |
| 81 | { |
| 82 | int i = 0; |
| 83 | char * start = input; |
| 84 | char * end; |
| 85 | |
| 86 | while (input[i] == ' ') { |
| 87 | ++start; |
| 88 | ++i; |
| 89 | } |
| 90 | |
| 91 | while (input[i] != '\0') { |
Andrew Duggan | 849fea3 | 2014-11-13 21:15:48 -0800 | [diff] [blame] | 92 | if (input[++i] == ' ') |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 93 | break; |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 94 | } |
| 95 | end = &input[i]; |
| 96 | |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 97 | if (start == end) |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 98 | return 0; |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 99 | |
| 100 | *endpp = end; |
| 101 | strncpy(result, start, end - start); |
Andrew Duggan | 849fea3 | 2014-11-13 21:15:48 -0800 | [diff] [blame] | 102 | result[end - start] = '\0'; |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 103 | |
| 104 | return 1; |
| 105 | } |
| 106 | |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 107 | void interactive(RMIDevice * device, unsigned char *report) |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 108 | { |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 109 | char token[256]; |
| 110 | char * start; |
| 111 | char * end; |
| 112 | int rc; |
| 113 | |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 114 | for (;;) { |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 115 | fprintf(stdout, "\n"); |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 116 | print_cmd_usage(); |
| 117 | char input[256]; |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 118 | |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 119 | if (fgets(input, 256, stdin)) { |
| 120 | memset(token, 0, 256); |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 121 | |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 122 | if (input[0] == 's') { |
| 123 | start = input + 2; |
| 124 | find_token(start, token, &end); |
| 125 | int mode = strtol(token, NULL, 0); |
| 126 | if (mode >= 0 && mode <= 2) { |
| 127 | if (device->SetMode(mode)) { |
| 128 | fprintf(stderr, "Set RMI Mode to: %d\n", mode); |
| 129 | } else { |
| 130 | fprintf(stderr, "Set RMI Mode FAILED!\n"); |
| 131 | continue; |
| 132 | } |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 133 | } |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 134 | } else if (input[0] == 'r') { |
| 135 | start = input + 2; |
| 136 | find_token(start, token, &end); |
| 137 | start = end + 1; |
| 138 | unsigned int addr = strtol(token, NULL, 0); |
| 139 | find_token(start, token, &end); |
| 140 | start = end + 1; |
| 141 | unsigned int len = strtol(token, NULL, 0); |
| 142 | fprintf(stdout, "Address = 0x%02x Length = %d\n", addr, len); |
| 143 | |
| 144 | memset(report, 0, 256); |
| 145 | rc = device->Read(addr, report, len); |
| 146 | if (rc < 0) |
| 147 | fprintf(stderr, "Failed to read report: %d\n", rc); |
| 148 | print_buffer(report, len); |
| 149 | } else if (input[0] == 'w') { |
| 150 | int index = 0; |
| 151 | start = input + 2; |
| 152 | find_token(start, token, &end); |
| 153 | start = end + 1; |
| 154 | unsigned int addr = strtol(token, NULL, 0); |
| 155 | unsigned int len = 0; |
| 156 | |
| 157 | memset(report, 0, 256); |
| 158 | while (find_token(start, token, &end)) { |
| 159 | start = end; |
Andrew Duggan | 849fea3 | 2014-11-13 21:15:48 -0800 | [diff] [blame] | 160 | report[index++] = strtol(token, NULL, 0); |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 161 | ++len; |
| 162 | } |
| 163 | |
| 164 | if (device->Write(addr, report, len) < 0) { |
| 165 | fprintf(stderr, "Failed to Write Report\n"); |
| 166 | continue; |
| 167 | } |
| 168 | } else if (input[0] == 'a') { |
| 169 | unsigned int bytes = 256; |
Andrew Duggan | f73fdc7 | 2014-11-09 11:02:22 -0800 | [diff] [blame] | 170 | device->GetAttentionReport(NULL, |
| 171 | RMI_INTERUPT_SOURCES_ALL_MASK, |
| 172 | report, &bytes); |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 173 | print_buffer(report, bytes); |
| 174 | } else if (input[0] == 'q') { |
| 175 | return; |
| 176 | } else { |
| 177 | print_cmd_usage(); |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 178 | } |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 179 | } |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 180 | } |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | static void cleanup(int status) |
| 184 | { |
| 185 | if (report_attn) { |
| 186 | report_attn = 0; |
| 187 | if (g_device) |
| 188 | g_device->Cancel(); |
| 189 | } else { |
| 190 | exit(0); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | int main(int argc, char ** argv) |
| 195 | { |
| 196 | int rc; |
| 197 | struct sigaction sig_cleanup_action; |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 198 | int opt; |
| 199 | int index; |
| 200 | RMIDevice *device; |
| 201 | const char *protocol = "HID"; |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 202 | unsigned char report[256]; |
| 203 | char token[256]; |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 204 | static struct option long_options[] = { |
| 205 | {"help", 0, NULL, 'h'}, |
| 206 | {"protocol", 1, NULL, 'p'}, |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 207 | {"interactive", 0, NULL, 'i'}, |
| 208 | {"read", 1, NULL, 'r'}, |
| 209 | {"write", 1, NULL, 'w'}, |
| 210 | {"firmware-id", 0, NULL, 'f'}, |
| 211 | {"props", 0, NULL, 'o'}, |
| 212 | {"attention", 0, NULL, 'a'}, |
| 213 | {"print-functions", 0, NULL, 'm'}, |
Andrew Duggan | 161c83c | 2015-05-06 18:06:03 -0700 | [diff] [blame] | 214 | {"rebind-driver", 0, NULL, 'b'}, |
Andrew Duggan | 2c24adb | 2015-05-06 18:18:06 -0700 | [diff] [blame^] | 215 | {"device-info", 0, NULL, 'd'}, |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 216 | {0, 0, 0, 0}, |
| 217 | }; |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 218 | enum rmihidtool_cmd cmd = RMIHIDTOOL_CMD_INTERACTIVE; |
Andrew Duggan | 8b79f31 | 2014-05-16 13:26:09 -0700 | [diff] [blame] | 219 | unsigned int addr = 0; |
| 220 | unsigned int len = 0; |
| 221 | char * data = NULL; |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 222 | char * start; |
| 223 | char * end; |
Andrew Duggan | 849fea3 | 2014-11-13 21:15:48 -0800 | [diff] [blame] | 224 | int i = 0; |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 225 | |
| 226 | memset(&sig_cleanup_action, 0, sizeof(struct sigaction)); |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 227 | sig_cleanup_action.sa_handler = cleanup; |
| 228 | sig_cleanup_action.sa_flags = SA_RESTART; |
| 229 | sigaction(SIGINT, &sig_cleanup_action, NULL); |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 230 | |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 231 | while ((opt = getopt_long(argc, argv, RMI4UPDATE_GETOPTS, long_options, &index)) != -1) { |
| 232 | switch (opt) { |
| 233 | case 'h': |
| 234 | print_help(argv[0]); |
| 235 | return 0; |
| 236 | case 'p': |
| 237 | protocol = optarg; |
| 238 | break; |
| 239 | case 'i': |
| 240 | cmd = RMIHIDTOOL_CMD_INTERACTIVE; |
| 241 | break; |
| 242 | case 'r': |
| 243 | cmd = RMIHIDTOOL_CMD_READ; |
| 244 | addr = strtol(optarg, NULL, 0); |
| 245 | len = strtol(argv[optind++], NULL, 0); |
| 246 | break; |
| 247 | case 'w': |
| 248 | cmd = RMIHIDTOOL_CMD_WRITE; |
| 249 | addr = strtol(optarg, NULL, 0); |
| 250 | data = argv[optind++]; |
| 251 | break; |
| 252 | case 'f': |
| 253 | cmd = RMIHIDTOOL_CMD_FW_ID; |
| 254 | break; |
| 255 | case 'o': |
| 256 | cmd = RMIHIDTOOL_CMD_PROPS; |
| 257 | break; |
| 258 | case 'a': |
| 259 | cmd = RMIHIDTOOL_CMD_ATTN; |
| 260 | break; |
| 261 | case 'm': |
| 262 | cmd = RMIHIDTOOL_CMD_PRINT_FUNCTIONS; |
| 263 | break; |
Andrew Duggan | 161c83c | 2015-05-06 18:06:03 -0700 | [diff] [blame] | 264 | case 'b': |
| 265 | cmd = RMIHIDTOOL_CMD_REBIND_DRIVER; |
| 266 | break; |
Andrew Duggan | 2c24adb | 2015-05-06 18:18:06 -0700 | [diff] [blame^] | 267 | case 'd': |
| 268 | cmd = RMIHIDTOOL_CMD_PRINT_DEVICE_INFO; |
| 269 | break; |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 270 | default: |
| 271 | print_help(argv[0]); |
| 272 | return 0; |
| 273 | break; |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 274 | |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 275 | } |
| 276 | } |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 277 | |
| 278 | if (!strncasecmp("hid", protocol, 3)) { |
| 279 | device = new HIDDevice(); |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 280 | } else { |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 281 | fprintf(stderr, "Invalid Protocol: %s\n", protocol); |
| 282 | return -1; |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 283 | } |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 284 | |
Andrew Duggan | 4667eb7 | 2014-04-29 13:37:42 -0700 | [diff] [blame] | 285 | if (optind >= argc) { |
| 286 | print_help(argv[0]); |
| 287 | return -1; |
| 288 | } |
| 289 | |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 290 | rc = device->Open(argv[optind++]); |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 291 | if (rc) { |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 292 | fprintf(stderr, "%s: failed to initialize rmi device (%d): %s\n", argv[0], errno, |
| 293 | strerror(errno)); |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 294 | return 1; |
| 295 | } |
| 296 | |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 297 | g_device = device; |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 298 | |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 299 | switch (cmd) { |
| 300 | case RMIHIDTOOL_CMD_READ: |
| 301 | memset(report, 0, sizeof(report)); |
| 302 | rc = device->Read(addr, report, len); |
| 303 | if (rc < 0) |
| 304 | fprintf(stderr, "Failed to read report: %d\n", rc); |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 305 | |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 306 | print_buffer(report, len); |
| 307 | break; |
| 308 | case RMIHIDTOOL_CMD_WRITE: |
Andrew Duggan | 849fea3 | 2014-11-13 21:15:48 -0800 | [diff] [blame] | 309 | i = 0; |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 310 | start = data; |
| 311 | memset(report, 0, sizeof(report)); |
| 312 | while (find_token(start, token, &end)) { |
| 313 | start = end; |
Andrew Duggan | 849fea3 | 2014-11-13 21:15:48 -0800 | [diff] [blame] | 314 | report[i++] = (unsigned char)strtol(token, NULL, 0); |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 315 | ++len; |
| 316 | } |
| 317 | |
| 318 | if (device->Write(addr, report, len) < 0) { |
| 319 | fprintf(stderr, "Failed to Write Report\n"); |
| 320 | return -1; |
| 321 | } |
| 322 | break; |
| 323 | case RMIHIDTOOL_CMD_FW_ID: |
| 324 | device->ScanPDT(); |
| 325 | device->QueryBasicProperties(); |
| 326 | fprintf(stdout, "firmware id: %lu\n", device->GetFirmwareID()); |
| 327 | break; |
| 328 | case RMIHIDTOOL_CMD_PROPS: |
| 329 | device->ScanPDT(); |
| 330 | device->QueryBasicProperties(); |
| 331 | device->PrintProperties(); |
| 332 | break; |
| 333 | case RMIHIDTOOL_CMD_ATTN: |
| 334 | report_attn = 1; |
| 335 | while(report_attn) { |
| 336 | unsigned int bytes = 256; |
Andrew Duggan | f73fdc7 | 2014-11-09 11:02:22 -0800 | [diff] [blame] | 337 | rc = device->GetAttentionReport(NULL, |
| 338 | RMI_INTERUPT_SOURCES_ALL_MASK, |
| 339 | report, &bytes); |
Andrew Duggan | f6e278f | 2014-10-07 21:58:02 -0700 | [diff] [blame] | 340 | if (rc > 0) { |
| 341 | print_buffer(report, bytes); |
| 342 | fprintf(stdout, "\n"); |
| 343 | } |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 344 | } |
| 345 | break; |
| 346 | case RMIHIDTOOL_CMD_PRINT_FUNCTIONS: |
| 347 | device->ScanPDT(); |
| 348 | device->PrintFunctions(); |
| 349 | break; |
Andrew Duggan | 161c83c | 2015-05-06 18:06:03 -0700 | [diff] [blame] | 350 | case RMIHIDTOOL_CMD_REBIND_DRIVER: |
| 351 | device->RebindDriver(); |
| 352 | break; |
Andrew Duggan | 2c24adb | 2015-05-06 18:18:06 -0700 | [diff] [blame^] | 353 | case RMIHIDTOOL_CMD_PRINT_DEVICE_INFO: |
| 354 | device->PrintDeviceInfo(); |
| 355 | break; |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 356 | case RMIHIDTOOL_CMD_INTERACTIVE: |
| 357 | default: |
| 358 | interactive(device, report); |
| 359 | break; |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 360 | } |
| 361 | |
Andrew Duggan | 63078d5 | 2014-04-08 11:20:15 -0700 | [diff] [blame] | 362 | device->Close(); |
Andrew Duggan | 4e81125 | 2014-04-03 15:17:57 -0700 | [diff] [blame] | 363 | |
| 364 | return 0; |
Andrew Duggan | e9a5cd0 | 2014-04-29 13:34:42 -0700 | [diff] [blame] | 365 | } |