├── Android.mk ├── Application.mk ├── LICENSE ├── README.md ├── build.sh ├── release ├── arm64-v8a │ ├── rucky-hid │ └── rucky-hid.sha512 ├── armeabi-v7a │ ├── rucky-hid │ └── rucky-hid.sha512 ├── genSHA512.sh ├── x86 │ ├── rucky-hid │ └── rucky-hid.sha512 └── x86_64 │ ├── rucky-hid │ └── rucky-hid.sha512 └── rucky-hid.c /Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH:= $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := rucky-hid 6 | 7 | LOCAL_SRC_FILES := rucky-hid.c 8 | 9 | LOCAL_CFLAGS += -fPIE 10 | LOCAL_LDFLAGS += -fPIE -pie 11 | 12 | include $(BUILD_EXECUTABLE) 13 | -------------------------------------------------------------------------------- /Application.mk: -------------------------------------------------------------------------------- 1 | APP_PLATFORM := android-19 2 | APP_ABI := armeabi-v7a arm64-v8a x86 x86_64 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Mayank Metha D 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rucky-Legacy-HID 2 | 3 | Legacy Rucky Binaries. Will not be supported now. 4 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | $HOME/Library/Android/sdk/ndk-bundle/ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk NDK_APPLICATION_MK=Application.mk 2 | -------------------------------------------------------------------------------- /release/arm64-v8a/rucky-hid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mayankmetha/Rucky-Legacy-HID/f09c92d5c8f2ea57bb214c21e1525d49298792af/release/arm64-v8a/rucky-hid -------------------------------------------------------------------------------- /release/arm64-v8a/rucky-hid.sha512: -------------------------------------------------------------------------------- 1 | 80c962c634d9b3a664cfde223d172dcefa6c57249b64b84b88853a5525fa4230e0cb5998ca1c5278fff2963dea0fa8b3f552b3363b874849e79c7f4377635815 2 | -------------------------------------------------------------------------------- /release/armeabi-v7a/rucky-hid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mayankmetha/Rucky-Legacy-HID/f09c92d5c8f2ea57bb214c21e1525d49298792af/release/armeabi-v7a/rucky-hid -------------------------------------------------------------------------------- /release/armeabi-v7a/rucky-hid.sha512: -------------------------------------------------------------------------------- 1 | 8f25323ed4c13a85837c10c0eb12fc0395a98749f2fb58a18a40de9d84b72fa6787177afa2834c24607801a125cfd23b21d775e40d7bb94f9832c999be0e2cfe 2 | -------------------------------------------------------------------------------- /release/genSHA512.sh: -------------------------------------------------------------------------------- 1 | openssl sha512 ./arm64-v8a/rucky-hid | cut -d"=" -f2 | cut -d" " -f2 > ./arm64-v8a/rucky-hid.sha512 2 | openssl sha512 ./armeabi-v7a/rucky-hid | cut -d"=" -f2 | cut -d" " -f2 > ./armeabi-v7a/rucky-hid.sha512 3 | openssl sha512 ./x86/rucky-hid | cut -d"=" -f2 | cut -d" " -f2 > ./x86/rucky-hid.sha512 4 | openssl sha512 ./x86_64/rucky-hid | cut -d"=" -f2 | cut -d" " -f2 > ./x86_64/rucky-hid.sha512 5 | -------------------------------------------------------------------------------- /release/x86/rucky-hid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mayankmetha/Rucky-Legacy-HID/f09c92d5c8f2ea57bb214c21e1525d49298792af/release/x86/rucky-hid -------------------------------------------------------------------------------- /release/x86/rucky-hid.sha512: -------------------------------------------------------------------------------- 1 | 59dabeb45e671d5dee1f534e4a6787b4be37035c3113cf115b153632b36f80e89f0e897a4abfd4528cb78e09353b532408de4717d0fe00db566973e636028b8d 2 | -------------------------------------------------------------------------------- /release/x86_64/rucky-hid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mayankmetha/Rucky-Legacy-HID/f09c92d5c8f2ea57bb214c21e1525d49298792af/release/x86_64/rucky-hid -------------------------------------------------------------------------------- /release/x86_64/rucky-hid.sha512: -------------------------------------------------------------------------------- 1 | 4936d23487a576285c372add741221d1a679f4460135d8562a80c0b52fee5f73afbe04d328881ad2766ba64e5033022892833ef2cae786fdc46526ca483d099c 2 | -------------------------------------------------------------------------------- /rucky-hid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #define BUF_LEN 512 12 | 13 | struct options { 14 | const char *opt; 15 | unsigned char val; 16 | }; 17 | 18 | static struct options kmod[] = { 19 | {.opt = "left-ctrl", .val = 0x01}, 20 | {.opt = "right-ctrl", .val = 0x10}, 21 | {.opt = "left-shift", .val = 0x02}, 22 | {.opt = "right-shift", .val = 0x20}, 23 | {.opt = "left-alt", .val = 0x04}, 24 | {.opt = "right-alt", .val = 0x40}, 25 | {.opt = "left-meta", .val = 0x08}, 26 | {.opt = "right-meta", .val = 0x80}, 27 | {.opt = NULL} 28 | }; 29 | 30 | static struct options kval[] = { 31 | {.opt = "a", .val = 0x04}, 32 | {.opt = "b", .val = 0x05}, 33 | {.opt = "c", .val = 0x06}, 34 | {.opt = "d", .val = 0x07}, 35 | {.opt = "e", .val = 0x08}, 36 | {.opt = "f", .val = 0x09}, 37 | {.opt = "g", .val = 0x0a}, 38 | {.opt = "h", .val = 0x0b}, 39 | {.opt = "i", .val = 0x0c}, 40 | {.opt = "j", .val = 0x0d}, 41 | {.opt = "k", .val = 0x0e}, 42 | {.opt = "l", .val = 0x0f}, 43 | {.opt = "m", .val = 0x10}, 44 | {.opt = "n", .val = 0x11}, 45 | {.opt = "o", .val = 0x12}, 46 | {.opt = "p", .val = 0x13}, 47 | {.opt = "q", .val = 0x14}, 48 | {.opt = "r", .val = 0x15}, 49 | {.opt = "s", .val = 0x16}, 50 | {.opt = "t", .val = 0x17}, 51 | {.opt = "u", .val = 0x18}, 52 | {.opt = "v", .val = 0x19}, 53 | {.opt = "w", .val = 0x1a}, 54 | {.opt = "x", .val = 0x1b}, 55 | {.opt = "y", .val = 0x1c}, 56 | {.opt = "z", .val = 0x1d}, 57 | {.opt = "1", .val = 0x1e}, 58 | {.opt = "2", .val = 0x1f}, 59 | {.opt = "3", .val = 0x20}, 60 | {.opt = "4", .val = 0x21}, 61 | {.opt = "5", .val = 0x22}, 62 | {.opt = "6", .val = 0x23}, 63 | {.opt = "7", .val = 0x24}, 64 | {.opt = "8", .val = 0x25}, 65 | {.opt = "9", .val = 0x26}, 66 | {.opt = "0", .val = 0x27}, 67 | {.opt = "return", .val = 0x28}, 68 | {.opt = "enter", .val = 0x28}, 69 | {.opt = "esc", .val = 0x29}, 70 | {.opt = "escape", .val = 0x29}, 71 | {.opt = "bckspc", .val = 0x2a}, 72 | {.opt = "backspace", .val = 0x2a}, 73 | {.opt = "tab", .val = 0x2b}, 74 | {.opt = "space", .val = 0x2c}, 75 | {.opt = "minus", .val = 0x2d}, 76 | {.opt = "dash", .val = 0x2d}, 77 | {.opt = "equals", .val = 0x2e}, 78 | {.opt = "equal", .val = 0x2e}, 79 | {.opt = "lbracket", .val = 0x2f}, 80 | {.opt = "rbracket", .val = 0x30}, 81 | {.opt = "backslash", .val = 0x31}, 82 | {.opt = "hash", .val = 0x32}, 83 | {.opt = "number", .val = 0x32}, 84 | {.opt = "semicolon", .val = 0x33}, 85 | {.opt = "quote", .val = 0x34}, 86 | {.opt = "backquote", .val = 0x35}, 87 | {.opt = "tilde", .val = 0x35}, 88 | {.opt = "comma", .val = 0x36}, 89 | {.opt = "period", .val = 0x37}, 90 | {.opt = "stop", .val = 0x37}, 91 | {.opt = "slash", .val = 0x38}, 92 | {.opt = "caps-lock", .val = 0x39}, 93 | {.opt = "capslock", .val = 0x39}, 94 | {.opt = "f1", .val = 0x3a}, 95 | {.opt = "f2", .val = 0x3b}, 96 | {.opt = "f3", .val = 0x3c}, 97 | {.opt = "f4", .val = 0x3d}, 98 | {.opt = "f5", .val = 0x3e}, 99 | {.opt = "f6", .val = 0x3f}, 100 | {.opt = "f7", .val = 0x40}, 101 | {.opt = "f8", .val = 0x41}, 102 | {.opt = "f9", .val = 0x42}, 103 | {.opt = "f10", .val = 0x43}, 104 | {.opt = "f11", .val = 0x44}, 105 | {.opt = "f12", .val = 0x45}, 106 | {.opt = "print", .val = 0x46}, 107 | {.opt = "scroll-lock", .val = 0x47}, 108 | {.opt = "scrolllock", .val = 0x47}, 109 | {.opt = "pause", .val = 0x48}, 110 | {.opt = "insert", .val = 0x49}, 111 | {.opt = "home", .val = 0x4a}, 112 | {.opt = "pageup", .val = 0x4b}, 113 | {.opt = "pgup", .val = 0x4b}, 114 | {.opt = "del", .val = 0x4c}, 115 | {.opt = "delete", .val = 0x4c}, 116 | {.opt = "end", .val = 0x4d}, 117 | {.opt = "pagedown", .val = 0x4e}, 118 | {.opt = "pgdown", .val = 0x4e}, 119 | {.opt = "right", .val = 0x4f}, 120 | {.opt = "left", .val = 0x50}, 121 | {.opt = "down", .val = 0x51}, 122 | {.opt = "up", .val = 0x52}, 123 | {.opt = "num-lock", .val = 0x53}, 124 | {.opt = "numlock", .val = 0x53}, 125 | {.opt = "kp-divide", .val = 0x54}, 126 | {.opt = "kp-multiply", .val = 0x55}, 127 | {.opt = "kp-minus", .val = 0x56}, 128 | {.opt = "kp-plus", .val = 0x57}, 129 | {.opt = "kp-enter", .val = 0x58}, 130 | {.opt = "kp-return", .val = 0x58}, 131 | {.opt = "kp-1", .val = 0x59}, 132 | {.opt = "kp-2", .val = 0x5a}, 133 | {.opt = "kp-3", .val = 0x5b}, 134 | {.opt = "kp-4", .val = 0x5c}, 135 | {.opt = "kp-5", .val = 0x5d}, 136 | {.opt = "kp-6", .val = 0x5e}, 137 | {.opt = "kp-7", .val = 0x5f}, 138 | {.opt = "kp-8", .val = 0x60}, 139 | {.opt = "kp-9", .val = 0x61}, 140 | {.opt = "kp-0", .val = 0x62}, 141 | {.opt = "kp-period", .val = 0x63}, 142 | {.opt = "kp-stop", .val = 0x63}, 143 | {.opt = "application", .val = 0x65}, 144 | {.opt = "power", .val = 0x66}, 145 | {.opt = "kp-equals", .val = 0x67}, 146 | {.opt = "kp-equal", .val = 0x67}, 147 | {.opt = "f13", .val = 0x68}, 148 | {.opt = "f14", .val = 0x69}, 149 | {.opt = "f15", .val = 0x6a}, 150 | {.opt = "f16", .val = 0x6b}, 151 | {.opt = "f17", .val = 0x6c}, 152 | {.opt = "f18", .val = 0x6d}, 153 | {.opt = "f19", .val = 0x6e}, 154 | {.opt = "f20", .val = 0x6f}, 155 | {.opt = "f21", .val = 0x70}, 156 | {.opt = "f22", .val = 0x71}, 157 | {.opt = "f23", .val = 0x72}, 158 | {.opt = "f24", .val = 0x73}, 159 | {.opt = "execute", .val = 0x74}, 160 | {.opt = "help", .val = 0x75}, 161 | {.opt = "menu", .val = 0x76}, 162 | {.opt = "select", .val = 0x77}, 163 | {.opt = "cancel", .val = 0x78}, 164 | {.opt = "redo", .val = 0x79}, 165 | {.opt = "undo", .val = 0x7a}, 166 | {.opt = "cut", .val = 0x7b}, 167 | {.opt = "copy", .val = 0x7c}, 168 | {.opt = "paste", .val = 0x7d}, 169 | {.opt = "find", .val = 0x7e}, 170 | {.opt = "mute", .val = 0x7f}, 171 | {.opt = "volume-up", .val = 0x80}, // These are multimedia keys, they will not work on standard keyboard, they need a different USB descriptor 172 | {.opt = "volume-down", .val = 0x81}, 173 | {.opt = NULL} 174 | }; 175 | 176 | int keyboard_fill_report(char report[8], char buf[BUF_LEN], int *hold) 177 | { 178 | char *tok = strtok(buf, " "); 179 | int key = 0; 180 | int i = 0; 181 | 182 | for (; tok != NULL; tok = strtok(NULL, " ")) { 183 | 184 | if (strncmp(tok, "--", 2) == 0) 185 | tok += 2; 186 | 187 | if (strcmp(tok, "quit") == 0) 188 | return -1; 189 | 190 | if (strcmp(tok, "hold") == 0) { 191 | *hold = 1; 192 | continue; 193 | } 194 | 195 | if (key < 6) { 196 | for (i = 0; kval[i].opt != NULL; i++) 197 | if (strcmp(tok, kval[i].opt) == 0) { 198 | report[2 + key++] = kval[i].val; 199 | break; 200 | } 201 | if (kval[i].opt != NULL) 202 | continue; 203 | } 204 | 205 | for (i = 0; kmod[i].opt != NULL; i++) 206 | if (strcmp(tok, kmod[i].opt) == 0) { 207 | report[0] = report[0] | kmod[i].val; 208 | break; 209 | } 210 | if (kmod[i].opt != NULL) 211 | continue; 212 | 213 | if (key < 6) 214 | fprintf(stderr, "unknown option: %s\n", tok); 215 | } 216 | return 8; 217 | } 218 | 219 | static struct options mmod[] = { 220 | {.opt = "--b1", .val = 0x01}, 221 | {.opt = "--b2", .val = 0x02}, 222 | {.opt = "--b3", .val = 0x04}, 223 | {.opt = NULL} 224 | }; 225 | 226 | int mouse_fill_report(char report[8], char buf[BUF_LEN], int *hold) 227 | { 228 | char *tok = strtok(buf, " "); 229 | int mvt = 0; 230 | int i = 0; 231 | for (; tok != NULL; tok = strtok(NULL, " ")) { 232 | 233 | if (strcmp(tok, "--quit") == 0) 234 | return -1; 235 | 236 | if (strcmp(tok, "--hold") == 0) { 237 | *hold = 1; 238 | continue; 239 | } 240 | 241 | for (i = 0; mmod[i].opt != NULL; i++) 242 | if (strcmp(tok, mmod[i].opt) == 0) { 243 | report[0] = report[0] | mmod[i].val; 244 | break; 245 | } 246 | if (mmod[i].opt != NULL) 247 | continue; 248 | 249 | if (!(tok[0] == '-' && tok[1] == '-') && mvt < 2) { 250 | errno = 0; 251 | report[1 + mvt++] = (char)strtol(tok, NULL, 0); 252 | if (errno != 0) { 253 | fprintf(stderr, "Bad value:'%s'\n", tok); 254 | report[1 + mvt--] = 0; 255 | } 256 | continue; 257 | } 258 | 259 | fprintf(stderr, "unknown option: %s\n", tok); 260 | } 261 | return 3; 262 | } 263 | 264 | static struct options jmod[] = { 265 | {.opt = "--b1", .val = 0x10}, 266 | {.opt = "--b2", .val = 0x20}, 267 | {.opt = "--b3", .val = 0x40}, 268 | {.opt = "--b4", .val = 0x80}, 269 | {.opt = "--hat1", .val = 0x00}, 270 | {.opt = "--hat2", .val = 0x01}, 271 | {.opt = "--hat3", .val = 0x02}, 272 | {.opt = "--hat4", .val = 0x03}, 273 | {.opt = "--hatneutral", .val = 0x04}, 274 | {.opt = NULL} 275 | }; 276 | 277 | int joystick_fill_report(char report[8], char buf[BUF_LEN], int *hold) 278 | { 279 | char *tok = strtok(buf, " "); 280 | int mvt = 0; 281 | int i = 0; 282 | 283 | *hold = 1; 284 | 285 | /* set default hat position: neutral */ 286 | report[3] = 0x04; 287 | 288 | for (; tok != NULL; tok = strtok(NULL, " ")) { 289 | 290 | if (strcmp(tok, "--quit") == 0) 291 | return -1; 292 | 293 | for (i = 0; jmod[i].opt != NULL; i++) 294 | if (strcmp(tok, jmod[i].opt) == 0) { 295 | report[3] = (report[3] & 0xF0) | jmod[i].val; 296 | break; 297 | } 298 | if (jmod[i].opt != NULL) 299 | continue; 300 | 301 | if (!(tok[0] == '-' && tok[1] == '-') && mvt < 3) { 302 | errno = 0; 303 | report[mvt++] = (char)strtol(tok, NULL, 0); 304 | if (errno != 0) { 305 | fprintf(stderr, "Bad value:'%s'\n", tok); 306 | report[mvt--] = 0; 307 | } 308 | continue; 309 | } 310 | 311 | fprintf(stderr, "unknown option: %s\n", tok); 312 | } 313 | return 4; 314 | } 315 | 316 | void print_options(char c) 317 | { 318 | int i = 0; 319 | 320 | if (c == 'k') { 321 | printf(" keyboard options:\n" 322 | " hold\n"); 323 | for (i = 0; kmod[i].opt != NULL; i++) 324 | printf("\t\t%s\n", kmod[i].opt); 325 | printf("\n keyboard values:\n" 326 | " [a-z] or [0-9] or\n"); 327 | for (i = 0; kval[i].opt != NULL; i++) 328 | printf("\t\t%-8s%s", kval[i].opt, i % 2 ? "\n" : ""); 329 | printf("\n"); 330 | } else if (c == 'm') { 331 | printf(" mouse options:\n" 332 | " --hold\n"); 333 | for (i = 0; mmod[i].opt != NULL; i++) 334 | printf("\t\t%s\n", mmod[i].opt); 335 | printf("\n mouse values:\n" 336 | " Two signed numbers\n\n"); 337 | } else { 338 | printf(" joystick options:\n"); 339 | for (i = 0; jmod[i].opt != NULL; i++) 340 | printf("\t\t%s\n", jmod[i].opt); 341 | printf("\n joystick values:\n" 342 | " three signed numbers\n" 343 | "--quit to close\n"); 344 | } 345 | } 346 | 347 | int main(int argc, const char *argv[]) 348 | { 349 | const char *filename = NULL; 350 | int fd = 0; 351 | char buf[BUF_LEN]; 352 | int cmd_len; 353 | char report[8]; 354 | int to_send = 8; 355 | int hold = 0; 356 | fd_set rfds; 357 | int retval, i; 358 | 359 | if (argc < 3) { 360 | fprintf(stderr, "Usage: %s devname mouse|keyboard|joystick\n", 361 | argv[0]); 362 | 363 | print_options('k'); 364 | print_options('m'); 365 | print_options('j'); 366 | 367 | return 1; 368 | } 369 | 370 | if (argv[2][0] != 'k' && argv[2][0] != 'm' && argv[2][0] != 'j') 371 | return 2; 372 | 373 | filename = argv[1]; 374 | 375 | if ((fd = open(filename, O_RDWR, 0666)) == -1) { 376 | perror(filename); 377 | return 3; 378 | } 379 | 380 | while (42) { 381 | 382 | FD_ZERO(&rfds); 383 | FD_SET(STDIN_FILENO, &rfds); 384 | FD_SET(fd, &rfds); 385 | 386 | retval = select(fd + 1, &rfds, NULL, NULL, NULL); 387 | if (retval == -1 && errno == EINTR) 388 | continue; 389 | if (retval < 0) { 390 | perror("select()"); 391 | return 4; 392 | } 393 | 394 | if (FD_ISSET(fd, &rfds)) { 395 | cmd_len = read(fd, buf, BUF_LEN - 1); 396 | printf("recv report:"); 397 | for (i = 0; i < cmd_len; i++) 398 | printf(" %02x", buf[i]); 399 | printf("\n"); 400 | } 401 | 402 | if (FD_ISSET(STDIN_FILENO, &rfds)) { 403 | memset(report, 0x0, sizeof(report)); 404 | cmd_len = read(STDIN_FILENO, buf, BUF_LEN - 1); 405 | 406 | if (cmd_len == 0) 407 | break; 408 | 409 | buf[cmd_len - 1] = '\0'; 410 | hold = 0; 411 | 412 | memset(report, 0x0, sizeof(report)); 413 | if (argv[2][0] == 'k') 414 | to_send = keyboard_fill_report(report, buf, &hold); 415 | else if (argv[2][0] == 'm') 416 | to_send = mouse_fill_report(report, buf, &hold); 417 | else 418 | to_send = joystick_fill_report(report, buf, &hold); 419 | 420 | if (to_send == -1) 421 | break; 422 | 423 | if (write(fd, report, to_send) != to_send) { 424 | perror(filename); 425 | return 5; 426 | } 427 | if (!hold) { 428 | memset(report, 0x0, sizeof(report)); 429 | if (write(fd, report, to_send) != to_send) { 430 | perror(filename); 431 | return 6; 432 | } 433 | } 434 | } 435 | } 436 | 437 | close(fd); 438 | return 0; 439 | } 440 | --------------------------------------------------------------------------------