Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions AnalogSense.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class AsProvider
const active_keys = [];
for (const [scancode, value] of Object.entries(this.buffer))
{
active_keys.push({ scancode, value });
active_keys.push({ scancode, value, actuated: null });
}
return active_keys;
}
Expand All @@ -361,7 +361,7 @@ class AsProviderWootingV1 extends AsProvider
const scancode = (event.data.getUint8(i++) << 8) | event.data.getUint8(i++);
if (scancode == 0) break;
const value = event.data.getUint8(i++);
active_keys.push({ scancode, value: value / 255 });
active_keys.push({ scancode, value: value / 255, actuated: null });
}
handler(active_keys);
};
Expand Down Expand Up @@ -396,6 +396,7 @@ class AsProviderWootingV2 extends AsProvider
const packed = data.getUint8(i + 2);
const value_hi = data.getUint8(i + 3);

const actuated = packed & 0x1;
const keyNamespace = (packed >> 2) & 0xf;
const value_lo = (packed >> 6) & 0x3;

Expand All @@ -405,7 +406,7 @@ class AsProviderWootingV2 extends AsProvider
if (scancode === 0) break;
if (value === 0) continue;

active_keys.push({ scancode, value: value / 1023 });
active_keys.push({ scancode, value: value / 1023, actuated });
}
handler(active_keys);
};
Expand Down Expand Up @@ -442,7 +443,8 @@ class AsProviderRazerHuntsman extends AsProvider
const value = event.data.getUint8(i++);
active_keys.push({
scancode: analogsense.razerScancodeToHidScancode(scancode),
value: value / 255
value: value / 255,
actuated: null
});
}
handler(active_keys);
Expand Down Expand Up @@ -483,7 +485,8 @@ class AsProviderRazerHuntsmanV3 extends AsProvider
i++; // unclear, might be something like "priority."
active_keys.push({
scancode: analogsense.razerScancodeToHidScancode(scancode),
value: value / 255
value: value / 255,
actuated: null
});
}
handler(active_keys);
Expand Down Expand Up @@ -575,7 +578,8 @@ class AsProviderDrunkdeer extends AsProvider
{
this.active_keys.push({
scancode: analogsense.drunkdeerIndexToHidScancode((n * (64 - 5)) + (i - 4)),
value: value / 40
value: value / 40,
actuated: null
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Once loaded, the following global functions become available:
- `analogsense.scancodeToString(scancode: number): string`

A device instance has the following members:
- `startListening(handler: function<void({scancode: int, value: float}[])>)`
- `startListening(handler: function<void({scancode: int, value: float, actuated: 0 | 1 | null}[])>)`
- `stopListening()`
- `getProductName(): string`
- `forget()`
Expand Down
1 change: 1 addition & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ <h2 id="devname"></h2>
const bar = document.createElement("div");
bar.className = "progress-bar";
bar.style.width = (key.value * 100) + "%";
bar.style.backgroundColor = key.actuated ? "#7e28bf" : "";
bar.textContent = analogsense.scancodeToString(key.scancode);
div.appendChild(bar);
}
Expand Down