Keyboard improvements (#240)

- Renamed various keyboard functions so it's easier to differentiate hardware versus software keyboard functionality
- Created `Tactility/lvgl/Keyboard.h` as a proxy  for the internal `Gui` service.
- Implemented `tt_lvgl_keyboard.h` in `TactilityC`.
This commit is contained in:
Ken Van Hoeylandt
2025-03-10 00:21:49 +01:00
committed by GitHub
parent 13d7e84ef3
commit 85a6ad3bbe
14 changed files with 274 additions and 130 deletions
@@ -0,0 +1,59 @@
#pragma once
#include <lvgl.h>
namespace tt::lvgl {
/**
* Show the on-screen keyboard.
* @param[in] textarea the textarea to focus the input for
*/
void software_keyboard_show(lv_obj_t* textarea);
/**
* Hide the on-screen keyboard.
* Has no effect when the keyboard is not visible.
*/
void software_keyboard_hide();
/**
* The on-screen keyboard is only shown when both of these conditions are true:
* - there is no hardware keyboard
* - TT_CONFIG_FORCE_ONSCREEN_KEYBOARD is set to true in tactility_config.h
* @return if we should show a on-screen keyboard for text input inside our apps
*/
bool software_keyboard_is_enabled();
/**
* Activate the keypad for a widget group.
* @param group
*/
void software_keyboard_activate(lv_group_t* group);
/**
* Deactivate the keypad for the current widget group (if any).
* You don't have to call this after calling _activate() because widget
* cleanup automatically removes itself from the group it belongs to.
*/
void software_keyboard_deactivate();
/**
* @return true if LVGL is configured with a keypad
*/
bool hardware_keyboard_is_available();
/**
* Set the keypad.
* @param device the keypad device
*/
void hardware_keyboard_set_indev(lv_indev_t* device);
/**
* Glue code for the on-screen keyboard and the hardware keyboard:
* - Attach automatic hide/show parameters for the on-screen keyboard.
* - Registers the textarea to the default lv_group_t for hardware keyboards.
* @param[in] textarea
*/
void keyboard_add_textarea(lv_obj_t* textarea);
}
@@ -1,34 +0,0 @@
/**
* This code relates to the hardware keyboard support also known as "keypads" in LVGL.
*/
#pragma once
#include <lvgl.h>
namespace tt::lvgl {
/**
* @return true if LVGL is configured with a keypad
*/
bool keypad_is_available();
/**
* Set the keypad.
* @param device the keypad device
*/
void keypad_set_indev(lv_indev_t* device);
/**
* Activate the keypad for a widget group.
* @param group
*/
void keypad_activate(lv_group_t* group);
/**
* Deactivate the keypad for the current widget group (if any).
* You don't have to call this after calling _activate() because widget
* cleanup automatically removes itself from the group it belongs to.
*/
void keypad_deactivate();
} // namespace
@@ -1,51 +0,0 @@
#pragma once
#include "Tactility/app/AppInstance.h"
#include "Tactility/app/AppContext.h"
namespace tt::service::gui {
typedef struct Gui Gui;
/**
* Set the app viewport in the gui state and request the gui to draw it.
* @param[in] app
*/
void showApp(std::shared_ptr<app::AppContext> app);
/**
* Hide the current app's viewport.
* Does not request a re-draw because after hiding the current app,
* we always show the previous app, and there is always at least 1 app running.
*/
void hideApp();
/**
* Show the on-screen keyboard.
* @param[in] textarea the textarea to focus the input for
*/
void keyboardShow(lv_obj_t* textarea);
/**
* Hide the on-screen keyboard.
* Has no effect when the keyboard is not visible.
*/
void keyboardHide();
/**
* The on-screen keyboard is only shown when both of these conditions are true:
* - there is no hardware keyboard
* - TT_CONFIG_FORCE_ONSCREEN_KEYBOARD is set to true in tactility_config.h
* @return if we should show a on-screen keyboard for text input inside our apps
*/
bool keyboardIsEnabled();
/**
* Glue code for the on-screen keyboard and the hardware keyboard:
* - Attach automatic hide/show parameters for the on-screen keyboard.
* - Registers the textarea to the default lv_group_t for hardware keyboards.
* @param[in] textarea
*/
void keyboardAddTextArea(lv_obj_t* textarea);
} // namespace