本文整理汇总了Python中pygame.JOYBUTTONUP属性的典型用法代码示例。如果您正苦于以下问题:Python pygame.JOYBUTTONUP属性的具体用法?Python pygame.JOYBUTTONUP怎么用?Python pygame.JOYBUTTONUP使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pygame
的用法示例。
在下文中一共展示了pygame.JOYBUTTONUP属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_button
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import JOYBUTTONUP [as 别名]
def check_button(self, pg_event):
try:
button = self.event_map[pg_event.button]
if pg_event.type == pg.JOYBUTTONDOWN:
self.press(button)
elif pg_event.type == pg.JOYBUTTONUP:
self.release(button)
except (KeyError, AttributeError):
pass
示例2: getInputs
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import JOYBUTTONUP [as 别名]
def getInputs(self,_event,_push = True, _outputOnRelease = True):
if _event.type not in [pygame.JOYAXISMOTION, pygame.JOYBUTTONDOWN, pygame.JOYBUTTONUP]:
return None
k = None
output = True
if _event.type == pygame.JOYAXISMOTION:
#getJoystickInput will get a pad and an axis, and return the value of that stick
#by checking it along with the other axis of that joystick, if there is one.
k = self.key_bindings.getJoystickInput(_event.joy,_event.axis,_event.value)
if k and k in self.keys_held: k = None
if k and k not in self.keys_held:
self.keys_held.append(k)
if k and _push:
self.keys_to_pass.append(k)
if k == 0:
output = output and _outputOnRelease
a, b = self.key_bindings.axis_bindings.get(_event.axis)
if a in self.keys_held: self.keys_held.remove(a)
if b in self.keys_held: self.keys_held.remove(b)
if _push:
self.keys_to_release.extend([a,b])
elif _event.type == pygame.JOYBUTTONDOWN:
#getButtonInput is much more simple. It gets the key that button is mapped to
k = self.key_bindings.getButtonInput(_event.joy,_event.button)
elif _event.type == pygame.JOYBUTTONUP:
output = output and _outputOnRelease
k = self.key_bindings.getButtonInput(_event.joy,_event.button)
if k:
if _event.type == pygame.JOYBUTTONDOWN:
if k not in self.keys_held: self.keys_held.append(k)
if _push: self.keys_to_pass.append(k)
elif _event.type == pygame.JOYBUTTONUP:
if k in self.keys_held: self.keys_held.remove(k)
if _push: self.keys_to_release.append(k)
if output: return k
return None
示例3: shutdownScreen
# 需要导入模块: import pygame [as 别名]
# 或者: from pygame import JOYBUTTONUP [as 别名]
def shutdownScreen():
if PI:
device.clear();
device.show();
drawImage('/home/pi/shutdown.bmp')
show_message(device,"Press Select to shutdown!",fill="white", font=proportional(CP437_FONT), scroll_delay=0.01)
else:
drawImage('shutdown.bmp')
while True:
pygame.event.pump()
for event in pygame.event.get(): # User did something
# print("event detected {}".format(event))
# Possible joystick actions: JOYAXISMOTION JOYBALLMOTION JOYBUTTONDOWN JOYBUTTONUP JOYHATMOTION
if event.type == pygame.JOYBUTTONDOWN or event.type == KEYDOWN:
if event.type == pygame.JOYBUTTONDOWN:
myevent = event.button
else:
if event.key in mykeys:
myevent = mykeys[event.key]
else:
myevent = -1
# print("Joystick button pressed: {}".format(event.button))
if (myevent!=JKEY_SEL):
# print("exiting clock")
clearScreen()
updateScreen()
return
else:
if not PI:
terminate()
else:
clearScreen()
updateScreen()
show_message(device,"Shutdown...",fill="white", font=proportional(CP437_FONT), scroll_delay=0.01)
subprocess.Popen(['shutdown','-h','now'])
#call("sudo nohup shutdown -h now", shell=True)
terminate()
if event.type == pygame.QUIT: # get all the QUIT events
terminate() # terminate if any QUIT events are present
updateScreen()
time.sleep(.2)