Skip to content

Commit

Permalink
KeyboardAPI: Keyboard matrix is modified immediately, if no delay is …
Browse files Browse the repository at this point in the history
…specified
  • Loading branch information
dirkwhoffmann committed Sep 11, 2024
1 parent 961f73b commit f697c40
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Emulator/Components/Amiga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,14 +523,16 @@ Amiga::refreshRate() const

} else {

return nativeRefreshRate() * config.speedBoost / 100.0;
auto boost = config.speedBoost ? config.speedBoost : 100;
return nativeRefreshRate() * boost / 100.0;
}
}

i64
Amiga::masterClockFrequency() const
{
return nativeMasterClockFrequency() * config.speedBoost / 100;
auto boost = config.speedBoost ? config.speedBoost : 100;
return nativeMasterClockFrequency() * boost / 100;
}

void
Expand Down
1 change: 0 additions & 1 deletion Emulator/Misc/RetroShell/CommandConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ CommandConsole::initCommands(Command &root)
});

cmd = registerComponent(remoteManager.serServer, root / "server");

cmd = registerComponent(remoteManager.rshServer, root / "server");

root.add({"server", cmd, "start"},
Expand Down
4 changes: 3 additions & 1 deletion Emulator/Misc/RetroShell/DebugConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ namespace vamiga {
void
DebugConsole::_pause()
{
retroShell.asyncExec("state");
*this << '\n' << '\n';
exec("state");
*this << getPrompt();
}

string
Expand Down
38 changes: 36 additions & 2 deletions Emulator/VAmiga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -855,17 +855,51 @@ KeyboardAPI::isPressed(KeyCode key) const
void
KeyboardAPI::press(KeyCode key, double delay, double duration)
{
emu->put(Cmd(CMD_KEY_PRESS, KeyCmd { .keycode = key, .delay = delay }));
if (delay == 0.0) {

keyboard->press(key);
emu->isDirty = true;

} else {

emu->put(Cmd(CMD_KEY_PRESS, KeyCmd { .keycode = key, .delay = delay }));
}
if (duration != 0.0) {

emu->put(Cmd(CMD_KEY_RELEASE, KeyCmd { .keycode = key, .delay = delay + duration }));
}
}

void
KeyboardAPI::toggle(KeyCode key, double delay, double duration)
{
if (delay == 0.0) {

keyboard->toggle(key);
emu->isDirty = true;

} else {

emu->put(Cmd(CMD_KEY_TOGGLE, KeyCmd { .keycode = key, .delay = delay }));
}
if (duration != 0.0) {

emu->put(Cmd(CMD_KEY_TOGGLE, KeyCmd { .keycode = key, .delay = delay + duration }));
}
}

void
KeyboardAPI::release(KeyCode key, double delay)
{
emu->put(Cmd(CMD_KEY_RELEASE, KeyCmd { .keycode = key, .delay = delay }));
if (delay == 0.0) {

keyboard->release(key);
emu->isDirty = true;

} else {

emu->put(Cmd(CMD_KEY_RELEASE, KeyCmd { .keycode = key, .delay = delay }));
}
}

void
Expand Down
7 changes: 7 additions & 0 deletions Emulator/VAmiga.h
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,13 @@ struct KeyboardAPI : public API {
*/
void press(KeyCode key, double delay = 0.0, double duration = 0.0);

/** @brief Toggles a key
* @param key The key to toggle.
* @param delay An optional delay in seconds until the key is toggled.
* @param duration If specified, the key will be toggled again after the additional delay.
*/
void toggle(KeyCode key, double delay = 0.0, double duration = 0.0);

/** @brief Releases a key
* @param key The key to release.
* @param delay An optional delay in seconds.
Expand Down

0 comments on commit f697c40

Please sign in to comment.