當前位置: 首頁>>代碼示例>>Python>>正文


Python pygame.JOYBUTTONUP屬性代碼示例

本文整理匯總了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 
開發者ID:pygame,項目名稱:stuntcat,代碼行數:11,代碼來源:event_handling.py

示例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 
開發者ID:digiholic,項目名稱:universalSmashSystem,代碼行數:41,代碼來源:controller.py

示例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) 
開發者ID:makeTVee,項目名稱:ledmatrix,代碼行數:47,代碼來源:games_pi_only.py


注:本文中的pygame.JOYBUTTONUP屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。