M module-apps/apps-common/Application.hpp => module-apps/apps-common/Application.hpp +2 -2
@@ 13,8 13,8 @@
#include "Service/Service.hpp" // for Service
#include "Timers/TimerHandle.hpp"
#include "SwitchData.hpp" // for SwitchData
-#include "SystemManager/SystemManagerCommon.hpp" // for SystemManager
-#include "bsp/keyboard/key_codes.hpp" // for bsp
+#include <SystemManager/SystemManagerCommon.hpp>
+#include <hal/key_input/KeyEventDefinitions.hpp>
#include "gui/Common.hpp" // for ShowMode
#include "projdefs.h" // for pdMS_TO_TICKS
#include <PhoneModes/Observer.hpp>
M module-bsp/CMakeLists.txt => module-bsp/CMakeLists.txt +2 -0
@@ 27,6 27,8 @@ target_sources(
PUBLIC
hal/temperature_source/TemperatureSource.hpp
hal/battery_charger/AbstractBatteryCharger.hpp
+ hal/key_input/AbstractKeyInput.hpp
+ hal/key_input/KeyEventDefinitions.hpp
)
add_board_subdirectory(board)
M module-bsp/board/linux/CMakeLists.txt => module-bsp/board/linux/CMakeLists.txt +1 -1
@@ 11,7 11,6 @@ target_sources(module-bsp
eink_frontlight/eink_frontlight.cpp
eink/ED028TC1.c
headset/headset.cpp
- keyboard/keyboard.cpp
keypad_backlight/keypad_backlight.cpp
light_sensor/light_sensor.cpp
lpm/LinuxLPM.cpp
@@ 24,6 23,7 @@ target_sources(module-bsp
watchdog/watchdog.cpp
hal/temperature_source/TemperatureSource.cpp
hal/battery_charger/BatteryCharger.cpp
+ hal/key_input/KeyInput.cpp
${CMAKE_CURRENT_BINARY_DIR}/eink-config.h
)
R module-bsp/board/linux/keyboard/keyboard.cpp => module-bsp/board/linux/hal/key_input/KeyInput.cpp +29 -57
@@ 1,49 1,30 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-/*
- * linux_keyboard.cpp
- *
- * Created on: May 27, 2019
- * Author: kuba
- */
-
-#include <iostream>
-
-#include <stdio.h>
-#include <stdint.h>
-#include <assert.h>
-#include <memory>
-
-#include "FreeRTOS.h"
-#include "queue.h"
-#include "task.h"
-#include "timers.h"
+#include "KeyInput.hpp"
+#include <hal/GenericFactory.hpp>
#include <sys/stat.h>
#include <fcntl.h>
-#include "bsp/keyboard/keyboard.hpp"
-
-namespace bsp::keyboard
+namespace hal::key_input
{
namespace
{
TaskHandle_t linux_keyboard_worker_handle = nullptr;
- uint8_t kcode = 0;
- uint8_t kevent = 0;
-
+ std::uint8_t keyCode = 0;
+ std::uint8_t keyEventType = 0;
int fd;
bool handleSliderKey()
{
bool breakIfSliderReleased = false;
- if (kcode == static_cast<uint8_t>(bsp::KeyCodes::SSwitchUp) ||
- kcode == static_cast<uint8_t>(bsp::KeyCodes::SSwitchMid) ||
- kcode == static_cast<uint8_t>(bsp::KeyCodes::SSwitchDown)) {
- if (kevent == static_cast<uint8_t>(bsp::KeyEvents::Pressed)) {
- kevent = static_cast<uint8_t>(bsp::KeyEvents::Moved);
+ if (keyCode == static_cast<uint8_t>(bsp::KeyCodes::SSwitchUp) ||
+ keyCode == static_cast<uint8_t>(bsp::KeyCodes::SSwitchMid) ||
+ keyCode == static_cast<uint8_t>(bsp::KeyCodes::SSwitchDown)) {
+ if (keyEventType == static_cast<uint8_t>(bsp::KeyEvents::Pressed)) {
+ keyEventType = static_cast<uint8_t>(bsp::KeyEvents::Moved);
}
else {
breakIfSliderReleased = true;
@@ 65,28 46,19 @@ namespace bsp::keyboard
fd = open(myfifo, O_RDONLY | O_NONBLOCK);
while (1) {
- uint8_t buff[10];
- int32_t readedBytes = read(fd, buff, 10);
+ std::uint8_t buff[10];
+ std::int32_t readedBytes = read(fd, buff, 10);
if (readedBytes > 1) {
- kevent = buff[0];
- kcode = buff[1];
+ keyEventType = buff[0];
+ keyCode = buff[1];
xQueueHandle qhandle = reinterpret_cast<xQueueHandle>(pvp);
- uint8_t notification = 0;
- if (kcode == static_cast<uint8_t>(bsp::KeyCodes::FnRight)) {
- if (kevent == static_cast<uint8_t>(bsp::KeyEvents::Pressed))
- notification = 0x02;
- else
- notification = 0x04;
- }
- else
- notification = 0x01;
-
if (handleSliderKey()) {
break;
}
+ std::uint8_t notification = 0x01;
xQueueSend(qhandle, ¬ification, 100);
}
vTaskDelay(50);
@@ 96,28 68,28 @@ namespace bsp::keyboard
}
} // namespace
- std::vector<KeyEvent> getKeyEvents(std::uint8_t notification)
+ std::shared_ptr<AbstractKeyInput> AbstractKeyInput::Factory::create()
{
- KeyEvent keyEvent;
- keyEvent.code = static_cast<KeyCodes>(kcode);
- keyEvent.event = static_cast<KeyEvents>(kevent);
- return std::vector<KeyEvent>{keyEvent};
+ return hal::impl::factory<LinuxKeyInput, AbstractKeyInput>();
}
- std::int32_t init(xQueueHandle qHandle)
+ void LinuxKeyInput::init(xQueueHandle qHandle)
{
-
- if (xTaskCreate(linux_keyboard_worker, "keyboard", 512, qHandle, 0, &linux_keyboard_worker_handle) != pdPASS) {
- return 1;
- }
- return 0;
+ xTaskCreate(linux_keyboard_worker, "keyboard", 512, qHandle, 0, &linux_keyboard_worker_handle);
}
- std::int32_t deinit()
+ void LinuxKeyInput::deinit()
{
vTaskDelete(linux_keyboard_worker_handle);
close(fd);
- return 0;
}
-} // namespace bsp::keyboard
+ std::vector<bsp::KeyEvent> LinuxKeyInput::getKeyEvents(std::uint8_t)
+ {
+ using namespace bsp;
+ KeyEvent keyEvent;
+ keyEvent.code = static_cast<KeyCodes>(keyCode);
+ keyEvent.event = static_cast<KeyEvents>(keyEventType);
+ return std::vector<KeyEvent>{keyEvent};
+ }
+} // namespace hal::key_input
A module-bsp/board/linux/hal/key_input/KeyInput.hpp => module-bsp/board/linux/hal/key_input/KeyInput.hpp +17 -0
@@ 0,0 1,17 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <module-bsp/hal/key_input/AbstractKeyInput.hpp>
+
+namespace hal::key_input
+{
+ class LinuxKeyInput : public AbstractKeyInput
+ {
+ public:
+ void init(xQueueHandle qHandle) final;
+ void deinit() final;
+ std::vector<bsp::KeyEvent> getKeyEvents(std::uint8_t) final;
+ };
+} // namespace hal::key_input
M module-bsp/board/rt1051/CMakeLists.txt => module-bsp/board/rt1051/CMakeLists.txt +0 -1
@@ 19,7 19,6 @@ target_sources(module-bsp
bsp/eMMC/fsl_sdmmc_event.c
bsp/eMMC/fsl_sdmmc_host.c
bsp/headset/headset.cpp
- bsp/keyboard/keyboard.cpp
bsp/keypad_backlight/keypad_backlight.cpp
bsp/light_sensor/light_sensor.cpp
bsp/lpm/ClockState.cpp
M module-bsp/board/rt1051/bellpx/CMakeLists.txt => module-bsp/board/rt1051/bellpx/CMakeLists.txt +2 -0
@@ 12,10 12,12 @@ target_sources(
PRIVATE
hal/temperature_source/TemperatureSource.cpp
hal/battery_charger/BatteryCharger.cpp
+ hal/key_input/KeyInput.cpp
pin_mux.c
clock_config.cpp
irq_gpio.cpp
+
PUBLIC
eink-config.h
board/pin_mux.h
A module-bsp/board/rt1051/bellpx/hal/key_input/KeyInput.cpp => module-bsp/board/rt1051/bellpx/hal/key_input/KeyInput.cpp +36 -0
@@ 0,0 1,36 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "KeyInput.hpp"
+
+#include <hal/GenericFactory.hpp>
+
+namespace hal::key_input
+{
+ std::shared_ptr<AbstractKeyInput> AbstractKeyInput::Factory::create()
+ {
+ return hal::impl::factory<KeyInput, AbstractKeyInput>();
+ }
+
+ void KeyInput::init(xQueueHandle)
+ {}
+
+ void KeyInput::deinit()
+ {}
+
+ std::vector<bsp::KeyEvent> KeyInput::getKeyEvents(std::uint8_t)
+ {
+ return std::vector<bsp::KeyEvent>{};
+ }
+
+ BaseType_t generalIRQHandler()
+ {
+ return 0;
+ }
+
+ BaseType_t rightFunctionalIRQHandler()
+ {
+ return 0;
+ }
+
+} // namespace hal::key_input
A module-bsp/board/rt1051/bellpx/hal/key_input/KeyInput.hpp => module-bsp/board/rt1051/bellpx/hal/key_input/KeyInput.hpp +17 -0
@@ 0,0 1,17 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <module-bsp/hal/key_input/AbstractKeyInput.hpp>
+
+namespace hal::key_input
+{
+ class KeyInput : public AbstractKeyInput
+ {
+ public:
+ void init(xQueueHandle) final;
+ void deinit() final;
+ std::vector<bsp::KeyEvent> getKeyEvents(std::uint8_t) final;
+ };
+} // namespace hal::key_input
M module-bsp/board/rt1051/bellpx/irq_gpio.cpp => module-bsp/board/rt1051/bellpx/irq_gpio.cpp +2 -2
@@ 10,7 10,7 @@
#include "board/rt1051/bsp/eink/bsp_eink.h"
#include <hal/battery_charger/AbstractBatteryCharger.hpp>
-#include "bsp/keyboard/keyboard.hpp"
+#include <hal/key_input/AbstractKeyInput.hpp>
#include "bsp/BoardDefinitions.hpp"
#include "bsp/light_sensor/light_sensor.hpp"
@@ 107,7 107,7 @@ namespace bsp
uint32_t irq_mask = GPIO_GetPinsInterruptFlags(GPIO2);
if (irq_mask & (1 << BOARD_KEYBOARD_IRQ_GPIO_PIN)) {
- xHigherPriorityTaskWoken |= bsp::keyboard::IRQHandler();
+ xHigherPriorityTaskWoken |= hal::key_input::generalIRQHandler();
}
// Clear all IRQs
M module-bsp/board/rt1051/puretx/CMakeLists.txt => module-bsp/board/rt1051/puretx/CMakeLists.txt +3 -1
@@ 12,7 12,9 @@ target_sources(
PRIVATE
hal/battery_charger/BatteryCharger.cpp
bsp/battery_charger/battery_charger.cpp
- pin_mux.c
+ hal/key_input/KeyInput.cpp
+ bsp/keyboard/keyboard.cpp
+ pin_mux.c
clock_config.cpp
irq_gpio.cpp
R module-bsp/board/rt1051/bsp/keyboard/TCA8418.hpp => module-bsp/board/rt1051/puretx/bsp/keyboard/TCA8418.hpp +0 -0
R module-bsp/board/rt1051/bsp/keyboard/keyboard.cpp => module-bsp/board/rt1051/puretx/bsp/keyboard/keyboard.cpp +1 -1
@@ 106,7 106,7 @@ namespace bsp::keyboard
.pin = static_cast<uint32_t>(BoardDefinitions::KEYBOARD_IRQ_PIN)});
std::uint32_t reg = 0;
- status_t error = 0;
+ status_t error = 0;
gpio->WritePin(static_cast<std::uint32_t>(BoardDefinitions::KEYBOARD_RESET_PIN), 0);
vTaskDelay(1);
R module-bsp/bsp/keyboard/keyboard.hpp => module-bsp/board/rt1051/puretx/bsp/keyboard/keyboard.hpp +7 -17
@@ 3,30 3,20 @@
#pragma once
-#include "key_codes.hpp"
-
-#include <bsp/common.hpp>
+#include <hal/key_input/KeyEventDefinitions.hpp>
#include <cstdint>
#include <vector>
-namespace bsp::keyboard
+namespace bsp::keyboard
{
- struct KeyEvent
- {
- KeyCodes code;
- KeyEvents event;
- };
-
- std::vector<KeyEvent> getKeyEvents(std::uint8_t notification);
+ std::vector<KeyEvent> getKeyEvents(std::uint8_t notification);
- std::int32_t init(xQueueHandle qHandle);
+ std::int32_t init(xQueueHandle qHandle);
- std::int32_t deinit();
+ std::int32_t deinit();
- BaseType_t IRQHandler();
+ BaseType_t IRQHandler();
- BaseType_t rightFunctionalIRQHandler();
+ BaseType_t rightFunctionalIRQHandler();
} // namespace bsp::keyboard
-
-
A module-bsp/board/rt1051/puretx/hal/key_input/KeyInput.cpp => module-bsp/board/rt1051/puretx/hal/key_input/KeyInput.cpp +41 -0
@@ 0,0 1,41 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#include "KeyInput.hpp"
+
+#include <hal/GenericFactory.hpp>
+#include <bsp/keyboard/keyboard.hpp>
+
+namespace hal::key_input
+{
+ std::shared_ptr<AbstractKeyInput> AbstractKeyInput::Factory::create()
+ {
+ return hal::impl::factory<KeyInput, AbstractKeyInput>();
+ }
+
+ void KeyInput::init(xQueueHandle queueHandle)
+ {
+ bsp::keyboard::init(queueHandle);
+ }
+
+ void KeyInput::deinit()
+ {
+ bsp::keyboard::deinit();
+ }
+
+ std::vector<bsp::KeyEvent> KeyInput::getKeyEvents(std::uint8_t notification)
+ {
+ return bsp::keyboard::getKeyEvents(notification);
+ }
+
+ BaseType_t generalIRQHandler()
+ {
+ return bsp::keyboard::IRQHandler();
+ }
+
+ BaseType_t rightFunctionalIRQHandler()
+ {
+ return bsp::keyboard::rightFunctionalIRQHandler();
+ }
+
+} // namespace hal::key_input
A module-bsp/board/rt1051/puretx/hal/key_input/KeyInput.hpp => module-bsp/board/rt1051/puretx/hal/key_input/KeyInput.hpp +17 -0
@@ 0,0 1,17 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <module-bsp/hal/key_input/AbstractKeyInput.hpp>
+
+namespace hal::key_input
+{
+ class KeyInput : public AbstractKeyInput
+ {
+ public:
+ void init(xQueueHandle queueHandle) final;
+ void deinit() final;
+ std::vector<bsp::KeyEvent> getKeyEvents(std::uint8_t) final;
+ };
+} // namespace hal::key_input
M module-bsp/board/rt1051/puretx/irq_gpio.cpp => module-bsp/board/rt1051/puretx/irq_gpio.cpp +3 -3
@@ 10,8 10,8 @@
#include "board/rt1051/bsp/eink/bsp_eink.h"
#include <hal/battery_charger/AbstractBatteryCharger.hpp>
+#include <hal/key_input/AbstractKeyInput.hpp>
#include "bsp/cellular/bsp_cellular.hpp"
-#include "bsp/keyboard/keyboard.hpp"
#include "bsp/headset/headset.hpp"
#include "bsp/BoardDefinitions.hpp"
#include "bsp/magnetometer/magnetometer.hpp"
@@ 110,7 110,7 @@ namespace bsp
uint32_t irq_mask = GPIO_GetPinsInterruptFlags(GPIO2);
if (irq_mask & (1 << BOARD_KEYBOARD_RF_BUTTON_PIN)) {
- xHigherPriorityTaskWoken |= bsp::keyboard::rightFunctionalIRQHandler();
+ xHigherPriorityTaskWoken |= hal::key_input::rightFunctionalIRQHandler();
}
if (irq_mask & (1 << BOARD_BATTERY_CHARGER_INOKB_PIN)) {}
@@ 142,7 142,7 @@ namespace bsp
uint32_t irq_mask = GPIO_GetPinsInterruptFlags(GPIO2);
if (irq_mask & (1 << BOARD_KEYBOARD_IRQ_GPIO_PIN)) {
- xHigherPriorityTaskWoken |= bsp::keyboard::IRQHandler();
+ xHigherPriorityTaskWoken |= hal::key_input::generalIRQHandler();
}
if (irq_mask & (1 << BOARD_USBC_NINT_PIN)) {
M module-bsp/bsp/common.hpp => module-bsp/bsp/common.hpp +0 -7
@@ 3,7 3,6 @@
#pragma once
-//TODO maybe move KeyEvents to keyboard.hpp
namespace bsp
{
enum class RetCode{
@@ 12,12 11,6 @@ namespace bsp
};
- enum class KeyEvents{
- Released,
- Pressed,
- Moved,
- };
-
/// CPU frequency is dependent on the clock settings.
/// Only a few thresholds are available in the current configuration
enum class CpuFrequencyHz
D module-bsp/bsp/keyboard/key_codes.hpp => module-bsp/bsp/keyboard/key_codes.hpp +0 -107
@@ 1,107 0,0 @@
-#pragma once
-
-namespace bsp {
-
- enum class KeyCodes {
- Undefined = 0,
- NumericKey1 = 31,
- NumericKey2 = 32,
- NumericKey3 = 33,
- NumericKey4 = 41,
- NumericKey5 = 42,
- NumericKey6 = 43,
- NumericKey7 = 51,
- NumericKey8 = 52,
- NumericKey9 = 53,
- NumericKey0 = 62,
- NumericKeyAst = 61,
- NumericKeyPnd = 63,
-
- JoystickLeft = 11,
- JoystickRight = 13,
- JoystickUp = 2,
- JoystickDown = 22,
- JoystickEnter = 12,
-
- FnLeft = 21,//1,
- FnRight = 23,//3,
-
- VolUp = 4,
- VolDown = 14,
-
- Torch = 24,
-
- SSwitchUp = 34,
- SSwitchDown = 54,
- SSwitchMid = 44,
-
- HeadsetOk = 71,
- HeadsetVolUp = 72,
- HeadsetVolDown = 73
- };
-}
-
-inline const char *c_str(bsp::KeyCodes code)
-{
- switch (code) {
- case bsp::KeyCodes::Undefined:
- return "Undefined";
- case bsp::KeyCodes::NumericKey1:
- return "NumericKey1";
- case bsp::KeyCodes::NumericKey2:
- return "NumericKey2";
- case bsp::KeyCodes::NumericKey3:
- return "NumericKey3";
- case bsp::KeyCodes::NumericKey4:
- return "NumericKey4";
- case bsp::KeyCodes::NumericKey5:
- return "NumericKey5";
- case bsp::KeyCodes::NumericKey6:
- return "NumericKey6";
- case bsp::KeyCodes::NumericKey7:
- return "NumericKey7";
- case bsp::KeyCodes::NumericKey8:
- return "NumericKey8";
- case bsp::KeyCodes::NumericKey9:
- return "NumericKey9";
- case bsp::KeyCodes::NumericKey0:
- return "NumericKey0";
- case bsp::KeyCodes::NumericKeyAst:
- return "NumericKeyAst";
- case bsp::KeyCodes::NumericKeyPnd:
- return "NumericKeyPnd";
- case bsp::KeyCodes::JoystickLeft:
- return "JoystickLeft";
- case bsp::KeyCodes::JoystickRight:
- return "JoystickRight";
- case bsp::KeyCodes::JoystickUp:
- return "JoystickUp";
- case bsp::KeyCodes::JoystickDown:
- return "JoystickDown";
- case bsp::KeyCodes::JoystickEnter:
- return "JoystickEnter";
- case bsp::KeyCodes::FnLeft:
- return "FnLeft";
- case bsp::KeyCodes::FnRight:
- return "FnRight";
- case bsp::KeyCodes::VolUp:
- return "VolUp";
- case bsp::KeyCodes::VolDown:
- return "VolDown";
- case bsp::KeyCodes::Torch:
- return "Torch";
- case bsp::KeyCodes::SSwitchUp:
- return "SSwitchUp";
- case bsp::KeyCodes::SSwitchDown:
- return "SSwitchDown";
- case bsp::KeyCodes::SSwitchMid:
- return "SSwitchMid";
- case bsp::KeyCodes::HeadsetOk:
- return "HeadsetOk";
- case bsp::KeyCodes::HeadsetVolUp:
- return "HeadsetVolUp";
- case bsp::KeyCodes::HeadsetVolDown:
- return "HeadsetVolDown";
- }
- return "";
-}
M module-bsp/bsp/magnetometer/magnetometer.hpp => module-bsp/bsp/magnetometer/magnetometer.hpp +1 -1
@@ 1,6 1,6 @@
#pragma once
-#include <bsp/keyboard/key_codes.hpp>
+#include <hal/key_input/KeyEventDefinitions.hpp>
#include <cstdint>
#include <optional>
A module-bsp/hal/key_input/AbstractKeyInput.hpp => module-bsp/hal/key_input/AbstractKeyInput.hpp +33 -0
@@ 0,0 1,33 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include "KeyEventDefinitions.hpp"
+#include <FreeRTOS.h>
+#include <queue.h>
+
+#include <memory>
+#include <vector>
+
+namespace hal::key_input
+{
+ class AbstractKeyInput
+ {
+ public:
+ struct Factory
+ {
+ static std::shared_ptr<AbstractKeyInput> create();
+ };
+
+ virtual ~AbstractKeyInput() = default;
+
+ virtual void init(xQueueHandle) = 0;
+ virtual void deinit() = 0;
+ virtual std::vector<bsp::KeyEvent> getKeyEvents(std::uint8_t) = 0;
+ };
+
+ BaseType_t generalIRQHandler();
+ BaseType_t rightFunctionalIRQHandler();
+
+} // namespace hal::key_input
A module-bsp/hal/key_input/KeyEventDefinitions.hpp => module-bsp/hal/key_input/KeyEventDefinitions.hpp +67 -0
@@ 0,0 1,67 @@
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
+
+#pragma once
+
+#include <magic_enum.hpp>
+
+namespace bsp
+{
+
+ enum class KeyCodes
+ {
+ Undefined = 0,
+ NumericKey1 = 31,
+ NumericKey2 = 32,
+ NumericKey3 = 33,
+ NumericKey4 = 41,
+ NumericKey5 = 42,
+ NumericKey6 = 43,
+ NumericKey7 = 51,
+ NumericKey8 = 52,
+ NumericKey9 = 53,
+ NumericKey0 = 62,
+ NumericKeyAst = 61,
+ NumericKeyPnd = 63,
+
+ JoystickLeft = 11,
+ JoystickRight = 13,
+ JoystickUp = 2,
+ JoystickDown = 22,
+ JoystickEnter = 12,
+
+ FnLeft = 21, // 1,
+ FnRight = 23, // 3,
+
+ VolUp = 4,
+ VolDown = 14,
+
+ Torch = 24,
+
+ SSwitchUp = 34,
+ SSwitchDown = 54,
+ SSwitchMid = 44,
+
+ HeadsetOk = 71,
+ HeadsetVolUp = 72,
+ HeadsetVolDown = 73
+ };
+
+ enum class KeyEvents
+ {
+ Released,
+ Pressed,
+ Moved,
+ };
+
+ struct KeyEvent
+ {
+ KeyCodes code;
+ KeyEvents event;
+ };
+} // namespace bsp
+
+inline const char *c_str(bsp::KeyCodes code)
+{
+ return magic_enum::enum_name(code).data();
+}
M module-gui/gui/input/InputEvent.hpp => module-gui/gui/input/InputEvent.hpp +0 -1
@@ 6,7 6,6 @@
#include <sstream>
#include <cstdint>
#include <type_traits>
-#include "bsp/keyboard/key_codes.hpp"
#include "common_data/RawKey.hpp"
namespace gui
M module-gui/gui/input/Translator.hpp => module-gui/gui/input/Translator.hpp +0 -1
@@ 5,7 5,6 @@
#include "InputEvent.hpp"
#include "Profile.hpp"
-#include <bsp/keyboard/key_codes.hpp>
#include <common_data/RawKey.hpp>
#include <cstdint>
#include <map>
M module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.hpp => module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.hpp +1 -1
@@ 8,7 8,7 @@
#include <Common/Query.hpp>
#include <Service/Common.hpp>
#include <Service/Service.hpp>
-#include <bsp/keyboard/key_codes.hpp>
+#include <hal/key_input/KeyEventDefinitions.hpp>
#include <input/InputEvent.hpp>
#include <module-db/Interface/SMSRecord.hpp>
#include <endpoints/BaseHelper.hpp>
M module-services/service-eink/board/linux/renderer/src/RWindow.cpp => module-services/service-eink/board/linux/renderer/src/RWindow.cpp +1 -1
@@ 5,7 5,7 @@
#include <module-bsp/board/linux/board.h>
#include <module-bsp/bsp/common.hpp>
-#include <module-bsp/bsp/keyboard/key_codes.hpp>
+#include <hal/key_input/KeyEventDefinitions.hpp>
#include <module-services/service-eink/board/linux/renderer/src/RArea.hpp>
#include <glibmm/signalproxy.h>
M module-services/service-eink/board/linux/renderer/src/RWindow.hpp => module-services/service-eink/board/linux/renderer/src/RWindow.hpp +1 -1
@@ 5,7 5,7 @@
#include "RArea.hpp"
-#include <module-bsp/bsp/keyboard/key_codes.hpp>
+#include <hal/key_input/KeyEventDefinitions.hpp>
#include <gdk/gdk.h>
#include <gtkmm.h>
M module-services/service-evtmgr/EventManager.cpp => module-services/service-evtmgr/EventManager.cpp +1 -1
@@ 18,7 18,7 @@
#include <SystemManager/SystemManagerCommon.hpp>
#include <bsp/common.hpp>
#include <bsp/rtc/rtc.hpp>
-#include <bsp/keyboard/key_codes.hpp>
+#include <hal/key_input/KeyEventDefinitions.hpp>
#include <log.hpp>
#include <Logger.hpp>
#include <service-appmgr/Controller.hpp>
M module-services/service-evtmgr/WorkerEventCommon.cpp => module-services/service-evtmgr/WorkerEventCommon.cpp +5 -5
@@ 11,7 11,6 @@
#include <MessageType.hpp>
#include <Service/Worker.hpp>
#include <bsp/cellular/bsp_cellular.hpp>
-#include <bsp/keyboard/keyboard.hpp>
#include <bsp/magnetometer/magnetometer.hpp>
#include <bsp/rtc/rtc.hpp>
#include <bsp/torch/torch.hpp>
@@ 46,7 45,8 @@ extern "C"
WorkerEventCommon::WorkerEventCommon(sys::Service *service)
: sys::Worker(service, stackDepthBytes),
- service(service), batteryCharger{hal::battery::AbstractBatteryCharger::Factory::create(service)}
+ service(service), batteryCharger{hal::battery::AbstractBatteryCharger::Factory::create(service)},
+ keyInput{hal::key_input::AbstractKeyInput::Factory::create()}
{}
bool WorkerEventCommon::handleMessage(uint32_t queueID)
@@ 68,7 68,7 @@ bool WorkerEventCommon::handleMessage(uint32_t queueID)
if (!queue->Dequeue(¬ification, 0)) {
return false;
}
- for (const auto &key : bsp::keyboard::getKeyEvents(notification)) {
+ for (const auto &key : keyInput->getKeyEvents(notification)) {
processKeyEvent(key.event, key.code);
}
}
@@ 135,7 135,7 @@ bool WorkerEventCommon::initEventQueues()
bool WorkerEventCommon::initCommonHardwareComponents()
{
- bsp::keyboard::init(queues[static_cast<int32_t>(WorkerEventQueues::queueKeyboardIRQ)]->GetQueueHandle());
+ keyInput->init(queues[static_cast<int32_t>(WorkerEventQueues::queueKeyboardIRQ)]->GetQueueHandle());
auto queueBatteryHandle = queues[static_cast<int32_t>(WorkerEventQueues::queueBattery)]->GetQueueHandle();
auto queueChargerDetect = queues[static_cast<int32_t>(WorkerEventQueues::queueChargerDetect)]->GetQueueHandle();
batteryCharger->init(queueBatteryHandle, queueChargerDetect);
@@ 171,7 171,7 @@ bool WorkerEventCommon::deinit(void)
deinitProductHardware();
- bsp::keyboard::deinit();
+ keyInput->deinit();
batteryCharger->deinit();
battery_level_check::deinit();
M module-services/service-evtmgr/service-evtmgr/EVMessages.hpp => module-services/service-evtmgr/service-evtmgr/EVMessages.hpp +1 -1
@@ 12,7 12,7 @@
#include <SwitchData.hpp>
#include <bsp/cellular/bsp_cellular.hpp>
#include <bsp/common.hpp>
-#include <bsp/keyboard/key_codes.hpp>
+#include <hal/key_input/KeyEventDefinitions.hpp>
#include <bsp/torch/torch.hpp>
#include <bsp/keypad_backlight/keypad_backlight.hpp>
#include <vibra/Vibra.hpp>
M module-services/service-evtmgr/service-evtmgr/WorkerEventCommon.hpp => module-services/service-evtmgr/service-evtmgr/WorkerEventCommon.hpp +2 -2
@@ 9,10 9,9 @@
#include <Service/Service.hpp>
#include <Service/Worker.hpp>
#include <bsp/common.hpp>
-#include <bsp/keyboard/key_codes.hpp>
-#include <bsp/keyboard/key_codes.hpp>
#include <Service/CpuSentinel.hpp>
#include <hal/battery_charger/AbstractBatteryCharger.hpp>
+#include <hal/key_input/AbstractKeyInput.hpp>
#include <cstdint>
#include <list>
@@ 82,6 81,7 @@ class WorkerEventCommon : public sys::Worker
bsp::KeyCodes lastPressed = static_cast<bsp::KeyCodes>(0);
std::shared_ptr<sys::CpuSentinel> cpuSentinel;
std::shared_ptr<hal::battery::AbstractBatteryCharger> batteryCharger;
+ std::shared_ptr<hal::key_input::AbstractKeyInput> keyInput;
public:
explicit WorkerEventCommon(sys::Service *service);
M module-utils/common_data/RawKey.hpp => module-utils/common_data/RawKey.hpp +1 -1
@@ 4,7 4,7 @@
#pragma once
#include <cstdint>
-#include <bsp/keyboard/key_codes.hpp>
+#include <hal/key_input/KeyEventDefinitions.hpp>
/// default application timer trigger
const inline uint32_t keyTimerMs = 200;