forked from AbleOS/ableos
PS/2 literally almost work
This commit is contained in:
parent
3d5a8f6f10
commit
8f265ebf40
|
@ -18,5 +18,6 @@ Anyone who works on this should work to keep this list as small as possible/remo
|
|||
- 0x03xx
|
||||
- 0x04xx
|
||||
- Literally all PS/2 keyboards can be handeled the exact same way. We have the capability for detecting different keyboard types, I just don't bother with it because that would litreally take months to get working.
|
||||
- The device doesn't send any data while we're waiting for an `ACK`.
|
||||
|
||||
Supporting mice in the keyboard port and vice versa was a ***bad*** idea, but I do not regret it because it means we're "superior" to real world operating systems.
|
|
@ -11,15 +11,25 @@ keyboard_buffer := 0
|
|||
info := controller.Info.(0)
|
||||
|
||||
send_command := fn(port: ^controller.Port, byte: u8): void {
|
||||
controller.send_byte(port, byte)
|
||||
loop {
|
||||
info = controller.get_info()
|
||||
if controller.has_input(info) == false {
|
||||
continue
|
||||
}
|
||||
input := controller.get_input()
|
||||
if controller.get_port(info) != port {
|
||||
if check_complete(port) == false {
|
||||
controller.send_byte(port, byte)
|
||||
loop {
|
||||
info = controller.get_info()
|
||||
if controller.has_input(info) == false {
|
||||
continue
|
||||
}
|
||||
input := controller.get_input()
|
||||
if controller.get_port(info) != port {
|
||||
if check_complete(port) == false {
|
||||
port.packet[port.packet_length] = input
|
||||
port.packet_length += 1
|
||||
}
|
||||
continue
|
||||
}
|
||||
if input == 0xFA {
|
||||
return
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,9 +61,12 @@ process := fn(port: ^controller.Port): void {
|
|||
port.device.value = port.packet[0]
|
||||
} else {
|
||||
port.device.value = port.packet[1] | port.packet[0] << 8
|
||||
send_command(port, 0xF4)
|
||||
}
|
||||
log.info("Identified device!\0")
|
||||
log.info(string.display_int(port.device.value, format_page, 16))
|
||||
} else {
|
||||
log.info("KEY PRESSED\0")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,8 +83,17 @@ check_complete := fn(port: ^controller.Port): bool {
|
|||
} else if port.device == devices.MOUSE_SCROLLWHEEL | port.device == devices.MOUSE_5_BUTTON {
|
||||
if port.packet_length == 4 return true
|
||||
} else {
|
||||
log.error("Very unexpected error. Cannot handle this!\0")
|
||||
return true
|
||||
if port.packet[0] == 0xE1 {
|
||||
if port.packet_length == 6 {
|
||||
return true
|
||||
}
|
||||
} else if port.packet[0] != 0xE0 {
|
||||
return true
|
||||
} else if port.packet_length == 2 & port.packet[1] != 0x2A & port.packet[1] != 0xB7 {
|
||||
return true
|
||||
} else if port.packet_length == 4 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@ -82,6 +104,13 @@ main := fn(): void {
|
|||
|
||||
controller.init()
|
||||
|
||||
if controller.port1.exists {
|
||||
controller.send_byte(&controller.port1, 0xF4)
|
||||
}
|
||||
if controller.port2.exists {
|
||||
controller.send_byte(&controller.port2, 0xF4)
|
||||
}
|
||||
|
||||
loop {
|
||||
info = controller.get_info()
|
||||
|
||||
|
@ -98,9 +127,10 @@ main := fn(): void {
|
|||
process(port)
|
||||
}
|
||||
input := controller.get_input()
|
||||
if input == 0xAA & port.can_hot_plug {
|
||||
/*if input == 0xAA & port.can_hot_plug {
|
||||
port.device = devices.NO_DEVICE
|
||||
}
|
||||
controller.send_byte(port, 0xF4)
|
||||
}*/
|
||||
port.packet[port.packet_length] = input
|
||||
port.packet_length += 1
|
||||
if check_complete(port) {
|
||||
|
|
Loading…
Reference in a new issue