Architecture overview¶
Class Diagram¶
classDiagram
class Device {
+str name
+info Tuple[int, int, int]
+rdescs List[List[int]]
+report_rate int
+endpoints List[Endpoint]
+actuators List[Actuator]
+hw Dict[str, HWComponent]
+fw Firmware
+destroy()
+transform_action(action) %% Passes the action by the actuators and returns the transformed result ()
+send_hid_action(action) %% Sends HID action to all endpoints (create_report -> call_input_event)
+simulate_action(action) %% Transforms high-level action into HID timed events and sends them ()
}
class UHIDDevice
UHIDDevice --|> Endpoint : inherits
class Endpoint {
-_owner Device
-_hid_properties List[HIDProperty]
+rdesc List[int]
+name str
+number int
+uhid_dev_is_ready bool
-_update_hid_properties() %% Parses the report descriptor and populates _hid_properties ()
-_receive(data, size, rtype) %% HID data receive callback (triggers the firmware callback)
+send(data) %% Sends HID data ()
+create_report(action, skip_empty) %% Creates a report based on the HID data ()
+populate_hid_data(action, packets) %% Uses the _hid_properties to populate HID events ()
}
Device --> Endpoint : owns
class Firmware {
-_owner Device
+hid_receive(data, size, rtype, endpoint)
+hid_send(data, endpoint)
}
Device --> Firmware : owns
class Actuator {
-keys List[str]
+transforms(action) %% Transform a high-level action ()
}
Device --o Actuator : uses (actuators)
class HWComponent
Device --o HWComponent : uses (hw)
class HIDProperty {
-keys List[str]
+populate(action) %% Transform a high-level action ()
}
Endpoint --o HIDProperty : uses (_hid_properties)
simulate_action() Sequence Diagram¶
sequenceDiagram
participant API User
participant Device
participant Actuator
participant Endpoint
participant HIDProperty
API User->>Device: simulate_action(action)
Device->>+Device: hid_action = transform_action(action)
loop actuators
Device-->>Actuator: transform(data)
end
Device-->>-Device:
Device->>+Endpoint: populate_hid_data(hid_action, packets)
loop HID properties
Endpoint-->>HIDProperty: populate(hid_action, packets)
end
Endpoint-->>-Device:
loop packets
Device->>Endpoint: send(create_report(packet))
end
Device-->>API User: