1 /* Public Domain Curses */
6 unsigned long pdc_key_modifiers
= 0L;
8 #if CONFIG(LP_SERIAL_CONSOLE)
9 /* We treat serial like a vt100 terminal. For now we
10 do the cooking in here, but we should probably eventually
11 pass it to dedicated vt100 code */
13 static int getkeyseq(char *buffer
, int len
, int max
)
18 for(i
= 0; i
< 75; i
++) {
19 if (serial_havechar())
27 buffer
[len
++] = serial_getchar();
56 { "[21~", KEY_F(10) },
57 { "[23~", KEY_F(11) },
58 { "[24~", KEY_F(12) },
62 static int handle_escape(void)
65 int len
= getkeyseq(buffer
, 0, sizeof(buffer
));
71 for(i
= 0; escape_codes
[i
].seq
!= NULL
; i
++) {
72 const char *p
= escape_codes
[i
].seq
;
74 for(t
= 0; t
< len
; t
++) {
75 if (!*p
|| *p
!= buffer
[t
])
81 return escape_codes
[i
].key
;
87 static int cook_serial(unsigned char ch
)
94 return handle_escape();
102 void PDC_set_keyboard_binary(bool on
)
104 PDC_LOG(("PDC_set_keyboard_binary() - called\n"));
107 /* check if a key event is waiting */
109 bool PDC_check_key(void)
111 #if CONFIG(LP_USB_HID)
113 if ((curses_flags
& F_ENABLE_CONSOLE
) &&
119 #if CONFIG(LP_PC_KEYBOARD)
120 if ((curses_flags
& F_ENABLE_CONSOLE
) &&
121 keyboard_havechar()) {
126 #if CONFIG(LP_SERIAL_CONSOLE)
127 if ((curses_flags
& F_ENABLE_SERIAL
) &&
136 /* return the next available key event */
138 int PDC_get_key(void)
142 #if CONFIG(LP_USB_HID)
144 if ((curses_flags
& F_ENABLE_CONSOLE
) &&
146 c
= usbhid_getchar();
150 #if CONFIG(LP_PC_KEYBOARD)
151 if ((curses_flags
& F_ENABLE_CONSOLE
) &&
152 keyboard_havechar() && (c
== 0)) {
153 c
= keyboard_getchar();
157 #if CONFIG(LP_SERIAL_CONSOLE)
158 if ((curses_flags
& F_ENABLE_SERIAL
) &&
159 serial_havechar() && (c
== 0)) {
160 c
= cook_serial(serial_getchar());
164 SP
->key_code
= FALSE
;
176 /* discard any pending keyboard input -- this is the core
177 routine for flushinp() */
179 void PDC_flushinp(void)
181 PDC_LOG(("PDC_flushinp() - called\n"));
183 while (PDC_check_key()) PDC_get_key();
186 int PDC_mouse_set(void)
191 int PDC_modifiers_set(void)