File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ class State {
5353};
5454
5555State scan ();
56+ State scanForInterruptionAndPopState ();
5657State popState ();
5758
5859static_assert (sizeof (State)*8 >NumberOfKeys, " Ion::Keyboard::State cannot hold a keyboard snapshot" );
Original file line number Diff line number Diff line change 4747namespace Ion {
4848
4949namespace Keyboard {
50- void willPopState () {}
50+
51+ State scanForInterruptionAndPopState () {
52+ /* There is no need to manually scan to get the interruptions, as they are
53+ * done in hardware. We only need to do it on simulators. */
54+ return popState ();
55+ }
56+
5157}
5258
5359namespace Device {
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ namespace Ion {
77namespace Keyboard {
88
99State popState () {
10- willPopState ();
1110 if (Queue::sharedQueue ()->isEmpty ()) {
1211 return State (-1 );
1312 }
Original file line number Diff line number Diff line change 66namespace Ion {
77namespace Keyboard {
88
9- void willPopState (); // Callback only implemented on simulator, to refresh the window
109void resetMemoizedState ();
1110void keyboardWasScanned (State state);
1211
Original file line number Diff line number Diff line change @@ -47,9 +47,10 @@ constexpr int sNumberOfKeyPairs = sizeof(sKeyPairs)/sizeof(KeySDLKeyPair);
4747namespace Ion {
4848namespace Keyboard {
4949
50- void willPopState () {
51- // Grab this opportunity to refresh the display if needed
52- Simulator::Window::refresh ();
50+ State scanForInterruptionAndPopState () {
51+ // We get eventual user interruptions via the simulator keyboard
52+ scan ();
53+ return popState ();
5354}
5455
5556State scan () {
@@ -65,6 +66,9 @@ State scan() {
6566 // Notify callbacks in case we need to do something
6667 Simulator::Keyboard::didScan ();
6768
69+ // Grab this opportunity to refresh the display if needed
70+ Simulator::Window::refresh ();
71+
6872#if !EPSILON_SDL_SCREEN_ONLY
6973 // Register a key for the mouse, if any
7074 Key k = Simulator::Layout::getHighlightedKey ();
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ bool micropython_port_interrupt_if_needed() {
5757 bool interruption = false ;
5858 while (state != Ion::Keyboard::State (-1 )) {
5959 interruption = state.keyDown (interruptKey) ? true : interruption;
60- state = Ion::Keyboard::popState ();
60+ state = Ion::Keyboard::scanForInterruptionAndPopState ();
6161 };
6262
6363 if (interruption) {
You can’t perform that action at this time.
0 commit comments