speps / XInputDotNet

C# wrapper around XInput, works with any Mono or .NET application (eg. Unity3D)
464 stars 96 forks source link

Impulse Trigger #34

Open JOELwindows7 opened 5 years ago

JOELwindows7 commented 5 years ago

Introduction

Xbox One controller has aditional small vibrator on each of the two triggers. Microsoft calls this Impulse Trigger. Demo Video: Xbox One controller Impulse trigger demo Article: GamesRadar Sorry for I couldn't find good articles right now.

As you can see, aside from its large vibrators on the grip, the trigger has its own little vibration to increase feedback clarity.

Experiencing

If you have a device that runs Universal Windows Platform app such as Xbox One, Windows 10, etc. you can test your Xbox One controller with this app called Game Controller Tester. This free utility allows you to test whether or not your controller works well.

To the Impulse Trigger

To understand what does Impulse Trigger actually feels, please do the following:

If you are using Xbox One controller, you will feel vibration just on the trigger since the Impulse Trigger was ticked on the test setting. Otherwise, you will feel nothing on Xbox 360 Controller since there is no vibrator on each trigger.

if you tick Vibration, and start testing again, you will feel the grip vibrates.

Problem

Xbox One Impulse trigger is one of the cool feature that may fit within our Stand Out standard. This is because it is unusual and unique feature that stands out from the rest. Therefore we have a desire to implement Xbox One Impulse trigger on most of our game in Unity. Unfortunately, we encountered troubles as we are finding out ways to do so.

Thank you for your attention.

JOELwindows7 commented 5 years ago

does Impulse triggger works on Forza?

JOELwindows7 commented 5 years ago

does Impulse triggger works on Forza?

Of course! all UWP and Xbox One games supports Impulse Trigger.

Forza is from Microsoft

JOELwindows7 commented 5 years ago

Duh! I forgot to say..

The point is, I request Impulse trigger support in this library whenever possible. And unfortunately, Microsoft is ugh!

MoctezumaDev commented 5 years ago

I'm also interested in this issue, I forked the project and started to investigate a bit, I was able to use the UWP Api with C++ but even though I was able to catch the controllers connection and disconnection events, and read the gamepad state, somehow the vibration set function doesn't seem to work, the result of the operation returns a succesful value but nothing happens. :(

Here are so references I used:

https://stackoverflow.com/questions/41286503/how-to-use-the-namespace-windows-gaming-input-in-c-without-using-uwp

https://github.com/araghon007/X1nput

There is also a new Arduino XInput library that enables you to simulate a xbox controller, but it also miss the vibration part.

https://github.com/dmadison/ArduinoXInput

MoctezumaDev commented 5 years ago

Today I researched a bit more, seems like someone has a driver for linux written in C which supports vibration in the triggers. I'm very ingnorant when it comes to Windows drivers, I wonder if there is a way to read/write the xbox controller usb port without using XInput.

https://github.com/atar-axis/xpadneo/tree/master/hid-xpadneo/src

speps commented 5 years ago

I have done some research on this as well. There is a XInputSetStateEx in more recent versions of xinput*.dll which can apparently set the impulse triggers. I would accept a PR for this as I’m busy at the moment.

From: Leon Moctezuma Sent: 08 July 2019 21:01 To: speps/XInputDotNet Cc: Subscribed Subject: Re: [speps/XInputDotNet] Impulse Trigger (#34)

Today I researched a bit more, seems like someone has a driver for linux written in C, I'm very ingnorant when it comes to Windows drivers, I wonder if there is a way to read/write the xbox controller usb port without using XInput — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

MoctezumaDev commented 5 years ago

I have done some research on this as well. There is a XInputSetStateEx in more recent versions of xinput*.dll which can apparently set the impulse triggers. I would accept a PR for this as I’m busy at the moment.

Hi Remi, thanks for sharing this project.

Interesting, well I did a dumpbin of xinput1_4.dll and one can set that there are at least 6 non named exported functions.

You actually are using one of them the 100 in the followin line:

mGetState = (XInputGetStatePointer)GetProcAddress(mHandle, (LPCSTR)100);

How did you managed to figure out what this function was?

How did you find about XInputSetStateEx? Do you have any link or reference?

image

MoctezumaDev commented 5 years ago

Maybe a DLL redirection might help, I have never done such thing... I would need a program that uses those noname functions through XInput.

https://www.ethicalhacker.net/columns/heffner/intercepted-windows-hacking-via-dll-redirection/

Dealman commented 3 years ago

Any update on this? I'd love to contribute myself, but this kind of stuff is a fair bit too advanced for me.

Seems like a rather big oversight not to include and expose this functionality in XInput? Or maybe it was an attempt to push people to use UWP? 😄

What I'm trying to use it for is rendered useless since you can't use the gamepad if your UWP app loses focus, so seems like I'm gonna have to try and find some way to fake/intercept the focus if at all possible.

Guessing this is why only a select few games make use of them, cause they have to use UWP. Shame really cause it's a really cool feature.

speps commented 3 years ago

I found some more information, will have a go at it this week possibly.

JOELwindows7 commented 3 years ago

Today I researched a bit more, seems like someone has a driver for linux written in C which supports vibration in the triggers. I'm very ingnorant when it comes to Windows drivers, I wonder if there is a way to read/write the xbox controller usb port without using XInput.

https://github.com/atar-axis/xpadneo/tree/master/hid-xpadneo/src

Oh yeah, btw, I had tried that xpadneo driver on Linux. It is currently only works for Bluetooth for now, to make xpadneo effect work. Once you've paired the bluetooth, you'll be greeted with vibration dance with Impulse trigger.

Unfortunately, that support for Impulse trigger in every game in xpadneo basically augments current standard Rumble. If you hold either or both of trigger, then the Rumble event happens, the Impulse Trigger will happen until you drop the triggerr or Rumble event stop. Yeah, basically just addition of vibration, not meaning to add coding functionality for Linux game developer about Impulse trigger event thingy.

I'm also interested in this issue, I forked the project and started to investigate a bit, I was able to use the UWP Api with C++ but even though I was able to catch the controllers connection and disconnection events, and read the gamepad state, somehow the vibration set function doesn't seem to work, the result of the operation returns a succesful value but nothing happens. :(

Here are so references I used:

https://stackoverflow.com/questions/41286503/how-to-use-the-namespace-windows-gaming-input-in-c-without-using-uwp

https://github.com/araghon007/X1nput

There is also a new Arduino XInput library that enables you to simulate a xbox controller, but it also miss the vibration part.

https://github.com/dmadison/ArduinoXInput

I had ever attempted to Windows Gamepad API on C# Unity when the platform is on PC (Win32). It doesn't work. it errors.

but as your stack overflow share above, which is C++ win32, hmmm, that's interesting.

speps commented 3 years ago

I did find how to do it, I just need to try. It would be on Windows only for now. I need to dig into UWP later.

LCrucio commented 3 years ago

I did find how to do it, I just need to try. It would be on Windows only for now. I need to dig into UWP later.

Did you manage to try it out? I tried myself, but no success here

lexasss commented 3 years ago

What I'm trying to use it for is rendered useless since you can't use the gamepad if your UWP app loses focus.

This is something I'm fighting against now while developing my UWP app.

So far, this is what I learned:

Conclusion: so far, I see no way to vibrate trigger motors in Xbox controller when the app is not in focus. Same was found by others.