Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Impulse Trigger #34

Open
JOELwindows7 opened this issue Mar 3, 2019 · 14 comments
Open

Impulse Trigger #34

JOELwindows7 opened this issue Mar 3, 2019 · 14 comments

Comments

@JOELwindows7
Copy link

JOELwindows7 commented Mar 3, 2019

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:

  • Install Game Controller Tester
  • Press Start and type Game Controller Tester
  • select new interface
  • select test option
  • setting the impulse trigger
  • start testing
  • select controller
  • Now press which trigger. LT will vibrate left Trigger, and RT with vibrate right trigger.
    press trigger

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.

  • Xbox Impulse trigger is exclusive to Microsoft Environment. Many developer could only implement Impulse trigger for Microsoft's closed environment such as UWP, and Xbox One xex. You will be disappointed for that you could not experience Impulse trigger on a version that it not Microsoft Store like UWP or xex Xbox One. e.g., Game A supports Impulse Trigger on Microsoft Store version, but Game A doesn't support Impulse Trigger on Steam version.
  • Unity editor cannot debug Windows namespace, cannot have Windows namespace in editor. The manual according to this Link did not give clear and exact action for what to do to create placeholder namespace for editor, nor give any dummy namespace library for it. the name space using Windows.Gaming.Input only works if you build it to UWP. therefore the only solution to prevent error is to wrap them inside
#if !UNITY_EDITOR
// Plugin code
 using Windows.Gaming.Input;
#endif
  • Also you have to make sure to wrap code with UNITY_WSA defintion to detect exactly if you are on UWP export build and not in editor. This version if for cross platform project.
#if UNITY_WSA && !UNITY_EDITOR
// Plugin code
 using Windows.Gaming.Input;
#endif

Unity platform dependent defintion

  • You will be blind to test things for that. You will not be able to find out if something went wrong.
  • There are not much information regarding Impulse Trigger development API. only the premade example found on Gamepad and Vibration. and that is the UWP raw project made with just some c++ or c# codes from scratch.
  • Nobody talked about Unity Impulse Trigger, or the search engine placed the discussion somewhere too far.
  • Only one company managed to Impulse trigger outside UWP. the F1 2017 game, the exe version according to this Impulse Trigger on PC Games. Please note that however we haven't yet tested the F1 2017 ourselves to confirm the information whether it is fact or hoax. Beside of that, all UWP games supports Impulse Trigger.
  • We did not found the Impulse trigger method in this XInputDotNetpure

Thank you for your attention.

@JOELwindows7
Copy link
Author

does Impulse triggger works on Forza?

@JOELwindows7
Copy link
Author

does Impulse triggger works on Forza?

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

Forza is from Microsoft

@JOELwindows7
Copy link
Author

JOELwindows7 commented Jun 22, 2019

Duh! I forgot to say..

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

@MoctezumaDev
Copy link

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

MoctezumaDev commented Jul 8, 2019

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

speps commented Jul 9, 2019 via email

@MoctezumaDev
Copy link

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

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

Dealman commented Oct 7, 2020

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

speps commented Oct 7, 2020

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

@JOELwindows7
Copy link
Author

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

speps commented Oct 8, 2020

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

LCrucio commented Feb 24, 2021

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

lexasss commented Apr 14, 2021

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:

  • The "no-vibration-if-the-app-is-out-of-focus" problem appears only when using Windows.Gaming.Gamepad. And this is the only class that allows me to use all 4 vibration motors in Xbox controller.
  • The "no-vibration-..." problem does NOT appear when using Windows.Gaming.Input.RawGameController, it vibrates the controller perfectly when the app is not in focus. However, its SimpleHapticsControllers list includes only the side motors but not the trigger motors.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants