[apps] Handle Ion::Events::USBPlug in processEvent

This gives apps a chance to catch this event. This is used in the
hardware test.
This commit is contained in:
Romain Goyet
2018-05-04 15:52:03 +02:00
committed by Ecco
parent 29aca1a7dc
commit 69545b9cf9

View File

@@ -86,19 +86,7 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
bool didProcessEvent = false;
if (event == Ion::Events::USBPlug) {
if (Ion::USB::isPlugged()) {
if (GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) {
displayExamModePopUp(false);
} else {
Ion::USB::enable();
}
Ion::Backlight::setBrightness(Ion::Backlight::MaxBrightness);
} else {
Ion::USB::disable();
}
didProcessEvent = true;
} else if (event == Ion::Events::USBEnumeration) {
if (event == Ion::Events::USBEnumeration) {
if (Ion::USB::isPlugged()) {
App::Snapshot * activeSnapshot = (activeApp() == nullptr ? appSnapshotAtIndex(0) : activeApp()->snapshot());
switchTo(usbConnectedAppSnapshot());
@@ -132,6 +120,19 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
}
bool AppsContainer::processEvent(Ion::Events::Event event) {
if (event == Ion::Events::USBPlug) {
if (Ion::USB::isPlugged()) {
if (GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) {
displayExamModePopUp(false);
} else {
Ion::USB::enable();
}
Ion::Backlight::setBrightness(Ion::Backlight::MaxBrightness);
} else {
Ion::USB::disable();
}
return true;
}
if (event == Ion::Events::Home || event == Ion::Events::Back) {
switchTo(appSnapshotAtIndex(0));
return true;