mirror of
https://github.com/irmen/ksim65.git
synced 2024-06-06 07:29:29 +00:00
35 lines
1.0 KiB
Kotlin
35 lines
1.0 KiB
Kotlin
|
package razorvine.ksim65.components
|
||
|
|
||
|
import razorvine.ksim65.IHostInterface
|
||
|
|
||
|
/**
|
||
|
* Simple keyboard for text entry.
|
||
|
* The keyboard device itself takes care of decoding the keys,
|
||
|
* this device simply produces the actual keys pressed.
|
||
|
* There's NO support right now to detect keydown/keyup events or the
|
||
|
* state of the shift/control/function keys.
|
||
|
*
|
||
|
* reg. value
|
||
|
* ---- ---------
|
||
|
* 00 character from keyboard, 0 = no character/key pressed
|
||
|
*/
|
||
|
class Keyboard(startAddress: Address, endAddress: Address, private val host: IHostInterface) :
|
||
|
MemMappedComponent(startAddress, endAddress) {
|
||
|
|
||
|
init {
|
||
|
require(endAddress - startAddress + 1 == 1) { "keyboard needs exactly 1 memory byte" }
|
||
|
}
|
||
|
|
||
|
override fun clock() {}
|
||
|
override fun reset() {}
|
||
|
|
||
|
override operator fun get(address: Address): UByte {
|
||
|
return when(address-startAddress) {
|
||
|
0x00 -> host.keyboard()?.toShort() ?: 0
|
||
|
else -> 0xff
|
||
|
}
|
||
|
}
|
||
|
|
||
|
override operator fun set(address: Address, data: UByte) { /* read-only device */ }
|
||
|
}
|