..:: PCSX2 Forums ::..

Full Version: DS4 To XInput Wrapper
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
(01-15-2014, 09:52 PM)electrobrains Wrote: [ -> ]I'm trying to make it try exclusive mode first then shared mode but can't for the life of me figure out what's going wrong with the CreateFile calls. I think something is up with the two NativeMethods.CreateFiles being overloaded? Don't we only need just one of them? Here's what I'm trying to do:
Code:
/*
         * Attempt to open in exclusive mode, if possible, to work-around double input reported in some programs.
         * Always try to open in shared mode for people whose controllers get disconnected while a program is actively using the controller.
         */
        private SafeFileHandle OpenHandle(String devicePathName, Boolean readAndWrite)
        {
            const int Exclusive = 0, Shared = NativeMethods.FILE_SHARE_READ | NativeMethods.FILE_SHARE_WRITE;
            uint Access = readAndWrite ? NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE : 0;

            for (int sharing = Exclusive; ; sharing = Shared)
            {
                try
                {
                    SafeFileHandle fh = NativeMethods.CreateFile(devicePathName, Access, sharing, IntPtr.Zero, NativeMethods.OpenExisting, 0, 0);
                    if (fh.IsInvalid)
                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
                    else
                        return fh;
                }
                catch (Exception)
                {
                    if (sharing == Shared)
                        throw;
                }
            }
        }

It could be more user friendly solution . but it won't fix the problem for people who have freezes while using exclusive access. For me the freeze was over in few min and i am able to launch AC3 with Uplay on windows 7 the problem, and after in game it works. But if i try task switching process es it will do the hand again.

Maybe its because your sharing is signed int
(01-15-2014, 10:06 PM)InhexSTER Wrote: [ -> ]It could be more user friendly solution . but it won't fix the problem for people who have freezes while using exclusive access. For me the freeze was over in few min and i am able to launch AC3 with Uplay on windows 7 the problem, and after in game it works. But if i try task switching process es it will do the hand again.

Maybe its because your sharing is signed int

I'm happy to implement shared/exclusive as a toggle but I still don't understand why the calls won't work. I'll try messing around with the short/int/uint argument types, I suppose.
(01-15-2014, 11:23 PM)electrobrains Wrote: [ -> ]I'm happy to implement shared/exclusive as a toggle but I still don't understand why the calls won't work. I'll try messing around with the short/int/uint argument types, I suppose.

Well, you try to put text (Exclusive) into a variable of the type Integer, sounds like it shouldnt work.
Hey InhexSTER, just wanted to thank you for all you hard work and effort into creating this wonderfully useful tool for us all and I'm sure with the available code some very talented people will help make this tool become perfect. I see that is already starting to unfold with electrobrains diving right in.

I wanted to ask if anyone has any problems with certain games with this tool though, although some games work others do not. For example I can use Steam Big Picture, Metal Gear Rising: Revengeance to an extent, and The Witcher 2 just fine. Some problem games for me so far are Vindictus and Dark Souls.

For MGR:R everything seems to work fine except the square button, Dark Souls it just doesn't recognize the controller I think. Vindictus I can't get to work - it just doesn't do anything. Anyone else have these problems?

Also I got bluetooth to sort of work (on combo card with Maximus V motherboard) - sometimes iffy - after I had the disconnecting problem. Had to go into properties of the gamepad BEFORE I started pairing the device and check 'device, drivers etc etc'. Then if it came up with 'allow device to connect' I checked that and immediately went into gamepad properties to make sure it recognized my inputs.
(01-16-2014, 05:30 AM)Rimark Wrote: [ -> ]I wanted to ask if anyone has any problems with certain games with this tool though, although some games work others do not. For example I can use Steam Big Picture, Metal Gear Rising: Revengeance to an extent, and The Witcher 2 just fine. Some problem games for me so far are Vindictus and Dark Souls.

For MGR:R everything seems to work fine except the square button, Dark Souls it just doesn't recognize the controller I think. Vindictus I can't get to work - it just doesn't do anything. Anyone else have these problems?

I haven't tried Vindictus, but Dark Souls works perfectly for me, wired and wirelessly. Windows 7, 64-bit.
Has anyone got the trackpad to work in Assassins Creed IV 4 Black Flag ??

The rest of the controller works fine with or without DS4Tools, however the trackpad doesnt work. I assume this occurs in any games that auto-detect the microsoft drivers or the double-controller scenarios.

I am assuming that the game is detecting the 'Wireless Controller' (device that shows as soon as I plug in DS4 usb) which shows separately from the 'Xbox 360 Controller for Windows' (the device that DS4 to XInput Mapper creates).

Even when I remove the 'Wireless Controller' device, the DS4Tools trackpad functionality stays, but the game still doesnt move when trackpad is used. Also if I disable the driver for the 'Wireless Controller', the 'Xbox...' controller just disappears and DS4Tools cant see the device anymore.

Oh also, I have tried many times the L2+R2+Touchpad Hotkey. That works and is responsive on the desktop. Just not in the game.

Anyway to use trackpad in AC4?
(01-16-2014, 05:44 AM)pedrovay2003 Wrote: [ -> ]I haven't tried Vindictus, but Dark Souls works perfectly for me, wired and wirelessly. Windows 7, 64-bit.

Hmm, yeah I've seen other people say that it works for them too, I just can't for the life of me figure out why mine can't work. Any process of troubleshooting this sort of stuff? In the meantime I'll look for a log or to see where the connection is cutting off..

Edit: oh also, do you have DSMfix (dark souls mouse fix) still in it? I've seen a post where that 'might' interfere but I haven't tried w/ removing DSMfix, I'll try that right away too.
Edit2: I fixed Dark Souls - it was indeed DSMfix, so disabling DSMfix will allow you to use a gamepad properly. Now to figure out Vindictus!
(01-16-2014, 09:10 AM)Rimark Wrote: [ -> ]Edit2: I fixed Dark Souls - it was indeed DSMfix, so disabling DSMfix will allow you to use a gamepad properly. Now to figure out Vindictus!

I'm glad you fixed Dark Souls! I never actually had DSMfix installed (I always just used a controller), but it makes sense that that would be the problem.

As far as Vindictus goes, are you making sure the controller is set up before you start the game?
(01-16-2014, 08:19 AM)nyeates Wrote: [ -> ]Has anyone got the trackpad to work in Assassins Creed IV 4 Black Flag ??

The rest of the controller works fine with or without DS4Tools, however the trackpad doesnt work. I assume this occurs in any games that auto-detect the microsoft drivers or the double-controller scenarios.

I am assuming that the game is detecting the 'Wireless Controller' (device that shows as soon as I plug in DS4 usb) which shows separately from the 'Xbox 360 Controller for Windows' (the device that DS4 to XInput Mapper creates).

Even when I remove the 'Wireless Controller' device, the DS4Tools trackpad functionality stays, but the game still doesnt move when trackpad is used. Also if I disable the driver for the 'Wireless Controller', the 'Xbox...' controller just disappears and DS4Tools cant see the device anymore.

Oh also, I have tried many times the L2+R2+Touchpad Hotkey. That works and is responsive on the desktop. Just not in the game.

Anyway to use trackpad in AC4?

If synthetic mouse events don't work with some software then the only alternative that I know of is implementing trackpad as a virtual trackpad/mouse/tablet device. That's a LOT of work compared to what is there now. I just tried AC4 and I see exactly what you see, that it does not track synthetic mouse events. By the way, touchpad support works a TON better with the changes I've made -- I think lots of events were getting delayed because of all the memory allocations in the fastpath.

Note to self: investigate whether SendInput() or SetCursorPos() behave any differently
@InhexSTER
I really love you tool man!Wub Very useful, since most games for windows have special support for the 360 controller.Biggrin But when I use the Beta 3 of your tool the controls hang sometimes, so it's like if I would press the button all the time for a few seconds... and that makes the games unplayable... The controller works how it is supposed to, if I don't use the tool but i have no coloured led, no use for the touchpad and no rumble. Sad
I'll try out the previous versions of your tool and keep u posted Wink
Edit: I'm using the controller via bluetooth

Btw: I'm on Win XP Pro, SP 3, .NET 4.0