generated from rnentjes/kotlin-server-web-undertow
27 lines
465 B
Kotlin
27 lines
465 B
Kotlin
package mtmc.emulator
|
|
|
|
class MTMCIO {
|
|
var value: Int = 0
|
|
|
|
internal enum class Buttons(val mask: Int) {
|
|
UP(128),
|
|
DOWN(64),
|
|
LEFT(32),
|
|
RIGHT(16),
|
|
START(8),
|
|
SELECT(4),
|
|
B(2),
|
|
A(1)
|
|
}
|
|
|
|
fun keyPressed(key: String) {
|
|
val button = Buttons.valueOf(key.uppercase())
|
|
value = value or button.mask
|
|
}
|
|
|
|
fun keyReleased(key: String) {
|
|
val button = Buttons.valueOf(key.uppercase())
|
|
value = value and button.mask.inv()
|
|
}
|
|
}
|