Node.js driver for Sony Buzz! wireless controllers (PS2/PS3 quiz buzzers) using HID/USB
npm install @thalaguer/buzzernode-hid which requires native compilation.
bash
npm install @thalaguer/buzzer
`
Usage
`javascript
import Buzzer from '@thalaguer/buzzer';
const buzzers = Buzzer();
// Called when the system is fully initialized
buzzers.onReady(() => {
console.log("Buzzers are ready & functional.");
// Turn on player 1's LED
buzzers.setLeds(true, false, false, false);
// Or using array syntax
buzzers.setLedsarray([true, false, true, false]); // Players 1 & 3 on
});
// Button press events
buzzers.onPress((data) => {
console.log(Buzzer #${data.controller} pressed the ${data.color} button(${data.button}).);
console.log(Full event: ${JSON.stringify(data)});
});
// Button release events
buzzers.onRelease((data) => {
console.log(Buzzer #${data.controller} released the ${data.color} button.);
});
// Any state change (press or release)
buzzers.onChange((data) => {
console.log(Buzzer #${data.controller} ${data.state} the ${data.color} button.);
});
buzzers.onError((data) => {
console.log(An error occurred : ${data.message});
})
// Clean up when done (optional)
// await buzzers.close();
`
API Reference
$3
Creates a new buzzer manager instance.
$3
Registers a callback when the system is fully initialized. The startup LED animation will play when ready.
$3
Registers a callback for button press events. The callback receives an event object with:
- controller: Player number (1-4)
- color: Button color ('RED', 'BLUE', 'ORANGE', 'GREEN', 'YELLOW')
- button: Button identifier ( 0=> red, 1=> blue, 2=> orange, 3=> green, 4=> yellow)
- state: Event state ('press', 'released') - mostly useful for onChange(callback).
$3
Registers a callback for button release events (same event object structure as onPress).
$3
Registers a callback for any button state change (both press and release).
$3
Registers a callback for any error happening.
$3
Controls the red LEDs for each player:
- player1 - Player 1 LED (boolean)
- player2 - Player 2 LED (boolean)
- player3 - Player 3 LED (boolean)
- player4 - Player 4 LED (boolean)
$3
Convenience method that accepts an array of boolean values.
$3
Closes connections and releases resources. Returns a Promise.
Windows Driver Setup (ZADIG)
On Windows, the Buzz! dongle might not work with the default driver. You need to install the WinUSB driver using ZADIG:
1. Download ZADIG from https://zadig.akeo.ie/
2. Run ZADIG as Administrator
3. Configure ZADIG:
- Go to Options → List All Devices
- Check both Ignore Hubs or Composite Parents and Show only current configuration
4. Select the Buzz! Dongle:
- From the dropdown, select the Buzz! device (should appear as "Buzz!" or with VID 054C and PID 1000)
- If you don't see it, try:
- Unplugging and replugging the dongle
- Checking if it appears under a different name
- Trying with and without controllers connected
5. Install/Replace Driver:
- Ensure the driver selected is WinUSB (not libusb)
- Click Replace Driver or Install Driver
- Wait for the installation to complete
6. Test:
- Unplug and replug the dongle
- Run your application again
Note: If you have multiple Buzz! dongles, repeat these steps for each one.
Linux Permissions
On Linux, you may need to add a udev rule or run with sudo:
`bash
Temporary solution (run with sudo)
sudo node your-app.js
Permanent solution (create udev rule):
sudo nano /etc/udev/rules.d/99-buzz.rules
`
Add this line:
`
SUBSYSTEM=="usb", ATTR{idVendor}=="054c", ATTR{idProduct}=="1000", MODE="0666"
`
Then reload udev rules:
`bash
sudo udevadm control --reload-rules
sudo udevadm trigger
`
Troubleshooting
$3
1. Check the USB connection
2. Verify the driver is installed (Windows: ZADIG)
3. Check if another application is using the device
4. Try a different USB port
$3
Most Buzz! dongles use VID: 0x054c and PID: 0x1000. If yours is different:
`javascript
// In your node_modules/@thalaguer/buzzer/src/config.js
export const VID = 0x054c; // ← change to your VID
export const PID = 0x1000; // ← change to your PID
`
To find your dongle's VID/PID:
- Windows: Device Manager → Properties → Details → Hardware IDs
- Linux: lsusb` command