Skip to main content

Map gamepad axes and buttons

Project description

Gamepad Mapping

import pygame
from gamepad_mapper import load_or_map, read_gamepad

pygame.init()
pygame.joystick.init()
assert pygame.joystick.get_count() > 0, "No game controller found."

joystick = pygame.joystick.Joystick(0)
joystick.init()
mapping = load_or_map(joystick, ["Roll", "Pitch", "Throttle", "Yaw"], ["arm"], force=True, name="example")
axes, buttons = read_gamepad(joystick, mapping)
print(axes)
print(buttons)

Output

{'Roll': 0.796051025390625, 'Pitch': 0.62353515625, 'Throttle': -0.17645263671875, 'Yaw': -0.741180419921875}
{'arm': 1}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gamepad_mapper-0.0.5.tar.gz (3.0 kB view details)

Uploaded Source

File details

Details for the file gamepad_mapper-0.0.5.tar.gz.

File metadata

  • Download URL: gamepad_mapper-0.0.5.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for gamepad_mapper-0.0.5.tar.gz
Algorithm Hash digest
SHA256 31dfe23636ef1d46bdc36e2139c422ca9d7ddb44f458b6e5b5235de103da21a7
MD5 edd71832651627028477b237b49345fd
BLAKE2b-256 edcb41cf660f4280064156dd8df1921154a471d12408e56cf89151ffa1fff06f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page