| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- package hid
- import (
- "testing"
- "github.com/sstallion/go-hid"
- )
- func TestReadTimesOutWithoutData(t *testing.T) {
- // We can't directly inject an fd into the go-hid Device,
- // so we skip this test without a real HID device.
- t.Skip("requires real HID device")
- }
- // The signature is an exact pair, and the two halves are load-bearing in both
- // directions: a firmware that puts Raw HID on a neighbouring page is a board this
- // tool cannot address, and taking it anyway would mean writing lighting commands
- // to a collection that does not answer them. A board that does so has to show up
- // in the passed-over listing instead, which is what tells a user why.
- func TestRawHIDIsAnExactPair(t *testing.T) {
- tests := []struct {
- name string
- usagePage uint16
- usage uint16
- want bool
- }{
- {name: "the QMK Raw HID signature", usagePage: 0xff60, usage: 0x61, want: true},
- {name: "the Impact 80's own vendor interface", usagePage: 0xff80, usage: 0x61, want: false},
- {name: "another usage on the same page", usagePage: 0xff60, usage: 0x62, want: false},
- {name: "the keyboard collection of a keyboard", usagePage: 0x0001, usage: 0x06, want: false},
- {name: "the page with no usage", usagePage: 0xff60, usage: 0x00, want: false},
- }
- for _, tt := range tests {
- t.Run(tt.name, func(t *testing.T) {
- info := &hid.DeviceInfo{UsagePage: tt.usagePage, Usage: tt.usage}
- if got := isRawHID(info); got != tt.want {
- t.Errorf("isRawHID(%04X/%02X) = %t, want %t", tt.usagePage, tt.usage, got, tt.want)
- }
- })
- }
- }
|