fix endianness in device descriptor
[goodfet] / client / USBKeyboard.py
index 64f6ec0..2d5f99e 100644 (file)
@@ -45,14 +45,17 @@ class USBKeyboardInterface(USBInterface):
                 descriptors
         )
 
-        # "ls<ENTER><KEY UP>"
-        self.text = [ chr(x) for x in [ 0x0f, 0x16, 0x28, 0x00 ] ]
+        # "l<KEY UP>s<KEY UP><ENTER><KEY UP>"
+        empty_preamble = [ 0x00 ] * 10
+        text = [ 0x0f, 0x00, 0x16, 0x00, 0x28, 0x00 ]
+
+        self.keys = [ chr(x) for x in empty_preamble + text ]
 
     def handle_buffer_available(self):
-        if not self.text:
+        if not self.keys:
             return
 
-        letter = self.text.pop(0)
+        letter = self.keys.pop(0)
         self.type_letter(letter)
 
     def type_letter(self, letter, modifiers=0):
@@ -61,7 +64,7 @@ class USBKeyboardInterface(USBInterface):
         if self.verbose > 2:
             print(self.name, "sending keypress 0x%02x" % ord(letter))
 
-        self.device.maxusb_app.send_on_endpoint(3, data)
+        self.configuration.device.maxusb_app.send_on_endpoint(3, data)
 
 
 class USBKeyboardDevice(USBDevice):
@@ -70,7 +73,7 @@ class USBKeyboardDevice(USBDevice):
     def __init__(self, maxusb_app, verbose=0):
         config = USBConfiguration(
                 1,                                          # index
-                "Maxim Emulated Keyboard Configuration",    # string desc
+                "Emulated Keyboard",    # string desc
                 [ USBKeyboardInterface() ]                  # interfaces
         )