maix.peripheral.hid

maix.peripheral.hid module

You can use maix.peripheral.hid to access this module with MaixPy
This module is generated from MaixPy and MaixCDK

Module

No module

Enum

DeviceType

Device enum of hid

item describe
values DEVICE_MOUSE:
DEVICE_KEYBOARD:
DEVICE_TOUCHPAD:

C++ defination code:

enum DeviceType {
        DEVICE_MOUSE = 0,
        DEVICE_KEYBOARD,
        DEVICE_TOUCHPAD
    }

Variable

Function

Class

Hid

Hid class

C++ defination code:

class Hid

__init__

def __init__(self, device_type: DeviceType, open: bool = True) -> None

Hid Device constructor

item description
type func
param device_type: Device type, used to select mouse, keyboard, or touchpad.
open: auto open device in constructor, if false, you need call open() to open device
static False

C++ defination code:

Hid(hid::DeviceType device_type, bool open = true)

open

def open(self) -> maix.err.Err

Open hid device

item description
type func
return err::Err
static False

C++ defination code:

err::Err open()

close

def close(self) -> maix.err.Err

Close hid device

item description
type func
return err::Err
static False

C++ defination code:

err::Err close()

write

def write(self, data: list[int]) -> maix.err.Err

Write data to hid device

item description
type func
param data: data to write
For the keyboard, 8 bytes of data need to be written, with the format as follows:
data = [0x00, #
0x00, #
0x00, # Key value. Refer to the "Universal Serial Bus HID Usage Tables" section of the official documentation(https://www.usb.org).
0x00, #
0x00, #
0x00, #
0x00, #
0x00] #
For the mouse, 4 bytes of data need to be written, with the format as follows:
data = [0x00, # Button state
0x00: no button pressed
0x01: press left button
0x02: press right button
0x04: press middle button
x, # X-axis relative coordinates. Signed number, positive values for x indicate movement to the right
y, # Y-axis relative coordinates. Signed number, positive values for y indicate movement downward
0x00] # Wheel movement. Signed number, positive values indicate downward movement.
For the touchpad, 6 bytes of data need to be written, with the format as follows:
data = [0x00, # Button state (0: no button pressed, 0x01: press left button, 0x10, press right button.)
x & 0xFF, (x >> 8) & 0xFF, # X-axis absolute coordinate, 0 means unused.
Note: You must map the target position to the range [0x1, 0x7FFF]. This means x value = <position_to_move> * 0x7FFF / <actual_screen_width>
y & 0xFF, (y >> 8) & 0xFF, # Y-axis absolute coordinate, 0 means unused.
Note: You must map the target position to the range [0x1, 0x7FFF]. This means y value = <position_to_move> * 0x7FFF / <actual_screen_height>
0x00, # Wheel movement. Signed number, positive values indicate downward movement.
return err::Err
static False

C++ defination code:

err::Err write(std::vector<int> &data)

is_opened

def is_opened(self) -> bool

Check if hid device is opened

item description
type func
return bool
static False

C++ defination code:

bool is_opened()