XInput-Python icon indicating copy to clipboard operation
XInput-Python copied to clipboard

Add support for xbox guide button

Open danielbibit opened this issue 3 years ago • 3 comments

This PR adds the xbox guide button support.

I'm calling the xinput function by ordinal as described in this post: http://reverseengineerlog.blogspot.com/2016/06/xinputs-hidden-functions.html

Also, this xinput wrapper for AutoHotKey use this to be able to get the guide button: https://www.autohotkey.com/boards/viewtopic.php?t=29659#:~:text=XInput.,triggers%20are%20pulled%20at%20once.

(_XInput_GetState        := DllCall("GetProcAddress" ,"ptr",_XInput_hm ,"ptr",100 ,"ptr"))
|| (_XInput_GetState        := DllCall("GetProcAddress" ,"ptr",_XInput_hm ,"astr","XInputGetState" ,"ptr"))

I took the liberty to update the example code as well. Hope this PR is helpfull.

danielbibit avatar Mar 30 '22 18:03 danielbibit

Hey there (:

thank you very much for your work and the detailed information you gave alongside with it ^^

I've tried it out, but it doesn't seem to work on my end. I presume you tested it and it did work for you, right? I've tested it with an XBox 360 controller as well as a regular XBox One controller, but didn't have any luck unfortunately.

May I ask, which Windows version are you using?

Zuzu-Typ avatar Mar 30 '22 18:03 Zuzu-Typ

Here's my windows info

Edition	Windows 10 Pro
Version	21H2
Installed on	‎01/‎06/‎2021
OS build	19044.1586
Experience	Windows Feature Experience Pack 120.2212.4170.0

My controller is a xbox one series x connected via the microsoft dongle.

I just tested using 'XInput1_4.dll' and 'XInput1_3.dll'.

Yeah, it's working fine, I'm testing using this script:

if __name__ == "__main__":

    from XInput import *
    from time import sleep

    while True:
        print(get_button_values(get_state(0))['GUIDE'])
        sleep(0.5)

The console log prints true when pressed.

Can you use your guide button on steam to open big picture, or use it in another application ?

danielbibit avatar Mar 30 '22 19:03 danielbibit

The dolphin emulator achive this the same way:

// Ordinal 100 is the same as XInputGetState, except it doesn't dummy out the guide
// button info. Try loading it and fall back if needed.
PXInputGetState = (XInputGetState_t)::GetProcAddress(hXInput, (LPCSTR)100);

https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/InputCommon/ControllerInterface/XInput/XInput.cpp

danielbibit avatar Apr 12 '22 10:04 danielbibit