File tree 1 file changed +6
-8
lines changed 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 33
33
raise ImportError ('{0} is not supported in CircuitPython 2.x or lower' .format (__name__ ))
34
34
35
35
# pylint: disable=wrong-import-position
36
+ import struct
36
37
import time
37
38
import usb_hid
38
39
@@ -53,10 +54,7 @@ def __init__(self):
53
54
raise IOError ("Could not find an HID Consumer device." )
54
55
55
56
# Reuse this bytearray to send consumer reports.
56
- self .report = bytearray (2 )
57
-
58
- # View bytes as a single 16-bit number.
59
- self .usage_id = memoryview (self .report )[0 :2 ]
57
+ self ._report = bytearray (2 )
60
58
61
59
# Do a no-op to test if HID device is ready.
62
60
# If not, wait a bit and try once more.
@@ -82,7 +80,7 @@ def send(self, consumer_code):
82
80
# Advance to next track (song).
83
81
consumer_control.send(ConsumerControlCode.SCAN_NEXT_TRACK)
84
82
"""
85
- self .usage_id [ 0 ] = consumer_code
86
- self .hid_consumer .send_report (self .report )
87
- self .usage_id [ 0 ] = 0x0
88
- self .hid_consumer .send_report (self .report )
83
+ struct . pack_into ( "<H" , self ._report , 0 , consumer_code )
84
+ self .hid_consumer .send_report (self ._report )
85
+ self ._report [ 0 ] = self . _report [ 1 ] = 0x0
86
+ self .hid_consumer .send_report (self ._report )
You can’t perform that action at this time.
0 commit comments