88#include < ion/backlight.h>
99#include < poincare/preferences.h>
1010
11+ #include < algorithm>
12+
1113extern " C" {
1214#include < assert.h>
1315}
@@ -218,6 +220,13 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
218220 return didProcessEvent || alphaLockWantsRedraw;
219221}
220222
223+ static constexpr Ion::Events::Event switch_events[] = {
224+ Ion::Events::ShiftSeven, Ion::Events::ShiftEight, Ion::Events::ShiftNine,
225+ Ion::Events::ShiftFour, Ion::Events::ShiftFive, Ion::Events::ShiftSix,
226+ Ion::Events::ShiftOne, Ion::Events::ShiftTwo, Ion::Events::ShiftThree,
227+ Ion::Events::ShiftZero, Ion::Events::ShiftDot, Ion::Events::ShiftEE
228+ };
229+
221230bool AppsContainer::processEvent (Ion::Events::Event event) {
222231 // Warning: if the window is dirtied, you need to call window()->redraw()
223232 if (event == Ion::Events::USBPlug) {
@@ -242,6 +251,15 @@ bool AppsContainer::processEvent(Ion::Events::Event event) {
242251 switchTo (appSnapshotAtIndex (1 ));
243252 return true ;
244253 }
254+
255+ for (int i = 0 ; i < std::min ((int ) (sizeof (switch_events) / sizeof (Ion::Events::Event)), APPS_CONTAINER_SNAPSHOT_COUNT); i++) {
256+ if (event == switch_events[i]) {
257+ m_window.redraw (true );
258+ switchTo (appSnapshotAtIndex (i+1 ));
259+ return true ;
260+ }
261+ }
262+
245263 if (event == Ion::Events::OnOff) {
246264 suspend (true );
247265 return true ;
0 commit comments