added proper timing and key assignment in key press/release handler
This commit is contained in:
parent
b2d4a5ec1b
commit
1af2fd3c52
8
kbd.c
8
kbd.c
@ -53,14 +53,14 @@ void kbd_read_key(struct cpu_reg_state* cpu) {
|
||||
u8 scancode = serial_read_byte(KBD_PORT);
|
||||
if(scancode & 0x80) {
|
||||
// Key released
|
||||
kbd_state &= KBD_RELEASE;
|
||||
kbd_key = keymap[scancode & 0x7f]; // clamp to 127 as the max val(gcc is anoying)
|
||||
kbd_state = KBD_RELEASE;
|
||||
kbd_time = pit_timer_ticks;
|
||||
}
|
||||
else {
|
||||
// Key pressed
|
||||
kbd_key = keymap[scancode & 0x7f]; // clamp to 127 as the max val(gcc is anoying)
|
||||
kbd_state = kbd_state & !KBD_RELEASE & KBD_PRESS;
|
||||
//printf("@");printhex(pit_timer_ticks);
|
||||
//printf("diff:"); printhex(pit_timer_ticks - kbd_time);
|
||||
kbd_state = KBD_PRESS;
|
||||
kbd_time = pit_timer_ticks;
|
||||
}
|
||||
}
|
||||
|
9
kbd.h
9
kbd.h
@ -2,16 +2,17 @@
|
||||
#define KBD_H
|
||||
#include "types.h"
|
||||
#include "interrupts.h"
|
||||
#include "framebuffer.h"
|
||||
|
||||
#define KBD_PORT 0x60
|
||||
|
||||
#define KBD_PRESS 0b00000001
|
||||
#define KBD_RELEASE 0b00000010
|
||||
#define KBD_SHIFT 0b00000100
|
||||
#define KBD_PRESS 1
|
||||
#define KBD_WAITING 2
|
||||
#define KBD_RELEASE 0x80
|
||||
|
||||
char kbd_key;
|
||||
u8 kbd_state;
|
||||
u8 kbd_time;
|
||||
u32 kbd_time;
|
||||
|
||||
void kbd_install_keyboard(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user