Litrally amlmost functional PS/2 driver. #19
|
@ -18,5 +18,6 @@ Anyone who works on this should work to keep this list as small as possible/remo
|
||||||
- 0x03xx
|
- 0x03xx
|
||||||
- 0x04xx
|
- 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.
|
- 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.
|
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)
|
info := controller.Info.(0)
|
||||||
|
|
||||||
send_command := fn(port: ^controller.Port, byte: u8): void {
|
send_command := fn(port: ^controller.Port, byte: u8): void {
|
||||||
controller.send_byte(port, byte)
|
|
||||||
loop {
|
loop {
|
||||||
info = controller.get_info()
|
controller.send_byte(port, byte)
|
||||||
if controller.has_input(info) == false {
|
loop {
|
||||||
continue
|
info = controller.get_info()
|
||||||
}
|
if controller.has_input(info) == false {
|
||||||
input := controller.get_input()
|
continue
|
||||||
if controller.get_port(info) != port {
|
}
|
||||||
if check_complete(port) == false {
|
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]
|
port.device.value = port.packet[0]
|
||||||
} else {
|
} else {
|
||||||
port.device.value = port.packet[1] | port.packet[0] << 8
|
port.device.value = port.packet[1] | port.packet[0] << 8
|
||||||
|
send_command(port, 0xF4)
|
||||||
}
|
}
|
||||||
log.info("Identified device!\0")
|
log.info("Identified device!\0")
|
||||||
log.info(string.display_int(port.device.value, format_page, 16))
|
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 {
|
} else if port.device == devices.MOUSE_SCROLLWHEEL | port.device == devices.MOUSE_5_BUTTON {
|
||||||
if port.packet_length == 4 return true
|
if port.packet_length == 4 return true
|
||||||
} else {
|
} else {
|
||||||
log.error("Very unexpected error. Cannot handle this!\0")
|
if port.packet[0] == 0xE1 {
|
||||||
return true
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
@ -82,6 +104,13 @@ main := fn(): void {
|
||||||
|
|
||||||
controller.init()
|
controller.init()
|
||||||
|
|
||||||
|
if controller.port1.exists {
|
||||||
|
controller.send_byte(&controller.port1, 0xF4)
|
||||||
|
}
|
||||||
|
if controller.port2.exists {
|
||||||
|
controller.send_byte(&controller.port2, 0xF4)
|
||||||
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
info = controller.get_info()
|
info = controller.get_info()
|
||||||
|
|
||||||
|
@ -98,9 +127,10 @@ main := fn(): void {
|
||||||
process(port)
|
process(port)
|
||||||
}
|
}
|
||||||
input := controller.get_input()
|
input := controller.get_input()
|
||||||
if input == 0xAA & port.can_hot_plug {
|
/*if input == 0xAA & port.can_hot_plug {
|
||||||
port.device = devices.NO_DEVICE
|
port.device = devices.NO_DEVICE
|
||||||
}
|
controller.send_byte(port, 0xF4)
|
||||||
|
}*/
|
||||||
port.packet[port.packet_length] = input
|
port.packet[port.packet_length] = input
|
||||||
port.packet_length += 1
|
port.packet_length += 1
|
||||||
if check_complete(port) {
|
if check_complete(port) {
|
||||||
|
|
Loading…
Reference in a new issue