|
@@ -77,16 +77,16 @@ func (d * Device) Id() (linux.INPUT_id, error) {
|
|
const SIZEOF_LONG = uint(unsafe.Sizeof(*((*linux.UnsignedLong)(nil))))
|
|
const SIZEOF_LONG = uint(unsafe.Sizeof(*((*linux.UnsignedLong)(nil))))
|
|
const BITS_PER_LONG = SIZEOF_LONG * 8
|
|
const BITS_PER_LONG = SIZEOF_LONG * 8
|
|
|
|
|
|
-func BitsToLong(ebits linux.EventType) uint {
|
|
|
|
|
|
+func BitsToLong(ebits uint) uint {
|
|
bits := uint(ebits)
|
|
bits := uint(ebits)
|
|
return ((bits) + 8 * SIZEOF_LONG - 1) / (8 * SIZEOF_LONG)
|
|
return ((bits) + 8 * SIZEOF_LONG - 1) / (8 * SIZEOF_LONG)
|
|
}
|
|
}
|
|
|
|
|
|
func TestBit(bit uint, array []linux.UnsignedLong) bool {
|
|
func TestBit(bit uint, array []linux.UnsignedLong) bool {
|
|
- return ((array[ bit / BITS_PER_LONG ]) & (1 << (bit%BITS_PER_LONG))) != 0
|
|
|
|
|
|
+ return ((array[ bit / BITS_PER_LONG ]) >> (bit%BITS_PER_LONG)) & 1 != 0
|
|
}
|
|
}
|
|
|
|
|
|
-func (d * Device) SupportedEvents() ([]linux.EventType, error) {
|
|
|
|
|
|
+func (d * Device) SupportedEvents() ([]uint, error) {
|
|
size := BitsToLong(linux.EV_MAX)
|
|
size := BitsToLong(linux.EV_MAX)
|
|
bits := make([]linux.UnsignedLong, size)
|
|
bits := make([]linux.UnsignedLong, size)
|
|
for i := uint(0); i < size; i ++ {
|
|
for i := uint(0); i < size; i ++ {
|
|
@@ -97,10 +97,10 @@ func (d * Device) SupportedEvents() ([]linux.EventType, error) {
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
fmt.Printf("size %d, bits: %v\n", size, bits)
|
|
fmt.Printf("size %d, bits: %v\n", size, bits)
|
|
- result := []linux.EventType{}
|
|
|
|
|
|
+ result := []uint{}
|
|
for i := uint(0); i < uint(linux.EV_MAX); i++ {
|
|
for i := uint(0); i < uint(linux.EV_MAX); i++ {
|
|
if (TestBit(i, bits)) {
|
|
if (TestBit(i, bits)) {
|
|
- result = append(result, linux.EventType(i))
|
|
|
|
|
|
+ result = append(result, uint(i))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|