Ryochan7 / DS4Windows

Like those other ds4tools, but sexier
https://ryochan7.github.io/ds4windows-site/
GNU General Public License v3.0
6.96k stars 808 forks source link

[TODO] Migrate DS4Windows to WPF #824

Closed Ryochan7 closed 4 years ago

Ryochan7 commented 5 years ago

The successor build is definitely not going to happen in 2019. I would still like to move away from Windows Forms and start utilizing newer development practices though. The big areas of interest would be utilizing Windows Presentation Foundation and MVVM.

Ryochan7 commented 5 years ago

I really wish I would have saved some of my old test projects. Having to figure out quirks all over again has not been fun.

Anyway, I have set up a repository for developing a WPF version. It will stay in a separate repository for a while. The current status is not as far along as what I had before reformatting but it is getting close. If it works out then the code will be migrated to this repository and a version 1.8 (or 2.0) of DS4Windows would be made.

https://github.com/Ryochan7/DS4WindowsWPF

Darthagnon commented 5 years ago

Doesn't WPF mean "Windows 10 exclusive"? If so, please don't make regular DS4Windows like that :'(

Ryochan7 commented 5 years ago

No. Targeting UWP (Universal Windows Platform) is what would force Windows 10 usage. WPF (Windows Presentation Foundation) has been around since 2006 and is compatible with Windows Vista and later. Windows 7 SP1 is the minimum platform target for DS4Windows so there should be no problem with compatibility.

https://en.wikipedia.org/wiki/Windows_Presentation_Foundation

Ryochan7 commented 5 years ago

Some progress has been made. The main form has mostly been ported over. Controller hotplugging and profile selection work so the prototype is somewhat usable. Currently, the WPF version is slightly faster than the current Windows Forms version. The next step is to port over the main Options profile mapper form.

Ryochan7 commented 5 years ago

Now the main profile settings can be edited and saved. The actual binding editing portion has not been made yet. One other positive thing to come out of this is that a few old bugs in the current DS4Windows code have been found and fixed. I need to take some time and bundle a new DS4Windows release.

Ryochan7 commented 5 years ago

ds4win_wpf_20191009

Ryochan7 commented 5 years ago

The base binding window is now functional. The next step will be to work on the RecordBox control to allow mapping macros. The code for that component is going to be a pain to analyze. Very messy.

Ryochan7 commented 4 years ago

The RecordBox control is now pretty much finished. General macro parsing was the biggest issue to contend with but the new version should be much easier to maintain. There are other minor tasks to accomplish still but the next major milestone will be to get Special Actions working again.

Ryochan7 commented 4 years ago

The Special Actions editor is now complete. It has taken one month but the new version finally does everything that I use in DS4Windows. The new version is still not complete though. The next big step will be to get Auto Profile support to work fully.

The current user control has been ported and the new routine scans for apps much faster. One big problem is dealing with expression matching in addition to direct matches.

greggameplayer commented 4 years ago

@Ryochan7 will it be possible on WPF version to have the audio jack working on 3rd parties bluetooth dongle ?

Ryochan7 commented 4 years ago

No it will not work. That process was never fully worked out even in the old experimental Linux code. The only two ways to get the audio jack working will still be via the Sony Wireless Adapter and via USB on the DS4 v.2.

Ryochan7 commented 4 years ago

I am pretty sure that enough has changed to justify bumping the version number to 2.0 once the WPF version gets a public release.

Ryochan7 commented 4 years ago

If anyone is curious, here is a test build of the current WPF progress. The test build has been tested on Windows 10 and Windows 7. Make sure to place this build in its own directory and copy over your Profiles folder and other config files if you want. Do not write over the stable DS4Windows build. Appdata support should technically work although it has not been tested.

https://drive.google.com/file/d/1MuIku_lYl9yuVGoLQwbPtSVbOXG9rdlU/view?usp=sharing

Ryochan7 commented 4 years ago

The Auto Profile system is now working. Some ideas that I had for changes were kind of squashed when it came to dealing with expression entries. I ended up just doing a straight port of the routine. Pulling the various bits from the DS4Form class was an issue. The DS4Form class has been acting as a major God class doing far more than it should.

As it is now, profile switching seems to happen faster with the new version.

Ryochan7 commented 4 years ago

Updated WPF build. Besides auto profile being usable again, some other updates are fixes to output controller switching, changed Run as Task behavior, and more options added back to the Settings tab.

https://drive.google.com/file/d/1lzyf_2LFzcKYiOfok2gc6t7CwL0bUYD-/view?usp=sharing

Ryochan7 commented 4 years ago

Updated WPF build. Changes:

https://drive.google.com/file/d/1rMMmgmvuQxhGI4o6NeG_NX843_fB-9V5/view?usp=sharing

Ryochan7 commented 4 years ago

The Controller Readings tab conversion is almost finished. Some layout changes will likely happen but the main functionality has been added back. WPF definitely made the process of laying out those controls much easier than the process required for the Windows Forms build. The actual code for the new update process could be better but the dev version is still an improvement.

That should be the last major piece of functionality that had been missing. Apart from localization and other minor tweaks, the build is pretty close to being complete. I will get a new WPF test build posted in a couple of days.

mika-n commented 4 years ago

The WPF GUI version seems to work a bit snappier than WinForms version. Here are couple random ordered comments about the WPF version:

Ryochan7 commented 4 years ago

Thank you mika for the feedback.

mika-n commented 4 years ago

Few more comments about "auto-profile" dialog and functionality:

Ryochan7 commented 4 years ago

Gotten some of those issues fixed. The Auto Profile Debug messages problem was due to the AutoProfileChecker class linking to an older placeholder class rather than the log class from DS4Control. The rest of the system worked so changing the log calls fixed it so debug messages now show up in the Log list.

The debug checkbox being disabled is due to disabling the panel that holds the checkbox and other controls in that sidebar. I will need to change the layout a bit to split that checkbox from that panel.

The Browse Directory option was a recent addition due to Microsoft not providing a suitable folder browser dialog for WPF. The general advice on SO is to use the version from Windows Forms. I ended up choosing to use Ookii Dialogs to have a native WPF dialog for browsing directories. That was a higher priority than browsing for an individual executable. Leaving out the Origin games import option was done on purpose but maybe it will have to be added back.

One last thing is that the device number assumption for the Profile editor has been changed. A new field has been added to the ViewModel to make the editor choose Slot 1 if the temp slot number of 4 is passed to the editor. That is pretty much what is done in the WinForms build although it takes the temp device value from the NumericUpDown nUDSixaxis control.

Ryochan7 commented 4 years ago

New WPF build. Changes:

https://drive.google.com/file/d/1_wKzLjKswRTskG0-P11MZbKcBZm6Q83Q/view?usp=sharing

mika-n commented 4 years ago

Just tested the latest version from GitHub. Few more comments about auto-profile feature:

The AutoProfile list should check that if an existing entry is modified (process name or wndTitle) then it should overwrite the existing entry and use the new process name (with optional keywords) as a list key value. This way it would be possible to add the same process name again in the list with a different process name search keyword. If there are potentially conflicting process or wndTitle search keywords (ie. multiple rules would match the same process/wnd) then the first rule in the list wins the race. This is how the old version worked with these cases and it is up to the user to order those auto-rules in a specific order.

Anyway. The new WPF version is getting closer to be usable in real world scenarios. Next I will test more special action macro rules and 360SteeringWheel emulation modes.

Ryochan7 commented 4 years ago

Didn't put the check for a matched object in the new path setter so the path is not persisted after the initial save. I never used the newer expression functionality so I really need to test that. I'll take a look into the crash problem too.

Ryochan7 commented 4 years ago

New WPF build. I have not tested auto profile support again so the previous issues still exist. Changes:

https://drive.google.com/file/d/1B4Q4fbF31OgBaeZayB5yoSs3SIB-5x6F/view?usp=sharing

Ryochan7 commented 4 years ago

New WPF build. Auto profile support has been edited. It seems like the old problems should be fixed. Multiple entries can be made per process. Expression search strings are updated with path or title changes. Added file check before trying to grab app icon.

Changes:

https://drive.google.com/file/d/1x4ApahGfFRX0eYKLiJw2kyf258E2qbwN/view?usp=sharing

mika-n commented 4 years ago

The latest WPF looks good. Auto-profile feature seems to work now great and 360-steeringWheel emulation mode works perfectly.

The next area where I did more testing was specialActions macro engine. Run on keyRelease, repeatWhileHeld, runSynchronized options seem to work. But there are couple issues in specAction screens:

Ryochan7 commented 4 years ago

Can you share the Actions.xml file that you are using for testing? I have mainly been testing with new actions so I have not had any legacy files to work with. I have not gotten around to creating an Actions.xml file in DS4Windows stable and trying it in the WPF version.

Editing time delays should work as they did last time I had tested it. I will double check the macro recorder.

With the last few commits that have been added to the repository, the WPF version is pretty much complete. Exploratory testing and testing the update process would be the last big tasks before a real transition can be made. I will get a new WPF build out shortly once I properly play test the recent changes. The problems that you have mentioned will likely still be present though.

Ryochan7 commented 4 years ago

Okay. I can confirm the lack of time delay editing. The TextBox gets hidden when it is given focus. Also I never got back to replacing that TextBox with an IntegerUpDown control.

Ryochan7 commented 4 years ago

New WPF build. Changes:

https://drive.google.com/file/d/1Jq0jMmvj4jHUw2sq4nq9rCpdw1ZfTJtl/view?usp=sharing

Ryochan7 commented 4 years ago

Looking into the Special Action problem now. There is supposed to be a flag to be able to distinguish between creating a new Special Action and editing an existing one; it does exist in the view model. The form validation code does not take it into account though. The validation code finds the previous version of the Special Action and sets the error flag for that field. It looks like this should be a simple fix.

Ryochan7 commented 4 years ago

New WPF build. Changes:

https://drive.google.com/file/d/1tKK6ZxZko-inNQGC_srcxEDJJ-8Vx57a/view?usp=sharing

Ryochan7 commented 4 years ago

Updated WPF build. Changes:

https://drive.google.com/file/d/1Nu2gJhGx9ZDQ1gnQP1qU2LwgPqjVvTyj/view?usp=sharing

mika-n commented 4 years ago

(hmm.... I thought I already commented this but looks like it is gone or I simply failed to press the "Comment" button).

Now specialAction editing and saving works (new vs edit). Modifying a delay in a recorded macro works and the app no longer crash when a delay line is removed from a macro.

.The latest change slight adjusted the width of a custom curve output textbox field (narrow but at the same time "..." button is wider). The new custom curve textBox is not wide enough to show the last few digits of "0.00, 0.00, 0.00, 0.00" curve definition string. Maybe the "..." button should be a bit smaller and the textBox few pixels wider?

Ryochan7 commented 4 years ago

Updated WPF beta build. Changes:

https://drive.google.com/file/d/1VQE_ukZhIo-009qr1BF2IEo5x7Q5mcLo/view?usp=sharing

Ryochan7 commented 4 years ago

Updated WPF build. Changes:

https://drive.google.com/file/d/1G-pfY2xCmUTtvHcqaTYxNjpVqkmS6N9L/view?usp=sharing

Ryochan7 commented 4 years ago

Updated WPF build. Changes:

https://drive.google.com/file/d/1Cn1m1ZbtC-PfS1B3nexBza_90cNIASnj/view?usp=sharing

Ryochan7 commented 4 years ago

Updated WPF build. Changes:

https://drive.google.com/file/d/19tQwR3p6HS1roTXGGWRO665oDUij-cDe/view?usp=sharing

Ryochan7 commented 4 years ago

At this point, I am planning on releasing DS4Windows 2.0 on Christmas Day. That will give me a little more time for testing and possibly implementing new functionality. Special Action migration was finally tested about two days ago and it seems to work perfectly fine.

Ryochan7 commented 4 years ago

Updated WPF build. Putting an update out now due to a problem with the Profile editor not closing after saving an existing profile. The event used to perform closing actions was moved in build 20191128 and all cases were not covered.

Changes:

https://drive.google.com/file/d/1A0644N-3TqQGFGJCjsaEvHJb_agP0Hm8/view?usp=sharing

Ryochan7 commented 4 years ago

Updated WPF build. This update is more meant for people to test the added output device change delay before it gets added to DS4Windows stable. There is now a 100 ms delay after plugging and unplugging output devices. A minor action queue is being utilized in the process.

Changes:

https://drive.google.com/file/d/128XDikjRcYEFbwgfqzqKBJfS0m9Q92Zl/view?usp=sharing

Ryochan7 commented 4 years ago

The WPF build has been partially migrated so now the executable will be DS4Windows.exe again. Also, an initial overwrite test has been done. An upgrade from DS4Windows 1.7.24 to version 1.9 has been successful. A newer WPF beta build will probably be released shortly.

I will hold off on migrating the code to this repo for a few more days. At least one more Windows Forms build of DS4Windows will be released before the update to version 2.0 is done. The plan is to make a backup branch with the final Windows Forms build code before replacing the code in the jay branch with the DS4WindowsWPF code.

Ryochan7 commented 4 years ago

Updated WPF build. Changes:

https://drive.google.com/file/d/1y1QhftReBbJD5cmw3qqnJz6UD1rw01BG/view?usp=sharing

Ryochan7 commented 4 years ago

Updated WPF build. Changes:

https://drive.google.com/file/d/1c0B0TDKSOyRSjseIJdPx133c7h7otYnk/view?usp=sharing

Ryochan7 commented 4 years ago

The WPF code has finally been imported into the jay branch. The old Windows Forms code has been placed in its own branch for archival purposes. It will probably be useful to refer back to the old code every once in a while.

https://github.com/Ryochan7/DS4Windows/tree/winforms

Ryochan7 commented 4 years ago

Looks like the updater won't do what I want. Just tried using it to copy the WPF files and I found a long standing problem. It can only copy files one directory deep. That means translation files never got updated and people that installed DS4Windows from before version 1.7.13 never had access to the curve editor. Making a couple of changes to copy along subdirectories allows the updater to update an installation to DS4Windows 1.9.1.

This is going to make the whole upgrade process much more complicated. A new WinForms build will have to be released with a new updater. Anyone who doesn't update in a week is likely going to run into problems.

Ryochan7 commented 4 years ago

Found another updater problem. Copying over the new updater in DS4Windows failed due to an invalid location file check. That error was my fault. Another new WinForms build (1.7.28) has been released.

Ryochan7 commented 4 years ago

Updated WPF beta build. At this point, no more changes should be needed and this build should be identical to DS4Windows 2.0 except for adding the update hooks back in and a changed version number. This should be the final beta build unless something significantly wrong is found with this version.

Changes:

https://drive.google.com/file/d/1zgTJ7lmpfCzIHi7IgwJ_2AZ0kXOrJ2Um/view?usp=sharing

mika-n commented 4 years ago

There is a small bug in WPF version while editing button re-maps of a profile using dualshock4 mode. The image of ds4 gamepad and all hotspots are slightly misaligned. Hotspots work but one must know where the hotspot is based on "misaligment offset". The following picture explains the issue.

DS4Win_RemapKeyHotSpotAligmentBug

Ryochan7 commented 4 years ago

Got Windows 10 back to the point where I could get VS set up. I must have missed changing the locations for the DS4 canvas when I edited that window last.