static inline void toggle_lock_state(struct cooked_kbd *ck, int lock_mask) { ck->lock_state ^= lock_mask; if(&ck->kbd == kbd_focus) kbd_set_leds(ck->lock_state); }
void handle_keyboard_event (unsigned char scancode) { unsigned char keycode; /* Convert scancode to keycode */ PRINTF ("scancode %x\n", scancode); if (scancode == 0xe0) { e0 = 1; /* special charakters */ return; } if (e0 == 1) { e0 = 0; /* delete flag */ if (!(((scancode & 0x7F) == 0x38) || /* the right ctrl key */ ((scancode & 0x7F) == 0x1D) || /* the right alt key */ ((scancode & 0x7F) == 0x35) || /* the right '/' key */ ((scancode & 0x7F) == 0x1C))) /* the right enter key */ /* we swallow unknown e0 codes */ return; } /* special cntrl keys */ switch (scancode) { case 0x2A: case 0x36: /* shift pressed */ shift = 1; return; /* do nothing else */ case 0xAA: case 0xB6: /* shift released */ shift = 0; return; /* do nothing else */ case 0x38: /* alt pressed */ alt = 1; return; /* do nothing else */ case 0xB8: /* alt released */ alt = 0; return; /* do nothing else */ case 0x1d: /* ctrl pressed */ ctrl = 1; return; /* do nothing else */ case 0x9d: /* ctrl released */ ctrl = 0; return; /* do nothing else */ case 0x46: /* scrollock pressed */ scroll_lock = ~scroll_lock; kbd_set_leds (); return; /* do nothing else */ case 0x3A: /* capslock pressed */ caps_lock = ~caps_lock; kbd_set_leds (); return; case 0x45: /* numlock pressed */ num_lock = ~num_lock; kbd_set_leds (); return; case 0xC6: /* scroll lock released */ case 0xC5: /* num lock released */ case 0xBA: /* caps lock released */ return; /* just swallow */ } if ((scancode & 0x80) == 0x80) /* key released */ return; /* now, decide which table we need */ if (scancode > (sizeof (kbd_plain_xlate) / sizeof (kbd_plain_xlate[0]))) { /* scancode not in list */ PRINTF ("unkown scancode %X\n", scancode); return; /* swallow it */ } /* setup plain code first */ keycode = kbd_plain_xlate[scancode]; if (caps_lock == 1) { /* caps_lock is pressed, overwrite plain code */ if (scancode > (sizeof (kbd_shift_xlate) / sizeof (kbd_shift_xlate[0]))) { /* scancode not in list */ PRINTF ("unkown caps-locked scancode %X\n", scancode); return; /* swallow it */ } keycode = kbd_shift_xlate[scancode]; if (keycode < 'A') { /* we only want the alphas capital */ keycode = kbd_plain_xlate[scancode]; } } if (shift == 1) { /* shift overwrites caps_lock */ if (scancode > (sizeof (kbd_shift_xlate) / sizeof (kbd_shift_xlate[0]))) { /* scancode not in list */ PRINTF ("unkown shifted scancode %X\n", scancode); return; /* swallow it */ } keycode = kbd_shift_xlate[scancode]; } if (ctrl == 1) { /* ctrl overwrites caps_lock and shift */ if (scancode > (sizeof (kbd_ctrl_xlate) / sizeof (kbd_ctrl_xlate[0]))) { /* scancode not in list */ PRINTF ("unkown ctrl scancode %X\n", scancode); return; /* swallow it */ } keycode = kbd_ctrl_xlate[scancode]; } /* check if valid keycode */ if (keycode == 0xff) { PRINTF ("unkown scancode %X\n", scancode); return; /* swallow unknown codes */ } kbd_put_queue (keycode); PRINTF ("%x\n", keycode); }
static void cooked_switch_to(struct kbd *kbd, int shift_state) { struct cooked_kbd *ck = (struct cooked_kbd *)kbd; kbd_set_leds(ck->lock_state); }