Components and supplies
Arduino Micro
Ewent controller
Tools and machines
Soldering iron (generic)
Project description
Code
Keyboard controller
c_cpp
This is the code for the keyboard and mouse controller.
1/* 2 * 3 * Keyboard and Mouse controller 4 * some comments might be in hungarian, sorry 5 * Peter Dio 2017 6 * 7 */ 8#define BA 5 // Button A 9#define BB 6 // Button B 10#define BX 8 // Button X 11#define BY 7 // Button Y 12 13#define BU 23 // Button Up 14#define BD 0 // Button Down 15#define BL 2 // Button Left 16#define BR 15 // Button Right 17 18#define BL1 11 // Button Left 1 19#define BR1 3 // Button Right 1 20#define BL2 12 // Button Left 2 21#define BR2 4 // Button Right 2 22#define BLS 13 // Button Left Stick 23#define BRS 22 // Button Right Stick 24 25#define BMODE 1 // Button Mode 26#define BSTART 10 // Button Start 27#define BSELECT 16 // Button Select 28#define BAUTO 9 // Button Auto 29#define BTURBO 14 // Button Turbo 30#define BCLEAR 17 // Button Clear 31 32#define SLX 21 // Stick Left X 33#define SLY 20 // Stick Left Y 34#define SRX 19 // Stick Right X 35#define SRY 18 // Stick Right Y 36 37#include "Keyboard.h" 38#include "Mouse.h" 39 40int mode = 0, // Segédváltozó 41 nr_modes = 3, // Number of modes 42 aSLX, // Analog beolvasás 43 aSLY, // Analog beolvasás 44 aSRX, // Analog beolvasás 45 aSRY, // Analog beolvasás 46 sense = 3; // Mouse sensitivity 1-5 47//============================================================================================================================================================================================================ 48void setup() { 49 pinMode(BA, INPUT_PULLUP); 50 pinMode(BB, INPUT_PULLUP); 51 pinMode(BX, INPUT_PULLUP); 52 pinMode(BY, INPUT_PULLUP); 53 pinMode(BU, INPUT_PULLUP); 54 pinMode(BD, INPUT_PULLUP); 55 pinMode(BL, INPUT_PULLUP); 56 pinMode(BR, INPUT_PULLUP); 57 pinMode(BL1, INPUT_PULLUP); 58 pinMode(BR1, INPUT_PULLUP); 59 pinMode(BL2, INPUT_PULLUP); 60 pinMode(BR2, INPUT_PULLUP); 61 pinMode(BLS, INPUT_PULLUP); 62 pinMode(BRS, INPUT_PULLUP); 63 pinMode(BMODE, INPUT_PULLUP); 64 pinMode(BSTART, INPUT_PULLUP); 65 pinMode(BSELECT, INPUT_PULLUP); 66 pinMode(BAUTO, INPUT_PULLUP); 67 pinMode(BTURBO, INPUT_PULLUP); 68 pinMode(BCLEAR, INPUT_PULLUP); 69 pinMode(SLX, INPUT); 70 pinMode(SLY, INPUT); 71 pinMode(SRX, INPUT); 72 pinMode(SRY, INPUT); 73 pinMode(30, INPUT); 74 Keyboard.begin(); 75 Mouse.begin(); 76} 77//============================================================================================================================================================================================================ 78void loop() { 79 if(mode >= (nr_modes)){ 80 mode = 0; 81 } 82//============================================================================================================================================================================================================ 83 ///////////////////////////////////////////////////////////// MODE 2 84 if(mode == 2){ 85 digitalWrite(30, 1); 86 87 if(digitalRead(BA) == LOW){//////////////////////////////// ABXY 88 Keyboard.press('a'); 89 } 90 if(digitalRead(BA) == HIGH){ 91 Keyboard.release('a'); 92 } 93 if(digitalRead(BB) == LOW){ 94 Keyboard.press('b'); 95 } 96 if(digitalRead(BB) == HIGH){ 97 Keyboard.release('b'); 98 } 99 if(digitalRead(BX) == LOW){ 100 Keyboard.press('x'); 101 } 102 if(digitalRead(BX) == HIGH){ 103 Keyboard.release('x'); 104 } 105 if(digitalRead(BY) == LOW){ 106 Keyboard.press('y'); 107 } 108 if(digitalRead(BY) == HIGH){ 109 Keyboard.release('y'); 110 } 111 112 if(digitalRead(BU) == LOW){//////////////////////////////// UDLR 113 Keyboard.press('u'); 114 } 115 if(digitalRead(BU) == HIGH){ 116 Keyboard.release('u'); 117 } 118 if(digitalRead(BD) == LOW){ 119 Keyboard.press('d'); 120 } 121 if(digitalRead(BD) == HIGH){ 122 Keyboard.release('d'); 123 } 124 if(digitalRead(BL) == LOW){ 125 Keyboard.press('l'); 126 } 127 if(digitalRead(BL) == HIGH){ 128 Keyboard.release('l'); 129 } 130 if(digitalRead(BR) == LOW){ 131 Keyboard.press('r'); 132 } 133 if(digitalRead(BR) == HIGH){ 134 Keyboard.release('r'); 135 } 136 137 if(digitalRead(BL1) == LOW){/////////////////////////////// 123456 138 Keyboard.press('1'); 139 } 140 if(digitalRead(BL1) == HIGH){ 141 Keyboard.release('1'); 142 } 143 if(digitalRead(BR1) == LOW){ 144 Keyboard.press('2'); 145 } 146 if(digitalRead(BR1) == HIGH){ 147 Keyboard.release('2'); 148 } 149 if(digitalRead(BL2) == LOW){ 150 Keyboard.press('3'); 151 } 152 if(digitalRead(BL2) == HIGH){ 153 Keyboard.release('3'); 154 } 155 if(digitalRead(BR2) == LOW){ 156 Keyboard.press('4'); 157 } 158 if(digitalRead(BR2) == HIGH){ 159 Keyboard.release('4'); 160 } 161 if(digitalRead(BLS) == LOW){ 162 Keyboard.press('5'); 163 } 164 if(digitalRead(BLS) == HIGH){ 165 Keyboard.release('5'); 166 } 167 if(digitalRead(BRS) == LOW){ 168 Keyboard.press('6'); 169 } 170 if(digitalRead(BRS) == HIGH){ 171 Keyboard.release('6'); 172 } 173 174 if(digitalRead(BSTART) == LOW){//////////////////////////// FUNCTION KEYS 175 Keyboard.press('s'); 176 } 177 if(digitalRead(BSTART) == HIGH){ 178 Keyboard.release('s'); 179 } 180 if(digitalRead(BSELECT) == LOW){ 181 Keyboard.press('e'); 182 } 183 if(digitalRead(BSELECT) == HIGH){ 184 Keyboard.release('e'); 185 } 186 if(digitalRead(BAUTO) == LOW){ 187 Keyboard.press('o'); 188 } 189 if(digitalRead(BAUTO) == HIGH){ 190 Keyboard.release('o'); 191 } 192 if(digitalRead(BTURBO) == LOW){ 193 Keyboard.press('t'); 194 } 195 if(digitalRead(BTURBO) == HIGH){ 196 Keyboard.release('t'); 197 } 198 pinMode(BCLEAR, INPUT_PULLUP); 199 if(digitalRead(BCLEAR) == LOW){ 200 Keyboard.press('c'); 201 } 202 pinMode(BCLEAR, INPUT_PULLUP); 203 if(digitalRead(BCLEAR) == HIGH){ 204 Keyboard.release('c'); 205 } 206 if(digitalRead(BMODE) == LOW){//////////////////////////// MODE SELECTION 207 mode++; 208 digitalWrite(30, 0); 209 delay(100); 210 digitalWrite(30, 1); 211 delay(200); 212 } 213 } 214 ///////////////////////////////////////////////////////////// MODE 2 215//============================================================================================================================================================================================================ 216 ///////////////////////////////////////////////////////////// MODE 0 217 if(mode==0){ 218 if(sense >= 6){ 219 sense = 1; 220 } 221 digitalWrite(30, 1); 222 223 if(digitalRead(BA) == LOW){//////////////////////////////// ABXY 224 Mouse.press(); 225 } 226 if(digitalRead(BA) == HIGH){ 227 Mouse.release(); 228 } 229 if(digitalRead(BB) == LOW){ 230 Mouse.press(2); 231 } 232 if(digitalRead(BB) == HIGH){ 233 Mouse.release(2); 234 } 235 if(digitalRead(BX) == LOW){ 236 Keyboard.press(KEY_RETURN); 237 } 238 if(digitalRead(BX) == HIGH){ 239 Keyboard.release(KEY_RETURN); 240 } 241 if(digitalRead(BY) == LOW){ 242 Keyboard.press(KEY_BACKSPACE); 243 } 244 if(digitalRead(BY) == HIGH){ 245 Keyboard.release(KEY_BACKSPACE); 246 } 247 248 if(digitalRead(BU) == LOW){//////////////////////////////// UDLR 249 Keyboard.press(KEY_UP_ARROW); 250 } 251 if(digitalRead(BU) == HIGH){ 252 Keyboard.release(KEY_UP_ARROW); 253 } 254 if(digitalRead(BD) == LOW){ 255 Keyboard.press(KEY_DOWN_ARROW); 256 } 257 if(digitalRead(BD) == HIGH){ 258 Keyboard.release(KEY_DOWN_ARROW); 259 } 260 if(digitalRead(BL) == LOW){ 261 Keyboard.press(KEY_LEFT_ARROW); 262 } 263 if(digitalRead(BL) == HIGH){ 264 Keyboard.release(KEY_LEFT_ARROW); 265 } 266 if(digitalRead(BR) == LOW){ 267 Keyboard.press(KEY_RIGHT_ARROW); 268 } 269 if(digitalRead(BR) == HIGH){ 270 Keyboard.release(KEY_RIGHT_ARROW); 271 } 272 273 if(digitalRead(BL1) == LOW){/////////////////////////////// 123456 274 Keyboard.press(KEY_LEFT_SHIFT); 275 } 276 if(digitalRead(BL1) == HIGH){ 277 Keyboard.release(KEY_LEFT_SHIFT); 278 } 279 if(digitalRead(BR1) == LOW){ 280 Keyboard.press(KEY_RIGHT_ALT); 281 } 282 if(digitalRead(BR1) == HIGH){ 283 Keyboard.release(KEY_RIGHT_ALT); 284 } 285 if(digitalRead(BL2) == LOW){ 286 Keyboard.press(KEY_LEFT_CTRL); 287 } 288 if(digitalRead(BL2) == HIGH){ 289 Keyboard.release(KEY_LEFT_CTRL); 290 } 291 if(digitalRead(BR2) == LOW){ 292 Keyboard.press(' '); 293 } 294 if(digitalRead(BR2) == HIGH){ 295 Keyboard.release(' '); 296 } 297 if(digitalRead(BLS) == LOW){ 298 sense++; 299 delay(200); 300 } 301 if(digitalRead(BRS) == LOW){ 302 Mouse.press(4); 303 } 304 if(digitalRead(BRS) == HIGH){ 305 Mouse.release(4); 306 } 307 308 if(digitalRead(BSTART) == LOW){//////////////////////////// FUNCTION KEYS 309 Keyboard.press(KEY_ESC); 310 } 311 if(digitalRead(BSTART) == HIGH){ 312 Keyboard.release(KEY_ESC); 313 } 314 if(digitalRead(BSELECT) == LOW){ 315 Keyboard.press(KEY_LEFT_GUI); 316 } 317 if(digitalRead(BSELECT) == HIGH){ 318 Keyboard.release(KEY_LEFT_GUI); 319 } 320 pinMode(BCLEAR, INPUT_PULLUP); 321 if(digitalRead(BCLEAR) == LOW){ 322 Keyboard.press(KEY_LEFT_ALT); 323 delay(100); 324 Keyboard.press(KEY_F4); 325 delay(100); 326 Keyboard.release(KEY_F4); 327 Keyboard.release(KEY_LEFT_ALT); 328 delay(100); 329 } 330 331 if(digitalRead(BMODE) == LOW){//////////////////////////// MODE SELECTION 332 mode++; 333 digitalWrite(30, 0); 334 delay(100); 335 digitalWrite(30, 1); 336 delay(100); 337 digitalWrite(30, 0); 338 delay(100); 339 } 340 341 aSLX = analogRead(SLX);/////////////////////////////////////// CURSOR AND WHEEL 342 aSLY = analogRead(SLY); 343 //aSRX = analogRead(SRX); 344 aSRY = analogRead(SRY); 345 346 if(aSLX >= 509){/////////////////////////////////////// CURSOR X 347 if(aSLX >= 600){ 348 if(aSLX >= 900){ 349 Mouse.move(-2*sense, 0, 0); 350 } 351 else{ 352 Mouse.move(-1*sense, 0, 0); 353 } 354 } 355 else{ 356 Mouse.move(-1, 0, 0); 357 } 358 } 359 if(aSLX <= 501){ 360 if(aSLX <= 400){ 361 if(aSLX <= 100){ 362 Mouse.move(2*sense, 0, 0); 363 } 364 else{ 365 Mouse.move(sense, 0, 0); 366 } 367 } 368 else{ 369 Mouse.move(1, 0, 0); 370 } 371 } 372 373 if(aSLY >= 526){ ////////////////////////////////////// CURSOR Y 374 if(aSLY >= 600){ 375 if(aSLY >= 900){ 376 Mouse.move(0, -2*sense, 0); 377 } 378 else{ 379 Mouse.move(0, -1*sense, 0); 380 } 381 } 382 else{ 383 Mouse.move(0, -1, 0); 384 } 385 } 386 if(aSLY <= 518){ 387 if(aSLY <= 400){ 388 if(aSLY <= 100){ 389 Mouse.move(0, 2*sense, 0); 390 } 391 else{ 392 Mouse.move(0, 1*sense, 0); 393 } 394 } 395 else{ 396 Mouse.move(0, 1, 0); 397 } 398 } 399 400 if(aSRY >= 519){/////////////////////////////////// WHEEL 401 if(aSRY >= 600){ 402 if(aSRY >= 900){ 403 Mouse.move(0, 0, 1); 404 delay(50); 405 } 406 else{ 407 Mouse.move(0, 0, 1); 408 delay(100); 409 } 410 } 411 else{ 412 Mouse.move(0, 0, 1); 413 delay(200); 414 } 415 } 416 if(aSRY <= 511){ 417 if(aSRY <= 400){ 418 if(aSRY <= 100){ 419 Mouse.move(0, 0, -1); 420 delay(50); 421 } 422 else{ 423 Mouse.move(0, 0, -1); 424 delay(100); 425 } 426 } 427 else{ 428 Mouse.move(0, 0, -1); 429 delay(200); 430 } 431 } 432 } 433 ///////////////////////////////////////////////////////////// MODE 0 434//============================================================================================================================================================================================================ 435 ///////////////////////////////////////////////////////////// MODE 1 436 if(mode == 1){ 437 unsigned long pmillis, 438 cmillis; 439 440 digitalWrite(30, 1); 441 442 if(digitalRead(BMODE) == LOW){//////////////////////////// MODE SELECTION 443 mode++; 444 digitalWrite(30, 0); 445 delay(100); 446 digitalWrite(30, 1); 447 delay(100); 448 digitalWrite(30, 0); 449 delay(100); 450 digitalWrite(30, 1); 451 delay(100); 452 digitalWrite(30, 0); 453 delay(100); 454 } 455 456 if(digitalRead(BU) == LOW){//////////////////////////////// UDLR 457 Keyboard.press(KEY_BACKSPACE); 458 } 459 if(digitalRead(BU) == HIGH){ 460 Keyboard.release(KEY_BACKSPACE); 461 } 462 if(digitalRead(BR) == LOW){ 463 Keyboard.press(KEY_RETURN); 464 } 465 if(digitalRead(BR) == HIGH){ 466 Keyboard.release(KEY_RETURN); 467 } 468 469 if(digitalRead(BL1) == LOW){/////////////////////////////// 123456 470 Keyboard.press(KEY_LEFT_SHIFT); 471 } 472 if(digitalRead(BL1) == HIGH){ 473 Keyboard.release(KEY_LEFT_SHIFT); 474 } 475 if(digitalRead(BR2) == LOW){ 476 Keyboard.press(' '); 477 } 478 if(digitalRead(BR2) == HIGH){ 479 Keyboard.release(' '); 480 } 481 482 if(digitalRead(BSTART) == LOW){//////////////////////////// FUNCTION KEYS 483 Keyboard.press(KEY_ESC); 484 } 485 if(digitalRead(BSTART) == HIGH){ 486 Keyboard.release(KEY_ESC); 487 } 488 if(digitalRead(BSELECT) == LOW){ 489 Keyboard.press(KEY_LEFT_GUI); 490 } 491 if(digitalRead(BSELECT) == HIGH){ 492 Keyboard.release(KEY_LEFT_GUI); 493 } 494 pinMode(BCLEAR, INPUT_PULLUP); 495 if(digitalRead(BCLEAR) == LOW){ 496 Keyboard.press(KEY_LEFT_ALT); 497 delay(100); 498 Keyboard.press(KEY_F4); 499 delay(100); 500 Keyboard.release(KEY_F4); 501 Keyboard.release(KEY_LEFT_ALT); 502 delay(100); 503 } 504 505 comehere: 506 507 if(digitalRead(BA) == LOW){/////////////////////////////// ABCD 508 pmillis = millis(); 509 cmillis = pmillis; 510 while(digitalRead(BA) == LOW){ 511 delay(1); 512 } 513 while(digitalRead(BA) == HIGH){ 514 cmillis = millis(); 515 if(cmillis - pmillis >= 500){ 516 Keyboard.write('a'); 517 goto comehere; 518 } 519 } 520 pmillis = cmillis; 521 while(digitalRead(BA) == LOW){ 522 delay(1); 523 } 524 while(digitalRead(BA) == HIGH){ 525 cmillis = millis(); 526 if(cmillis - pmillis >= 500){ 527 Keyboard.write('b'); 528 goto comehere; 529 } 530 } 531 pmillis = cmillis; 532 while(digitalRead(BA) == LOW){ 533 delay(1); 534 } 535 while(digitalRead(BA) == HIGH){ 536 cmillis = millis(); 537 if(cmillis - pmillis >= 500){ 538 Keyboard.write('c'); 539 goto comehere; 540 } 541 } 542 pmillis = cmillis; 543 while(digitalRead(BA) == LOW){ 544 delay(1); 545 } 546 while(digitalRead(BA) == HIGH){ 547 cmillis = millis(); 548 if(cmillis - pmillis >= 500){ 549 Keyboard.write('d'); 550 goto comehere; 551 } 552 } 553 goto comehere; 554 } 555 556 if(digitalRead(BB) == LOW){/////////////////////////////// EFGH 557 pmillis = millis(); 558 cmillis = pmillis; 559 while(digitalRead(BB) == LOW){ 560 delay(1); 561 } 562 while(digitalRead(BB) == HIGH){ 563 cmillis = millis(); 564 if(cmillis - pmillis >= 500){ 565 Keyboard.write('e'); 566 goto comehere; 567 } 568 } 569 pmillis = cmillis; 570 while(digitalRead(BB) == LOW){ 571 delay(1); 572 } 573 while(digitalRead(BB) == HIGH){ 574 cmillis = millis(); 575 if(cmillis - pmillis >= 500){ 576 Keyboard.write('f'); 577 goto comehere; 578 } 579 } 580 pmillis = cmillis; 581 while(digitalRead(BB) == LOW){ 582 delay(1); 583 } 584 while(digitalRead(BB) == HIGH){ 585 cmillis = millis(); 586 if(cmillis - pmillis >= 500){ 587 Keyboard.write('g'); 588 goto comehere; 589 } 590 } 591 pmillis = cmillis; 592 while(digitalRead(BB) == LOW){ 593 delay(1); 594 } 595 while(digitalRead(BB) == HIGH){ 596 cmillis = millis(); 597 if(cmillis - pmillis >= 500){ 598 Keyboard.write('h'); 599 goto comehere; 600 } 601 } 602 goto comehere; 603 } 604 605 if(digitalRead(BX) == LOW){/////////////////////////////// IJKL 606 pmillis = millis(); 607 cmillis = pmillis; 608 while(digitalRead(BX) == LOW){ 609 delay(1); 610 } 611 while(digitalRead(BX) == HIGH){ 612 cmillis = millis(); 613 if(cmillis - pmillis >= 500){ 614 Keyboard.write('i'); 615 goto comehere; 616 } 617 } 618 pmillis = cmillis; 619 while(digitalRead(BX) == LOW){ 620 delay(1); 621 } 622 while(digitalRead(BX) == HIGH){ 623 cmillis = millis(); 624 if(cmillis - pmillis >= 500){ 625 Keyboard.write('j'); 626 goto comehere; 627 } 628 } 629 pmillis = cmillis; 630 while(digitalRead(BX) == LOW){ 631 delay(1); 632 } 633 while(digitalRead(BX) == HIGH){ 634 cmillis = millis(); 635 if(cmillis - pmillis >= 500){ 636 Keyboard.write('k'); 637 goto comehere; 638 } 639 } 640 pmillis = cmillis; 641 while(digitalRead(BX) == LOW){ 642 delay(1); 643 } 644 while(digitalRead(BX) == HIGH){ 645 cmillis = millis(); 646 if(cmillis - pmillis >= 500){ 647 Keyboard.write('l'); 648 goto comehere; 649 } 650 } 651 goto comehere; 652 } 653 654 if(digitalRead(BY) == LOW){/////////////////////////////// MNOP 655 pmillis = millis(); 656 cmillis = pmillis; 657 while(digitalRead(BY) == LOW){ 658 delay(1); 659 } 660 while(digitalRead(BY) == HIGH){ 661 cmillis = millis(); 662 if(cmillis - pmillis >= 500){ 663 Keyboard.write('m'); 664 goto comehere; 665 } 666 } 667 pmillis = cmillis; 668 while(digitalRead(BY) == LOW){ 669 delay(1); 670 } 671 while(digitalRead(BY) == HIGH){ 672 cmillis = millis(); 673 if(cmillis - pmillis >= 500){ 674 Keyboard.write('n'); 675 goto comehere; 676 } 677 } 678 pmillis = cmillis; 679 while(digitalRead(BY) == LOW){ 680 delay(1); 681 } 682 while(digitalRead(BY) == HIGH){ 683 cmillis = millis(); 684 if(cmillis - pmillis >= 500){ 685 Keyboard.write('o'); 686 goto comehere; 687 } 688 } 689 pmillis = cmillis; 690 while(digitalRead(BY) == LOW){ 691 delay(1); 692 } 693 while(digitalRead(BY) == HIGH){ 694 cmillis = millis(); 695 if(cmillis - pmillis >= 500){ 696 Keyboard.write('p'); 697 goto comehere; 698 } 699 } 700 goto comehere; 701 } 702 703 if(digitalRead(BD) == LOW){/////////////////////////////// QRST 704 pmillis = millis(); 705 cmillis = pmillis; 706 while(digitalRead(BD) == LOW){ 707 delay(1); 708 } 709 while(digitalRead(BD) == HIGH){ 710 cmillis = millis(); 711 if(cmillis - pmillis >= 500){ 712 Keyboard.write('q'); 713 goto comehere; 714 } 715 } 716 pmillis = cmillis; 717 while(digitalRead(BD) == LOW){ 718 delay(1); 719 } 720 while(digitalRead(BD) == HIGH){ 721 cmillis = millis(); 722 if(cmillis - pmillis >= 500){ 723 Keyboard.write('r'); 724 goto comehere; 725 } 726 } 727 pmillis = cmillis; 728 while(digitalRead(BD) == LOW){ 729 delay(1); 730 } 731 while(digitalRead(BD) == HIGH){ 732 cmillis = millis(); 733 if(cmillis - pmillis >= 500){ 734 Keyboard.write('s'); 735 goto comehere; 736 } 737 } 738 pmillis = cmillis; 739 while(digitalRead(BD) == LOW){ 740 delay(1); 741 } 742 while(digitalRead(BD) == HIGH){ 743 cmillis = millis(); 744 if(cmillis - pmillis >= 500){ 745 Keyboard.write('t'); 746 goto comehere; 747 } 748 } 749 goto comehere; 750 } 751 752 if(digitalRead(BL) == LOW){/////////////////////////////// UVWXYZ 753 pmillis = millis(); 754 cmillis = pmillis; 755 while(digitalRead(BL) == LOW){ 756 delay(1); 757 } 758 while(digitalRead(BL) == HIGH){ 759 cmillis = millis(); 760 if(cmillis - pmillis >= 500){ 761 Keyboard.write('u'); 762 goto comehere; 763 } 764 } 765 pmillis = cmillis; 766 while(digitalRead(BL) == LOW){ 767 delay(1); 768 } 769 while(digitalRead(BL) == HIGH){ 770 cmillis = millis(); 771 if(cmillis - pmillis >= 500){ 772 Keyboard.write('v'); 773 goto comehere; 774 } 775 } 776 pmillis = cmillis; 777 while(digitalRead(BL) == LOW){ 778 delay(1); 779 } 780 while(digitalRead(BL) == HIGH){ 781 cmillis = millis(); 782 if(cmillis - pmillis >= 500){ 783 Keyboard.write('w'); 784 goto comehere; 785 } 786 } 787 pmillis = cmillis; 788 while(digitalRead(BL) == LOW){ 789 delay(1); 790 } 791 while(digitalRead(BL) == HIGH){ 792 cmillis = millis(); 793 if(cmillis - pmillis >= 500){ 794 Keyboard.write('x'); 795 goto comehere; 796 } 797 } 798 pmillis = cmillis; 799 while(digitalRead(BL) == LOW){ 800 delay(1); 801 } 802 while(digitalRead(BL) == HIGH){ 803 cmillis = millis(); 804 if(cmillis - pmillis >= 500){ 805 Keyboard.write('z'); // ez lesz az y 806 goto comehere; 807 } 808 } 809 pmillis = cmillis; 810 while(digitalRead(BL) == LOW){ 811 delay(1); 812 } 813 while(digitalRead(BL) == HIGH){ 814 cmillis = millis(); 815 if(cmillis - pmillis >= 500){ 816 Keyboard.write('y'); // ez lesz a z 817 goto comehere; 818 } 819 } 820 goto comehere; 821 } 822 823 if(digitalRead(BR1) == LOW){/////////////////////////////// ,.?! 824 pmillis = millis(); 825 cmillis = pmillis; 826 while(digitalRead(BR1) == LOW){ 827 delay(1); 828 } 829 while(digitalRead(BR1) == HIGH){ 830 cmillis = millis(); 831 if(cmillis - pmillis >= 500){ 832 Keyboard.write(','); // , 833 goto comehere; 834 } 835 } 836 pmillis = cmillis; 837 while(digitalRead(BR1) == LOW){ 838 delay(1); 839 } 840 while(digitalRead(BR1) == HIGH){ 841 cmillis = millis(); 842 if(cmillis - pmillis >= 500){ 843 Keyboard.write('.'); // . 844 goto comehere; 845 } 846 } 847 pmillis = cmillis; 848 while(digitalRead(BR1) == LOW){ 849 delay(1); 850 } 851 while(digitalRead(BR1) == HIGH){ 852 cmillis = millis(); 853 if(cmillis - pmillis >= 500){ 854 Keyboard.write(60); // ? 855 goto comehere; 856 } 857 } 858 pmillis = cmillis; 859 while(digitalRead(BR1) == LOW){ 860 delay(1); 861 } 862 while(digitalRead(BR1) == HIGH){ 863 cmillis = millis(); 864 if(cmillis - pmillis >= 500){ 865 Keyboard.write(36); // ! 866 goto comehere; 867 } 868 } 869 goto comehere; 870 } 871 872 if(digitalRead(BTURBO) == LOW){/////////////////////////////// 12345 873 pmillis = millis(); 874 cmillis = pmillis; 875 while(digitalRead(BTURBO) == LOW){ 876 delay(1); 877 } 878 while(digitalRead(BTURBO) == HIGH){ 879 cmillis = millis(); 880 if(cmillis - pmillis >= 500){ 881 Keyboard.write('1'); 882 goto comehere; 883 } 884 } 885 pmillis = cmillis; 886 while(digitalRead(BTURBO) == LOW){ 887 delay(1); 888 } 889 while(digitalRead(BTURBO) == HIGH){ 890 cmillis = millis(); 891 if(cmillis - pmillis >= 500){ 892 Keyboard.write('2'); 893 goto comehere; 894 } 895 } 896 pmillis = cmillis; 897 while(digitalRead(BTURBO) == LOW){ 898 delay(1); 899 } 900 while(digitalRead(BTURBO) == HIGH){ 901 cmillis = millis(); 902 if(cmillis - pmillis >= 500){ 903 Keyboard.write('3'); 904 goto comehere; 905 } 906 } 907 pmillis = cmillis; 908 while(digitalRead(BTURBO) == LOW){ 909 delay(1); 910 } 911 while(digitalRead(BTURBO) == HIGH){ 912 cmillis = millis(); 913 if(cmillis - pmillis >= 500){ 914 Keyboard.write('4'); 915 goto comehere; 916 } 917 } 918 pmillis = cmillis; 919 while(digitalRead(BTURBO) == LOW){ 920 delay(1); 921 } 922 while(digitalRead(BTURBO) == HIGH){ 923 cmillis = millis(); 924 if(cmillis - pmillis >= 500){ 925 Keyboard.write('5'); 926 goto comehere; 927 } 928 } 929 goto comehere; 930 } 931 932 if(digitalRead(BAUTO) == LOW){/////////////////////////////// 67890 933 pmillis = millis(); 934 cmillis = pmillis; 935 while(digitalRead(BAUTO) == LOW){ 936 delay(1); 937 } 938 while(digitalRead(BAUTO) == HIGH){ 939 cmillis = millis(); 940 if(cmillis - pmillis >= 500){ 941 Keyboard.write('6'); 942 goto comehere; 943 } 944 } 945 pmillis = cmillis; 946 while(digitalRead(BAUTO) == LOW){ 947 delay(1); 948 } 949 while(digitalRead(BAUTO) == HIGH){ 950 cmillis = millis(); 951 if(cmillis - pmillis >= 500){ 952 Keyboard.write('7'); 953 goto comehere; 954 } 955 } 956 pmillis = cmillis; 957 while(digitalRead(BAUTO) == LOW){ 958 delay(1); 959 } 960 while(digitalRead(BAUTO) == HIGH){ 961 cmillis = millis(); 962 if(cmillis - pmillis >= 500){ 963 Keyboard.write('8'); 964 goto comehere; 965 } 966 } 967 pmillis = cmillis; 968 while(digitalRead(BAUTO) == LOW){ 969 delay(1); 970 } 971 while(digitalRead(BAUTO) == HIGH){ 972 cmillis = millis(); 973 if(cmillis - pmillis >= 500){ 974 Keyboard.write('9'); 975 goto comehere; 976 } 977 } 978 pmillis = cmillis; 979 while(digitalRead(BAUTO) == LOW){ 980 delay(1); 981 } 982 while(digitalRead(BAUTO) == HIGH){ 983 cmillis = millis(); 984 if(cmillis - pmillis >= 500){ 985 Keyboard.write(96); 986 goto comehere; 987 } 988 } 989 goto comehere; 990 } 991 992 if(digitalRead(BLS) == LOW){//////////////////////////////// MOUSE CLICKS 993 Mouse.press(); 994 } 995 if(digitalRead(BLS) == HIGH){ 996 Mouse.release(); 997 } 998 if(digitalRead(BRS) == LOW){ 999 Mouse.press(2); 1000 } 1001 if(digitalRead(BRS) == HIGH){ 1002 Mouse.release(2); 1003 } 1004 1005 aSLX = analogRead(SLX);/////////////////////////////////////// CURSOR AND WHEEL 1006 aSLY = analogRead(SLY); 1007 //aSRX = analogRead(SRX); 1008 aSRY = analogRead(SRY); 1009 1010 if(aSLX >= 509){/////////////////////////////////////// CURSOR X 1011 if(aSLX >= 600){ 1012 if(aSLX >= 900){ 1013 Mouse.move(-2*sense, 0, 0); 1014 } 1015 else{ 1016 Mouse.move(-1*sense, 0, 0); 1017 } 1018 } 1019 else{ 1020 Mouse.move(-1, 0, 0); 1021 } 1022 } 1023 if(aSLX <= 501){ 1024 if(aSLX <= 400){ 1025 if(aSLX <= 100){ 1026 Mouse.move(2*sense, 0, 0); 1027 } 1028 else{ 1029 Mouse.move(sense, 0, 0); 1030 } 1031 } 1032 else{ 1033 Mouse.move(1, 0, 0); 1034 } 1035 } 1036 1037 if(aSLY >= 526){ ////////////////////////////////////// CURSOR Y 1038 if(aSLY >= 600){ 1039 if(aSLY >= 900){ 1040 Mouse.move(0, -2*sense, 0); 1041 } 1042 else{ 1043 Mouse.move(0, -1*sense, 0); 1044 } 1045 } 1046 else{ 1047 Mouse.move(0, -1, 0); 1048 } 1049 } 1050 if(aSLY <= 518){ 1051 if(aSLY <= 400){ 1052 if(aSLY <= 100){ 1053 Mouse.move(0, 2*sense, 0); 1054 } 1055 else{ 1056 Mouse.move(0, 1*sense, 0); 1057 } 1058 } 1059 else{ 1060 Mouse.move(0, 1, 0); 1061 } 1062 } 1063 1064 if(aSRY >= 519){/////////////////////////////////// WHEEL 1065 if(aSRY >= 600){ 1066 if(aSRY >= 900){ 1067 Mouse.move(0, 0, 1); 1068 delay(50); 1069 } 1070 else{ 1071 Mouse.move(0, 0, 1); 1072 delay(100); 1073 } 1074 } 1075 else{ 1076 Mouse.move(0, 0, 1); 1077 delay(200); 1078 } 1079 } 1080 if(aSRY <= 511){ 1081 if(aSRY <= 400){ 1082 if(aSRY <= 100){ 1083 Mouse.move(0, 0, -1); 1084 delay(50); 1085 } 1086 else{ 1087 Mouse.move(0, 0, -1); 1088 delay(100); 1089 } 1090 } 1091 else{ 1092 Mouse.move(0, 0, -1); 1093 delay(200); 1094 } 1095 } 1096 1097 } 1098 ///////////////////////////////////////////////////////////// MODE 1 1099//============================================================================================================================================================================================================ 1100} 1101
Comments
Only logged in users can leave comments
pdio
0 Followers
•0 Projects
Table of contents
Intro
3
0