Mirror of CollapseOS
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

26 lines
798B

  1. #include <stdint.h>
  2. #include <stdbool.h>
  3. // These are keycodes for special keys
  4. #define KBD_ALPHA 0x57
  5. #define KBD_2ND 0x65
  6. // NOTE: We don't manage the ON key here.
  7. typedef struct {
  8. // Bitmask of pressed keys. Like on real hardware, 0xff means nothing
  9. // pressed. The group 7 has no key, but for code simplicity, we have a neat
  10. // array of 8 bytes.
  11. uint8_t pressed[8];
  12. // Selected groups. Active low.
  13. uint8_t selected;
  14. } KBD;
  15. void kbd_init(KBD *kbd);
  16. uint8_t kbd_rd(KBD *kbd);
  17. void kbd_wr(KBD *kbd, uint8_t val);
  18. // The key is separated in two nibble. High nibble is group, low nibble is key.
  19. void kbd_setkey(KBD *kbd, uint8_t key, bool pressed);
  20. // Attempts to returns a key code corresponding to the specified char. 0 if
  21. // nothing matches.
  22. uint8_t kbd_trans(char c);