static int keyboard_msghandler (int m, int c) { if (m == 0) return keyboard_getchar (); return 0; }
/** * Scrive in un buffer tot dati ricevuti dalla tastiera */ uint32_t keyboard_read(char *data, uint32_t size, uint64_t off) { int i = 0; char c; while(((c = keyboard_getchar()) != 0) && (i < size)) { data[i] = c; i++; } return i; }
int conthread(void *arg) { for (;;) { c = keyboard_getchar(); if (c == '\n') { monitor_put(c); int ret; ret = return_fn(cmd); memset(&cmd[0], 0, sizeof(cmd)); newcmd(); } else { append(cmd, c); monitor_put(c); } } return 6; }
static int curses_getchar(int _delay) { #if CONFIG(LP_USB_HID) || CONFIG(LP_PC_KEYBOARD) || \ CONFIG(LP_SERIAL_CONSOLE) unsigned short c; #endif do { #if CONFIG(LP_USB_HID) usb_poll(); if ((curses_flags & F_ENABLE_CONSOLE) && usbhid_havechar()) { c = usbhid_getchar(); if (c != 0) return c; } #endif #if CONFIG(LP_PC_KEYBOARD) if ((curses_flags & F_ENABLE_CONSOLE) && keyboard_havechar()) { c = keyboard_getchar(); if (c != 0) return c; } #endif #if CONFIG(LP_SERIAL_CONSOLE) if ((curses_flags & F_ENABLE_SERIAL) && serial_havechar()) { c = serial_getchar(); return cook_serial(c); } #endif if (_delay == 0) { break; } else if (_delay >= 10) { mdelay(10); _delay -= 10; } else if (_delay > 0) { mdelay(_delay); _delay = 0; } } while (1); return ERR; }
static int curses_getchar(int _delay) { #if defined(CONFIG_USB_HID) || defined(CONFIG_PC_KEYBOARD) || defined(CONFIG_SERIAL_CONSOLE) unsigned short c; #endif do { #ifdef CONFIG_USB_HID usb_poll(); if ((curses_flags & F_ENABLE_CONSOLE) && usbhid_havechar()) { c = usbhid_getchar(); if (c != 0) return c; } #endif #ifdef CONFIG_PC_KEYBOARD if ((curses_flags & F_ENABLE_CONSOLE) && keyboard_havechar()) { c = keyboard_getchar(); if (c != 0) return c; } #endif #ifdef CONFIG_SERIAL_CONSOLE if ((curses_flags & F_ENABLE_SERIAL) && serial_havechar()) { c = serial_getchar(); return cook_serial(c); } #endif if (_delay == 0) break; if (_delay > 0) { mdelay(1); _delay--; } } while (1); return ERR; }
int PDC_get_key(void) { int c = 0; #ifdef CONFIG_USB_HID usb_poll(); if ((curses_flags & F_ENABLE_CONSOLE) && usbhid_havechar()) { c = usbhid_getchar(); } #endif #ifdef CONFIG_PC_KEYBOARD if ((curses_flags & F_ENABLE_CONSOLE) && keyboard_havechar() && (c==0)) { c = keyboard_getchar(); } #endif #ifdef CONFIG_SERIAL_CONSOLE if ((curses_flags & F_ENABLE_SERIAL) && serial_havechar() && (c==0)) { c = cook_serial(serial_getchar()); } #endif SP->key_code = FALSE; if (c == 0) { c = ERR; } if (c >= KEY_MIN) { SP->key_code = TRUE; } return c; }
short console_getline(console_color_t color, char *str, unsigned short *len) { unsigned short i=0; char c; unsigned char c233 = vga_color233(vga_console_color(color)); while (i < *len-1) { if ((sysio[0] & 0x2) == 0x2) c = keyboard_getchar(); else c = serial_getchar(0); if (c >= ' ' && c <= '~') { if ((sysio[0] & 0x2) == 0x2) vga_putchar(c233,c); else serial_putchar(0, c); str[i++] = c; } if (c == '\r' || c == '\n') { str[i] = '\0'; return i; } if (c == 0x03) { str[0] = '\0'; return -1; } if ((c == 0x7f || c == 0x08) && i > 0) { if ((sysio[0] & 0x2) == 0x2) vga_putchar(c233, c); else serial_putchar(0, c); i--; } } str[i+1] = '\0'; return i; }