Gadget: removed relative mouse
This commit is contained in:
		@@ -9,7 +9,6 @@ echo "" > UDC
 | 
				
			|||||||
echo "Clean up configs"
 | 
					echo "Clean up configs"
 | 
				
			||||||
rm configs/c.1/hid.kbd0
 | 
					rm configs/c.1/hid.kbd0
 | 
				
			||||||
rm configs/c.1/hid.mouse0
 | 
					rm configs/c.1/hid.mouse0
 | 
				
			||||||
rm configs/c.1/hid.mouse1
 | 
					 | 
				
			||||||
rm configs/c.1/mass_storage.disk1
 | 
					rm configs/c.1/mass_storage.disk1
 | 
				
			||||||
rm configs/c.1/mass_storage.cdrom1
 | 
					rm configs/c.1/mass_storage.cdrom1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -19,7 +18,6 @@ rmdir configs/c.1
 | 
				
			|||||||
echo "Clean up functions"
 | 
					echo "Clean up functions"
 | 
				
			||||||
rmdir functions/hid.kbd0
 | 
					rmdir functions/hid.kbd0
 | 
				
			||||||
rmdir functions/hid.mouse0
 | 
					rmdir functions/hid.mouse0
 | 
				
			||||||
rmdir functions/hid.mouse1
 | 
					 | 
				
			||||||
rmdir functions/mass_storage.disk1
 | 
					rmdir functions/mass_storage.disk1
 | 
				
			||||||
rmdir functions/mass_storage.cdrom1
 | 
					rmdir functions/mass_storage.cdrom1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,7 @@ gserial=$(awk '/Serial/ { print $3 }' /proc/cpuinfo)
 | 
				
			|||||||
gmanufacturer="Petrkr.NET"
 | 
					gmanufacturer="Petrkr.NET"
 | 
				
			||||||
gproduct="rPi KVM"
 | 
					gproduct="rPi KVM"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Mouse 0 relative descriptor
 | 
					#Mouse absolute descriptor
 | 
				
			||||||
MOUSE0=""
 | 
					MOUSE0=""
 | 
				
			||||||
MOUSE0="$MOUSE0\\x05\\x01\\x09\\x02" # Usage generic desktop, Usage mouse
 | 
					MOUSE0="$MOUSE0\\x05\\x01\\x09\\x02" # Usage generic desktop, Usage mouse
 | 
				
			||||||
MOUSE0="$MOUSE0\\xa1\\x01\\x09\\x01" # Collection App, Usage Pointer
 | 
					MOUSE0="$MOUSE0\\xa1\\x01\\x09\\x01" # Collection App, Usage Pointer
 | 
				
			||||||
@@ -14,31 +14,17 @@ MOUSE0="$MOUSE0\\x05\\x09" # Use Page buttons
 | 
				
			|||||||
MOUSE0="$MOUSE0\\x19\\x01\\x29\\x08\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08" # Usage min 1, max 8, logical min 0, max 1, report 8, size 1
 | 
					MOUSE0="$MOUSE0\\x19\\x01\\x29\\x08\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08" # Usage min 1, max 8, logical min 0, max 1, report 8, size 1
 | 
				
			||||||
MOUSE0="$MOUSE0\\x81\\x02" # Input data, variable, absolute
 | 
					MOUSE0="$MOUSE0\\x81\\x02" # Input data, variable, absolute
 | 
				
			||||||
MOUSE0="$MOUSE0\\x05\\x01" # Usage page generic desktop
 | 
					MOUSE0="$MOUSE0\\x05\\x01" # Usage page generic desktop
 | 
				
			||||||
MOUSE0="$MOUSE0\\x09\\x30\\x09\\x31\\x09\\x38\\x15\\x81\\x25\\x7f\\x75\\x08\\x95\\x03" # Usage X,Y,Wheel, Log min -127, log max 127, size 8, report 3
 | 
					MOUSE0="$MOUSE0\\x09\\x30\\x16\\x00\\x00\\x26\\x80\\x07\\x75\\x10\\x95\\x01" # Usage X, Log min 0, log max 1920, size 16, report 1
 | 
				
			||||||
MOUSE0="$MOUSE0\\x81\\x02" # Input data, variable, absolute
 | 
					MOUSE0="$MOUSE0\\x81\\x02" # Input data, variable, absolute
 | 
				
			||||||
 | 
					MOUSE0="$MOUSE0\\x05\\x01" # Usage page generic desktop
 | 
				
			||||||
 | 
					MOUSE0="$MOUSE0\\x09\\x31\\x16\\x00\\x00\\x26\\x38\\x04\\x75\\x10\\x95\\x01" # Usage Y, Log min 0, log max 1080, size 16, report 1
 | 
				
			||||||
 | 
					MOUSE0="$MOUSE0\\x81\\x02" # Input data, variable, absolute
 | 
				
			||||||
 | 
					MOUSE0="$MOUSE0\\x05\\x01" # Usage page generic desktop
 | 
				
			||||||
 | 
					MOUSE0="$MOUSE0\\x09\\x38\\x15\\x81\\x25\\x7f\\x75\\x08\\x95\\x01" # Usage Wheel, log min -127, max 127, size 8, report 1
 | 
				
			||||||
 | 
					MOUSE0="$MOUSE0\\x81\\x06" # Input data, variable, relative
 | 
				
			||||||
MOUSE0="$MOUSE0\\xc0" # End collection Physical
 | 
					MOUSE0="$MOUSE0\\xc0" # End collection Physical
 | 
				
			||||||
MOUSE0="$MOUSE0\\xc0" # End collection Application
 | 
					MOUSE0="$MOUSE0\\xc0" # End collection Application
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Mouse 1 absolute descriptor
 | 
					 | 
				
			||||||
MOUSE1=""
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x05\\x01\\x09\\x02" # Usage generic desktop, Usage mouse
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\xa1\\x01\\x09\\x01" # Collection App, Usage Pointer
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\xa1\\x00" # Collection Physical
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x05\\x09" # Use Page buttons
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x19\\x01\\x29\\x08\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08" # Usage min 1, max 8, logical min 0, max 1, report 8, size 1
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x81\\x02" # Input data, variable, absolute
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x05\\x01" # Usage page generic desktop
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x09\\x30\\x16\\x00\\x00\\x26\\x80\\x07\\x75\\x10\\x95\\x01" # Usage X, Log min 0, log max 1920, size 16, report 1
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x81\\x02" # Input data, variable, absolute
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x05\\x01" # Usage page generic desktop
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x09\\x31\\x16\\x00\\x00\\x26\\x38\\x04\\x75\\x10\\x95\\x01" # Usage Y, Log min 0, log max 1080, size 16, report 1
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x81\\x02" # Input data, variable, absolute
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x05\\x01" # Usage page generic desktop
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x09\\x38\\x15\\x81\\x25\\x7f\\x75\\x08\\x95\\x01" # Usage Wheel, log min -127, max 127, size 8, report 1
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\x81\\x06" # Input data, variable, relative
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\xc0" # End collection Physical
 | 
					 | 
				
			||||||
MOUSE1="$MOUSE1\\xc0" # End collection Application
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cd /sys/kernel/config/usb_gadget/
 | 
					cd /sys/kernel/config/usb_gadget/
 | 
				
			||||||
mkdir -p $gname
 | 
					mkdir -p $gname
 | 
				
			||||||
cd $gname
 | 
					cd $gname
 | 
				
			||||||
@@ -68,20 +54,13 @@ echo 1 > functions/hid.kbd0/subclass
 | 
				
			|||||||
echo 8 > functions/hid.kbd0/report_length
 | 
					echo 8 > functions/hid.kbd0/report_length
 | 
				
			||||||
echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x05\\x07\\x19\\xe0\\x29\\xe7\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\\x05\\x08\\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03\\x95\\x06\\x75\\x08\\x15\\x00\\x25\\xff\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0 > functions/hid.kbd0/report_desc
 | 
					echo -ne \\x05\\x01\\x09\\x06\\xa1\\x01\\x05\\x07\\x19\\xe0\\x29\\xe7\\x15\\x00\\x25\\x01\\x75\\x01\\x95\\x08\\x81\\x02\\x95\\x01\\x75\\x08\\x81\\x03\\x95\\x05\\x75\\x01\\x05\\x08\\x19\\x01\\x29\\x05\\x91\\x02\\x95\\x01\\x75\\x03\\x91\\x03\\x95\\x06\\x75\\x08\\x15\\x00\\x25\\xff\\x05\\x07\\x19\\x00\\x29\\x65\\x81\\x00\\xc0 > functions/hid.kbd0/report_desc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "  HID Mouse Relative"
 | 
					echo "  HID Mouse"
 | 
				
			||||||
mkdir -p functions/hid.mouse0
 | 
					mkdir -p functions/hid.mouse0
 | 
				
			||||||
echo 2 > functions/hid.mouse0/protocol
 | 
					echo 2 > functions/hid.mouse0/protocol
 | 
				
			||||||
echo 1 > functions/hid.mouse0/subclass
 | 
					echo 1 > functions/hid.mouse0/subclass
 | 
				
			||||||
echo 8 > functions/hid.mouse0/report_length
 | 
					echo 8 > functions/hid.mouse0/report_length
 | 
				
			||||||
echo -ne $MOUSE0 > functions/hid.mouse0/report_desc
 | 
					echo -ne $MOUSE0 > functions/hid.mouse0/report_desc
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "  HID Mouse Absolute"
 | 
					 | 
				
			||||||
mkdir -p functions/hid.mouse1
 | 
					 | 
				
			||||||
echo 2 > functions/hid.mouse1/protocol
 | 
					 | 
				
			||||||
echo 1 > functions/hid.mouse1/subclass
 | 
					 | 
				
			||||||
echo 8 > functions/hid.mouse1/report_length
 | 
					 | 
				
			||||||
echo -ne $MOUSE1 > functions/hid.mouse1/report_desc
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "  Mass storage"
 | 
					echo "  Mass storage"
 | 
				
			||||||
mkdir -p functions/mass_storage.disk1
 | 
					mkdir -p functions/mass_storage.disk1
 | 
				
			||||||
@@ -95,7 +74,6 @@ echo 1 > functions/mass_storage.cdrom1/lun.0/removable
 | 
				
			|||||||
echo "Activating gadgeds"
 | 
					echo "Activating gadgeds"
 | 
				
			||||||
ln -s functions/hid.kbd0 configs/c.1/
 | 
					ln -s functions/hid.kbd0 configs/c.1/
 | 
				
			||||||
ln -s functions/hid.mouse0 configs/c.1/
 | 
					ln -s functions/hid.mouse0 configs/c.1/
 | 
				
			||||||
ln -s functions/hid.mouse1 configs/c.1/
 | 
					 | 
				
			||||||
ln -s functions/mass_storage.disk1 configs/c.1/
 | 
					ln -s functions/mass_storage.disk1 configs/c.1/
 | 
				
			||||||
ln -s functions/mass_storage.cdrom1 configs/c.1/
 | 
					ln -s functions/mass_storage.cdrom1 configs/c.1/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -106,4 +84,3 @@ ls /sys/class/udc > UDC
 | 
				
			|||||||
echo "Change permissions"
 | 
					echo "Change permissions"
 | 
				
			||||||
chgrp input /dev/hidg0; chmod 660 /dev/hidg0
 | 
					chgrp input /dev/hidg0; chmod 660 /dev/hidg0
 | 
				
			||||||
chgrp input /dev/hidg1; chmod 660 /dev/hidg1
 | 
					chgrp input /dev/hidg1; chmod 660 /dev/hidg1
 | 
				
			||||||
chgrp input /dev/hidg2; chmod 660 /dev/hidg2
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,8 +12,6 @@
 | 
				
			|||||||
<div>
 | 
					<div>
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<input type=text />
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
<br/>
 | 
					<br/>
 | 
				
			||||||
Server response: <span></span>
 | 
					Server response: <span></span>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										81
									
								
								templates/keyboard.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								templates/keyboard.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,81 @@
 | 
				
			|||||||
 | 
					<!doctype html>
 | 
				
			||||||
 | 
					<html lang="en">
 | 
				
			||||||
 | 
					<head>
 | 
				
			||||||
 | 
					  <meta charset="utf-8">
 | 
				
			||||||
 | 
					  <title>Klávesnice remote SSH</title>
 | 
				
			||||||
 | 
					  <style>
 | 
				
			||||||
 | 
					  </style>
 | 
				
			||||||
 | 
					  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
 | 
				
			||||||
 | 
					</head>
 | 
				
			||||||
 | 
					<body>
 | 
				
			||||||
 | 
						HID input service, POST data to /keyboard or /mouse <br/>
 | 
				
			||||||
 | 
					<div>
 | 
				
			||||||
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<br/>
 | 
				
			||||||
 | 
					Server response: <span></span>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<script>
 | 
				
			||||||
 | 
					function zapis(t) {
 | 
				
			||||||
 | 
					  $("div").text(t);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					var previous;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$(window).bind('keydown', function(event) {
 | 
				
			||||||
 | 
					  event.preventDefault();
 | 
				
			||||||
 | 
					  var str = String.fromCharCode(event.which).toLowerCase();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  var ctrl = event.ctrlKey;
 | 
				
			||||||
 | 
					  if (previous == 17) {
 | 
				
			||||||
 | 
					    ctrl = true;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  var obj = {
 | 
				
			||||||
 | 
					    ctrlKey: ctrl,
 | 
				
			||||||
 | 
					    shiftKey: event.shiftKey,
 | 
				
			||||||
 | 
					    altKey: event.altKey,
 | 
				
			||||||
 | 
					    which: event.which,
 | 
				
			||||||
 | 
						code: event.code,
 | 
				
			||||||
 | 
					    str: str
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (event.which != 16 && event.which != 17 && event.which != 18) {
 | 
				
			||||||
 | 
					    console.log(obj);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    var ret = $.ajax({
 | 
				
			||||||
 | 
					        type: "POST",
 | 
				
			||||||
 | 
					        url: "hid/keyboard",
 | 
				
			||||||
 | 
					        data: JSON.stringify(obj),
 | 
				
			||||||
 | 
					        contentType: "application/json; charset=utf-8",
 | 
				
			||||||
 | 
					        dataType: "json"
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						$("span").text(ret.responseText);
 | 
				
			||||||
 | 
						console.log(ret);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  var text = "";
 | 
				
			||||||
 | 
					  if (ctrl) {
 | 
				
			||||||
 | 
					    text = text + ' + Control';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (event.shiftKey) {
 | 
				
			||||||
 | 
					    text = text + ' + Shift';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  if (event.altKey) {
 | 
				
			||||||
 | 
					    text = text + ' + Alt';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  text = text + ' + ' + str;
 | 
				
			||||||
 | 
					  text = text.substr(3);
 | 
				
			||||||
 | 
					  zapis(text);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  previous = event.keyCode;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					</script>
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					</body>
 | 
				
			||||||
 | 
					</html>
 | 
				
			||||||
		Reference in New Issue
	
	Block a user