aboutsummaryrefslogtreecommitdiff
path: root/src/machine/keyctrl.rs
blob: 43f92d1d9ac838c60ba7659f3f374029f4a0afb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use self::super::kbd_defs::*;
use self::super::key::*;
use crate::machine::device_io::*;

// this is the driver for keyboard controller not to confuse with the keyboard module.
// The later is an abstraction
// This one serves a the HW driver

// TODO
// [functions]
// Keyboard_Controller()
// get_ascii_code()
// key_decoded()
// key_hit()
// reboot()
// set_led(char led,bool on)
// set_repeat_rate(int speed,int delay)

pub struct KeyboardController {
	code: u8,
	prefix: u8,
	gather: Key,
	leds: u8,
}

impl KeyboardController {
	const CTRL_PORT:u16 =  0x64;
	const DATA_PORT:u16 =  0x60;
	pub fn new() -> Self {
		Self {
			code: 0,
			prefix: 9,
			gather: Key::new(),
			leds: 0,
		}
	}

	pub fn key_hit(&mut self) -> Key {
		todo!();
		// for debugging only
		let mut invalid: Key = Key::new();
		invalid.set_raw(0xff);

		let status = inb(Self::CTRL_PORT);
		return Key::new();
		// TODO here
	}

	pub fn reboot(&mut self)  {
		todo!();
	}
}