Skip to main content

High level API wrapper around inputs library for working with input devices like gamepads, joysticks, etc.

Project description

input_devices

input_devices is a Python library designed to provide a high-level API for interacting with various electronic input devices. This includes game controllers (such as Xbox and PlayStation controllers), joysticks, remote controllers, as well as computer peripherals like keyboards and mice. The goal of input_devices is to simplify the process of integrating these devices into Python projects by offering a straightforward and unified interface.

Features

  • Game Controllers: Support for Xbox Gen4 controllers.

Future

  • Joysticks: Compatibility with various models of joysticks.
  • Remote Controllers: Integration with different types of remote control devices.
  • Computer Peripherals: Support for keyboards and mice, facilitating complex input handling.
  • Extensible: Designed to be easily extendable for more types of devices.

Installation

Install input_devices using pip:

pip install input_devices

Quick Start

Here is a simple example of how to use input_devices to listen for inputs from an Xbox controller:

from input_devices import XboxControllerGen4
from inputs import get_gamepad

#event subscription example
controller = XboxControllerGen4(get_gamepad())
controller.A.on_press(lambda: print("A pressed")) \
          .on_release(lambda: print("A released"), lambda: print("A released x2")) 

# interaction with different types of buttons
controller.directional_pad.up.on_press(lambda: print("D-pad up press"))
controller.directional_pad.left.on_release(lambda: print("D-pad down release"))

while True:
     # updating events and trigger states
     controller.update() 
     # getting mapped x axis value from left stick on the xbox controller
     print(controller.left_stick.get_mapped_x(), new_minimum=-1, new_maximum=1) 
     # getting raw y values from left trigger on the xbox controller
     print(controller.left_trigger.get_y()) # get pressure-sensitive input

Documentation

For more detailed information about using input_devices, refer to the full documentation. Contributing

input_devices is an open project, and contributions are welcome! If you have suggestions for improvements or new features, please feel free to fork the repository and submit a pull request, or contact me directly via email at mtik.philosopher@gmail.com. Contact

If you have any questions or comments about input_devices, please feel free to reach out to me:

Project by: Mark Tikhonov
Email: mtik.philosopher@gmail.com

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

input_devices-0.1.2.tar.gz (3.3 kB view hashes)

Uploaded Source

Built Distribution

input_devices-0.1.2-py3-none-any.whl (3.4 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