pygame-input is a tool to simplify input handling with pygame
Project description
pygame-input
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pygame_input-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73a71a9f42c90c2df82c511a71fe7d5fd3886416bd7f8de38409c76250771c53 |
|
MD5 | c39668293456c0fb765bffdb341d2090 |
|
BLAKE2b-256 | 0024fe364a95af46d7a69d960986638541fe8abd70624012527edd8d99f45049 |