123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906 |
- //------------------------------------------------------------------------------
- // Include the IRremote library header
- //
- #include <IRremote.h>
- #include <HID-Project.h> // HID-Project 2.8.2
- // switch on/off debug mode at once
- bool isDebugBuild = false;
- // enable HID Keyboard output
- bool sendHID = true;
- bool enableVolumeButtons = false; // if set to false Vol+, Vol- and Mute commands will not be sent via USB to PC so that they can be used with a different IR-receiver i.E. to control to an AVR
- // ATTENTION - set ALL debug and useSerial to false in normal usage
- // as sending over Serial blocks the Arduino Leonardo unless a terminal application is connected!
- bool debug = false;
- bool debug2 = false;
- bool useSerial = false;
- // global conf vars
- unsigned int holdButton_releaseTimeout = 120; // global default, will be overwritten depending on RC code used
- #define BTN_UNKNOWN 0
- #define BTN_1 1
- #define BTN_2 2
- #define BTN_3 3
- #define BTN_4 4
- #define BTN_5 5
- #define BTN_6 6
- #define BTN_7 7
- #define BTN_8 8
- #define BTN_9 9
- #define BTN_0 10
- #define BTN_PLAY 11
- #define BTN_PAUSE 12
- #define BTN_STOP 13
- #define BTN_REC 14
- #define BTN_REWD 15
- #define BTN_FFWD 16
- #define BTN_PREV 17
- #define BTN_NEXT 18
- #define BTN_LEFT 20
- #define BTN_RIGHT 21
- #define BTN_UP 22
- #define BTN_DOWN 23
- #define BTN_OK_ENTER 24
- #define BTN_BACK 25
- #define BTN_MENU 26
- #define BTN_HOME 27
- #define BTN_RED 30
- #define BTN_GREEN 31
- #define BTN_YELLOW 32
- #define BTN_BLUE 33
- #define BTN_STATUS 34
- #define BTN_RETURN 35
- #define BTN_SETUP 36
- #define BTN_GUIDE 37
- #define BTN_RADIO 38
- #define BTN_PREVCH 39
- #define BTN_CH_DOWN 40
- #define BTN_CH_UP 41
- #define BTN_VOL_DOWN 42
- #define BTN_VOL_UP 43
- #define BTN_MUTE 44
- #define BTN_TV 46
- #define BTN_VIDEOS 47
- #define BTN_MUSIC 48
- #define BTN_PICTURES 49
- #define BTN_STAR 50
- #define BTN_HASH 51
- #define BTN_PAGE_UP 60
- #define BTN_PAGE_DOWN 61
- #define BTN_CONTEXT 62
- #define BTN_INFO 63
- #define BTN_POWER 100
- #define BTN_TASKSWITCH 101
- #define BTN_SLEEP 102
- #define BTN_REPETITION 255
- // Button Modes
- #define BUTTONMODE_LAST 0
- #define BUTTONMODE_ONCE 1
- #define BUTTONMODE_HOLD 2
- #define BUTTONMODE_REPEAT 3
- #define BUTTONMODE_EXTENDED_REPEAT 4
- // Remote Types
- #define REMOTETYPE_RC5 0
- #define REMOTETYPE_RC6 1
- // global vars
- unsigned long lastNECcode;
- unsigned long lastReceivedMillis;
- unsigned long holdButton_lastTriggeredMillis = 0;
- //------------------------------------------------------------------------------
- // Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
- //
- int recvPin = 2;
- IRrecv irrecv(recvPin);
- //+=============================================================================
- // Configure the Arduino
- //
- void setup ( )
- {
- if (isDebugBuild) {
- useSerial = true;
- debug = true;
- debug2 = true;
- }
- if (useSerial || debug || debug2) Serial.begin(115200);
- BootKeyboard.begin();
- Consumer.begin();
- System.begin();
- irrecv.enableIRIn(); // Start the receiver
- }
- //+=============================================================================
- // Dump out the decode_results structure.
- //
- void dumpInfo (decode_results *results)
- {
- // Check if the buffer overflowed
- // if (results->overflow) {
- // Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWLEN");
- // return;
- // }
- if (debug) {
- if ((results->decode_type != UNKNOWN && results->bits > 0) && debug2) {
- if (useSerial) {
- Serial.println();
- Serial.println();
- Serial.print(F("RECEIVED: "));
- encoding(results);
- Serial.print(";0x");
- ircode(results);
- Serial.print(";");
- Serial.print(results->bits, DEC);
- Serial.println();
- }
- }
- }
- // RC5 CODES
- if (results->decode_type == RC5 && results->bits == 12) {
- // RC5 code
- // 3 bytes, start byte for this device is 0xF or 0x7 depending on toggle bit
- uint8_t _currRC5Code = results->value ^ 0xF00;
- uint8_t _currRC5Pref = ( _currRC5Code ^ results->value ) >> 8;
- if (debug) {
- Serial.print(F(" _currRC5Code=0x"));
- Serial.print(_currRC5Code, HEX);
- Serial.print(F(" _currRC5Pref=0x"));
- Serial.println(_currRC5Pref, HEX);
- }
- // Hauppauge Remote
- if (_currRC5Code == 0xBD) { // POWER (upper right key)
- //handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- //handlePowerButton();
- handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xBB) { // HOME/GO (upper left key)
- //handleButton_RCx(BTN_HOME, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- //handleTaskSwitchButton();
- handleButton_RCx(BTN_TASKSWITCH, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- }
- // media player controls
- else if (_currRC5Code == 0xB7) { // REC
- handleButton_RCx(BTN_REC, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xB6) { // STOP
- handleButton_RCx(BTN_STOP, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xB5) { // PLAY
- handleButton_RCx(BTN_PLAY, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xB0) { // PAUSE
- handleButton_RCx(BTN_PAUSE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xA4) { // PREV
- handleButton_RCx(BTN_PREV, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x9E) { // NEXT
- handleButton_RCx(BTN_NEXT, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xB2) { // REWIND
- //handleButton_RCx(BTN_REWD, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- //handleButton_RCx(BTN_REWD, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
- handleButton_RCx(BTN_REWD, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xB4) { // FAST_FORWARD
- //handleButton_RCx(BTN_FFWD, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- //handleButton_RCx(BTN_FFWD, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
- handleButton_RCx(BTN_FFWD, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- // above control pad
- else if (_currRC5Code == 0x9B) { // GUIDE -> left above control pad
- //handleButton_RCx(BTN_GUIDE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- handleButton_RCx(BTN_TASKSWITCH, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x8C) { // RADIO -> right above control pad
- //handleButton_RCx(BTN_RADIO, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- handleButton_RCx(BTN_CONTEXT, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- // control pad
- else if (_currRC5Code == 0xA5) { // OK
- //handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x94) { // ARROW UP
- //handleButton_RCx(BTN_UP, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- //handleButton_RCx(BTN_UP, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
- handleButton_RCx(BTN_UP, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x95) { // ARROW DOWN
- //handleButton_RCx(BTN_DOWN, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- //handleButton_RCx(BTN_DOWN, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
- handleButton_RCx(BTN_DOWN, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x96) { // ARROW LEFT
- //handleButton_RCx(BTN_LEFT, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- //handleButton_RCx(BTN_LEFT, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
- handleButton_RCx(BTN_LEFT, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x97) { // ARROW RIGHT
- //handleButton_RCx(BTN_RIGHT, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- //handleButton_RCx(BTN_RIGHT, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
- handleButton_RCx(BTN_RIGHT, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xA5) { // OK
- //handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_EXTENDED_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- }
- // below control pad
- else if (_currRC5Code == 0x9F) { // BACK/EXIT -> -> swapped and used as on the other remotes as MENU
- handleButton_RCx(BTN_MENU, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x8D) { // i/MENU -> swapped and used as on the other remotes as BACK/EXIT
- handleButton_RCx(BTN_BACK, BUTTONMODE_HOLD, _currRC5Pref, REMOTETYPE_RC5);
- }
- // volume controls
- else if (_currRC5Code == 0x90) { // VOL+
- handleButton_RCx(BTN_VOL_UP, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x91) { // VOL-
- handleButton_RCx(BTN_VOL_DOWN, BUTTONMODE_REPEAT, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x8F) { // MUTE
- handleButton_RCx(BTN_MUTE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- // channel controls
- else if (_currRC5Code == 0xA1) { // CH- used as page down
- handleButton_RCx(BTN_CH_DOWN, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xA0) { // CH+ used as page up
- handleButton_RCx(BTN_CH_UP, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x92) { // PREV.CH
- handleButton_RCx(BTN_CONTEXT, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- // sources
- else if (_currRC5Code == 0x9C) { // TV
- handleButton_RCx(BTN_TV, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x98) { // VIDEOS
- handleButton_RCx(BTN_VIDEOS, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x99) { // MUSIC
- handleButton_RCx(BTN_MUSIC, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x9A) { // PICTURES
- handleButton_RCx(BTN_PICTURES, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- // number keys
- else if (_currRC5Code == 0x81) { // 1
- handleButton_RCx(BTN_1, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x82) { // 2
- handleButton_RCx(BTN_2, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x83) { // 3
- handleButton_RCx(BTN_3, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x84) { // 4
- handleButton_RCx(BTN_4, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x85) { // 5
- handleButton_RCx(BTN_5, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x86) { // 6
- handleButton_RCx(BTN_6, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x87) { // 7
- handleButton_RCx(BTN_7, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x88) { // 8
- handleButton_RCx(BTN_8, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x89) { // 9
- handleButton_RCx(BTN_9, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x80) { // 0
- handleButton_RCx(BTN_0, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x8A) { // *
- handleButton_RCx(BTN_STAR, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0x8E) { // #
- handleButton_RCx(BTN_HASH, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- // color keys
- else if (_currRC5Code == 0x8B) { // RED
- handleButton_RCx(BTN_RED, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xAE) { // GREEN
- handleButton_RCx(BTN_GREEN, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xB8) { // YELLOW
- handleButton_RCx(BTN_YELLOW, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- else if (_currRC5Code == 0xA9) { // BLUE
- handleButton_RCx(BTN_BLUE, BUTTONMODE_ONCE, _currRC5Pref, REMOTETYPE_RC5);
- }
- } // END RC5 CODES
- // SONY CODES
- else if (results->decode_type == SONY && results->bits == 12) {
- // DENON RC-1014 REMOTE, Mode AUDIO/CD, MEDIA KEYS (set to SONY CD Player)
- if (results->value == 0x9D1) { // PAUSE
- handleButton(BTN_PAUSE, false);
- }
- else if (results->value == 0xCD1) { // REWD
- handleButton(BTN_REWD, true);
- }
- else if (results->value == 0x2D1) { // FFWD
- handleButton(BTN_FFWD, true);
- }
- else if (results->value == 0xD1) { // PREV
- handleButton(BTN_PREV, false);
- }
- else if (results->value == 0x8D1) { // NEXT
- handleButton(BTN_NEXT, false);
- }
- else if (results->value == 0x4D1) { // PLAY
- handleButton(BTN_PLAY, false);
- }
- else if (results->value == 0x1D1) { // STOP
- handleButton(BTN_STOP, false);
- }
- } // END SONY CODES
- // RC6 CODES
- else if (results->decode_type == RC6 && results->bits == 20) {
- unsigned int _currRC6Code = results->value ^ 0xF0000;
- uint8_t _currRC6Pref = ( _currRC6Code ^ results->value ) >> 16;
- if (debug) {
- Serial.print(F(" _currRC6Code=0x"));
- Serial.print(_currRC6Code, HEX);
- Serial.print(F(" _currRC6Pref=0x"));
- Serial.println(_currRC6Pref, HEX);
- }
- // Pioneer Remote in BD mode, configured code preset to Sat-PVR/Philips 6139 (RC6 code)
- // with the most important buttons available.
- // Missing buttons configured using learning function, which does not work well with RCx format due to the toggle bit,
- // so i used an old unused IR remote with NEC code for these, which will be OK for non-repeating buttons.
- // power
- if (_currRC6Code == 0x270C) { // POWER (of SOURCE)
- //handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
- //handlePowerButton();
- handleButton_RCx(BTN_POWER, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
- }
- // above control pad
- else if (_currRC6Code == 0x2743) { // X - AUDIO PARAMETER - left above control pad
- //handleButton_RCx(BTN_HOME, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- //handleTaskSwitchButton();
- handleButton_RCx(BTN_TASKSWITCH, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2754) { // VIDEO PARAMETER - right above control pad
- //handleButton_RCx(BTN_MENU, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- handleButton_RCx(BTN_CONTEXT, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- // control pad
- else if (_currRC6Code == 0x275C) { // OK/ENTER
- //handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- handleButton_RCx(BTN_OK_ENTER, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x275A) { // LEFT
- //handleButton_RCx(BTN_LEFT, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
- //handleButton_RCx(BTN_LEFT, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
- handleButton_RCx(BTN_LEFT, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x275B) { // RIGHT
- //handleButton_RCx(BTN_RIGHT, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
- //handleButton_RCx(BTN_RIGHT, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
- handleButton_RCx(BTN_RIGHT, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2758) { // UP
- //handleButton_RCx(BTN_UP, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
- //handleButton_RCx(BTN_UP, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
- handleButton_RCx(BTN_UP, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2759) { // DOWN
- //handleButton_RCx(BTN_DOWN, BUTTONMODE_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
- //handleButton_RCx(BTN_DOWN, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
- handleButton_RCx(BTN_DOWN, BUTTONMODE_EXTENDED_REPEAT, _currRC6Pref, REMOTETYPE_RC6);
- }
- // below control pad
- else if (_currRC6Code == 0x27CC) { // HOME MENU - left below control pad
- handleButton_RCx(BTN_MENU, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2783) { // RETURN/BACK - right below control pad
- //handleButton_RCx(BTN_BACK, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- handleButton_RCx(BTN_BACK, BUTTONMODE_HOLD, _currRC6Pref, REMOTETYPE_RC6);
- }
- // media player controls
- else if (_currRC6Code == 0x2771) { // PLAY
- handleButton_RCx(BTN_PLAY, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x276F) { // PAUSE
- handleButton_RCx(BTN_PAUSE, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x276E) { // STOP
- handleButton_RCx(BTN_STOP, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x276D) { // PREVIOUS
- handleButton_RCx(BTN_PREV, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2770) { // NEXT
- handleButton_RCx(BTN_NEXT, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- // number keys
- else if (_currRC6Code == 0x2701) { // 1
- handleButton_RCx(BTN_1, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2702) { // 2
- handleButton_RCx(BTN_2, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2703) { // 3
- handleButton_RCx(BTN_3, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2704) { // 4
- handleButton_RCx(BTN_4, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2705) { // 5
- handleButton_RCx(BTN_5, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2706) { // 6
- handleButton_RCx(BTN_6, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2707) { // 7
- handleButton_RCx(BTN_7, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2708) { // 8
- handleButton_RCx(BTN_8, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2709) { // 9
- handleButton_RCx(BTN_9, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2700) { // 0
- handleButton_RCx(BTN_0, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- // channel up/down
- else if (_currRC6Code == 0x2720) { // CH+
- handleButton_RCx(BTN_CH_UP, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- else if (_currRC6Code == 0x2721) { // CH-
- handleButton_RCx(BTN_CH_DOWN, BUTTONMODE_ONCE, _currRC6Pref, REMOTETYPE_RC6);
- }
- // Buttons in NEC CODE due to limitations of this RC:
- // RED
- // GREEN
- // YELLOW
- // BLUE
- // REWIND
- // FAST FORWARD
- // ./CLR
- // CLASS/ENTER
- // AUDIO
- // INFO/DISP
- } // END RC6 CODES
- // NEC CODES - used also for Pioneer remote codes here (Pioneer code consists of 2 NEC codes and is not directly supported by Arduino IRRemote.h)
- else if (results->decode_type == NEC && results->bits == 32) {
- // Pioneer Remote in BD mode, configured code preset to Sat-PVR/Philips 6139 (RC6 code)
- // -> missing/unused buttons "learned" with codes in NEC format
- if (results->value == 0x4FF18E7) { // RED
- handleButton_NEC(BTN_RED, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x4FF02FD) { // GREEN
- handleButton_NEC(BTN_GREEN, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x4FF827D) { // YELLOW
- handleButton_NEC(BTN_YELLOW, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x4FF38C7) { // BLUE
- handleButton_NEC(BTN_BLUE, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x4FFB847) { // REWIND
- handleButton_NEC(BTN_REWD, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x4FF08F7) { // FAST FORWARD
- handleButton_NEC(BTN_FFWD, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x4FF6897) { // ./CLR
- //handleButton_NEC(BTN_, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x4FF9867) { // CLASS/ENTER
- handleButton_NEC(BTN_OK_ENTER, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x4FFF807) { // AUDIO
- //handleButton_NEC(BTN_, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x4FF7887) { // DISPLAY/INFO
- handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- }
- // TOSHIBA SE-R0319
- // NEC 32bit codes
- else if (results->value == 0x2FD48B7) { // POWER
- handleButton_NEC(BTN_POWER, BUTTONMODE_REPEAT);
- }
- else if (results->value == 0x2FDA857) { // SLEEP
- handleButton_NEC(BTN_SLEEP, BUTTONMODE_ONCE);
- }
- // above control pad
- else if (results->value == 0x2FDCA35) { // left above control pad -> TASKSWITCH
- handleButton_NEC(BTN_TASKSWITCH, BUTTONMODE_REPEAT);
- }
- else if (results->value == 0xA25D9E61) { // right above control pad -> CONTEXT
- handleButton_NEC(BTN_CONTEXT, BUTTONMODE_ONCE);
- }
- // control pad
- else if (results->value == 0x2FDBC43) { // ENTER
- handleButton_NEC(BTN_OK_ENTER, BUTTONMODE_HOLD);
- }
- else if (results->value == 0x22DD8A75) { // LEFT
- //handleButton_NEC(BTN_LEFT, BUTTONMODE_HOLD);
- handleButton_NEC(BTN_LEFT, BUTTONMODE_EXTENDED_REPEAT);
- }
- else if (results->value == 0x22DDB24D) { // RIGHT
- //handleButton_NEC(BTN_RIGHT, BUTTONMODE_HOLD);
- handleButton_NEC(BTN_RIGHT, BUTTONMODE_EXTENDED_REPEAT);
- }
- else if (results->value == 0x2FD7C83) { // UP
- //handleButton_NEC(BTN_UP, BUTTONMODE_HOLD);
- handleButton_NEC(BTN_UP, BUTTONMODE_EXTENDED_REPEAT);
- }
- else if (results->value == 0x2FDFC03) { // DOWN
- //handleButton_NEC(BTN_DOWN, BUTTONMODE_HOLD);
- handleButton_NEC(BTN_DOWN, BUTTONMODE_EXTENDED_REPEAT);
- }
- // below control pad
- else if (results->value == 0x2FD708F) { // left below control pad -> MENU
- handleButton_NEC(BTN_MENU, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x22DDF708) { // left below control pad -> BACK
- handleButton_NEC(BTN_BACK, BUTTONMODE_ONCE);
- }
- // volume control
- else if (results->value == 0x2FD58A7) { // VOL+
- handleButton_NEC(BTN_VOL_UP, BUTTONMODE_REPEAT);
- }
- else if (results->value == 0x2FD7887) { // VOL-
- handleButton_NEC(BTN_VOL_DOWN, BUTTONMODE_REPEAT);
- }
- else if (results->value == 0x2FD08F7) { // MUTE
- handleButton_NEC(BTN_MUTE, BUTTONMODE_ONCE);
- }
- // media player controls
- else if (results->value == 0x22DDA857) { // PLAY
- handleButton_NEC(BTN_PLAY, BUTTONMODE_ONCE);
- }
- // else if (results->value == 0xA25DA857) { // PAUSE - combined with GREEN - unused as PLAY/PAUSE is 1 key anyway
- // handleButton_NEC(BTN_PAUSE, BUTTONMODE_ONCE);
- // }
- else if (results->value == 0x22DD28D7) { // STOP
- handleButton_NEC(BTN_STOP, BUTTONMODE_ONCE);
- }
- else if (results->value == 0xA25DC43B) { // PREV
- handleButton_NEC(BTN_PREV, BUTTONMODE_ONCE);
- }
- else if (results->value == 0xA25D24DB) { // NEXT
- handleButton_NEC(BTN_NEXT, BUTTONMODE_ONCE);
- }
- else if (results->value == 0xA25D9867) { // REWD
- handleButton_NEC(BTN_REWD, BUTTONMODE_ONCE);
- }
- else if (results->value == 0xA25DC837) { // FFWD
- handleButton_NEC(BTN_FFWD, BUTTONMODE_ONCE);
- }
- // number keys
- else if (results->value == 0x2FD807F) { // 1
- handleButton_NEC(BTN_1, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x2FD40BF) { // 2
- handleButton_NEC(BTN_2, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x2FDC03F) { // 3
- handleButton_NEC(BTN_3, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x2FD20DF) { // 4
- handleButton_NEC(BTN_4, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x2FDA05F) { // 5
- handleButton_NEC(BTN_5, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x2FD609F) { // 6
- handleButton_NEC(BTN_6, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x2FDE01F) { // 7
- handleButton_NEC(BTN_7, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x2FD10EF) { // 8
- handleButton_NEC(BTN_8, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x2FD906F) { // 9
- handleButton_NEC(BTN_9, BUTTONMODE_ONCE);
- }
- else if (results->value == 0x2FD00FF) { // 0
- handleButton_NEC(BTN_0, BUTTONMODE_ONCE);
- }
- // color keys
- else if (results->value == 0xA25D708F) { // RED (also SLOW REWD)
- handleButton_NEC(BTN_RED, BUTTONMODE_ONCE);
- }
- else if (results->value == 0xA25DA857) { // GREEN (also PAUSE)
- handleButton_NEC(BTN_GREEN, BUTTONMODE_ONCE);
- }
- else if (results->value == 0xA25D07F8) { // YELLOW (also PLAY MODE)
- handleButton_NEC(BTN_YELLOW, BUTTONMODE_ONCE);
- }
- else if (results->value == 0xA25DB04F) { // BLUE (also SLOW FWD)
- handleButton_NEC(BTN_BLUE, BUTTONMODE_ONCE);
- }
- // other
- else if (results->value == 0x2FD38C7) { // DISPLAY
- handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- }
- // else if (results->value == 0xA23DCD32) { // TV/DVD
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0xA25DAF50) { // EJECT
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0x22DDE11E) { // SUBTITLE
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0x2FDF00F) { // INPUT
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0x2FD9867) { // MENU/DVD
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0x22DDFB04) { // MENU/TOP
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0x22DDCA35) { // AUDIO SELECT
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0xA25D02FD) { // CH.RTN/ZOOM
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0x22DDBA45) { // RETURN (next to PLAY)
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0xA25D37C8) { // MARKER
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0x22DD6996) { // ANGLE
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0x22DD3AC5) { // REPEAT A+B
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0x22DDD926) { // JUMP
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // else if (results->value == 0x2FD9A65) { // PIC SIZE
- // handleButton_NEC(BTN_INFO, BUTTONMODE_ONCE);
- // }
- // Pioneer Codes - here we have to take 2 received codes into account, so we check against the last received that we stored in a global variable then ;-)
- // // Pioneer 2238 code for BD ---- NOT UNUSED ANY MORE
- // if (lastNECcode == 0xD52A34CB && results->value == 0xF50AC639) { // LEFT
- // handleButton(BTN_LEFT, true);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A26D9) { // RIGHT
- // handleButton(BTN_RIGHT, true);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A4FB0) { // UP
- // handleButton(BTN_UP, true);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50ACF30) { // DOWN
- // handleButton(BTN_DOWN, true);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AF708) { // ENTER + CLASS ENTER
- // handleButton(BTN_OK_ENTER, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A3DC2) { // POWER
- // //handleButton(BTN_POWER, false);
- // handlePowerButton();
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A2DD2) { // AUDIO PARAMETER - top left at control pad
- // //handleButton(BTN_, false);
- // }
- // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A3CC3) { // VIDEO PARAMETER - top right at control pad
- // //handleButton(BTN_, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A0DF2) { // HOME MENU - bottom left at control pad
- // handleButton(BTN_MENU, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A2FD0) { // RETURN - bottom right at control pad
- // handleButton(BTN_BACK, false);
- // }
- // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A26D9) { // RED
- // handleButton(BTN_RED, false);
- // }
- // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50AA659) { // GREEN
- // handleButton(BTN_GREEN, false);
- // }
- // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A1FE0) { // YELLOW
- // handleButton(BTN_YELLOW, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A9D62) { // BLUE
- // handleButton(BTN_BLUE, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A57A8) { // REWIND
- // handleButton(BTN_REWD, true);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A9768) { // FFWD
- // handleButton(BTN_FFWD, true);
- // }
- // else if (lastNECcode == 0xD52A44BB && results->value == 0xD52A44BB) { // PLAY
- // handleButton(BTN_PLAY, false);
- // }
- // else if (lastNECcode == 0xD52AE41B && results->value == 0xD52AE41B) { // PREVIOUS
- // handleButton(BTN_PREV, false);
- // }
- // else if (lastNECcode == 0xD52AC43B && results->value == 0xD52AC43B) { // PAUSE
- // handleButton(BTN_PAUSE, false);
- // }
- // else if (lastNECcode == 0xD52A04FB && results->value == 0xD52A04FB) { // STOP
- // handleButton(BTN_STOP, false);
- // }
- // else if (lastNECcode == 0xD52A649B && results->value == 0xD52A649B) { // NEXT TRACK
- // handleButton(BTN_NEXT, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A05FA) { // 0
- // handleButton(BTN_0, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A857A) { // 1
- // handleButton(BTN_1, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A45BA) { // 2
- // handleButton(BTN_2, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AC53A) { // 3
- // handleButton(BTN_3, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A25DA) { // 4
- // handleButton(BTN_4, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AA55A) { // 5
- // handleButton(BTN_5, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A659A) { // 6
- // handleButton(BTN_6, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AE51A) { // 7
- // handleButton(BTN_7, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A15EA) { // 8
- // handleButton(BTN_8, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A956A) { // 9
- // handleButton(BTN_9, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50A7D82) { // AUDIO
- // //handleButton(BTN_POWER, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AC738) { // DISP/INFO
- // //handleButton(BTN_POWER, false);
- // }
- // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50A7689) { // CH_UP
- // handleButton(BTN_CH_UP, false);
- // }
- // else if (lastNECcode == 0xD52A54AB && results->value == 0xF50AF609) { // CH_DOWN
- // handleButton(BTN_CH_DOWN, false);
- // }
- // else if (lastNECcode == 0xD52A34CB && results->value == 0xF50AA758) { // ./CLR/D.ACCESS
- // //handleButton(BTN_POWER, false);
- // }
- // remember last NEC code - for PIONEER remotes sending 2 NEC codes as one PIONEER code
- //lastNECcode = results->value;
- else {
- // unknown / not implemented NEC code -> must reset last key or a repeat of this unknown key will trigger the last one
- handleButton_NEC(BTN_UNKNOWN, BUTTONMODE_REPEAT);
- }
- } // END NEC CODES
- // NEC repetitions (0 bits)
- // RC using NEC code send a 0 bit NEC code as repetition after the actual key press
- else if (results->decode_type == NEC && results->bits == 0) {
- if (debug) Serial.println(F("NEC REPETITION"));
- handleButton_NEC(BTN_REPETITION, BUTTONMODE_LAST);
- }
- }
- //+=============================================================================
- // The repeating section of the code
- //
- void loop ( )
- {
- decode_results results; // Somewhere to store the results
- if (irrecv.decode(&results)) { // Grab an IR code
- dumpInfo(&results); // Output the results (if not in ignore time window)
- irrecv.resume(); // Prepare for the next value
- }
- handlePowerButton_loop();
- handleTaskSwitchButton_loop();
- handleHoldButtons_loop(); // release all keys after timeout
- }
|