Advertisement
Guest User

Untitled

a guest
Apr 19th, 2025
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. let device = null;
  2.  
  3. // Connect to the ASUS keyboard HID device
  4. async function connectDevice() {
  5. const [d] = await navigator.hid.requestDevice({
  6. filters: [{ vendorId: 0x0b05, productId: 0x4543 }],
  7. });
  8. if (!d) throw new Error("❌ No device selected");
  9. await d.open();
  10. device = d;
  11. console.log("✅ Connected to:", d.productName);
  12. }
  13.  
  14. // Send a 4-byte command wrapped in 64-byte HID report
  15. async function sendCommand(b0, b1, b2, b3) {
  16. if (!device || !device.opened) throw new Error("❌ Device not connected");
  17. const report = new Uint8Array(64);
  18. report[0] = b0;
  19. report[1] = b1;
  20. report[2] = b2;
  21. report[3] = b3;
  22.  
  23. const hex = [b0, b1, b2, b3].map(b => b.toString(16).padStart(2, '0')).join(' ');
  24. console.log(`➡️ Sending: ${hex}`);
  25. await device.sendFeatureReport(0x5a, report);
  26. }
  27.  
  28. // Disable touchpad
  29. async function disableTouchpad() {
  30. await sendCommand(0xf4, 0x00, 0x00, 0x00);
  31. }
  32.  
  33. // Enable touchpad
  34. async function enableTouchpad() {
  35. await sendCommand(0xf4, 0x00, 0x00, 0x01);
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement