Python Forum
[PyGame] pygame-manu : using controller buttons to move around menu
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] pygame-manu : using controller buttons to move around menu
#3
Forget about the menu and focus on getting events from the controller. Can you do that? Can you see controller button presses?
import pygame


def pgprint(text):
    text = f"{text}::{pygame.joystick.get_count()}"
    surface = font.render(text, True, "black")
    x = (700 - surface.get_width()) // 2
    y = (100 - surface.get_height()) // 2
    screen.fill("white")
    screen.blit(surface, (x, y))
    pygame.display.update()


pygame.init()
screen = pygame.display.set_mode((700, 100))
font = pygame.font.Font(None, 16)

running = True
while running:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        pgprint(str(event))

pygame.quit()
Reply


Messages In This Thread
RE: pygame-manu : using controller buttons to move around menu - by deanhystad - Mar-12-2023, 01:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [PyGame] my pygame car wont move Erio85 1 1,048 Apr-24-2023, 04:52 PM
Last Post: Erio85
  How to make an image move in relation to another in PYGAME CompleteNewb 1 2,280 Nov-10-2021, 03:38 PM
Last Post: metulburr
  Getting a ship to move in pygame djwilson0495 2 3,547 Dec-09-2020, 11:03 AM
Last Post: djwilson0495
  Pygame - Images As Buttons vman44 3 12,813 Mar-20-2020, 08:13 PM
Last Post: vman44
  [PyGame] Problems w/ controller Zman350x 5 4,582 Oct-29-2019, 10:31 PM
Last Post: Zman350x
  [pygame] Equiping inventory slots with invisible buttons SheeppOSU 6 4,660 Apr-26-2019, 08:45 PM
Last Post: SheeppOSU
  Problems with loading buttons (pygame) SheeppOSU 2 3,051 Apr-12-2019, 08:04 PM
Last Post: SheeppOSU
  Buttons in PyGame mzmingle 4 12,952 Oct-09-2018, 05:19 PM
Last Post: Mekire
  Menus, buttons and other widgets for Pygame Olleus 4 11,411 Apr-17-2017, 11:08 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020