mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Merge changes I4fcc116c,I2033a99f,I6dd667fb
* changes: [apps/hardware_test] Clean plugging USB test [escher] App can have timers that are ticked when the app is active [ion] Clean alpha shift event modifiers
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
AlphaLockView::AlphaLockView() :
|
||||
View(),
|
||||
m_alphaView(KDText::FontSize::Small, I18n::Message::Default, 1.0f, 0.5f, KDColorWhite, Palette::YellowDark),
|
||||
m_status(Status::Default)
|
||||
m_status(Ion::Events::ShiftAlphaStatus::Default)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -11,15 +11,22 @@ void AlphaLockView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
ctx->fillRect(bounds(), Palette::YellowDark);
|
||||
}
|
||||
|
||||
bool AlphaLockView::setStatus(Status status) {
|
||||
bool AlphaLockView::setStatus(Ion::Events::ShiftAlphaStatus status) {
|
||||
if (status != m_status) {
|
||||
m_status = status;
|
||||
if (m_status == Status::Alpha || m_status == Status::AlphaLock) {
|
||||
m_alphaView.setMessage(I18n::Message::Alpha);
|
||||
} else if (m_status == Status::CapitalAlpha || m_status == Status::CapitalAlphaLock) {
|
||||
m_alphaView.setMessage(I18n::Message::CapitalAlpha);
|
||||
} else {
|
||||
m_alphaView.setMessage(I18n::Message::Default);
|
||||
switch (status) {
|
||||
case Ion::Events::ShiftAlphaStatus::Alpha:
|
||||
case Ion::Events::ShiftAlphaStatus::AlphaLock:
|
||||
case Ion::Events::ShiftAlphaStatus::AlphaLockShift:
|
||||
m_alphaView.setMessage(I18n::Message::Alpha);
|
||||
break;
|
||||
case Ion::Events::ShiftAlphaStatus::ShiftAlpha:
|
||||
case Ion::Events::ShiftAlphaStatus::ShiftAlphaLock:
|
||||
m_alphaView.setMessage(I18n::Message::CapitalAlpha);
|
||||
break;
|
||||
default:
|
||||
m_alphaView.setMessage(I18n::Message::Default);
|
||||
break;
|
||||
}
|
||||
markRectAsDirty(bounds());
|
||||
return true;
|
||||
@@ -36,13 +43,12 @@ KDSize AlphaLockView::minimalSizeForOptimalDisplay() const {
|
||||
|
||||
int AlphaLockView::numberOfSubviews() const {
|
||||
switch (m_status) {
|
||||
case Status::Alpha:
|
||||
case Ion::Events::ShiftAlphaStatus::Alpha:
|
||||
case Ion::Events::ShiftAlphaStatus::ShiftAlpha:
|
||||
return 1;
|
||||
case Status::AlphaLock:
|
||||
return 2;
|
||||
case Status::CapitalAlpha:
|
||||
return 1;
|
||||
case Status::CapitalAlphaLock:
|
||||
case Ion::Events::ShiftAlphaStatus::AlphaLock:
|
||||
case Ion::Events::ShiftAlphaStatus::AlphaLockShift:
|
||||
case Ion::Events::ShiftAlphaStatus::ShiftAlphaLock:
|
||||
return 2;
|
||||
default:
|
||||
return 0;
|
||||
|
||||
@@ -7,16 +7,9 @@
|
||||
|
||||
class AlphaLockView : public View {
|
||||
public:
|
||||
enum class Status {
|
||||
Default,
|
||||
Alpha,
|
||||
AlphaLock,
|
||||
CapitalAlpha,
|
||||
CapitalAlphaLock
|
||||
};
|
||||
AlphaLockView();
|
||||
void drawRect(KDContext * ctx, KDRect rect) const override;
|
||||
bool setStatus(Status status);
|
||||
bool setStatus(Ion::Events::ShiftAlphaStatus status);
|
||||
KDSize minimalSizeForOptimalDisplay() const override;
|
||||
private:
|
||||
constexpr static KDCoordinate k_lockRightMargin = 5;
|
||||
@@ -25,7 +18,7 @@ private:
|
||||
View * subviewAtIndex(int index) override;
|
||||
LockView m_lockView;
|
||||
MessageTextView m_alphaView;
|
||||
Status m_status;
|
||||
Ion::Events::ShiftAlphaStatus m_status;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -204,16 +204,11 @@ Window * AppsContainer::window() {
|
||||
return &m_window;
|
||||
}
|
||||
|
||||
int AppsContainer::numberOfTimers() {
|
||||
bool onBoardingTimer = activeApp()->snapshot() == onBoardingAppSnapshot() && ((OnBoarding::App *)activeApp())->hasTimer();
|
||||
return 4+(GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate) + onBoardingTimer;
|
||||
int AppsContainer::numberOfContainerTimers() {
|
||||
return 4+(GlobalPreferences::sharedGlobalPreferences()->examMode() == GlobalPreferences::ExamMode::Activate);
|
||||
}
|
||||
|
||||
Timer * AppsContainer::timerAtIndex(int i) {
|
||||
bool onBoardingTimer = activeApp()->snapshot() == onBoardingAppSnapshot() && ((OnBoarding::App *)activeApp())->hasTimer();
|
||||
if (onBoardingTimer && i == 4) {
|
||||
return ((OnBoarding::App *)activeApp())->timer();
|
||||
}
|
||||
Timer * timers[6] = {&m_batteryTimer, &m_USBTimer, &m_suspendTimer, &m_backlightDimmingTimer, &m_ledTimer, &m_ledTimer};
|
||||
Timer * AppsContainer::containerTimerAtIndex(int i) {
|
||||
Timer * timers[5] = {&m_batteryTimer, &m_USBTimer, &m_suspendTimer, &m_backlightDimmingTimer, &m_ledTimer};
|
||||
return timers[i];
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ public:
|
||||
UpdateController * updatePopUpController();
|
||||
private:
|
||||
Window * window() override;
|
||||
int numberOfTimers() override;
|
||||
Timer * timerAtIndex(int i) override;
|
||||
int numberOfContainerTimers() override;
|
||||
Timer * containerTimerAtIndex(int i) override;
|
||||
static constexpr int k_numberOfCommonApps = 8;
|
||||
static constexpr int k_totalNumberOfApps = 2+k_numberOfCommonApps;
|
||||
AppsWindow m_window;
|
||||
|
||||
@@ -31,19 +31,7 @@ void AppsWindow::refreshPreferences() {
|
||||
}
|
||||
|
||||
bool AppsWindow::updateAlphaLock() {
|
||||
AlphaLockView::Status alphaLockStatus = AlphaLockView::Status::Default;
|
||||
if (Ion::Events::isAlphaLocked()) {
|
||||
alphaLockStatus = AlphaLockView::Status::AlphaLock;
|
||||
} else if (Ion::Events::isShiftAlphaLocked()) {
|
||||
alphaLockStatus = AlphaLockView::Status::CapitalAlphaLock;
|
||||
} else if (Ion::Events::isAlphaActive()) {
|
||||
if (Ion::Events::isShiftActive()) {
|
||||
alphaLockStatus = AlphaLockView::Status::CapitalAlpha;
|
||||
} else {
|
||||
alphaLockStatus = AlphaLockView::Status::Alpha;
|
||||
}
|
||||
}
|
||||
return m_titleBarView.setAlphaLockStatus(alphaLockStatus);
|
||||
return m_titleBarView.setAlphaLockStatus(Ion::Events::shiftAlphaStatus());
|
||||
}
|
||||
|
||||
void AppsWindow::hideTitleBarView(bool hide) {
|
||||
|
||||
@@ -18,8 +18,22 @@ App::Descriptor * App::Snapshot::descriptor() {
|
||||
|
||||
App::App(Container * container, Snapshot * snapshot) :
|
||||
::App(container, snapshot, &m_keyboardController),
|
||||
m_keyboardController(&m_modalViewController)
|
||||
m_keyboardController(&m_modalViewController),
|
||||
m_USBTestController(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
ViewController * App::USBController() {
|
||||
return &m_USBTestController;
|
||||
}
|
||||
|
||||
int App::numberOfTimers() {
|
||||
return firstResponder() == &m_USBTestController;
|
||||
}
|
||||
|
||||
Timer * App::timerAtIndex(int i) {
|
||||
assert(i == 0);
|
||||
return &m_USBTestController;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define HARDWARE_TEST_APP_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "usb_test_controller.h"
|
||||
#include "keyboard_test_controller.h"
|
||||
|
||||
class AppsContainer;
|
||||
@@ -15,9 +16,13 @@ public:
|
||||
App * unpack(Container * container) override;
|
||||
Descriptor * descriptor() override;
|
||||
};
|
||||
ViewController * USBController();
|
||||
int numberOfTimers() override;
|
||||
Timer * timerAtIndex(int i) override;
|
||||
private:
|
||||
App(Container * container, Snapshot * snapshot);
|
||||
KeyboardTestController m_keyboardController;
|
||||
USBTestController m_USBTestController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "battery_test_controller.h"
|
||||
#include "../constant.h"
|
||||
#include "app.h"
|
||||
extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
@@ -11,8 +12,7 @@ namespace HardwareTest {
|
||||
|
||||
BatteryTestController::BatteryTestController(Responder * parentResponder) :
|
||||
ViewController(parentResponder),
|
||||
m_view(),
|
||||
m_usbTestController(this)
|
||||
m_view()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ bool BatteryTestController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::OK) {
|
||||
if (strcmp(m_view.batteryStateTextView()->text(), k_batteryOKText) == 0) {
|
||||
ModalViewController * modal = (ModalViewController *)parentResponder();
|
||||
modal->displayModalViewController(&m_usbTestController, 0.0f, 0.0f);
|
||||
App * a = (App *)app();
|
||||
modal->displayModalViewController(a->USBController(), 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
updateBatteryState(Ion::Battery::voltage(), Ion::Battery::isCharging());
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define HARDWARE_TEST_BATTERY_TEST_CONTROLLER_H
|
||||
|
||||
#include <escher.h>
|
||||
#include "usb_test_controller.h"
|
||||
|
||||
namespace HardwareTest {
|
||||
|
||||
@@ -35,7 +34,6 @@ private:
|
||||
constexpr static const char * k_batteryNeedChargingText = "BATTERY: NEED RECHARGE";
|
||||
void updateBatteryState(float batteryLevel, bool batteryCharging);
|
||||
ContentView m_view;
|
||||
USBTestController m_usbTestController;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,9 @@ namespace HardwareTest {
|
||||
|
||||
USBTestController::USBTestController(Responder * parentResponder) :
|
||||
ViewController(parentResponder),
|
||||
Timer(1),
|
||||
m_view(),
|
||||
m_shouldPlugUSB(true),
|
||||
m_resetController(this)
|
||||
{
|
||||
}
|
||||
@@ -19,41 +21,31 @@ View * USBTestController::view() {
|
||||
return &m_view;
|
||||
}
|
||||
|
||||
bool USBTestController::handleEvent(Ion::Events::Event event) {
|
||||
if (event == Ion::Events::UpperM) {
|
||||
return true;
|
||||
}
|
||||
if (event == Ion::Events::OK) {
|
||||
if (Ion::USB::isPlugged() && strcmp(m_view.USBTextView()->text(), k_USBPlugText) == 0) {
|
||||
m_view.USBTextView()->setText(k_USBUnplugText);
|
||||
m_view.arrowView()->setDirection(false);
|
||||
m_view.arrowView()->setColor(KDColorRed);
|
||||
}
|
||||
if (!Ion::USB::isPlugged() && strcmp(m_view.USBTextView()->text(), k_USBUnplugText) == 0) {
|
||||
ModalViewController * modal = (ModalViewController *)parentResponder();
|
||||
modal->displayModalViewController(&m_resetController, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
bool USBTestController::handleEvent(Ion::Events::Event e) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void USBTestController::viewWillAppear() {
|
||||
m_view.USBTextView()->setText(k_USBPlugText);
|
||||
m_view.arrowView()->setDirection(true);
|
||||
m_view.arrowView()->setColor(KDColorGreen);
|
||||
bool USBTestController::fire() {
|
||||
if (Ion::USB::isPlugged() && m_shouldPlugUSB) {
|
||||
m_view.USBTextView()->setText(k_USBUnplugText);
|
||||
m_view.arrowView()->setDirection(false);
|
||||
m_view.arrowView()->setColor(KDColorRed);
|
||||
m_shouldPlugUSB = false;
|
||||
return true;
|
||||
}
|
||||
if (!Ion::USB::isPlugged() && !m_shouldPlugUSB) {
|
||||
ModalViewController * modal = (ModalViewController *)parentResponder();
|
||||
modal->displayModalViewController(&m_resetController, 0.0f, 0.0f);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void USBTestController::didBecomeFirstResponder() {
|
||||
Container * c = (Container *)app()->container();
|
||||
/* We dispatch a random event that is caught by the hardware test application
|
||||
* to force the window redraw. */
|
||||
c->dispatchEvent(Ion::Events::UpperM);
|
||||
while (!Ion::USB::isPlugged() && strcmp(m_view.USBTextView()->text(), k_USBPlugText) == 0) {}
|
||||
/* We dispatch an event to force the window to redraw (and update the drawn
|
||||
* instructions at the same type) */
|
||||
c->dispatchEvent(Ion::Events::OK);
|
||||
while (Ion::USB::isPlugged() && strcmp(m_view.USBTextView()->text(), k_USBUnplugText) == 0) {}
|
||||
c->dispatchEvent(Ion::Events::OK);
|
||||
void USBTestController::viewWillAppear() {
|
||||
m_shouldPlugUSB = true;
|
||||
m_view.USBTextView()->setText(k_USBPlugText);
|
||||
m_view.arrowView()->setDirection(true);
|
||||
m_view.arrowView()->setColor(KDColorGreen);
|
||||
}
|
||||
|
||||
void USBTestController::ContentView::USBView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
|
||||
namespace HardwareTest {
|
||||
|
||||
class USBTestController : public ViewController {
|
||||
class USBTestController : public ViewController, public Timer {
|
||||
public:
|
||||
USBTestController(Responder * parentResponder);
|
||||
View * view() override;
|
||||
bool handleEvent(Ion::Events::Event event) override;
|
||||
void viewWillAppear() override;
|
||||
void didBecomeFirstResponder() override;
|
||||
bool handleEvent(Ion::Events::Event e) override;
|
||||
private:
|
||||
bool fire() override;
|
||||
class ContentView : public SolidColorView {
|
||||
public:
|
||||
ContentView();
|
||||
@@ -39,6 +39,7 @@ private:
|
||||
constexpr static const char * k_USBPlugText = "PLUG USB";
|
||||
constexpr static const char * k_USBUnplugText = "OK, UNPLUG USB";
|
||||
ContentView m_view;
|
||||
bool m_shouldPlugUSB;
|
||||
ResetController m_resetController;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "app.h"
|
||||
#include "../apps_container.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace OnBoarding {
|
||||
|
||||
@@ -23,11 +24,12 @@ void App::reinitOnBoarding() {
|
||||
m_languageController.reinitOnBoarding();
|
||||
}
|
||||
|
||||
bool App::hasTimer() {
|
||||
int App::numberOfTimers() {
|
||||
return firstResponder() == &m_logoController;
|
||||
}
|
||||
|
||||
Timer * App::timer() {
|
||||
Timer * App::timerAtIndex(int i) {
|
||||
assert(i == 0);
|
||||
return &m_logoController;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ public:
|
||||
Descriptor * descriptor() override;
|
||||
};
|
||||
void reinitOnBoarding();
|
||||
bool hasTimer();
|
||||
Timer * timer();
|
||||
int numberOfTimers() override;
|
||||
Timer * timerAtIndex(int i) override;
|
||||
private:
|
||||
App(Container * container, Snapshot * snapshot);
|
||||
LanguageController m_languageController;
|
||||
|
||||
@@ -42,7 +42,7 @@ bool TitleBarView::setIsPlugged(bool isPlugged) {
|
||||
return m_batteryView.setIsPlugged(isPlugged);
|
||||
}
|
||||
|
||||
bool TitleBarView::setAlphaLockStatus(AlphaLockView::Status status) {
|
||||
bool TitleBarView::setAlphaLockStatus(Ion::Events::ShiftAlphaStatus status) {
|
||||
return m_alphaLockView.setStatus(status);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
bool setChargeState(Ion::Battery::Charge chargeState);
|
||||
bool setIsCharging(bool isCharging);
|
||||
bool setIsPlugged(bool isPlugged);
|
||||
bool setAlphaLockStatus(AlphaLockView::Status status);
|
||||
bool setAlphaLockStatus(Ion::Events::ShiftAlphaStatus status);
|
||||
void refreshPreferences();
|
||||
private:
|
||||
constexpr static KDCoordinate k_batteryRightMargin = 5;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <escher/image.h>
|
||||
#include <escher/i18n.h>
|
||||
#include <escher/responder.h>
|
||||
#include <escher/timer.h>
|
||||
#include <escher/view_controller.h>
|
||||
#include <escher/warning_controller.h>
|
||||
|
||||
@@ -53,6 +54,8 @@ public:
|
||||
|
||||
virtual void didBecomeActive(Window * window);
|
||||
virtual void willBecomeInactive();
|
||||
virtual int numberOfTimers();
|
||||
virtual Timer * timerAtIndex(int i);
|
||||
protected:
|
||||
App(Container * container, Snapshot * snapshot, ViewController * rootViewController, I18n::Message warningMessage = (I18n::Message)0);
|
||||
ModalViewController m_modalViewController;
|
||||
|
||||
@@ -31,6 +31,10 @@ protected:
|
||||
virtual Window * window() = 0;
|
||||
private:
|
||||
void step();
|
||||
int numberOfTimers() override;
|
||||
Timer * timerAtIndex(int i) override;
|
||||
virtual int numberOfContainerTimers();
|
||||
virtual Timer * containerTimerAtIndex(int i);
|
||||
App * m_activeApp;
|
||||
};
|
||||
|
||||
|
||||
@@ -119,3 +119,12 @@ void App::willBecomeInactive() {
|
||||
setFirstResponder(nullptr);
|
||||
m_modalViewController.viewDidDisappear();
|
||||
}
|
||||
|
||||
int App::numberOfTimers() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Timer * App::timerAtIndex(int i) {
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <escher/container.h>
|
||||
#include <ion.h>
|
||||
#include <assert.h>
|
||||
|
||||
Container::Container() :
|
||||
RunLoop(),
|
||||
@@ -48,3 +49,22 @@ void Container::run() {
|
||||
RunLoop::run();
|
||||
}
|
||||
|
||||
int Container::numberOfTimers() {
|
||||
return m_activeApp->numberOfTimers() + numberOfContainerTimers();
|
||||
}
|
||||
|
||||
Timer * Container::timerAtIndex(int i) {
|
||||
if (i < m_activeApp->numberOfTimers()) {
|
||||
return m_activeApp->timerAtIndex(i);
|
||||
}
|
||||
return containerTimerAtIndex(i-m_activeApp->numberOfTimers());
|
||||
}
|
||||
|
||||
int Container::numberOfContainerTimers() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Timer * Container::containerTimerAtIndex(int i) {
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -37,13 +37,22 @@ private:
|
||||
uint8_t m_id;
|
||||
};
|
||||
|
||||
enum class ShiftAlphaStatus {
|
||||
Default,
|
||||
Shift,
|
||||
Alpha,
|
||||
ShiftAlpha,
|
||||
AlphaLock,
|
||||
AlphaLockShift,
|
||||
ShiftAlphaLock,
|
||||
};
|
||||
|
||||
// Timeout is decremented
|
||||
Event getEvent(int * timeout);
|
||||
|
||||
ShiftAlphaStatus shiftAlphaStatus();
|
||||
bool isShiftActive();
|
||||
bool isAlphaActive();
|
||||
bool isAlphaLocked();
|
||||
bool isShiftAlphaLocked();
|
||||
|
||||
// Plain
|
||||
|
||||
|
||||
@@ -4,50 +4,77 @@
|
||||
namespace Ion {
|
||||
namespace Events {
|
||||
|
||||
static bool sIsShiftActive = false;
|
||||
static bool sIsAlphaActive = false;
|
||||
static bool sIsAlphaLocked = false;
|
||||
static bool sIsShiftAlphaLocked = false;
|
||||
static ShiftAlphaStatus sShiftAlphaStatus = ShiftAlphaStatus::Default;
|
||||
|
||||
ShiftAlphaStatus shiftAlphaStatus() {
|
||||
return sShiftAlphaStatus;
|
||||
}
|
||||
|
||||
bool isShiftActive() {
|
||||
return sIsShiftActive;
|
||||
return sShiftAlphaStatus == ShiftAlphaStatus::Shift || sShiftAlphaStatus == ShiftAlphaStatus::ShiftAlpha || sShiftAlphaStatus == ShiftAlphaStatus::AlphaLockShift || sShiftAlphaStatus == ShiftAlphaStatus::ShiftAlphaLock;
|
||||
}
|
||||
|
||||
bool isAlphaActive() {
|
||||
return sIsAlphaActive;
|
||||
}
|
||||
|
||||
bool isAlphaLocked() {
|
||||
return sIsAlphaLocked;
|
||||
}
|
||||
|
||||
bool isShiftAlphaLocked() {
|
||||
return sIsShiftAlphaLocked;
|
||||
return sShiftAlphaStatus == ShiftAlphaStatus::Alpha || sShiftAlphaStatus == ShiftAlphaStatus::ShiftAlpha || sShiftAlphaStatus == ShiftAlphaStatus::AlphaLock || sShiftAlphaStatus == ShiftAlphaStatus::AlphaLockShift || sShiftAlphaStatus == ShiftAlphaStatus::ShiftAlphaLock;
|
||||
;
|
||||
}
|
||||
|
||||
void updateModifiersFromEvent(Event e) {
|
||||
if (e == Shift) {
|
||||
sIsShiftActive = !sIsShiftActive;
|
||||
} else if (e == Alpha) {
|
||||
if (sIsAlphaLocked || sIsShiftAlphaLocked) {
|
||||
sIsAlphaLocked = false;
|
||||
sIsShiftAlphaLocked = false;
|
||||
sIsAlphaActive = false;
|
||||
} else if (sIsAlphaActive) {
|
||||
if (sIsShiftActive) {
|
||||
sIsShiftAlphaLocked = true;
|
||||
sIsAlphaActive = false;
|
||||
} else {
|
||||
sIsAlphaLocked = true;
|
||||
sIsAlphaActive = false;
|
||||
switch (sShiftAlphaStatus) {
|
||||
case ShiftAlphaStatus::Default:
|
||||
if (e == Shift) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::Shift;
|
||||
} else if (e == Alpha) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::Alpha;
|
||||
}
|
||||
} else {
|
||||
sIsAlphaActive = true;
|
||||
break;
|
||||
case ShiftAlphaStatus::Shift:
|
||||
if (e == Shift) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::Default;
|
||||
} else if (e == Alpha) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::ShiftAlpha;
|
||||
} else {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::Default;
|
||||
}
|
||||
break;
|
||||
case ShiftAlphaStatus::Alpha:
|
||||
if (e == Shift) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::ShiftAlpha;
|
||||
} else if (e == Alpha) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::AlphaLock;
|
||||
} else {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::Default;
|
||||
}
|
||||
break;
|
||||
case ShiftAlphaStatus::ShiftAlpha:
|
||||
if (e == Shift) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::Alpha;
|
||||
} else if (e == Alpha) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::ShiftAlphaLock;
|
||||
} else {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::Default;
|
||||
}
|
||||
break;
|
||||
case ShiftAlphaStatus::AlphaLock:
|
||||
if (e == Shift) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::AlphaLockShift;
|
||||
} else if (e == Alpha) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::Default;
|
||||
}
|
||||
break;
|
||||
case ShiftAlphaStatus::AlphaLockShift:
|
||||
if (e == Alpha) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::Shift;
|
||||
} else {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::AlphaLock;
|
||||
}
|
||||
break;
|
||||
case ShiftAlphaStatus::ShiftAlphaLock:
|
||||
if (e == Alpha) {
|
||||
sShiftAlphaStatus = ShiftAlphaStatus::Default;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
sIsShiftActive = false;
|
||||
sIsAlphaActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool sleepWithTimeout(int duration, int * timeout) {
|
||||
@@ -91,7 +118,7 @@ Event getEvent(int * timeout) {
|
||||
* Unfortunately there's no way to express this in standard C, so we have
|
||||
* to resort to using a builtin function. */
|
||||
Keyboard::Key key = (Keyboard::Key)(63-__builtin_clzll(keysSeenTransitionningFromUpToDown));
|
||||
Event event(key, sIsShiftActive || sIsShiftAlphaLocked, sIsAlphaActive || sIsAlphaLocked || sIsShiftAlphaLocked);
|
||||
Event event(key, isShiftActive(), isAlphaActive());
|
||||
updateModifiersFromEvent(event);
|
||||
sLastEvent = event;
|
||||
sLastKeyboardState = state;
|
||||
|
||||
Reference in New Issue
Block a user