Code Monkey home page Code Monkey logo

xinput-python's People

Contributors

texx00 avatar zuzu-typ avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xinput-python's Issues

Leo Bodnar eight axis joystick

Hi,
I connected a LeoBodnar BU0836A with eight axis joystick, windows driver see everything but XInput is not able to catch the joystick .. any idea ?!

Gamepad type/brand

Is there a way to know which type/brand of gamepad is connected? (Logitech, X-box ...) I want to change the button layout in the GUI based on gamepad type

how to use as a Continuous movement??

Hi
Thanks for your great work.
when i use your lib for example
elif event.type == EVENT_STICK_MOVED:
if event.stick == RIGHT:
print(event.x , event.y )

it seems the events are discrete not Continuous, i need to reported event.x and event.y very frequently
when i hold STICK_MOVED
any solution ??

"You need to specify at least one controller"

Forgive my inexperience working with the library here, but I'm trying to use this library to connect my XBox Controller to my VISCA Camera. When I try to run the attached script in Powershell I get this error message:

import XInput

class Handler(XInput.EventHandler):
    
    ALL_FACE_BUTTONS = XInput.BUTTON_A | XInput.BUTTON_B | XInput.BUTTON_Y | XInput.BUTTON_X
    ALL_DPAD_BUTTONS = XInput.BUTTON_DPAD_UP | XInput.BUTTON_DPAD_DOWN | XInput.BUTTON_DPAD_LEFT | XInput.BUTTON_DPAD_RIGHT
    ALL_MENU_BUTTONS = XInput.BUTTON_START | XInput.BUTTON_BACK
    ALL_THUMB_BUTTONS = XInput.BUTTON_LEFT_THUMB | XInput.BUTTON_RIGHT_THUMB
    ALL_SHOULDER_BUTTONS = XInput.BUTTON_LEFT_SHOULDER | XInput.BUTTON_RIGHT_SHOULDER
    ALL_BUTTONS = ALL_FACE_BUTTONS | ALL_DPAD_BUTTONS | ALL_MENU_BUTTONS | ALL_THUMB_BUTTONS | ALL_SHOULDER_BUTTONS
    
    # last_stickL_pos = (0.0, 0.0)
    # last_stickR_pos = (0.0, 0.0)
    
    def __init__(self, *controllers):
        super().__init__(*controllers, filter = Handler.ALL_BUTTONS + XInput.STICK_LEFT + XInput.STICK_RIGHT + XInput.TRIGGER_LEFT + XInput.TRIGGER_RIGHT)
    
    def process_button_event(self, event):
        print("(" + str(Event.button) + ") button pressed")
        # TODO: Connect button press to set preset command in VISCA
        # TODO: Connect shoulder button press to focus in/out in VISCA

    def process_trigger_event(self, event):
        if(Event.trigger == XInput.LEFT):
            print("Trigger L pressed to " + str(Event.value))
        if(Event.trigger == XInput.RIGHT):
            print("Trigger R pressed to " + str(Event.value))
        # TODO: Connect trigger push to camera zoom in/out in VISCA

    def process_stick_event(self, event):
        if(Event.stick == XInput.LEFT):
            print("Stick L moved to " + str(Event.value))
        if(Event.stick == XInput.RIGHT):
            print("Stick R moved to " + str(Event.value))
        # TODO: Check last_stick_pos to see if we need to send a new packet or not
        # TODO: Connect stick tilt to camera tilt/pan in VISCA
    
    def process_connection_event(self, event):
        print("Controller connected on port " + str(Event.user_index))

my_handler = Handler()
my_handler.add_filter(filter)
my_gamepad_thread = XInput.GamepadThread(my_handler)
Traceback (most recent call last):

  File "D:\Church Camera Python Controller\XBoxController.py", line 33, in <module>
    my_handler = Handler()

  File "D:\Church Camera Python Controller\XBoxController.py", line 13, in __init__
    super().__init__(*controllers, filter = Handler.ALL_BUTTONS + XInput.STICK_LEFT + XInput.STICK_RIGHT + XInput.TRIGGER_LEFT + XInput.TRIGGER_RIGHT)

  File "C:\Users\thebl\AppData\Local\Programs\Python\Python310\lib\site-packages\XInput.py", line 556, in __init__
    self.set_controllers(*controllers)

  File "C:\Users\thebl\AppData\Local\Programs\Python\Python310\lib\site-packages\XInput.py", line 582, in set_controllers
    raise ValueError("You need to specify at least one controller")

ValueError: You need to specify at least one controller

How do I specify a controller in the script?

Importing package

When importing package in python 2.7...... I receive an error
Line 555
Def init(self, *controllers, filter = FILTER_NONE):

there is a carrot " ^ " under the " r " in filter syntaxerror: invalid syntax

Battery information error

I was trying out the different functions available and came across this error:

>>> XInput.get_battery_information(XInput.get_state(0))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "XInput.py", line 268, in get_battery_information
    XInputGetBatteryInformation(user_index, BATTERY_DEVTYPE_GAMEPAD, battery_information)
  File "XInput.py", line 144, in XInputGetBatteryInformation
    return libXInput.XInputGetBatteryInformation(dwUserIndex, devType, ctypes.byref(batteryInformation))
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type

Also can I ask what you mean by "You shouldn't check this too frequently" in get_connected? Is it just due to it being slow?

No way to detect button combinations

So it's probably my lack of expertise with async programming speaking here but I could not figure out as to how to detect any button combinations being made on the controller, any way to do so or to implement some the filters to do the same?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.