Shadowtrance dc3f6104b8
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
2026-08-08 15:02:49 +02:00

36 lines
1.0 KiB
C++

// SPDX-License-Identifier: Apache-2.0
#include <tactility/device.h>
#include <tactility/drivers/keyboard.h>
#include <tactility/error.h>
#define KEYBOARD_DRIVER_API(driver) ((struct KeyboardApi*)driver->api)
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);
}
error_t keyboard_get_backlight(Device* device, Device** backlight_device) {
const auto* driver = device_get_driver(device);
if (KEYBOARD_DRIVER_API(driver)->get_backlight == nullptr) {
return ERROR_NOT_SUPPORTED;
}
return KEYBOARD_DRIVER_API(driver)->get_backlight(device, backlight_device);
}
const DeviceType KEYBOARD_TYPE {
.name = "keyboard"
};
}