Repository navigation
Expand file tree
/
Copy pathI2CKeyboardComponent.h
More file actions
51 lines (44 loc) · 1.84 KB
/
Copy pathI2CKeyboardComponent.h
File metadata and controls
51 lines (44 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once
#include <cstdint>
#include <deki/SetupComponent.h>
#include <deki/reflection/Property.h>
#include "InputApi.h"
namespace DekiInput
{
/// Boot-scene component for a keyboard on the I2C bus.
///
/// For a keyboard that answers a read with the next character typed: the
/// LilyGO T-Deck's (address 0x55) and the M5Stack CardKB (0x5F). Needs an
/// I2CBusComponent on the matching port earlier in the boot scene.
///
/// Keys arrive as KeyDown / KeyUp through DekiInput like any other
/// keyboard's: InputEvent::key is the key (Keys.h), InputEvent::character what
/// it typed.
///
/// A missing keyboard does not stop the boot. Its controller may still be
/// starting when this runs, so it is looked for over the first few seconds;
/// after that the step reports that nothing answered and stays quiet.
DEKI_CATEGORY("Input")
DEKI_DISPLAY_NAME("I2C Keyboard")
DEKI_DESCRIPTION(
"Reads a keyboard that hands over one typed character per I2C read: the LilyGO T-Deck's, the M5Stack CardKB.")
class DEKI_INPUT_API I2CKeyboardComponent : public Deki::SetupComponent
{
public:
DEKI_EXPORT
DEKI_TOOLTIP("Which I2C bus the keyboard is on. Must match the I2C Bus component that set that port up.")
DEKI_RANGE(0, 3)
int32_t i2cPort = 0;
DEKI_EXPORT
DEKI_TOOLTIP(
"The keyboard's address on the bus: 0x55 (85) for the LilyGO T-Deck, 0x5F (95) for the M5Stack CardKB.")
DEKI_RANGE(0, 127)
int32_t i2cAddress = 0x55;
DEKI_EXPORT
DEKI_TOOLTIP("The keyboard has a backlight it controls itself, set over the bus (the LilyGO T-Deck's: brightness "
"in register 0x01). Game code then sets it with I2CKeyboard::SetBacklight.")
bool hasBacklight = false;
void Setup(SetupCallback onComplete) override;
const char* GetSetupName() const override { return "I2C Keyboard"; }
};
} // namespace DekiInput