Papers3 improvements (#611)
- And Tab5 keyboard improvements - Usb host keyboard improvements - Symbols - Requires the device.py change from CL-32 PR but that only affects visuals and not build breaking
This commit is contained in:
@@ -23,7 +23,13 @@ enum DisplayCapability {
|
||||
DISPLAY_CAPABILITY_SLEEP = 1 << 6,
|
||||
DISPLAY_CAPABILITY_REQUIRES_FULL_FRAME = 1 << 7,
|
||||
/** Can be used by e-paper with pointer devices for long click timing changes. */
|
||||
DISPLAY_CAPABILITY_SLOW_REFRESH = 1 << 8
|
||||
DISPLAY_CAPABILITY_SLOW_REFRESH = 1 << 8,
|
||||
/**
|
||||
* Promise that draw_bitmap() never DMAs directly from the color_data pointer it's given (e.g.
|
||||
* it copies/converts into its own buffer first). Lets the LVGL bridge allocate this display's
|
||||
* draw buffer(s) from non-DMA-capable memory instead of forcing scarce internal RAM.
|
||||
*/
|
||||
DISPLAY_CAPABILITY_PREFER_EXTERNAL_RAM = 1 << 9
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -36,6 +42,11 @@ enum DisplayColorFormat {
|
||||
DISPLAY_COLOR_FORMAT_RGB565 = 0x3,
|
||||
DISPLAY_COLOR_FORMAT_RGB565_SWAPPED = 0x4,
|
||||
DISPLAY_COLOR_FORMAT_RGB888 = 0x5,
|
||||
// 8 bpp luminance, 0x00 = black, 0xFF = white (matches LVGL's LV_COLOR_FORMAT_L8). Unlike
|
||||
// MONOCHROME, the LVGL bridge does not force full-frame rendering for this format, so drivers
|
||||
// that want real partial/tile updates (e.g. grayscale e-paper panels) should report this
|
||||
// instead of MONOCHROME even if they intend to threshold down to black/white themselves.
|
||||
DISPLAY_COLOR_FORMAT_GRAYSCALE8 = 0x6,
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,25 @@ struct KeyboardKeyData {
|
||||
* immediately to drain it. False if this was the last pending event.
|
||||
*/
|
||||
bool continue_reading;
|
||||
/**
|
||||
* @brief True if Ctrl was held when this key was pressed.
|
||||
*
|
||||
* Reported separately rather than folded into `key` because the two encodings collide: the C0
|
||||
* control codes a terminal expects for Ctrl chords (Ctrl+C is 0x03, Ctrl+K is 0x0B, ...) overlap
|
||||
* the LVGL key constants drivers emit in the same field (LV_KEY_END is 3, LV_KEY_PREV is 11,
|
||||
* LV_KEY_UP is 17, ...), so a single uint32_t cannot express both. Consumers that want control
|
||||
* codes derive them here, e.g.
|
||||
* `((key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z')) ? (key & 0x1F) : key`
|
||||
* when ctrl is set.
|
||||
*
|
||||
* Drivers whose hardware cannot report Ctrl leave this false.
|
||||
*/
|
||||
bool ctrl;
|
||||
/**
|
||||
* @brief True if Alt was held when this key was pressed. See ctrl for why modifiers are reported
|
||||
* separately. Drivers whose hardware cannot report Alt leave this false.
|
||||
*/
|
||||
bool alt;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,7 +43,18 @@ typedef enum {
|
||||
typedef struct {
|
||||
UsbHidEventType type;
|
||||
union {
|
||||
struct { uint32_t key_code; bool pressed; } key;
|
||||
/**
|
||||
* @brief A key press or release.
|
||||
*
|
||||
* `ctrl` and `alt` report the modifiers separately rather than folding them into
|
||||
* `key_code`, because the two encodings collide: the C0 control codes a terminal expects
|
||||
* for Ctrl chords (Ctrl+C is 0x03, Ctrl+K is 0x0B) overlap the UsbHidKey constants above
|
||||
* (USB_HID_KEY_END is 3, USB_HID_KEY_PREV is 11). A consumer wanting control codes derives
|
||||
* them here, e.g.
|
||||
* `((key_code >= 'a' && key_code <= 'z') || (key_code >= 'A' && key_code <= 'Z')) ?
|
||||
* (key_code & 0x1F) : key_code`.
|
||||
*/
|
||||
struct { uint32_t key_code; bool pressed; bool ctrl; bool alt; } key;
|
||||
struct { int32_t dx; int32_t dy; } mouse_move;
|
||||
struct { bool button1; bool button2; } mouse_btn;
|
||||
struct { int32_t delta; } scroll;
|
||||
|
||||
@@ -9,6 +9,12 @@ extern "C" {
|
||||
|
||||
error_t keyboard_read_key(Device* device, KeyboardKeyData* data) {
|
||||
const auto* driver = device_get_driver(device);
|
||||
|
||||
// Default the modifier fields here rather than in each driver: only drivers whose hardware can
|
||||
// report modifiers set them, and the rest would otherwise leave whatever the caller's stack held.
|
||||
data->ctrl = false;
|
||||
data->alt = false;
|
||||
|
||||
return KEYBOARD_DRIVER_API(driver)->read_key(device, data);
|
||||
}
|
||||
|
||||
|
||||
@@ -171,6 +171,7 @@ const struct ModuleSymbol KERNEL_SYMBOLS[] = {
|
||||
DEFINE_MODULE_SYMBOL(file_system_unmount),
|
||||
DEFINE_MODULE_SYMBOL(file_system_is_mounted),
|
||||
DEFINE_MODULE_SYMBOL(file_system_get_path),
|
||||
DEFINE_MODULE_SYMBOL(file_system_for_each),
|
||||
// memory
|
||||
DEFINE_MODULE_SYMBOL(MEMORY_POLICY_DEFAULT),
|
||||
DEFINE_MODULE_SYMBOL(memory_print_stats),
|
||||
|
||||
Reference in New Issue
Block a user