parameters: (remote, xbmc)
return_statement: return done
docstring: Return codes:
      0 - key was processed normally
      2 - socket read timeout
      3 - PS and then Skip Plus was pressed (sequentially)
      4 - PS and then Skip Minus was pressed (sequentially)
  
      FIXME: move to enums
docstring_summary: Return codes:
      0 - key was processed normally
      2 - socket read timeout
      3 - PS and then Skip Plus was pressed (sequentially)
      4 - PS and then Skip Minus was pressed (sequentially)
docstring_tokens: Return codes : 0 - key was processed normally 2 - socket read timeout 3 - PS and then Skip Plus was pressed ( sequentially ) 4 - PS and then Skip Minus was pressed ( sequentially )
function: def process_keys(remote, xbmc):
      """
      Return codes:
      0 - key was processed normally
      2 - socket read timeout
      3 - PS and then Skip Plus was pressed (sequentially)
      4 - PS and then Skip Minus was pressed (sequentially)
  
      FIXME: move to enums
      """
      done = 0
  
      try:
          xbmc.previous_key
      except:
          xbmc.previous_key = ""
  
      xbmc.connect()
      datalen = 0
      try:
          data = remote.recv(1024)
          datalen = len(data)
      except Exception as e:
          if str(e)=="timed out":
              return 2
          time.sleep(2)
  
          # some other read exception occurred, so raise it
          raise e
  
      if datalen == 13:
          keycode = data.hex()[10:12]
          if keycode == "ff":
              xbmc.release_button()
              return done
          try:
              # if the user presses the PS button followed by skip + or skip -
              # return different codes.
              if xbmc.previous_key == "43":
                  xbmc.previous_key = keycode
                  if keycode == "31":    # skip +
                      return 3
                  elif keycode == "30":  # skip -
                      return 4
  
              # save previous key press
              xbmc.previous_key = keycode
  
              if g_keymap[keycode]:
                  xbmc.send_remote_button(g_keymap[keycode])
          except Exception as e:
              print("Unknown data: %s" % str(e))
      return done
function_tokens: def process_keys ( remote , xbmc ) : done = 0 try : xbmc . previous_key except : xbmc . previous_key = "" xbmc . connect ( ) datalen = 0 try : data = remote . recv ( 1024 ) datalen = len ( data ) except Exception as e : if str ( e ) == "timed out" : return 2 time . sleep ( 2 ) # some other read exception occurred, so raise it raise e if datalen == 13 : keycode = data . hex ( ) [ 10 : 12 ] if keycode == "ff" : xbmc . release_button ( ) return done try : # if the user presses the PS button followed by skip + or skip - # return different codes. if xbmc . previous_key == "43" : xbmc . previous_key = keycode if keycode == "31" : # skip + return 3 elif keycode == "30" : # skip - return 4 # save previous key press xbmc . previous_key = keycode if g_keymap [ keycode ] : xbmc . send_remote_button ( g_keymap [ keycode ] ) except Exception as e : print ( "Unknown data: %s" % str ( e ) ) return done