Skip to content

Commit d0d9ad3

Browse files
LeaNumworksHugoNumworks
authored andcommitted
[simulator] Refresh screen on web python
The refresh was done in the scan, but commit 9bfa204 "[ion] Simulator and device keyboard works similarly by queuing keyboard" changed the times where we could call scan, so the refresh was no longer done at the right moments. As a result, Python drawings on a web emulator would not be displayed in real time.
1 parent f7ae313 commit d0d9ad3

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

ion/src/device/shared/drivers/keyboard.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
#include <shared/drivers/keyboard.h>
4646

4747
namespace Ion {
48+
49+
namespace Keyboard {
50+
void willPopState() {}
51+
}
52+
4853
namespace Device {
4954
namespace Keyboard {
5055

ion/src/shared/keyboard.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Ion {
77
namespace Keyboard {
88

99
State popState() {
10+
willPopState();
1011
if (Queue::sharedQueue()->isEmpty()) {
1112
return State(-1);
1213
}

ion/src/shared/keyboard.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Ion {
77
namespace Keyboard {
88

9+
void willPopState(); // Callback only implemented on simulator, to refresh the window
910
void resetMemoizedState();
1011
void keyboardWasScanned(State state);
1112

ion/src/simulator/shared/keyboard.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ constexpr int sNumberOfKeyPairs = sizeof(sKeyPairs)/sizeof(KeySDLKeyPair);
4747
namespace Ion {
4848
namespace Keyboard {
4949

50+
void willPopState() {
51+
// Grab this opportunity to refresh the display if needed
52+
Simulator::Window::refresh();
53+
}
54+
5055
State scan() {
5156
State state(0);
5257

@@ -60,9 +65,6 @@ State scan() {
6065
// Notify callbacks in case we need to do something
6166
Simulator::Keyboard::didScan();
6267

63-
// Grab this opportunity to refresh the display if needed
64-
Simulator::Window::refresh();
65-
6668
#if !EPSILON_SDL_SCREEN_ONLY
6769
// Register a key for the mouse, if any
6870
Key k = Simulator::Layout::getHighlightedKey();

0 commit comments

Comments
 (0)