Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BrightnessValues = []string{"0x1f", "0x24", "0x1"}
Functions ¶
This section is empty.
Types ¶
type DeviceManager ¶
func NewDeviceManager ¶
func NewDeviceManager() *DeviceManager
NewDeviceManager creates and returns a new instance of DeviceManager. The DeviceManager is configured with default retry settings for detecting devices.
Returns: - A pointer to an initialized DeviceManager instance.
func (*DeviceManager) DetectDevices ¶
func (dm *DeviceManager) DetectDevices() (string, string, string, error)
DetectDevices scans the system's input devices to identify the touchpad and keyboard. It reads from `/proc/bus/input/devices` to locate devices based on their names and types.
Returns: - touchpad: The event ID of the detected touchpad (e.g., "5"). - keyboard: The event ID of the detected keyboard (e.g., "3"). - deviceID: The I2C device ID of the touchpad (e.g., "1"). - error: An error if detection fails after multiple retries.
func (*DeviceManager) InitializeDevices ¶
func (dm *DeviceManager) InitializeDevices(touchpad, keyboard string) (*evdev.InputDevice, *evdev.InputDevice, error)
InitializeDevices opens the detected touchpad and keyboard devices for event handling. It creates evdev InputDevice instances for each.
Parameters: - touchpad: The event ID of the detected touchpad (e.g., "5"). - keyboard: The event ID of the detected keyboard (e.g., "3").
Returns: - touchpadDevice: A pointer to the opened evdev InputDevice for the touchpad. - keyboardDevice: A pointer to the opened evdev InputDevice for the keyboard. - error: An error if either device fails to open.
type NumpadHandler ¶
type NumpadHandler struct {
KeyMap [][]byte
Columns int
Rows int
TopOffset float64
SleepDelay time.Duration
// contains filtered or unexported fields
}
func NewNumpadHandler ¶
func NewNumpadHandler(dT *evdev.InputDevice, udev uinput.Keyboard, deviceID string, model string) *NumpadHandler
NewNumpadHandler creates a new instance of NumpadHandler.
func (*NumpadHandler) HandleEvents ¶
func (nh *NumpadHandler) HandleEvents()
HandleEvents processes touchpad events to simulate numpad behavior. It listens for touchpad input events, interprets finger movements and taps, and maps them to virtual numpad keys or other actions such as toggling Num Lock or adjusting brightness.
type VirtualDevice ¶
func NewVirtualDevice ¶
func NewVirtualDevice() *VirtualDevice
NewVirtualDevice initializes and returns a new VirtualDevice instance. A VirtualDevice is used to emulate a keyboard with numpad functionality.
Returns: - A pointer to an initialized VirtualDevice instance.
func (*VirtualDevice) Close ¶
func (v *VirtualDevice) Close()
Close releases the virtual keyboard device. It ensures the underlying uinput device is properly closed.
Logs: - A success message if the device is closed without error. - An error message if closing the device fails.
func (*VirtualDevice) CreateVirtualDevice ¶
func (v *VirtualDevice) CreateVirtualDevice() error
CreateVirtualDevice sets up a virtual keyboard with predefined numpad keys. The keys enabled include numeric keypad keys, Num Lock, Calculator, and Left Shift.
Returns: - error: An error if the virtual keyboard cannot be created.
func (*VirtualDevice) SendKeyPress ¶
func (v *VirtualDevice) SendKeyPress(key byte) error
SendKeyPress simulates a key press event on the virtual keyboard.
Parameters: - key: The key code to press (e.g., uinput.KeyKp7).
Returns: - error: An error if the key press event fails or if the virtual keyboard is not initialized.