Skip to content

Commit f697c40

Browse files
committed
KeyboardAPI: Keyboard matrix is modified immediately, if no delay is specified
1 parent 961f73b commit f697c40

File tree

5 files changed

+50
-6
lines changed

5 files changed

+50
-6
lines changed

Emulator/Components/Amiga.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,14 +523,16 @@ Amiga::refreshRate() const
523523

524524
} else {
525525

526-
return nativeRefreshRate() * config.speedBoost / 100.0;
526+
auto boost = config.speedBoost ? config.speedBoost : 100;
527+
return nativeRefreshRate() * boost / 100.0;
527528
}
528529
}
529530

530531
i64
531532
Amiga::masterClockFrequency() const
532533
{
533-
return nativeMasterClockFrequency() * config.speedBoost / 100;
534+
auto boost = config.speedBoost ? config.speedBoost : 100;
535+
return nativeMasterClockFrequency() * boost / 100;
534536
}
535537

536538
void

Emulator/Misc/RetroShell/CommandConsole.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,6 @@ CommandConsole::initCommands(Command &root)
676676
});
677677

678678
cmd = registerComponent(remoteManager.serServer, root / "server");
679-
680679
cmd = registerComponent(remoteManager.rshServer, root / "server");
681680

682681
root.add({"server", cmd, "start"},

Emulator/Misc/RetroShell/DebugConsole.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ namespace vamiga {
1616
void
1717
DebugConsole::_pause()
1818
{
19-
retroShell.asyncExec("state");
19+
*this << '\n' << '\n';
20+
exec("state");
21+
*this << getPrompt();
2022
}
2123

2224
string

Emulator/VAmiga.cpp

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,17 +855,51 @@ KeyboardAPI::isPressed(KeyCode key) const
855855
void
856856
KeyboardAPI::press(KeyCode key, double delay, double duration)
857857
{
858-
emu->put(Cmd(CMD_KEY_PRESS, KeyCmd { .keycode = key, .delay = delay }));
858+
if (delay == 0.0) {
859859

860+
keyboard->press(key);
861+
emu->isDirty = true;
862+
863+
} else {
864+
865+
emu->put(Cmd(CMD_KEY_PRESS, KeyCmd { .keycode = key, .delay = delay }));
866+
}
860867
if (duration != 0.0) {
868+
861869
emu->put(Cmd(CMD_KEY_RELEASE, KeyCmd { .keycode = key, .delay = delay + duration }));
862870
}
863871
}
864872

873+
void
874+
KeyboardAPI::toggle(KeyCode key, double delay, double duration)
875+
{
876+
if (delay == 0.0) {
877+
878+
keyboard->toggle(key);
879+
emu->isDirty = true;
880+
881+
} else {
882+
883+
emu->put(Cmd(CMD_KEY_TOGGLE, KeyCmd { .keycode = key, .delay = delay }));
884+
}
885+
if (duration != 0.0) {
886+
887+
emu->put(Cmd(CMD_KEY_TOGGLE, KeyCmd { .keycode = key, .delay = delay + duration }));
888+
}
889+
}
890+
865891
void
866892
KeyboardAPI::release(KeyCode key, double delay)
867893
{
868-
emu->put(Cmd(CMD_KEY_RELEASE, KeyCmd { .keycode = key, .delay = delay }));
894+
if (delay == 0.0) {
895+
896+
keyboard->release(key);
897+
emu->isDirty = true;
898+
899+
} else {
900+
901+
emu->put(Cmd(CMD_KEY_RELEASE, KeyCmd { .keycode = key, .delay = delay }));
902+
}
869903
}
870904

871905
void

Emulator/VAmiga.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,13 @@ struct KeyboardAPI : public API {
782782
*/
783783
void press(KeyCode key, double delay = 0.0, double duration = 0.0);
784784

785+
/** @brief Toggles a key
786+
* @param key The key to toggle.
787+
* @param delay An optional delay in seconds until the key is toggled.
788+
* @param duration If specified, the key will be toggled again after the additional delay.
789+
*/
790+
void toggle(KeyCode key, double delay = 0.0, double duration = 0.0);
791+
785792
/** @brief Releases a key
786793
* @param key The key to release.
787794
* @param delay An optional delay in seconds.

0 commit comments

Comments
 (0)