Skip to main content

pygame-input is a tool to simplify input handling with pygame

Project description

pygame-input

Code style: black

pygame-input will simplify your input handling with pygame by providing a simple way to assign callbacks to given key press or joystick events.

Look how easy it is to use:

import pygame
from pygame_input import Inputs, Button, JoyButton

inputs = Inputs()
inputs["fire"] = Button(pygame.K_SPACE, JoyButton(1))
inputs["fire"].on_press_repeated(player.fire, delay=0.1)

This will call your player.fire() function every 0.1 seconds while any button, whether it is the space bar or the button one on your joystick is pressed.

Features

  • Joystick
  • Boolean input values (ie. is key pressed ?) and scalar input values (ie. how much is the stick on the left ?)
  • Register callbacks on:
    • press,
    • release,
    • double-press
    • or all the time

What pygame-input is not (yet ?):

  • handling key modifiers
  • handling mouse input
  • recognising mouse gestures
  • doing gamepad configuration (ie. you need to know which id is the "A" button)

Though the first two will probably be implemented quite soon, depending on when I need them.

Installation

Install pygame-input by running::

pip install pygame-input

Alternativelly you can just copy pygame_input.py into your game folder as the whole code is just one file. Feel free to modify it as much as you need.

Usage

See the examples.

Contribute

  • Issue Tracker: gitlab.com/ddorn/pygame-input/issues
  • Source Code: gitlab.com/ddorn/pygame-input

Support

If you are having issues, please let me know. You can open an issue or send me a mail, my email address is on my gitlab profile.

License

The project is licensed under the MIT license.

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

pygame-input-0.1.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

pygame_input-0.1.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file pygame-input-0.1.1.tar.gz.

File metadata

  • Download URL: pygame-input-0.1.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/5.5.9-arch1-2

File hashes

Hashes for pygame-input-0.1.1.tar.gz
Algorithm Hash digest
SHA256 10d0bc7700e7a2f4f5e4285d07d418cffe42f0a441ca62ca188c2319b76041f6
MD5 8d110f5b1a5c96445e9b105a2f9a2e17
BLAKE2b-256 5eb95d12cd66fed84836f3ba935cfc96063889028116e31d0532d628918f69bb

See more details on using hashes here.

File details

Details for the file pygame_input-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pygame_input-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.2 Linux/5.5.9-arch1-2

File hashes

Hashes for pygame_input-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 73a71a9f42c90c2df82c511a71fe7d5fd3886416bd7f8de38409c76250771c53
MD5 c39668293456c0fb765bffdb341d2090
BLAKE2b-256 0024fe364a95af46d7a69d960986638541fe8abd70624012527edd8d99f45049

See more details on using hashes here.

Supported by

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