MCPcopy Create free account
hub / github.com/kiibohd/controller / codes

Method codes

Output/TestOut/host.py:179–213  ·  view source on GitHub ↗

Return a list of usb codes in the USB packet

( self )

Source from the content-addressed store, hash-verified

177 self.keys = usb_keys.keys # List of bytes
178
179 def codes( self ):
180 '''
181 Return a list of usb codes in the USB packet
182 '''
183 # keys array format
184 # Bits 0 - 3 unused
185 # Bits 4 - 164 (bytes 0 - 20) Keyboard Codes
186 # Bits 165 - 175 unused
187 # Bits 176 - 221 (bytes 22 - 27) Keypad Codes
188 # Bits 222 - 223 unused
189 keys = []
190
191 # Calculate modifiers
192 for bit in range( 0, 8 ):
193 if self.modifiers & (1<<bit):
194 keys.append( 0xE0 + bit )
195
196 # 6 keys for boot mode
197 if self.protocol == 0:
198 for index in range( 0, 6 ):
199 if self.keys[ index ] != 0x00:
200 keys.append( self.keys[ index ] )
201 # NKRO key extraction
202 elif self.protocol == 1:
203 # See output_com.c Output_usbCodeSend_capability for details on start/pos
204 start = 0
205 for byte in self.keys:
206 for pos, bit in zip( range( start, start + 8 ), range( 0, 8 ) ):
207 # Check if bit is set
208 if byte & (1<<bit):
209 if pos <= 221:
210 keys.append( pos )
211 start += 8
212
213 return keys
214
215 def __repr__( self ):
216 ''&#x27;

Callers 1

usb_keyboardMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected