Beispiel #1
0
  inputs = InputEvents( key_handler_func, mouse_handler_func, joystick_handler_func, syn_handler_func, unhandled_handler_func)
  #inputs = InputEvents(key_handler_func)

  while not inputs.key_state("KEY_ESC"):
    inputs.do_input_events()
    if inputs.key_state("KEY_LEFTCTRL"):
      inputs.grab_by_type("keyboard", grab=False)
      print("Name:",)
      s = raw_input()
      print("Hello",s)
      inputs.grab_by_type("keyboard", True)
    if inputs.key_state("BTN_LEFT"):
      v = inputs.get_mouse_movement()
      if v != (0,0,0,0,0):
          print(v)
    if inputs.key_state("BTN_RIGHT"):
      v = inputs.get_mouse_movement(1)
      if v != (0,0,0,0,0):
          print(v)
    if inputs.key_state("BTN_TOP2"):      #gamepad L1
      print(inputs.get_joystick())        #gamepad Left Analogue
    if inputs.key_state("BTN_BASE"):      #gamepad R1
      print(inputs.get_joystickR())      #gamepad Right Analogue
    if inputs.key_state("BTN_PINKIE"):      #gamepad L2
      v = inputs.get_hat()          #gamepad Direction pad
      if v != (0,0):
          print(v)
    if inputs.key_state("BTN_BASE2"):      #gamepad R2
      print(inputs.get_joystickR(1))     #gamepad Right Analogue (2nd device)

Beispiel #2
0
                         unhandled_handler_func)
    #inputs = InputEvents(key_handler_func)

    while not inputs.key_state("KEY_ESC"):
        inputs.do_input_events()
        if inputs.key_state("KEY_LEFTCTRL"):
            inputs.grab_by_type("keyboard", grab=False)
            print("Name:", )
            s = raw_input()
            print("Hello", s)
            inputs.grab_by_type("keyboard", True)
        if inputs.key_state("BTN_LEFT"):
            v = inputs.get_mouse_movement()
            if v != (0, 0, 0, 0, 0):
                print(v)
        if inputs.key_state("BTN_RIGHT"):
            v = inputs.get_mouse_movement(1)
            if v != (0, 0, 0, 0, 0):
                print(v)
        if inputs.key_state("BTN_TOP2"):  #gamepad L1
            print(inputs.get_joystick())  #gamepad Left Analogue
        if inputs.key_state("BTN_BASE"):  #gamepad R1
            print(inputs.get_joystickR())  #gamepad Right Analogue
        if inputs.key_state("BTN_PINKIE"):  #gamepad L2
            v = inputs.get_hat()  #gamepad Direction pad
            if v != (0, 0):
                print(v)
        if inputs.key_state("BTN_BASE2"):  #gamepad R2
            print(
                inputs.get_joystickR(1))  #gamepad Right Analogue (2nd device)
Beispiel #3
0
  #jrx, jry, jrz = inputs.get_joystickB3d() # xbox 360
  # sudo apt-get install xboxdrv
  # sudo xboxdrv -s -i 0
  jrx, jry = inputs.get_joystickR() # gamepad
  if abs(jrx) > 0.1:
      rot -= jrx*3

  if abs(jry) > 0.1:
      tilt -= jry*3

  xm = man.x()
  ym = man.y()
  zm = man.z()

  jx, jy = inputs.get_joystick()
  if abs(jy) > 0.2:
      xm += math.sin(math.radians(rot))*jy
      zm -= math.cos(math.radians(rot))*jy

  if abs(jx) > 0.2:
      xm -= math.sin(math.radians(rot-90))*jx
      zm += math.cos(math.radians(rot-90))*jx

  if inputs.key_state("BTN_LEFT"):
    xm -= math.sin(math.radians(rot))
    zm += math.cos(math.radians(rot))

  if inputs.key_state("KEY_W"):  #key W
    xm -= math.sin(math.radians(rot))
    zm += math.cos(math.radians(rot))