diff --git a/bin/boneshell/boneshell.c b/bin/boneshell/boneshell.c index a2ba2f5..2813903 100644 --- a/bin/boneshell/boneshell.c +++ b/bin/boneshell/boneshell.c @@ -157,16 +157,16 @@ int boneshell_handler(char* cmd) else if(num_opts==1) loop_terminal(); else - printk(cmd_boneshell.invalid_use_msg); + printk(cmd_boneshell.invalid_use_msg); return STATUS_OK; } struct cmd_t cmd_boneshell = { - .name = "boneshell", - .usage = "boneshell [--help] ", - .help = "boneshell(1) \t\t\t\t BoneOS Terminal Manual \n" + .name = "boneshell", + .usage = "boneshell [--help] ", + .help = "boneshell(1) \t\t\t\t BoneOS Terminal Manual \n" "NAME : \n " "\tboneshell\n" "SYNOPSIS : \n " @@ -176,11 +176,11 @@ struct cmd_t cmd_boneshell = "\tthe child of the previous parent shell process.\n " "\tcommand exit used to stop this child shell process.\n " "\ttype exit --help for more on exit command\n ", - .cmd_opts = cmd_boneshell_opts, - .handler = &boneshell_handler, - .invalid_use_msg = "Invalid use of boneshell command.\n" - "Type in boneshell --help for more help.\n", - .privilege = USER + .cmd_opts = cmd_boneshell_opts, + .handler = &boneshell_handler, + .invalid_use_msg = "Invalid use of boneshell command.\n" + "Type in boneshell --help for more help.\n", + .privilege = USER }; diff --git a/platform/pc/drv/ps2/kbd/kbd.c b/platform/pc/drv/ps2/kbd/kbd.c index 36b9e72..1dd8e45 100644 --- a/platform/pc/drv/ps2/kbd/kbd.c +++ b/platform/pc/drv/ps2/kbd/kbd.c @@ -66,10 +66,10 @@ extern volatile char __get_char_chr; //Keyboard Driver Handler struct device_driver_t kbd_driver = { - .name = "8042 Keyboard PS/2 Driver", - .init = &init_kbd, - .uninit = &uninit_kbd, - .version = "8042" + .name = "8042 Keyboard PS/2 Driver", + .init = &init_kbd, + .uninit = &uninit_kbd, + .version = "8042" }; @@ -88,9 +88,9 @@ struct device_driver_t kbd_driver = int key_press(uint8_t scancode) { if(kbd_info.is_shift) - return (kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_shift[scancode]); + return (kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_shift[scancode]); else - return (kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_no_shift[scancode]); + return (kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_no_shift[scancode]); } /* @@ -104,11 +104,11 @@ int key_press(uint8_t scancode) */ void key_release(uint8_t scancode) { - if ( - kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_no_shift[scancode] == KBD_LEFT_SHIFT_PRESS_ID || - kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_no_shift[scancode] == KBD_RIGHT_SHIFT_PRESS_ID - ) - kbd_info.is_shift = false; + if ( + kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_no_shift[scancode] == KBD_LEFT_SHIFT_PRESS_ID || + kbd_layouts[kbd_info.current_kbd_layout_index]->scancode_no_shift[scancode] == KBD_RIGHT_SHIFT_PRESS_ID + ) + kbd_info.is_shift = false; } /* @@ -185,72 +185,75 @@ void key_handler_util(int key) { if(isalpha(key)==0) { - if(print_scank == true && active_scank == true) - { - inc_al(); - printk("%c", key); - wait_until_enter(key); - } - - else if(active_scank == true) - wait_until_enter(key); + if(print_scank == true && active_scank == true) + { + inc_al(); + printk("%c", key); + wait_until_enter(key); + } + + else if(active_scank == true) + wait_until_enter(key); } else { - if(kbd_info.is_caps == false && print_scank == true && active_scank == true) - { - inc_al(); - if (kbd_info.is_shift == true) { - printk("%c", toupper(key)); - } - else if (kbd_info.is_shift == false) { - printk ("%c", tolower (key)); - } - wait_until_enter(key); - } - else if(kbd_info.is_caps == true && print_scank == true && active_scank == true) - { - inc_al(); - if(kbd_info.is_shift == true) + if(kbd_info.is_caps == false && print_scank == true && active_scank == true) { - key = tolower (key); + inc_al(); + if (kbd_info.is_shift == true) { + printk("%c", toupper(key)); + } + else if (kbd_info.is_shift == false) { + printk ("%c", tolower (key)); + } + wait_until_enter(key); } - else + else if(kbd_info.is_caps == true && print_scank == true && active_scank == true) { - key = toupper (key); + inc_al(); + if(kbd_info.is_shift == true) + { + key = tolower (key); + } + else + { + key = toupper (key); + } + printk ("%c", key); + wait_until_enter(key); } - printk ("%c", key); - wait_until_enter(key); - } - - else if(active_scank == true) - wait_until_enter(key); + else if(active_scank == true) + wait_until_enter(key); } } void key_handler_util_backspace() { - if(!((LENGTH_INPUT-1) < 0)) - { - if(active_scank) - buffer_scank[index_scank--] = 0; - if(print_scank == true) printk("\b"); - INDEX_CURSOR_POSITION-=1; - LENGTH_INPUT-=1; - } + if(!((LENGTH_INPUT-1) < 0)) + { + if(active_scank) + buffer_scank[index_scank--] = 0; + + if(print_scank == true) + printk("\b"); + + INDEX_CURSOR_POSITION-=1; + LENGTH_INPUT-=1; + } } - bool tab_util(volatile char* buf_scan, volatile char* _cmd) - { - for(int i=0; buf_scan[i]; i++) - if(buf_scan[i] != _cmd[i]) - return false; - return true; - } +bool tab_util(volatile char* buf_scan, volatile char* _cmd) +{ + for(int i=0; buf_scan[i]; i++) + if(buf_scan[i] != _cmd[i]) + return false; - void key_handler_util_tab() - { + return true; +} + +void key_handler_util_tab() +{ int index_tab=0; int num_cmds=0; for(int i=0; cmds[i]; i++) @@ -300,80 +303,90 @@ void key_handler_util_backspace() */ void key_handler() { - switch(kbd_info.key) - { - //Is shift pressed - case KBD_LEFT_SHIFT_PRESS_ID: - case KBD_RIGHT_SHIFT_PRESS_ID: - kbd_info.is_shift = true; - break; - case KBD_CAPS_PRESS_ID: - kbd_info.is_caps = !kbd_info.is_caps; - break; - case KBD_UP_KEY_ID: - if(TERMINAL_MODE == true && UP_KEY_ACTIVE == true) - { - UP_KEY_ACTIVE = false; - int LENGTH_INPUT_STORE = LENGTH_INPUT; - for (int i=0; i= 32 && ((int)kbd_info.key) <=47) - key_handler_util(kbd_info.key); - else if(((int)kbd_info.key) >= 58 && ((int)kbd_info.key) <=64) - key_handler_util(kbd_info.key); - else if(((int)kbd_info.key) >= 91 && ((int)kbd_info.key) <=96) - key_handler_util(kbd_info.key); - else if(((int)kbd_info.key) >= 123 && ((int)kbd_info.key) <=126) - key_handler_util(kbd_info.key); - break; - } + if(print_scank == true) + printk("\n"); + + break; + default: + if(isalpha(kbd_info.key)!=0) + key_handler_util(kbd_info.key); + else if(isdigit(kbd_info.key)!=0) + key_handler_util(kbd_info.key); + else if(((int)kbd_info.key) >= 32 && ((int)kbd_info.key) <=47) + key_handler_util(kbd_info.key); + else if(((int)kbd_info.key) >= 58 && ((int)kbd_info.key) <=64) + key_handler_util(kbd_info.key); + else if(((int)kbd_info.key) >= 91 && ((int)kbd_info.key) <=96) + key_handler_util(kbd_info.key); + else if(((int)kbd_info.key) >= 123 && ((int)kbd_info.key) <=126) + key_handler_util(kbd_info.key); + break; + } } @@ -388,9 +401,10 @@ void key_handler() */ void kbd_handler(int_regs *r) { - if(r){}; - kbd_info.scancode =kbd_enc_read_input_buf(); - if(kbd_info.scancode & 0x80) + if(r){}; + kbd_info.scancode =kbd_enc_read_input_buf(); + + if(kbd_info.scancode & 0x80) key_release(kbd_info.scancode & ~0x80); else { @@ -412,10 +426,10 @@ void kbd_handler(int_regs *r) */ int init_kbd() { - kbd_driver.initalized = true; - kbd_early_init(); - install_irq_handler(IRQ_NUM_KBD,kbd_handler); - return STATUS_OK; + kbd_driver.initalized = true; + kbd_early_init(); + install_irq_handler(IRQ_NUM_KBD,kbd_handler); + return STATUS_OK; } /* @@ -429,9 +443,9 @@ int init_kbd() */ int uninit_kbd() { - kbd_driver.initalized = false; - uninstall_irq_handler(IRQ_NUM_KBD); - return STATUS_OK; + kbd_driver.initalized = false; + uninstall_irq_handler(IRQ_NUM_KBD); + return STATUS_OK; }