Skip to content

Add support for xbox guide button #8

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

danielbibit
Copy link

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.

@Zuzu-Typ
Copy link
Owner

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?

@danielbibit
Copy link
Author

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
Copy link
Author

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants