M products/PurePhone/services/evtmgr/EventManager.cpp => products/PurePhone/services/evtmgr/EventManager.cpp +3 -1
@@ 92,6 92,8 @@ void EventManager::initProductEvents()
connect(sevm::ToggleTorchColorMessage(), [&]([[maybe_unused]] sys::Message *msg) {
toggleTorchColor();
+ // Handle only torch short press. Done here as workaround since only app can recognize press length.
+ backlightHandler.handleKeyPressed();
return sys::MessageNone{};
});
@@ 166,7 168,7 @@ void EventManager::handleKeyEvent(sys::Message *msg)
auto kbdMessage = dynamic_cast<sevm::KbdMessage *>(msg);
if (kbdMessage->key.state == RawKey::State::Pressed) {
- backlightHandler.handleKeyPressed();
+ backlightHandler.handleKeyPressed(kbdMessage->key.keyCode);
}
else if (kbdMessage->key.state == RawKey::State::Moved) {
handleKeyMoveEvent(kbdMessage->key);
M products/PurePhone/services/evtmgr/backlight-handler/BacklightHandler.cpp => products/PurePhone/services/evtmgr/backlight-handler/BacklightHandler.cpp +20 -3
@@ 18,6 18,21 @@ namespace backlight
constexpr auto lightFadeoutTimerTimeout = std::chrono::seconds(10);
} // namespace timers
+ namespace
+ {
+ constexpr std::array exclusions = {bsp::KeyCodes::Torch};
+
+ [[nodiscard]] bool isKeyOnExclusionList(bsp::KeyCodes key)
+ {
+ for (const auto &exclusion : exclusions) {
+ if (key == exclusion) {
+ return true;
+ }
+ }
+ return false;
+ }
+ } // namespace
+
Handler::Handler(std::shared_ptr<settings::Settings> settings, sys::Service *parent)
: HandlerCommon(std::move(settings),
std::make_shared<pure::screen_light_control::ScreenLightController>(parent),
@@ 53,10 68,12 @@ namespace backlight
});
}
- void Handler::handleKeyPressed([[maybe_unused]] int key)
+ void Handler::handleKeyPressed(bsp::KeyCodes key)
{
- handleKeypadLightRefresh();
- handleScreenLightRefresh();
+ if (!isKeyOnExclusionList(key)) {
+ handleKeypadLightRefresh();
+ handleScreenLightRefresh();
+ }
}
void Handler::processScreenRequest(screen_light_control::Action action,
M products/PurePhone/services/evtmgr/include/evtmgr/BacklightHandler.hpp => products/PurePhone/services/evtmgr/include/evtmgr/BacklightHandler.hpp +2 -1
@@ 8,6 8,7 @@
#include <Timers/TimerHandle.hpp>
#include <Service/ServiceProxy.hpp>
#include <backlight-handler/BacklightHandlerCommon.hpp>
+#include <hal/key_input/KeyEventDefinitions.hpp>
namespace settings
{
@@ 23,7 24,7 @@ namespace backlight
Handler(std::shared_ptr<settings::Settings> settings, sys::Service *parent);
void init() override;
- void handleKeyPressed(int key = 0);
+ void handleKeyPressed(bsp::KeyCodes key = bsp::KeyCodes::Undefined);
/// Process request of the keypad light control
/// @keypad_backlight::action an action to perform
/// @return True if request was processed successfully, false otherwise