keyboardFullEtc
} keyboard_t;
+typedef enum {
+ UP = 0,
+ DOWN,
+ RIGHT,
+ LEFT,
+ INVALID_ESC_CHAR
+} esc_chars_t;
+
+
static keyboard_t Keyboard;
static int TerminalWindowActive = 0;
static void ShiftPress(Boolean down, Boolean lockDown) FORMS_SEGMENT;
static void SendModifiedKey(unsigned char c) FORMS_SEGMENT;
static void ClearModifiers(void) FORMS_SEGMENT;
-static void SendUpArrowKey(void) FORMS_SEGMENT;
-static void SendDownArrowKey(void) FORMS_SEGMENT;
-static void SendRightArrowKey(void) FORMS_SEGMENT;
-static void SendLeftArrowKey(void) FORMS_SEGMENT;
+/* static void SendUpArrowKey(void) FORMS_SEGMENT; */
+/* static void SendDownArrowKey(void) FORMS_SEGMENT; */
+/* static void SendRightArrowKey(void) FORMS_SEGMENT; */
+/* static void SendLeftArrowKey(void) FORMS_SEGMENT; */
+static void SendEscapeChar(esc_chars_t) FORMS_SEGMENT;
static void SendFKey(UInt16 id) FORMS_SEGMENT;
static void SendScrollpadKey(UInt16 id) FORMS_SEGMENT;
static void SendEscapeKey(void) FORMS_SEGMENT;
};
+static unsigned char esc_keys[5] = {
+ 'A', // UP
+ 'B', // DOWN
+ 'C', // RIGHT
+ 'D', // LEFT
+};
+
static unsigned char altsym_character(unsigned char c)
{
if (c == '@') return '&';
}
-static void SendUpArrowKey(void)
-{
- ClearModifiers();
- if (ssh_app_cursor_keys(ss))
- ssh_keys(ss, "\eOA", 3);
- else
- ssh_keys(ss, "\e[A", 3);
-}
+/* static void SendUpArrowKey(void) */
+/* { */
+/* ClearModifiers(); */
+/* if (ssh_app_cursor_keys(ss)) */
+/* ssh_keys(ss, "\eOA", 3); */
+/* else */
+/* ssh_keys(ss, "\e[A", 3); */
+/* } */
-static void SendDownArrowKey(void)
-{
- ClearModifiers();
- if (ssh_app_cursor_keys(ss))
- ssh_keys(ss, "\eOB", 3);
- else
- ssh_keys(ss, "\e[B", 3);
-}
+/* static void SendDownArrowKey(void) */
+/* { */
+/* ClearModifiers(); */
+/* if (ssh_app_cursor_keys(ss)) */
+/* ssh_keys(ss, "\eOB", 3); */
+/* else */
+/* ssh_keys(ss, "\e[B", 3); */
+/* } */
-static void SendRightArrowKey(void)
-{
- ClearModifiers();
- if (ssh_app_cursor_keys(ss))
- ssh_keys(ss, "\eOC", 3);
- else
- ssh_keys(ss, "\e[C", 3);
-}
+/* static void SendRightArrowKey(void) */
+/* { */
+/* ClearModifiers(); */
+/* if (ssh_app_cursor_keys(ss)) */
+/* ssh_keys(ss, "\eOC", 3); */
+/* else */
+/* ssh_keys(ss, "\e[C", 3); */
+/* } */
-static void SendLeftArrowKey(void)
+/* static void SendLeftArrowKey(void) */
+/* { */
+/* ClearModifiers(); */
+/* if (ssh_app_cursor_keys(ss)) */
+/* ssh_keys(ss, "\eOD", 3); */
+/* else */
+/* ssh_keys(ss, "\e[D", 3); */
+/* } */
+
+
+static void SendEscapeChar(esc_chars_t c)
{
- ClearModifiers();
- if (ssh_app_cursor_keys(ss))
- ssh_keys(ss, "\eOD", 3);
- else
- ssh_keys(ss, "\e[D", 3);
+ uint8_t sequence[3];
+
+ ClearModifiers();
+ if (c >= INVALID_ESC_CHAR)
+ return;
+
+ sequence[0] = '\e';
+ sequence[1] = ssh_app_cursor_keys(ss) ? 'O' : '[';
+ sequence[2] = esc_keys[c];
+ ssh_keys(ss, sequence, 3);
}
// fixme these repeating buttons don't work as smoothly as the 5-way
case TerminalBFullUpButtonID:
// case TerminalRArrowsUpButtonID:
- SendUpArrowKey();
+ //SendUpArrowKey();
+ SendEscapeChar(UP);
return false;
case TerminalBFullDownButtonID:
// case TerminalRArrowsDownButtonID:
- SendDownArrowKey();
+ //SendDownArrowKey();
+ SendEscapeChar(DOWN);
return false;
case TerminalBFullLeftButtonID:
// case TerminalRArrowsLeftButtonID:
- SendLeftArrowKey();
+ //SendLeftArrowKey();
+ SendEscapeChar(LEFT);
return false;
case TerminalBFullRightButtonID:
// case TerminalRArrowsRightButtonID:
- SendRightArrowKey();
+ //SendRightArrowKey();
+ SendEscapeChar(RIGHT);
return false;
default:
// send CR rather than LF
if (c == 10) c = 13;
// remap DEL or BS based on backspace configuration
- if (c == 8 || c == 127) c = Backspace();
+ if (c == 8 || c == 127)
+ {
+ if (altPressed)
+ {
+ SendScrollpadKey(TerminalTEtcDelButtonID); //DELETE
+ return true;
+ }
+ c = Backspace();
+ }
+
if (altPressed) c = altsym_character(c);
// remap ` based on backquote configuration
if (c == '`') c = Backquote();
// send arrow key control codes rather than ASCII values
- if (c == 28) SendLeftArrowKey();
- else if (c == 29) SendRightArrowKey();
- else if (c == 30) SendUpArrowKey();
- else if (c == 31) SendDownArrowKey();
+ if (c == 28) SendEscapeChar(LEFT);//SendLeftArrowKey();
+ else if (c == 29) SendEscapeChar(RIGHT);//SendRightArrowKey();
+ else if (c == 30) SendEscapeChar(UP);//SendUpArrowKey();
+ else if (c == 31) SendEscapeChar(DOWN);//SendDownArrowKey();
// handle ctrl modifier on external keyboard
else if (e->data.keyDown.modifiers & controlKeyMask) SendModifiedKey(control_character(c));
else if (NavDirectionPressed(e, Up) || chr == vchrRockerUp)
{
ClearModifiers();
- SendUpArrowKey();
+// SendUpArrowKey();
+ SendEscapeChar(UP);
return true;
}
else if (NavDirectionPressed(e, Down) || chr == vchrRockerDown) {
ClearModifiers();
- SendDownArrowKey();
+// SendDownArrowKey();
+ SendEscapeChar(DOWN);
return true;
}
else if (NavDirectionPressed(e, Right) || chr == vchrRockerRight) {
ClearModifiers();
- SendRightArrowKey();
+// SendRightArrowKey();
+ SendEscapeChar(RIGHT);
return true;
}
else if (NavDirectionPressed(e, Left) || chr == vchrRockerLeft) {
ClearModifiers();
- SendLeftArrowKey();
+// SendLeftArrowKey();
+ SendEscapeChar(LEFT);
return true;
}
return false;