Bläddra i källkod

Optimized kvm firmware

Toby Chui 1 vecka sedan
förälder
incheckning
855ae40b5e

+ 3 - 3
remdeskd/mod/remdeshid/hidcomm.go

@@ -182,7 +182,7 @@ func appendMouseScrollEventSubtypes(data []byte, cmd HIDCommand, sensitivityDivi
 		//Scroll up
 		scrollValue = -scrollValue
 		if scrollValue > 0x7F {
-			scrollValue = 0x7F
+			scrollValue = 0x7E
 		}
 		scrollValue /= sensitivityDivider
 		data = append(data, 0x00)
@@ -190,7 +190,7 @@ func appendMouseScrollEventSubtypes(data []byte, cmd HIDCommand, sensitivityDivi
 	} else {
 		//SCroll down
 		if scrollValue > 0x7F {
-			scrollValue = 0x7F
+			scrollValue = 0x7E
 		}
 		scrollValue /= sensitivityDivider
 		data = append(data, 0x01)
@@ -219,7 +219,7 @@ func ConvHIDCommandToBytes(cmd HIDCommand) ([]byte, error) {
 	} else if cmd.EventType == FRONTEND_OPR_TYPE_MOUSE_SCROLL {
 		/* Mouse Scroll Event */
 		data = []byte{OPR_TYPE_MOUSE_SCROLL}
-		return appendMouseScrollEventSubtypes(data, cmd, 8)
+		return appendMouseScrollEventSubtypes(data, cmd, 32)
 	}
 
 	return nil, fmt.Errorf("invalid HID command type: %s", cmd.EventType)

+ 6 - 0
remdeskd/mod/remdeshid/remdeshid.go

@@ -90,6 +90,12 @@ func (c *Controller) Connect() error {
 	if err != nil {
 		return err
 	}
+
+	//Reset mouse press state
+	err = c.Send([]byte{OPR_TYPE_MOUSE_WRITE, SUBTYPE_MOUSE_RESET, 0x00})
+	if err != nil {
+		return err
+	}
 	return nil
 }
 

+ 9 - 14
usbkvm/usbkvm_fw/mouse_emu.ino

@@ -61,22 +61,16 @@ uint8_t mouse_move(uint8_t ux, uint8_t uy, uint8_t dx, uint8_t dy) {
 }
 
 //Handle mouse move, direction accept 0x00 (down / right) or 0x01 (up / left)
-uint8_t mouse_scroll(uint8_t direction, uint8_t utilt) {
+uint8_t mouse_wheel(uint8_t direction, uint8_t utilt) {
   int8_t tilt;
+  if (utilt >= 0x7E) {
+    tilt = 126;
+  }else{
+    tilt = (int8_t)utilt;
+  }
   if (direction == 0x01) {
     //Down
-    if (utilt >= 0x7F) {
-      tilt = -127;
-    } else {
-      tilt = (int8_t)utilt * -1;
-    }
-  } else {
-    //Up
-    if (utilt >= 0x7F) {
-      tilt = 127;
-    } else {
-      tilt = (int8_t)utilt;
-    }
+    tilt = tilt * -1;
   }
 #ifdef ENABLE_MOUSE_DEBUG
   Serial0_write(resp_start_of_info_msg);
@@ -84,7 +78,6 @@ uint8_t mouse_scroll(uint8_t direction, uint8_t utilt) {
   Serial0_write(resp_end_of_msg);
 #endif
   Mouse_scroll(tilt);
-  delay(MIN_KEY_EVENTS_DELAY);
   return resp_ok;
 }
 
@@ -138,11 +131,13 @@ uint8_t mouse_emulation(uint8_t subtype, uint8_t value) {
       } else {
         return resp_invalid_key_value;
       }
+      return resp_ok;
     case SUBTYPE_MOUSE_RESET:
       Mouse_release(MOUSE_LEFT);
       Mouse_release(MOUSE_RIGHT);
       Mouse_release(MOUSE_MIDDLE);
       delay(MIN_KEY_EVENTS_DELAY);
+      return resp_ok;
     default:
       return resp_invalid_opr_type;
   }

+ 3 - 3
usbkvm/usbkvm_fw/usbkvm_fw.ino

@@ -58,7 +58,7 @@ uint8_t serial_data = 0x00;
 uint8_t keyboard_emulation(uint8_t, uint8_t);
 uint8_t mouse_emulation(uint8_t, uint8_t);
 uint8_t mouse_move(uint8_t, uint8_t, uint8_t, uint8_t);
-uint8_t mouse_scroll(uint8_t, uint8_t);
+uint8_t mouse_wheel(uint8_t, uint8_t);
 
 /* KVM Operation Execution Catergory*/
 uint8_t kvm_execute_opr() {
@@ -75,11 +75,10 @@ uint8_t kvm_execute_opr() {
     case OPR_TYPE_MOUSE_SCROLL:
       //mouse scroll
       //for larger scroll tilt value, use the multipler
-      return mouse_scroll(opr_subtype, opr_payload);
+      return mouse_wheel(opr_subtype, opr_payload);
     default:
       return resp_unknown_opr;
   }
-  return resp_ok;
 }
 
 void setup() {
@@ -134,6 +133,7 @@ void loop() {
         opr_type = OPR_TYPE_RESERVED;
         instr_count = 0;
       }
+      Serial0_write(resp_ok);
     } else {
       opr_payload = serial_data;
       //Execute the kvm operation