123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535 |
- void printKey() {
- if (useSerial) {
- Serial.print(F("KEY_"));
- }
- }
- void printMedia() {
- if (useSerial) {
- Serial.print(F("MEDIA_"));
- }
- }
- void printArrow() {
- if (useSerial) {
- Serial.print(F("ARROW_"));
- }
- }
- //void sendKey(uint8_t _key) {
- // sendKey(_key, false);
- //}
- void sendKey(uint8_t _key, bool _hold) {
- if(_hold) {
- handleHoldButton();
- }
-
- if (debug) Serial.println(F("SENDING KEY"));
- switch (_key) {
- // case BTN_POWER:
- // //handlePowerButton();
- // if (useSerial) {
- // printKey();
- // Serial.println(F("POWER"));
- // }
- // break;
- case BTN_SLEEP:
- if (sendHID) {
- System.write(SYSTEM_SLEEP);
- }
- if (useSerial) {
- printKey();
- Serial.println(F("SLEEP"));
- }
- break;
- case BTN_OK_ENTER:
- if (sendHID) {
- if (_hold && !handleTaskSwitchButton_isActive()) BootKeyboard.press(KEY_ENTER);
- else {
- BootKeyboard.write(KEY_ENTER);
- if(handleTaskSwitchButton_isActive()) releaseAllKeys();
- }
- }
- handleHoldButton();
- if (useSerial) {
- printKey();
- Serial.println(F("OK_ENTER"));
- }
- break;
- case BTN_BACK:
- if (sendHID) {
- if (_hold) BootKeyboard.press(KEY_BACKSPACE);
- else BootKeyboard.write(KEY_BACKSPACE);
- }
- if (useSerial) {
- printKey();
- Serial.println(F("BACK"));
- }
- break;
- case BTN_UP:
- if (sendHID) {
- if (_hold && !handleTaskSwitchButton_isActive()) BootKeyboard.press(KEY_UP_ARROW);
- else BootKeyboard.write(KEY_UP_ARROW);
- }
- if (useSerial) {
- printKey();
- Serial.println(F("UP"));
- }
- if(handleTaskSwitchButton_isActive()) handleTaskSwitchButton_extendTimeout();
- break;
- case BTN_DOWN:
- if (sendHID) {
- if (_hold && !handleTaskSwitchButton_isActive()) BootKeyboard.press(KEY_DOWN_ARROW);
- else BootKeyboard.write(KEY_DOWN_ARROW);
- }
- if (useSerial) {
- printKey();
- Serial.println(F("DOWN"));
- }
- if(handleTaskSwitchButton_isActive()) handleTaskSwitchButton_extendTimeout();
- break;
- case BTN_RIGHT:
- if (sendHID) {
- if (_hold && !handleTaskSwitchButton_isActive()) BootKeyboard.press(KEY_RIGHT_ARROW);
- else BootKeyboard.write(KEY_RIGHT_ARROW);
- }
- if (useSerial) {
- printKey();
- Serial.println(F("RIGHT"));
- }
- if(handleTaskSwitchButton_isActive()) handleTaskSwitchButton_extendTimeout();
- break;
- case BTN_LEFT:
- if (sendHID) {
- if (_hold && !handleTaskSwitchButton_isActive()) BootKeyboard.press(KEY_LEFT_ARROW);
- else BootKeyboard.write(KEY_LEFT_ARROW);
- }
- if (useSerial) {
- printKey();
- Serial.println(F("LEFT"));
- }
- if(handleTaskSwitchButton_isActive()) handleTaskSwitchButton_extendTimeout();
- break;
- case BTN_PLAY:
- if (sendHID) Consumer.write(MEDIA_PLAY_PAUSE);
- if (useSerial) {
- printKey();
- printMedia();
- Serial.println(F("PLAY"));
- }
- break;
- case BTN_PAUSE:
- if (sendHID) Consumer.write(MEDIA_PLAY_PAUSE);
- if (useSerial) {
- printKey();
- printMedia();
- Serial.println(F("PAUSE"));
- }
- break;
- case BTN_STOP:
- if (sendHID) Consumer.write(MEDIA_STOP);
- if (useSerial) {
- printKey();
- printMedia();
- Serial.println(F("STOP"));
- }
- break;
- case BTN_REC:
- if (useSerial) {
- printKey();
- Serial.println(F("REC"));
- }
- break;
- case BTN_REWD:
- if (sendHID) Consumer.write(MEDIA_REWIND);
- if (useSerial) {
- printKey();
- printMedia();
- Serial.println(F("REWD"));
- }
- break;
- case BTN_FFWD:
- if (sendHID) Consumer.write(MEDIA_FAST_FORWARD);
- if (useSerial) {
- printKey();
- printMedia();
- Serial.println(F("FFWD"));
- }
- break;
- case BTN_PREV:
- if (sendHID) Consumer.write(MEDIA_PREVIOUS);
- if (useSerial) {
- printKey();
- printMedia();
- Serial.println(F("PREV"));
- }
- break;
- case BTN_NEXT:
- if (sendHID) Consumer.write(MEDIA_NEXT);
- if (useSerial) {
- printKey();
- printMedia();
- Serial.println(F("NEXT"));
- }
- break;
- case BTN_MENU:
- if (sendHID) BootKeyboard.write(KEY_ESC);
- if (useSerial) {
- printKey();
- Serial.println(F("MENU"));
- }
- break;
- case BTN_HOME:
- if (sendHID) BootKeyboard.write(KEY_LEFT_WINDOWS);
- if (useSerial) {
- printKey();
- Serial.println(F("HOME"));
- }
- break;
- case BTN_RED:
- if (sendHID) {
- BootKeyboard.press(KEY_LEFT_CTRL);
- BootKeyboard.press(KEY_LEFT_ALT);
- BootKeyboard.press(KEY_LEFT_WINDOWS);
- BootKeyboard.press(KEY_F7);
- handleHoldButton();
- //delay(50);
- //releaseAllKeys();
- }
- if (useSerial) {
- printKey();
- Serial.println(F("RED"));
- Serial.println("sending CTRL+ALT+WIN+F7");
- }
- break;
- case BTN_GREEN:
- if (sendHID) {
- BootKeyboard.press(KEY_LEFT_CTRL);
- BootKeyboard.press(KEY_LEFT_ALT);
- BootKeyboard.press(KEY_LEFT_WINDOWS);
- BootKeyboard.press(KEY_F8);
- handleHoldButton();
- //delay(50);
- //releaseAllKeys();
- }
- if (useSerial) {
- printKey();
- Serial.println(F("GREEN"));
- Serial.println(F("sending CTRL+ALT+WIN+F8"));
- }
- break;
- case BTN_YELLOW:
- if (sendHID) {
- BootKeyboard.press(KEY_LEFT_CTRL);
- BootKeyboard.press(KEY_LEFT_ALT);
- BootKeyboard.press(KEY_LEFT_WINDOWS);
- BootKeyboard.press(KEY_F9);
- handleHoldButton();
- //delay(50);
- //releaseAllKeys();
- }
- if (useSerial) {
- printKey();
- Serial.println(F("YELLOW"));
- Serial.println(F("sending CTRL+ALT+WIN+F9"));
- }
- break;
- case BTN_BLUE:
- if (sendHID) {
- BootKeyboard.press(KEY_LEFT_CTRL);
- BootKeyboard.press(KEY_LEFT_ALT);
- BootKeyboard.press(KEY_LEFT_WINDOWS);
- BootKeyboard.press(KEY_F10);
- handleHoldButton();
- //delay(50);
- //releaseAllKeys();
- }
- if (useSerial) {
- printKey();
- Serial.println(F("BLUE"));
- Serial.println("sending CTRL+ALT+WIN+F10");
- }
- break;
- case BTN_STATUS:
- if (useSerial) {
- printKey();
- Serial.println(F("STATUS"));
- }
- break;
- case BTN_RETURN:
- if (useSerial) {
- printKey();
- Serial.println(F("RETURN"));
- }
- break;
- case BTN_SETUP:
- if (useSerial) {
- printKey();
- Serial.println(F("SETUP"));
- }
- break;
- case BTN_GUIDE:
- if (sendHID) {
- BootKeyboard.press(KEY_LEFT_CTRL);
- BootKeyboard.press(KEY_LEFT_ALT);
- BootKeyboard.press(KEY_LEFT_WINDOWS);
- BootKeyboard.press(KEY_F5);
- handleHoldButton();
- //delay(20);
- //releaseAllKeys();
- }
- if (useSerial) {
- printKey();
- Serial.println(F("GUIDE"));
- Serial.println(F("sending CTRL+ALT+WIN+F5"));
- }
- break;
- case BTN_RADIO:
- if (sendHID) {
- BootKeyboard.press(KEY_LEFT_CTRL);
- BootKeyboard.press(KEY_LEFT_ALT);
- BootKeyboard.press(KEY_LEFT_WINDOWS);
- BootKeyboard.press(KEY_F6);
- handleHoldButton();
- //delay(20);
- //releaseAllKeys();
- }
- if (useSerial) {
- printKey();
- Serial.println(F("RADIO"));
- Serial.println(F("sending CTRL+ALT+WIN+F6"));
- }
- break;
- case BTN_PREVCH:
- if (useSerial) {
- printKey();
- Serial.println(F("PREVCH"));
- }
- break;
- case BTN_CONTEXT:
- if (useSerial) {
- printKey();
- Serial.println(F("CONTEXT"));
- }
- if(sendHID) BootKeyboard.write(KEY_C);
- break;
- case BTN_INFO:
- if (useSerial) {
- printKey();
- Serial.println(F("INFO"));
- }
- if(sendHID) BootKeyboard.write(KEY_I);
- break;
- case BTN_CH_DOWN:
- if (sendHID) {
- BootKeyboard.write(KEY_PAGE_DOWN);
- }
- if (useSerial) {
- printKey();
- Serial.println(F("CH_DOWN"));
- }
- break;
- case BTN_CH_UP:
- if (sendHID) {
- BootKeyboard.write(KEY_PAGE_UP);
- }
- if (useSerial) {
- printKey();
- Serial.println(F("CH_UP"));
- }
- break;
- case BTN_PAGE_DOWN:
- if (sendHID) {
- BootKeyboard.write(KEY_PAGE_DOWN);
- }
- if (useSerial) {
- printKey();
- Serial.println(F("PAGE_DOWN"));
- }
- break;
- case BTN_PAGE_UP:
- if (sendHID) {
- BootKeyboard.write(KEY_PAGE_UP);
- }
- if (useSerial) {
- printKey();
- Serial.println(F("PAGE_UP"));
- }
- break;
- case BTN_VOL_DOWN:
- if (sendHID && enableVolumeButtons) Consumer.write(MEDIA_VOLUME_DOWN);
- if (useSerial) {
- printKey();
- printMedia();
- Serial.println(F("VOLUME_DOWN"));
- }
- break;
- case BTN_VOL_UP:
- if (sendHID && enableVolumeButtons) Consumer.write(MEDIA_VOLUME_UP);
- if (useSerial) {
- printKey();
- printMedia();
- Serial.println(F("VOLUME_UP"));
- }
- break;
- case BTN_MUTE:
- if (sendHID && enableVolumeButtons) Consumer.write(MEDIA_VOLUME_MUTE);
- if (useSerial) {
- printKey();
- printMedia();
- Serial.println(F("VOLUME_MUTE"));
- }
- break;
- case BTN_TV:
- if (sendHID) {
- BootKeyboard.press(KEY_LEFT_CTRL);
- delay(2);
- BootKeyboard.press(KEY_LEFT_WINDOWS);
- delay(2);
- BootKeyboard.press(KEY_LEFT_ALT);
- delay(2);
- BootKeyboard.press(KEY_F1);
- delay(20);
- releaseAllKeys();
- }
- if (useSerial) {
- printKey();
- Serial.println(F("TV"));
- Serial.println(F("sending CTRL+ALT+WIN+F1"));
- }
- break;
- case BTN_VIDEOS:
- if (sendHID) {
- BootKeyboard.press(KEY_LEFT_CTRL);
- delay(2);
- BootKeyboard.press(KEY_LEFT_ALT);
- delay(2);
- BootKeyboard.press(KEY_LEFT_WINDOWS);
- delay(2);
- BootKeyboard.press(KEY_F2);
- delay(20);
- releaseAllKeys();
- }
- if (useSerial) {
- printKey();
- Serial.println(F("VIDEOS"));
- Serial.println(F("sending CTRL+ALT+WIN+F2"));
- }
- break;
- case BTN_MUSIC:
- if (sendHID) {
- BootKeyboard.press(KEY_LEFT_CTRL);
- BootKeyboard.press(KEY_LEFT_ALT);
- BootKeyboard.press(KEY_LEFT_WINDOWS);
- BootKeyboard.press(KEY_F3);
- handleHoldButton();
- //delay(20);
- //releaseAllKeys();
- }
- if (useSerial) {
- printKey();
- Serial.println(F("MUSIC"));
- Serial.println(F("sending CTRL+ALT+WIN+F3"));
- }
- break;
- case BTN_PICTURES:
- if (sendHID) {
- BootKeyboard.press(KEY_LEFT_CTRL);
- BootKeyboard.press(KEY_LEFT_WINDOWS);
- BootKeyboard.press(KEY_LEFT_ALT);
- BootKeyboard.press(KEY_F4);
- handleHoldButton();
- //delay(20);
- //releaseAllKeys();
- }
- if (useSerial) {
- printKey();
- Serial.println(F("PICTURES"));
- Serial.println(F("sending CTRL+ALT+WIN+F4"));
- }
- break;
- case BTN_STAR:
- if (useSerial) {
- printKey();
- Serial.println(F("STAR"));
- }
- break;
- case BTN_HASH:
- if (useSerial) {
- printKey();
- Serial.println(F("HASH"));
- }
- break;
- case BTN_0:
- if (sendHID) BootKeyboard.write('0');
- if (useSerial) {
- printKey();
- Serial.println("0");
- }
- break;
- case BTN_1:
- if (sendHID) BootKeyboard.write('1');
- if (useSerial) {
- printKey();
- Serial.println("1");
- }
- break;
- case BTN_2:
- if (sendHID) BootKeyboard.write('2');
- if (useSerial) {
- printKey();
- Serial.println("2");
- }
- break;
- case BTN_3:
- if (sendHID) BootKeyboard.write('3');
- if (useSerial) {
- printKey();
- Serial.println("3");
- }
- break;
- case BTN_4:
- if (sendHID) BootKeyboard.write('4');
- if (useSerial) {
- printKey();
- Serial.println("4");
- }
- break;
- case BTN_5:
- if (sendHID) BootKeyboard.write('5');
- if (useSerial) {
- printKey();
- Serial.println("5");
- }
- break;
- case BTN_6:
- if (sendHID) BootKeyboard.write('6');
- if (useSerial) {
- printKey();
- Serial.println("6");
- }
- break;
- case BTN_7:
- if (sendHID) BootKeyboard.write('7');
- if (useSerial) {
- printKey();
- Serial.println("7");
- }
- break;
- case BTN_8:
- if (sendHID) BootKeyboard.write('8');
- if (useSerial) {
- printKey();
- Serial.println("8");
- }
- break;
- case BTN_9:
- if (sendHID) BootKeyboard.write('9');
- if (useSerial) {
- printKey();
- Serial.println("9");
- }
- break;
- }
- }
|