+ min = i + 1;\r
+ }\r
+ }\r
+}\r
+\r
+#define STATE_LEFT_SHIFT 0x01\r
+#define STATE_RIGHT_SHIFT 0x02\r
+#define STATE_LEFT_CTRL 0x04\r
+#define STATE_LEFT_ALT 0x08\r
+#define STATE_RIGHT_ALT 0x10\r
+\r
+#define KEY_ESCAPE 0x1B // keycode = 0x006e\r
+#define KEY_MENUE 0x80 // keycode = 0x0070\r
+#define KEY_BACK 0x81 // keycode = 0x0071\r
+#define KEY_FORWARD 0x82 // keycode = 0x0072\r
+#define KEY_ADDRESS 0x83 // keycode = 0x0073\r
+#define KEY_WINDOW 0x84 // keycode = 0x0074\r
+#define KEY_1ST_PAGE 0x85 // keycode = 0x0075\r
+#define KEY_STOP 0x86 // keycode = 0x0076\r
+#define KEY_MAIL 0x87 // keycode = 0x0077\r
+#define KEY_FAVORITES 0x88 // keycode = 0x0078\r
+#define KEY_NEW_PAGE 0x89 // keycode = 0x0079\r
+#define KEY_SETUP 0x8A // keycode = 0x007a\r
+#define KEY_FONT 0x8B // keycode = 0x007b\r
+#define KEY_PRINT 0x8C // keycode = 0x007c\r
+#define KEY_ON_OFF 0x8E // keycode = 0x007c\r
+\r
+#define KEY_INSERT 0x90 // keycode = 0x004b\r
+#define KEY_DELETE 0x91 // keycode = 0x004c\r
+#define KEY_LEFT 0x92 // keycode = 0x004f\r
+#define KEY_HOME 0x93 // keycode = 0x0050\r
+#define KEY_END 0x94 // keycode = 0x0051\r
+#define KEY_UP 0x95 // keycode = 0x0053\r
+#define KEY_DOWN 0x96 // keycode = 0x0054\r
+#define KEY_PAGE_UP 0x97 // keycode = 0x0055\r
+#define KEY_PAGE_DOWN 0x98 // keycode = 0x0056\r
+#define KEY_RIGHT 0x99 // keycode = 0x0059\r
+#define KEY_MOUSE_1 0x9E // keycode = 0x0400\r
+#define KEY_MOUSE_2 0x9F // keycode = 0x0800\r
+\r
+static uint8_t\r
+get_fdc_key (uint16_t cmd)\r
+{\r
+ static uint8_t key_table[128] =\r
+ {\r
+ // 0 1 2 3 4 5 6 7 8 9 A B C D E F\r
+ 0, '^', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'ß', '´', 0, '\b',\r
+ '\t','q', 'w', 'e', 'r', 't', 'z', 'u', 'i', 'o', 'p', 'ü', '+', 0, 0, 'a',\r
+ 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'ö', 'ä', '#', '\r', 0, '<', 'y', 'x',\r
+ 'c', 'v', 'b', 'n', 'm', ',', '.', '-', 0, 0, 0, 0, 0, ' ', 0, 0,\r
+\r
+ 0, '°', '!', '"', '§', '$', '%', '&', '/', '(', ')', '=', '?', '`', 0, '\b',\r
+ '\t','Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', 'O', 'P', 'Ü', '*', 0, 0, 'A',\r
+ 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Ö', 'Ä', '\'','\r', 0, '>', 'Y', 'X',\r
+ 'C', 'V', 'B', 'N', 'M', ';', ':', '_', 0, 0, 0, 0, 0, ' ', 0, 0\r
+ };\r
+ static uint8_t state;\r
+\r
+ uint8_t key = 0;\r
+\r
+ switch (cmd)\r
+ {\r
+ case 0x002C: state |= STATE_LEFT_SHIFT; break; // pressed left shift\r
+ case 0x00AC: state &= ~STATE_LEFT_SHIFT; break; // released left shift\r
+ case 0x0039: state |= STATE_RIGHT_SHIFT; break; // pressed right shift\r
+ case 0x00B9: state &= ~STATE_RIGHT_SHIFT; break; // released right shift\r
+ case 0x003A: state |= STATE_LEFT_CTRL; break; // pressed left ctrl\r
+ case 0x00BA: state &= ~STATE_LEFT_CTRL; break; // released left ctrl\r
+ case 0x003C: state |= STATE_LEFT_ALT; break; // pressed left alt\r
+ case 0x00BC: state &= ~STATE_LEFT_ALT; break; // released left alt\r
+ case 0x003E: state |= STATE_RIGHT_ALT; break; // pressed left alt\r
+ case 0x00BE: state &= ~STATE_RIGHT_ALT; break; // released left alt\r
+\r
+ case 0x006e: key = KEY_ESCAPE; break;\r
+ case 0x004b: key = KEY_INSERT; break;\r
+ case 0x004c: key = KEY_DELETE; break;\r
+ case 0x004f: key = KEY_LEFT; break;\r
+ case 0x0050: key = KEY_HOME; break;\r
+ case 0x0051: key = KEY_END; break;\r
+ case 0x0053: key = KEY_UP; break;\r
+ case 0x0054: key = KEY_DOWN; break;\r
+ case 0x0055: key = KEY_PAGE_UP; break;\r
+ case 0x0056: key = KEY_PAGE_DOWN; break;\r
+ case 0x0059: key = KEY_RIGHT; break;\r
+ case 0x0400: key = KEY_MOUSE_1; break;\r
+ case 0x0800: key = KEY_MOUSE_2; break;\r
+\r
+ default:\r
+ {\r
+ if (!(cmd & 0x80)) // pressed key\r
+ {\r
+ if (cmd >= 0x70 && cmd <= 0x7F) // function keys\r
+ {\r
+ key = cmd + 0x10; // 7x -> 8x\r
+ }\r
+ else if (cmd < 64) // key listed in key_table\r
+ {\r
+ if (state & (STATE_LEFT_ALT | STATE_RIGHT_ALT))\r
+ {\r
+ switch (cmd)\r
+ {\r
+ case 0x0003: key = '²'; break;\r
+ case 0x0008: key = '{'; break;\r
+ case 0x0009: key = '['; break;\r
+ case 0x000A: key = ']'; break;\r
+ case 0x000B: key = '}'; break;\r
+ case 0x000C: key = '\\'; break;\r
+ case 0x001C: key = '~'; break;\r
+ case 0x002D: key = '|'; break;\r
+ case 0x0034: key = 'µ'; break;\r
+ }\r
+ }\r
+ else if (state & (STATE_LEFT_CTRL))\r
+ {\r
+ if (key_table[cmd] >= 'a' && key_table[cmd] <= 'z')\r
+ {\r
+ key = key_table[cmd] - 'a' + 1;\r
+ }\r
+ else\r
+ {\r
+ key = key_table[cmd];\r
+ }\r
+ }\r
+ else\r
+ {\r
+ int idx = cmd + ((state & (STATE_LEFT_SHIFT | STATE_RIGHT_SHIFT)) ? 64 : 0);\r
+\r
+ if (key_table[idx])\r
+ {\r
+ key = key_table[idx];\r
+ }\r
+ }\r
+ }\r
+ }\r
+ break;\r
+ }\r
+ }\r
+\r
+ return (key);\r
+}\r
+\r
+static int analyze = FALSE;\r
+static int list = FALSE;\r
+static IRMP_DATA irmp_data;\r
+\r
+static void\r
+next_tick (void)\r
+{\r
+ if (! analyze && ! list)\r
+ {\r
+ (void) irmp_ISR ();\r
+\r
+ if (irmp_get_data (&irmp_data))\r
+ {\r
+ uint8_t key;\r
+\r
+ ANALYZE_ONLY_NORMAL_PUTCHAR (' ');\r
+\r
+ if (verbose)\r
+ {\r
+ printf ("%8d ", time_counter);\r
+ }\r
+\r
+ if (irmp_data.protocol == IRMP_FDC_PROTOCOL && (key = get_fdc_key (irmp_data.command)) != 0)\r
+ {\r
+ if ((key >= 0x20 && key < 0x7F) || key >= 0xA0)\r
+ {\r
+ printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = '%c'\n",\r
+ irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, key);\r
+ }\r
+ else if (key == '\r' || key == '\t' || key == KEY_ESCAPE || (key >= 0x80 && key <= 0x9F)) // function keys\r
+ {\r
+ char * p = (char *) NULL;\r
+\r
+ switch (key)\r
+ {\r
+ case '\t' : p = "TAB"; break;\r
+ case '\r' : p = "CR"; break;\r
+ case KEY_ESCAPE : p = "ESCAPE"; break;\r
+ case KEY_MENUE : p = "MENUE"; break;\r
+ case KEY_BACK : p = "BACK"; break;\r
+ case KEY_FORWARD : p = "FORWARD"; break;\r
+ case KEY_ADDRESS : p = "ADDRESS"; break;\r
+ case KEY_WINDOW : p = "WINDOW"; break;\r
+ case KEY_1ST_PAGE : p = "1ST_PAGE"; break;\r
+ case KEY_STOP : p = "STOP"; break;\r
+ case KEY_MAIL : p = "MAIL"; break;\r
+ case KEY_FAVORITES : p = "FAVORITES"; break;\r
+ case KEY_NEW_PAGE : p = "NEW_PAGE"; break;\r
+ case KEY_SETUP : p = "SETUP"; break;\r
+ case KEY_FONT : p = "FONT"; break;\r
+ case KEY_PRINT : p = "PRINT"; break;\r
+ case KEY_ON_OFF : p = "ON_OFF"; break;\r
+\r
+ case KEY_INSERT : p = "INSERT"; break;\r
+ case KEY_DELETE : p = "DELETE"; break;\r
+ case KEY_LEFT : p = "LEFT"; break;\r
+ case KEY_HOME : p = "HOME"; break;\r
+ case KEY_END : p = "END"; break;\r
+ case KEY_UP : p = "UP"; break;\r
+ case KEY_DOWN : p = "DOWN"; break;\r
+ case KEY_PAGE_UP : p = "PAGE_UP"; break;\r
+ case KEY_PAGE_DOWN : p = "PAGE_DOWN"; break;\r
+ case KEY_RIGHT : p = "RIGHT"; break;\r
+ case KEY_MOUSE_1 : p = "KEY_MOUSE_1"; break;\r
+ case KEY_MOUSE_2 : p = "KEY_MOUSE_2"; break;\r
+ default : p = "<UNKNWON>"; break;\r
+ }\r
+\r
+ printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x, key = %s\n",\r
+ irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key, p);\r
+ }\r
+ else\r
+ {\r
+ printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x, asc = 0x%02x\n",\r
+ irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags, key);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ printf ("p = %2d, a = 0x%04x, c = 0x%04x, f = 0x%02x\n",\r
+ irmp_data.protocol, irmp_data.address, irmp_data.command, irmp_data.flags);\r
+ }\r