Skip to content

Commit 888c567

Browse files
committed
feat(UI): add mouse and keyboard support to T113
1 parent cd870cc commit 888c567

File tree

18 files changed

+233
-43
lines changed

18 files changed

+233
-43
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,20 @@ endif()
278278
target_compile_definitions(DuetScreen.lib PUBLIC MULTITHREADED)
279279

280280
if(PROCESSOR STREQUAL "T113")
281+
pkg_check_modules(XKBCOMMON xkbcommon)
281282
target_compile_definitions(lvgl PUBLIC
282283
LV_USE_LINUX_FBDEV=1
283284
LV_USE_EVDEV=1
284285
LV_LINUX_FBDEV_RENDER_MODE=LV_DISPLAY_RENDER_MODE_DIRECT
285286
LV_LINUX_FBDEV_BUFFER_COUNT=2)
287+
if(XKBCOMMON_FOUND)
288+
message(STATUS "xkbcommon found: enabling XKB support for evdev")
289+
target_compile_definitions(lvgl PUBLIC LV_EVDEV_XKB=1)
290+
target_link_libraries(lvgl PUBLIC ${XKBCOMMON_LIBRARIES})
291+
target_include_directories(lvgl PUBLIC ${XKBCOMMON_INCLUDE_DIRS})
292+
else()
293+
message(STATUS "xkbcommon not found: evdev keyboard support will be disabled")
294+
endif()
286295
# add_compile_definitions(T113=1)
287296

288297
target_compile_definitions(DuetScreen.lib PUBLIC T113=1)

assets/i18n/en-GB.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@
260260
"firmware_version": "Firmware Version:",
261261
"font": "Font",
262262
"icons": "Icons",
263+
"keyboard_layout": "USB Keyboard Layout:",
263264
"language": "Language:",
264265
"language_en": "English",
265266
"notification_auto_close_error": "Do not close error messages automatically:",

libraries/lvgl.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
3232
target_compile_definitions(lvgl PUBLIC
3333
# LV_USE_ASSERT_OBJ=1 # significantly increases unit test time and decreases frame rate
3434
LV_USE_LOG=1
35+
LV_LOG_LEVEL=LV_LOG_LEVEL_WARN
3536
LV_LOG_PRINTF=1
3637
LV_USE_SYSMON=1
3738
LV_USE_PERF_MONITOR=1

src/CMakeLists.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@ target_sources(
77
${CMAKE_CURRENT_SOURCE_DIR}/Debug.cpp
88
${CMAKE_CURRENT_SOURCE_DIR}/LockWrapper.cpp
99
${CMAKE_CURRENT_SOURCE_DIR}/Storage.cpp
10-
${CMAKE_CURRENT_SOURCE_DIR}/DebugCommands.cpp)
11-
12-
if(PROCESSOR STREQUAL "Simulation")
13-
target_sources(DuetScreen.lib
14-
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/mouse_cursor_icon.c)
15-
endif()
10+
${CMAKE_CURRENT_SOURCE_DIR}/DebugCommands.cpp
11+
${CMAKE_CURRENT_SOURCE_DIR}/mouse_cursor_icon.c)
1612

1713
add_subdirectory(Comm)
1814
add_subdirectory(Hardware)

src/Comm/Usb.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,8 @@ namespace Comm
596596
case UsbMode::InternalWiFi:
597597
setUsbHost(true);
598598
setUsbMux(false);
599-
setUsbState(false);
599+
setUsbState(false); /* probably `false` because smart USB chargers reset the screen in wifi mode if the
600+
state pin doesn't signal device mode */
600601
NetworkHelper::enable(true);
601602
break;
602603
default:

src/Storage.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ constexpr StorageKey<speed_t> ID_DUET_BAUD_RATE = {"duet:baud_rate", DEFAULT_BAU
5151
constexpr StorageKey<size_t> ID_THEME = {"ui:theme", std::numeric_limits<size_t>::max()};
5252
constexpr StorageKey<std::string_view> ID_FONT = {"ui:font", "OpenSans"};
5353
constexpr StorageKey<std::string_view> ID_ICON_FOLDER = {"ui:icon_folder", DEFAULT_ICON_SET};
54+
constexpr StorageKey<std::string_view> ID_KEYBOARD_LAYOUT = {"ui:keyboard_layout", "us"};
5455

5556
constexpr StorageKey<bool> ID_SCREENSAVER_ENABLE = {"ui:screensaver_enable", true};
5657
constexpr StorageKey<std::chrono::seconds> ID_SCREENSAVER_TIMEOUT = {"ui:screensaver_timeout", DEFAULT_SCREEN_TIMEOUT};

src/Storage.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ extern const StorageKey<speed_t> ID_DUET_BAUD_RATE;
134134
extern const StorageKey<size_t> ID_THEME;
135135
extern const StorageKey<std::string_view> ID_FONT;
136136
extern const StorageKey<std::string_view> ID_ICON_FOLDER;
137+
extern const StorageKey<std::string_view> ID_KEYBOARD_LAYOUT;
137138

138139
extern const StorageKey<bool> ID_SCREENSAVER_ENABLE;
139140
extern const StorageKey<std::chrono::seconds> ID_SCREENSAVER_TIMEOUT;

src/UI/Components/Input/DropdownMenu.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ namespace UI
8383
m_dropdown.clearText();
8484
}
8585

86-
void DropdownMenu::setOptions(std::span<std::string> options)
87-
{
88-
ZoneScoped;
89-
m_dropdown.setOptions(options);
90-
}
91-
9286
void DropdownMenu::addOption(const std::string& option, uint32_t pos)
9387
{
9488
ZoneScoped;

src/UI/Components/Input/DropdownMenu.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ namespace UI
2828
LvLabel& getLabel() { return m_label; }
2929
LvDropdown& getDropdownMenu() { return m_dropdown; }
3030

31-
void setOptions(std::span<std::string> options);
31+
template <typename T>
32+
requires std::convertible_to<T, std::string_view>
33+
void setOptions(std::span<T> options)
34+
{
35+
ZoneScoped;
36+
m_dropdown.setOptions(options);
37+
}
3238
void addOption(const std::string& option, uint32_t pos = LV_DROPDOWN_POS_LAST);
3339
void clearOptions();
3440
void setSelected(uint32_t selected);

0 commit comments

Comments
 (0)