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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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