コード例 #1
0
ファイル: TestEvents.py プロジェクト: Arexxk/pi3d
    pass

  def key_handler_func(sourceType, sourceIndex, key, value):
    #print(nameOf[key],"[",sourceIndex,"] =",value)
    print("key="+str(key),code_to_key(key),"[",sourceIndex,"] =",value)
    pass

  def syn_handler_func(sourceType, sourceIndex, code, value):
    #print("SYN",code,value)
    pass

  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
コード例 #2
0
        #print(nameOf[key],"[",sourceIndex,"] =",value)
        print("key=" + str(key), code_to_key(key), "[", sourceIndex, "] =",
              value)
        pass

    def syn_handler_func(sourceType, sourceIndex, code, value):
        #print("SYN",code,value)
        pass

    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
コード例 #3
0
CAMERA = Camera.instance()
while DISPLAY.loop_running() and not inputs.key_state("KEY_ESC"):
  CAMERA.reset()
  CAMERA.rotate(tilt, rot, 0)
  CAMERA.position((man.x(), man.y(), man.z() - aveyeleveladjust))

  myecube.position(man.x(), man.y(), man.z() - aveyeleveladjust)

  SolidObject.drawall()

  building.drawAll()

  mymap.draw()
  myecube.draw()

  inputs.do_input_events()
  """On some combined keyboard/mouse arrangements you might need to change
  this to inputs.get_mouse_movement(1) in order to get the correct input
  """
  mx, my, mv, mh, md = inputs.get_mouse_movement()

  rot -= (mx)*0.2
  tilt -= (my)*0.2

  #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