Skip to content

A simple library for getting the state of a connected XInput device (such as an xbox controller) in Windows.

License

Notifications You must be signed in to change notification settings

brainsMAKER/pyxboxcontroller

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyxboxcontroller

This module allows for accessing the current state of a connected Xbox controller via the XInput library on Windows.

Installation

Simply install using pip pip install pyxboxcontroller

Importing

from pyxboxcontroller import XboxController, XboxControllerState

Connect to controller

Connect to the controller with id (starting at 0) using: controller = XboxController(id)

Getting the current state of the controller

The current state of the controller can be gotten with: state: XboxControllerState = controller.state This returns an XboxControllerState object.

Some examples of accessing the states' values:

left_thumbstick_x: float = state.l_thumb_x
right_thumbstick_y: float = state.r_thumb_y
x_pressed: bool = state.x
lb_pressed: bool = state.lb

Alternately the state of the button (e.g. x) can be gotten with: button_pressed: bool = state.buttons["x"]

Examples

To see this code in action, why not try out:

from pyxboxcontroller.examples import example_state_gui
example_state_gui()

About

A simple library for getting the state of a connected XInput device (such as an xbox controller) in Windows.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%