Beispiel #1
0
def getNumButtons():
    return Joystick.get_button_count(joystick)
Beispiel #2
0
foundController = False

print "looking for controller, press A to chose the controller"
while not foundController:
    for i in range(0, 5):
        Joystick.update()
        if Joystick.is_connected(i):
            Joystick.update()
            if Joystick.is_button_pressed(i, A):
                foundController = True
                joystick = i

print "found controller ", i

print "buttons: ", Joystick.get_button_count(i)


# used inside the class, not necessary to call from outside this class, use the other calls
def getAxis(joyStickNumber, axis):
    size = maxValue - minValue
    return ((applyDeadZone(Joystick.get_axis_position(joyStickNumber, axis)) /
             (100.0 - deadZone)) * size) - minValue


def getPrimaryX():
    return getAxis(joystick, Joystick.X)


def getPrimaryY():
    return -getAxis(joystick, Joystick.Y)
Beispiel #3
0
 def getNumButtons(self):
     return Joystick.get_button_count(self.joystick)
Beispiel #4
0
def getNumButtons():
    return Joystick.get_button_count(joystick)
Beispiel #5
0
foundController = False

print "looking for controller, press A to chose the controller"
while not foundController:
    for i in range(0,5):
        Joystick.update()
        if Joystick.is_connected(i):
            Joystick.update()
            if Joystick.is_button_pressed(i, A):
                foundController = True
                joystick = i

print "found controller ", i

print "buttons: ", Joystick.get_button_count(i)

# used inside the class, not necessary to call from outside this class, use the other calls
def getAxis(joyStickNumber, axis):
    size = maxValue - minValue
    return ((applyDeadZone(Joystick.get_axis_position(joyStickNumber, axis))/(100.0-deadZone)) * size) - minValue

def getPrimaryX():
    return getAxis(joystick, Joystick.X)

def getPrimaryY():
    return -getAxis(joystick, Joystick.Y)

def getSecondaryX():
    return getAxis(joystick, Joystick.U)
Beispiel #6
0
writeonscreen = "Found controller " + str(i)
background.fill((250, 250, 250))
font = pygame.font.Font(None, 50)
text = font.render(writeonscreen, 1, (10, 10, 10))
textpos = text.get_rect()
textpos.centerx = background.get_rect().centerx
textpos.centery = background.get_rect().centery

background.blit(text, textpos)

screen.blit(background, (0, 0))

pygame.display.flip()

writeonscreen = "Buttons: " + str(Joystick.get_button_count(i))
font = pygame.font.Font(None, 50)
text = font.render(writeonscreen, 1, (10, 10, 10))
textpos = text.get_rect()
textpos.centerx = background.get_rect().centerx
textpos.centery = background.get_rect().centery + 50

background.blit(text, textpos)

screen.blit(background, (0, 0))

pygame.display.flip()

time.sleep(2)

# used inside the class, not necessary to call from outside this class, use the other calls