gui buttons will now trigger the action only once per click

This commit is contained in:
minjaesong
2022-12-14 15:58:01 +09:00
parent 86af873bdf
commit 45dd5be3f2
3 changed files with 49 additions and 43 deletions

View File

@@ -71,12 +71,7 @@ class VM(
init { init {
println("[VM] Creating new VM with ID of $id, memsize $memsize") println("[VM] Creating new VM with ID of $id, memsize $memsize")
peripheralTable[0] = PeripheralEntry( peripheralTable[0] = PeripheralEntry(IOSpace(this))
IOSpace(this),
// HW_RESERVE_SIZE,
// MMIO_SIZE.toInt() - 256,
// 64
)
} }
fun killAllContexts() { fun killAllContexts() {

View File

@@ -36,9 +36,12 @@ class ProfilesMenu(parent: VMEmuExecutable, x: Int, y: Int, w: Int, h: Int) : Em
} }
private var guiClickLatched = arrayOf(false, false, false, false, false, false, false, false)
override fun update() { override fun update() {
if (Gdx.input.isButtonPressed(Buttons.LEFT)) { if (Gdx.input.isButtonPressed(Buttons.LEFT)) {
if (!guiClickLatched[Buttons.LEFT]) {
val mx = Gdx.input.x - x val mx = Gdx.input.x - x
val my = Gdx.input.y - y val my = Gdx.input.y - y
@@ -79,16 +82,21 @@ class ProfilesMenu(parent: VMEmuExecutable, x: Int, y: Int, w: Int, h: Int) : Em
println("vm: $profileName; isRunning = ${theVM.isRunning}; mx = $mx") println("vm: $profileName; isRunning = ${theVM.isRunning}; mx = $mx")
if (mx in 377..390 && theVM.isRunning) { if (mx in 374..394 && theVM.isRunning) {
parent.killVMenv(theVM) parent.killVMenv(theVM)
} }
else if (mx in 398..412 && !theVM.isRunning) { else if (mx in 395..415 && !theVM.isRunning) {
parent.initVMenv(theVM) parent.initVMenv(theVM)
} }
} }
} }
} }
guiClickLatched[Buttons.LEFT] = true
}
}
else {
guiClickLatched[Buttons.LEFT] = false
} }
} }

View File

@@ -186,7 +186,7 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
private fun changeActiveSession(index: Int?) { private fun changeActiveSession(index: Int?) {
currentVMselection = index currentVMselection = index
// TODO somehow implement the inputstream that cares about the currentVMselection // TODO somehow implement the inputstream that cares about the currentVMselection
Gdx.input.inputProcessor = if (currentVMselection != null) vms[currentVMselection!!]?.vm?.getIO() else vmEmuInputProcessor Gdx.input.inputProcessor = if (currentVMselection != null) vms[currentVMselection!!]?.vm?.getIO() ?: null else vmEmuInputProcessor
} }
internal fun initVMenv(vm: VM) { internal fun initVMenv(vm: VM) {
@@ -214,6 +214,9 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
vmRunners[vm.id]?.close() vmRunners[vm.id]?.close()
coroutineJobs[vm.id]?.cancel() coroutineJobs[vm.id]?.cancel()
// re-create the IOSpace (peripheral index 0)
vm.peripheralTable[0] = PeripheralEntry(IOSpace(vm))
} }
private fun setCameraPosition(newX: Float, newY: Float) { private fun setCameraPosition(newX: Float, newY: Float) {