Modifying the behaviour of Joystick devices

I am about to design a new product that should enable the user to modify the behaviour and features of any joystick device attached to the system.
For example, the user may remap joystick buttons, hide unneeded axes or remap an axis as a POV hat switch.
From the system point of view, the remapping joystick device should replace the original device.
The user should be able to apply the modifier to any third-party hardware.
The target system is Windows 7 and up.

What is the correct approach to design such a product?

HID upper filter

wrote in message news:xxxxx@ntdev…
>I am about to design a new product that should enable the user to modify the behaviour and features of any joystick device attached to the system.
> For example, the user may remap joystick buttons, hide unneeded axes or remap an axis as a POV hat switch.
> From the system point of view, the remapping joystick device should replace the original device.
> The user should be able to apply the modifier to any third-party hardware.
> The target system is Windows 7 and up.
>
> What is the correct approach to design such a product?
>

Thank you Maxim.
Please explain why upper? Is it feasible to alter the HID Report Descriptor in the upper filter?
What are the relevant limitations of a lower filter?

xxxxx@gmail.com wrote:

Please explain why upper? Is it feasible to alter the HID Report Descriptor in the upper filter?

The upper filter has to deal with HID transactions. The lower filter
has to deal with USB requests. However, there are other
considerations. Some parts of the HID driver set communicate directly,
bypassing the IRP mechanism. Doron has that kind of thing memorized,
but it’s pretty easy just to build a simple filter driver and see what
you get.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thank you Tim,
Well, how about writing a minidriver? The minidriver has access to all HID driver communication I presume. However, writing a filter driver is probably more straightforward and I don’t have to replace the vendor’s minidriver (if at all exists).

You don’t want to rewrite the minidriver. You then have to understand spec USB, bth, i2c implementations as well as custom stuff. A lower filter below the miniport would let you intercept bth and USB traffic, not sure about i2c.

d

Bent from my phone


From: xxxxx@gmail.commailto:xxxxx
Sent: ?3/?4/?2015 10:32 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] Modifying the behaviour of Joystick devices

Thank you Tim,
Well, how about writing a minidriver? The minidriver has access to all HID driver communication I presume. However, writing a filter driver is probably more straightforward and I don’t have to replace the vendor’s minidriver (if at all exists).


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

Thank you Doron. So we are back to Upper/Lower filters.
I guess lower filter will give me more control but at what cost?
If I understand Tim correctly then there are certain things you cannot do in the upper filter. Can you change the way the device is seen by the system (Report Descriptor)? Can you modify the button/value data?
Sounds like upper filter require less coding. True?

Yes.

The filter is just a decorator which allows to meddle with anything in the IRP flow, including report descriptors etc.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

wrote in message news:xxxxx@ntdev…
> Thank you Doron. So we are back to Upper/Lower filters.
> I guess lower filter will give me more control but at what cost?
> If I understand Tim correctly then there are certain things you cannot do in the upper filter. Can you change the way the device is seen by the system (Report Descriptor)? Can you modify the button/value data?
> Sounds like upper filter require less coding. True?
>

The upper filter can alter the data being reported. An upper filter cannot change the descriptor. Changing the descriptor would require a lower filter below the hid miniport. if the miniport is WDF based, you can wedge yourself between hidclass and the miniport and have a simpler time, but hidusb is not WDF based so it doesn’t help you much

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, March 4, 2015 1:13 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Modifying the behaviour of Joystick devices

Thank you Doron. So we are back to Upper/Lower filters.
I guess lower filter will give me more control but at what cost?
If I understand Tim correctly then there are certain things you cannot do in the upper filter. Can you change the way the device is seen by the system (Report Descriptor)? Can you modify the button/value data?
Sounds like upper filter require less coding. True?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Hi All,
Thanks for your responses so far, I should introduce myself as I am the person who has initiated all this. My name is Clive, I wrote a (free) piece of software called UJR (Universal Joystick Remapper), which can read physical stick input from one or more sticks and route it, with modifications (ie axis invert, deadzone etc) to Shaul’s vJoy driver.
This became rather popular, and users of my software funded the initial code signing cert for Shaul’s vJoy driver, and now Shaul has agreed to help me out in writing a successor (Working title: “UCR - Universal Control Remapper”)

Shaul does not really know much about the workings of my code, so I thought it best (as tersely as possible) to lay out objectives, constraints, etc so that we can, if possible, find the best solution.

UJR and it’s successor are written in AutoHotkey.
Ostensibly a scripting language, this is actually starting to basically become a wrapper for windows functionality - especially with the advent of AHK v2.
I am not a windows coder. I use a lot of windows API calls etc via AHK, but I know next to nothing about the inner workings of windows and drivers.
Parts of the solution could be written in C, and AHK could be extended to do things it currently cannot (We have a developer of an AHK fork on board) - so there are plenty of options.
I have already implemented RawInput (And HIDP_ “Preparsed Data”) DLL calls to read stick states in AHK (Handling of WM_INPUT messages), so any solution that utilizes that would be great.

OK, so on to the actual reason for the posting.

Lets say that a user has a super-duper top-end flightstick from SomeCo
This come as two USB devices - the stick and the throttle.
Now please excuse me, I do not happen to own a working version of one of these super-expensive sticks, but from what I understand they work like this:
If you open the box and plug the devices in, you see two entries in the Windows’ Game Controllers dialog (WGC).
The devices are HID devices and without drivers will work in a default configuration.

If you wish to configure it, you must install SomeCo’s software that came with the sticks.
Now I guess this is a driver, but there is a UI part as well.
This config software will let you remap buttons to keys, or, most importantly, merge the stick and the throttle onto one virtual device.
This is important, because some games only allow input from one stick at a time, so if you wish to use stick and throttle, you are outta luck.
In this instance, the physical sticks will either disappear from WGC, or their states will never change - so if you go into a game’s bind routine and try to bind an input, the game will see the combined virtual controller move, not the individual controller.

Now for example, I know at one point the software that came with the $200+ Saitek Rhino stick did not support combining of both the sticks onto one virtual stick, so owners of that stick had pretty much no other solution than UJR to let them play certain games with their stick.

Now we come to the main reason for all these questions.

In UJR, because I could not hide the physical (individual) sticks from games, or stop them from updating, when using the bind routines in game option menus, you invariably bind the input to the physical stick, not the virtual stick. I had to write a system called “Quickbind” that lets you move the virtual stick without moving the physical stick.

So… this got me thinking…
UCR would be able to do everything that the manufacturer’s software could do and then some - so why not try to replace it?
In fact, it would be worth mentioning that the scope of UCR would potentially include remapping for any HID device - ie why stop at replacing the software that comes with joysticks? Why not replace the software that comes with any keyboard / mouse / stick, or even provide software if your device did not come with any.

With regards to “remapping” keyboard or mouse, I possibly do not need drivers etc to do that - I have also implemented hooks via SetWindowsHookEx DLL calls which I think can take care of most keyboards / mice etc. I dunno - it’s probably best to limit discussions for now to the subject of joysticks, as “blocking” physical sticks is the most asked-for feature from users of UJR.

In order to “block” the physical stick input, there appear to be two ways to go:
For both methods, my code would always need to be able to read the actual state of the physical sticks (Ideally via my existing WM_INPUT code).

  1. Stop games from seeing the physical sticks move. Games should then always see the virtual sticks move. This may not work though as some games may decide to not even scan all sticks. However, virtual sticks should always be the “preferred device”, so this may be unlikely.
  2. Hide the sticks entirely (don’t appear to exist) from games, just leave the virtual sticks visible.

Apologies for the wall-o-text on a first post, hopefully it makes what we are trying to do pretty clear.

For further hints on how an example manufacturer’s software works - see the manual for Thrustmaster T.A.R.G.E.T here: http://ts.thrustmaster.com/download/accessories/pc/hotas/software/TARGET/TARGET_User_Manual_v1.6_ENG.pdf

Page 11: Operating principles

Here is what happens when a profile is launched:
? The physical controllers are disconnected virtually.
? The virtual controller is activated.