Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let device = null;
- // Connect to the ASUS keyboard HID device
- async function connectDevice() {
- const [d] = await navigator.hid.requestDevice({
- filters: [{ vendorId: 0x0b05, productId: 0x4543 }],
- });
- if (!d) throw new Error("❌ No device selected");
- await d.open();
- device = d;
- console.log("✅ Connected to:", d.productName);
- }
- // Send a 4-byte command wrapped in 64-byte HID report
- async function sendCommand(b0, b1, b2, b3) {
- if (!device || !device.opened) throw new Error("❌ Device not connected");
- const report = new Uint8Array(64);
- report[0] = b0;
- report[1] = b1;
- report[2] = b2;
- report[3] = b3;
- const hex = [b0, b1, b2, b3].map(b => b.toString(16).padStart(2, '0')).join(' ');
- console.log(`➡️ Sending: ${hex}`);
- await device.sendFeatureReport(0x5a, report);
- }
- // Disable touchpad
- async function disableTouchpad() {
- await sendCommand(0xf4, 0x00, 0x00, 0x00);
- }
- // Enable touchpad
- async function enableTouchpad() {
- await sendCommand(0xf4, 0x00, 0x00, 0x01);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement