title: How do i capture the HID input using Python and Linux?
body: <p>I have IPD Ultima joystick connected to my Linux box. When i do following:</p>
  
  <p>$ modprobe uinput
  $ lsmod | grep uinput</p>
  
  <pre><code>uinput                 17246  0 
  </code></pre>
  
  <p>$ lsusb - ok</p>
  
  <pre><code>Bus 002 Device 002: ID 0461:4d65 Primax Electronics, Ltd
  </code></pre>
  
  <p>$ xinput list - nothing at all</p>
  
  <pre><code>⎡ Virtual core pointer                      id=2    [master pointer  (3)]
  ⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
  ⎜   ↳ SynPS/2 Synaptics TouchPad                id=12   [slave  pointer  (2)]
  ⎜   ↳ USB Optical Mouse                         id=14   [slave  pointer  (2)]
  ⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
      ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
      ↳ Video Bus                                 id=6    [slave  keyboard (3)]
      ↳ Power Button                              id=7    [slave  keyboard (3)]
      ↳ Sleep Button                              id=8    [slave  keyboard (3)]
      ↳ AT Translated Set 2 keyboard              id=11   [slave  keyboard (3)]
      ↳ Dell WMI hotkeys                          id=13   [slave  keyboard (3)]
  </code></pre>
  
  <p>$ dmesg - ok</p>
  
  <pre><code>H PRODUCTS CH Products IPD Ultima] on usb-0000:00:1d.1-1/input0
  [42731.000208] usb 3-1: USB disconnect, device number 2
  [42737.291095] usb 3-1: new low-speed USB device number 3 using uhci_hcd
  [42737.457157] usb 3-1: New USB device found, idVendor=068e, idProduct=0060
  [42737.457167] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
  [42737.457175] usb 3-1: Product: CH Products IPD Ultima
  [42737.457182] usb 3-1: Manufacturer: CH PRODUCTS
  [42737.489359] input: CH PRODUCTS CH Products IPD Ultima as /devices/pci0000:00/0000:00:1d.1/usb3/3-1/3-1:1.0/input/input13
  [42737.489867] generic-usb 0003:068E:0060.0005: input,hidraw0: USB HID v1.00 Joystick [CH PRODUCTS CH Products IPD Ultima] on usb-0000:00:1d.1-1/input0
  </code></pre>
  
  <p>$ python it: - not ok</p>
  
  <pre><code>sf1 = open("test.usbdump").read() # read the earlier usb dump from hiddevice
  kb = open("/dev/usb/hiddev0")
  while 1:
    print (kb.read(len(sf1)) == sf1)
  </code></pre>
  
  <p>$ pgame it: - not ok</p>
  
  <pre><code>#/usr/bin/env python
  #
  # yum list installed pygame*
  #Loaded plugins: auto-update-debuginfo, langpacks, presto, refresh-packagekit
  #Installed Packages
  #pygame.i686                               1.9.1-6.fc15                          @updates
  #pygame-devel.i686                         1.9.1-6.fc15                          @updates
  
  import os, pygame
  from pygame.locals import *
  def main():
    pygame.init()
    pygame.joystick.init()
    pygame.display.set_mode((468, 60))
    pygame.display.set_caption('HID Python')
    pygame.mouse.set_visible(0)
  
    while 1:
      for event in pygame.event.get():
        print event.type
        if event.type == QUIT:
          return
        elif event.type == KEYDOWN and event.key == K_ESCAPE:
          return
        elif event.type == MOUSEBUTTONDOWN:
          print '\/'
        elif event.type is MOUSEBUTTONUP:
          print '/\'
        elif event.type is JOYAXISMOTION:
          print '()'
        elif event.type is JOYBALLMOTION:
          print '()()'
        elif event.type is JOYHATMOTION:
          print '&lt;&gt;'
        elif event.type is JOYBUTTONUP:
          print '//\\'
        elif event.type is JOYBUTTONDOWN:
          print '\\//'
  
  if __name__ == '__main__': 
    main()
  </code></pre>
  
  <p>No luck. Any help idea why i can not get anything ?</p>
  
  <p><strong>Follow up:</strong></p>
  
  <pre><code># cat /dev/input/js0 
  =c��=c��=c��=c��=c��=c��=c��=c��=c�=c�� =c��
  =c��
       =c��=c��=c��
  &amp;n��n�Vp�&amp;q�r��r�Nt��t�&gt;u��u��v�w�~w��z���{��|�}�n}��}�~�N~��~��~�.������������������������&gt;�����拋6�����V�����������6�����&amp;��������v��昋�v��
  </code></pre>