|
@@ -7,7 +7,9 @@ package remdeshid
|
|
|
that can be sent over the USBKVM device
|
|
|
|
|
|
*/
|
|
|
-import "fmt"
|
|
|
+import (
|
|
|
+ "fmt"
|
|
|
+)
|
|
|
|
|
|
// Append the keyboard event subtypes to the data
|
|
|
func appendKeyboardEventSubtypes(data []byte, cmd HIDCommand) ([]byte, error) {
|
|
@@ -173,25 +175,25 @@ func appendMouseMoveEventSubtypes(data []byte, cmd HIDCommand) ([]byte, error) {
|
|
|
}
|
|
|
|
|
|
// Append the mouse scroll event subtypes to the data
|
|
|
-// The sensitivityDivider is used to divide the scroll value to make it less sensitive
|
|
|
func appendMouseScrollEventSubtypes(data []byte, cmd HIDCommand) ([]byte, error) {
|
|
|
//The mouse scroll command PosY contains the scroll value
|
|
|
//The scroll command require a direction byte and a scroll value byte
|
|
|
scrollValue := cmd.PosY
|
|
|
+ var sensitivity byte = 0x02
|
|
|
if scrollValue < 0 {
|
|
|
//Scroll up
|
|
|
- data = append(data, 0x00)
|
|
|
- data = append(data, 0x01)
|
|
|
+ data = append(data, 0x00) //Up
|
|
|
+ data = append(data, sensitivity) //Sensitive
|
|
|
} else {
|
|
|
//Scroll down
|
|
|
- data = append(data, 0x01)
|
|
|
- data = append(data, 0x01)
|
|
|
+ data = append(data, 0x01) //Down
|
|
|
+ data = append(data, sensitivity) //Sensitive
|
|
|
}
|
|
|
|
|
|
return data, nil
|
|
|
}
|
|
|
|
|
|
-//Entry function for converting a HIDCommand to bytes that can be sent over the USBKVM device
|
|
|
+// Entry function for converting a HIDCommand to bytes that can be sent over the USBKVM device
|
|
|
func ConvHIDCommandToBytes(cmd HIDCommand) ([]byte, error) {
|
|
|
// Convert the HID command to bytes
|
|
|
var data []byte
|
|
@@ -211,6 +213,12 @@ func ConvHIDCommandToBytes(cmd HIDCommand) ([]byte, error) {
|
|
|
/* Mouse Scroll Event */
|
|
|
data = []byte{OPR_TYPE_MOUSE_SCROLL}
|
|
|
return appendMouseScrollEventSubtypes(data, cmd)
|
|
|
+ } else if cmd.EventType == FRONT_END_OPR_RESET {
|
|
|
+ /* Reset Event */
|
|
|
+ data = []byte{OPR_TYPE_DATA_RESET, //Reset the data queue
|
|
|
+ OPR_TYPE_KEYBOARD_WRITE, SUBTYPE_KEYBOARD_SPECIAL_RESET, 0x00, //Reset the keyboard press state
|
|
|
+ OPR_TYPE_MOUSE_WRITE, SUBTYPE_MOUSE_RESET, 0x00} //Reset the mouse press state
|
|
|
+ return data, nil
|
|
|
}
|
|
|
|
|
|
return nil, fmt.Errorf("invalid HID command type: %s", cmd.EventType)
|