|
@@ -129,6 +129,30 @@ func (c *Controller) GetChipCurrentConfiguration() ([]byte, error) {
|
|
|
return resp, nil
|
|
|
}
|
|
|
|
|
|
+func (c *Controller) ChipSoftReset() error {
|
|
|
+ //Send the command to get chip configuration and info
|
|
|
+ cmd := []byte{0x57, 0xAB,
|
|
|
+ 0x00, 0x0F,
|
|
|
+ 0x00, //placeholder for checksum
|
|
|
+ }
|
|
|
+
|
|
|
+ cmd[4] = calcChecksum(cmd[:4])
|
|
|
+ err := c.Send(cmd)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("Error sending command: %v\n", err)
|
|
|
+ return errors.New("failed to send command")
|
|
|
+ }
|
|
|
+
|
|
|
+ _, err = c.WaitForReply(0x0F)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Printf("Error waiting for reply: %v\n", err)
|
|
|
+ return errors.New("failed to get reply")
|
|
|
+ }
|
|
|
+
|
|
|
+ fmt.Println("Chip soft reset successfully")
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
func (c *Controller) IsModifierKeys(keycode int) bool {
|
|
|
// Modifier keycodes for JavaScript
|
|
|
modifierKeys := []int{16, 17, 18, 91} // Shift, Ctrl, Alt, Meta (Windows/Command key)
|
|
@@ -215,6 +239,8 @@ func (c *Controller) ConstructAndSendCmd(HIDCommand *HIDCommand) ([]byte, error)
|
|
|
}
|
|
|
c.lastCursorEventTime = time.Now().UnixMilli()
|
|
|
return c.MouseScroll(HIDCommand.MouseScroll)
|
|
|
+ case EventTypeHIDReset:
|
|
|
+ return []byte{}, c.ChipSoftReset()
|
|
|
default:
|
|
|
return nil, fmt.Errorf("unsupported HID command event type: %d", HIDCommand.Event)
|
|
|
}
|