SHARE
TWEET

QWOP keys in Linux

a guest Aug 7th, 2012 2,021 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #QWOP you!!
  2. #needs https://launchpad.net/python-uinput/
  3.  
  4. import uinput
  5. import time
  6.  
  7. def sequence(device,t1,t2, t3, t4):
  8.     device.emit(uinput.KEY_W, 1) # Press.
  9.     time.sleep(t1)
  10.     device.emit(uinput.KEY_O, 1) # Press.
  11.     time.sleep(t1)
  12.     device.emit(uinput.KEY_O, 0) # Release.
  13.     device.emit(uinput.KEY_W, 0) # Release.
  14.     time.sleep(t2)
  15.     device.emit(uinput.KEY_Q, 1) # Press.
  16.     device.emit(uinput.KEY_P, 1) # Release.
  17.     time.sleep(t3)
  18.     device.emit(uinput.KEY_P, 0) # Press.
  19.     device.emit(uinput.KEY_Q, 0) # Release.
  20.     time.sleep(t4)
  21.     device.emit(uinput.KEY_P, 1) # Release.
  22.     device.emit(uinput.KEY_P, 0) # Press.
  23.     time.sleep(t4)
  24.    
  25. if __name__ == '__main__':
  26.     events = (uinput.KEY_Q, uinput.KEY_W, uinput.KEY_O, uinput.KEY_P)
  27.     device = uinput.Device(events)
  28.  
  29.     while 1:
  30.         sequence(device,0.1,0.1,0.2,0.1)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top