2014-03-28 02:50:40 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows.Forms;
|
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Diagnostics;
|
2014-11-18 22:23:41 +01:00
|
|
|
|
using System.ComponentModel;
|
2015-11-28 06:47:26 +01:00
|
|
|
|
using System.Globalization;
|
2017-04-20 07:54:09 +02:00
|
|
|
|
using Microsoft.Win32.TaskScheduler;
|
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
|
|
|
|
|
2014-11-18 22:23:41 +01:00
|
|
|
|
namespace DS4Windows
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
|
|
|
|
static class Program
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
|
|
|
|
static extern bool SetForegroundWindow(IntPtr hWnd);
|
|
|
|
|
|
2014-11-18 22:23:41 +01:00
|
|
|
|
// Add "global\" in front of the EventName, then only one instance is allowed on the
|
|
|
|
|
// whole system, including other users. But the application can not be brought
|
|
|
|
|
// into view, of course.
|
2017-07-03 17:31:58 +02:00
|
|
|
|
private static string SingleAppComEventName = "{a52b5b20-d9ee-4f32-8518-307fa14aa0c6}";
|
2014-11-18 22:23:41 +01:00
|
|
|
|
private static EventWaitHandle threadComEvent = null;
|
2017-07-03 17:31:58 +02:00
|
|
|
|
private static bool exitComThread = false;
|
2015-02-08 22:51:52 +01:00
|
|
|
|
public static ControlService rootHub;
|
2017-09-06 04:28:54 +02:00
|
|
|
|
private static Thread testThread;
|
2017-09-08 08:29:35 +02:00
|
|
|
|
private static Thread controlThread;
|
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The main entry point for the application.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[STAThread]
|
2014-11-18 22:23:41 +01:00
|
|
|
|
static void Main(string[] args)
|
2014-03-28 02:50:40 +01:00
|
|
|
|
{
|
2017-10-06 09:29:57 +02:00
|
|
|
|
//Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("ja");
|
2017-04-20 07:54:09 +02:00
|
|
|
|
for (int i = 0, argsLen = args.Length; i < argsLen; i++)
|
2014-12-02 01:07:29 +01:00
|
|
|
|
{
|
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
|
|
|
|
string s = args[i];
|
2014-12-13 21:12:03 +01:00
|
|
|
|
if (s == "driverinstall" || s == "-driverinstall")
|
2014-12-02 01:07:29 +01:00
|
|
|
|
{
|
|
|
|
|
Application.EnableVisualStyles();
|
2018-01-31 05:20:46 +01:00
|
|
|
|
Application.Run(new WelcomeDialog(true));
|
2014-12-02 01:07:29 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
|
|
|
|
else if (s == "re-enabledevice" || s == "-re-enabledevice")
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
i++;
|
|
|
|
|
string deviceInstanceId = args[i];
|
|
|
|
|
DS4Devices.reEnableDevice(deviceInstanceId);
|
|
|
|
|
Environment.ExitCode = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{
|
|
|
|
|
Environment.ExitCode = Marshal.GetLastWin32Error();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-04-20 07:54:09 +02:00
|
|
|
|
else if (s == "runtask" || s == "-runtask")
|
|
|
|
|
{
|
|
|
|
|
TaskService ts = new TaskService();
|
|
|
|
|
Task tasker = ts.FindTask("RunDS4Windows");
|
|
|
|
|
if (tasker != null)
|
|
|
|
|
{
|
|
|
|
|
tasker.Run("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Environment.ExitCode = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-12-02 01:07:29 +01:00
|
|
|
|
}
|
2017-06-20 06:37:08 +02:00
|
|
|
|
|
2014-03-28 02:50:40 +01:00
|
|
|
|
System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.LowLatency;
|
2017-04-21 05:09:08 +02:00
|
|
|
|
|
2014-03-29 06:29:08 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
2017-07-03 17:31:58 +02:00
|
|
|
|
Process.GetCurrentProcess().PriorityClass =
|
|
|
|
|
ProcessPriorityClass.High;
|
2014-03-29 06:29:08 +01:00
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// Ignore problems raising the priority.
|
|
|
|
|
}
|
2017-04-21 05:09:08 +02:00
|
|
|
|
|
2014-11-18 22:23:41 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// another instance is already running if OpenExsting succeeds.
|
|
|
|
|
threadComEvent = EventWaitHandle.OpenExisting(SingleAppComEventName);
|
|
|
|
|
threadComEvent.Set(); // signal the other instance.
|
|
|
|
|
threadComEvent.Close();
|
|
|
|
|
return; // return immediatly.
|
|
|
|
|
}
|
|
|
|
|
catch { /* don't care about errors */ }
|
2017-04-21 05:09:08 +02:00
|
|
|
|
|
2014-11-18 22:23:41 +01:00
|
|
|
|
// Create the Event handle
|
2017-07-03 17:31:58 +02:00
|
|
|
|
threadComEvent = new EventWaitHandle(false, EventResetMode.ManualReset, SingleAppComEventName);
|
2017-09-06 04:28:54 +02:00
|
|
|
|
//System.Threading.Tasks.Task.Run(() => CreateTempWorkerThread());
|
|
|
|
|
//CreateInterAppComThread();
|
|
|
|
|
CreateTempWorkerThread();
|
|
|
|
|
//System.Threading.Tasks.Task.Run(() => { Thread.CurrentThread.Priority = ThreadPriority.Lowest; CreateInterAppComThread(); Thread.CurrentThread.Priority = ThreadPriority.Lowest; }).Wait();
|
Version 1.4.5
Added support for the New DS4 USB Adapater (Thanks to boganhobo and
Chamilsaan)
Implemented teokp's amazing fix for hide ds4 not working on the
anniversary update of Windows 10: when a controller fails to enter
exclusive mode, DS4Windows will ask for admin privilages to fix the
issue.
Now (near)unlimited Special Actions can be made from the previous limit
of 50
Special Action Xbox Game DVR is now no longer limited to Windows 10,
renamed multi action button: Assign a macro to single tap, double tap,
and holding down a button
Added option for White DS4Windows Icon in the notification tray (While
not merged from, thanks to tehmantra)
Added option to temporarily turn off DS4Windows when using a certain
program (togglable in the Auto Profiles Tab) (Same case as above but
thanks to dedChar to bring to light)
Fixed Options crashes in certain locales where decimal points are
repesented with commas, such as German (Thanks to kiliansch)
Added/Updated translations for many languauges, now including Japanese,
Slovenian, Hungarian, Greek, Finnish, Czech, Indonesian, and Ukrainian
2016-09-22 03:38:38 +02:00
|
|
|
|
|
2017-07-03 10:24:54 +02:00
|
|
|
|
//if (mutex.WaitOne(TimeSpan.Zero, true))
|
|
|
|
|
//{
|
2017-09-08 05:37:56 +02:00
|
|
|
|
createControlService();
|
2017-11-21 10:30:41 +01:00
|
|
|
|
rootHub.createHidGuardKey();
|
2017-09-08 05:37:56 +02:00
|
|
|
|
//rootHub = new ControlService();
|
2014-11-18 22:23:41 +01:00
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
|
Application.Run(new DS4Form(args));
|
2017-11-21 10:30:41 +01:00
|
|
|
|
rootHub.removeHidGuardKey();
|
2017-07-03 17:31:58 +02:00
|
|
|
|
//mutex.ReleaseMutex();
|
2017-07-03 10:24:54 +02:00
|
|
|
|
//}
|
2014-11-18 22:23:41 +01:00
|
|
|
|
|
2017-07-03 17:31:58 +02:00
|
|
|
|
exitComThread = true;
|
|
|
|
|
threadComEvent.Set(); // signal the other instance.
|
2017-09-06 12:21:03 +02:00
|
|
|
|
while (testThread.IsAlive)
|
|
|
|
|
Thread.SpinWait(500);
|
2014-11-18 22:23:41 +01:00
|
|
|
|
threadComEvent.Close();
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 05:37:56 +02:00
|
|
|
|
private static void createControlService()
|
|
|
|
|
{
|
2017-09-08 08:29:35 +02:00
|
|
|
|
controlThread = new Thread(() => { rootHub = new ControlService(); });
|
|
|
|
|
controlThread.Priority = ThreadPriority.Normal;
|
|
|
|
|
controlThread.IsBackground = true;
|
|
|
|
|
controlThread.Start();
|
|
|
|
|
while (controlThread.IsAlive)
|
2017-09-08 05:37:56 +02:00
|
|
|
|
Thread.SpinWait(500);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 04:28:54 +02:00
|
|
|
|
private static void CreateTempWorkerThread()
|
|
|
|
|
{
|
2017-09-06 12:21:03 +02:00
|
|
|
|
testThread = new Thread(singleAppComThread_DoWork);
|
2017-09-06 04:28:54 +02:00
|
|
|
|
testThread.Priority = ThreadPriority.Lowest;
|
|
|
|
|
testThread.IsBackground = true;
|
|
|
|
|
testThread.Start();
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 12:21:03 +02:00
|
|
|
|
private static void singleAppComThread_DoWork()
|
2014-11-18 22:23:41 +01:00
|
|
|
|
{
|
|
|
|
|
WaitHandle[] waitHandles = new WaitHandle[] { threadComEvent };
|
|
|
|
|
|
2017-07-03 17:31:58 +02:00
|
|
|
|
while (!exitComThread)
|
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
|
|
|
|
{
|
2014-11-18 22:23:41 +01:00
|
|
|
|
// check every second for a signal.
|
2017-07-03 10:24:54 +02:00
|
|
|
|
if (WaitHandle.WaitAny(waitHandles) == 0)
|
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
|
|
|
|
{
|
2017-07-03 17:31:58 +02:00
|
|
|
|
threadComEvent.Reset();
|
2014-11-18 22:23:41 +01:00
|
|
|
|
// The user tried to start another instance. We can't allow that,
|
|
|
|
|
// so bring the other instance back into view and enable that one.
|
|
|
|
|
// That form is created in another thread, so we need some thread sync magic.
|
2017-07-03 17:31:58 +02:00
|
|
|
|
if (!exitComThread && Application.OpenForms.Count > 0)
|
2014-11-18 22:23:41 +01:00
|
|
|
|
{
|
|
|
|
|
Form mainForm = Application.OpenForms[0];
|
2017-08-17 01:00:44 +02:00
|
|
|
|
mainForm?.Invoke(new SetFormVisableDelegate(ThreadFormVisable), mainForm);
|
2014-11-18 22:23:41 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// When this method is called using a Invoke then this runs in the thread
|
|
|
|
|
/// that created the form, which is nice.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="frm"></param>
|
|
|
|
|
private delegate void SetFormVisableDelegate(Form frm);
|
|
|
|
|
static private void ThreadFormVisable(Form frm)
|
|
|
|
|
{
|
2014-11-18 23:07:27 +01:00
|
|
|
|
if (frm != null)
|
2014-11-18 22:23:41 +01:00
|
|
|
|
{
|
|
|
|
|
if (frm is DS4Form)
|
|
|
|
|
{
|
|
|
|
|
// display the form and bring to foreground.
|
|
|
|
|
frm.WindowState = FormWindowState.Normal;
|
2014-11-18 23:07:27 +01:00
|
|
|
|
frm.Focus();
|
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-11-18 22:23:41 +01:00
|
|
|
|
WinProgs wp = (WinProgs)frm;
|
2014-11-20 20:03:18 +01:00
|
|
|
|
wp.form.mAllowVisible = true;
|
2014-11-18 22:23:41 +01:00
|
|
|
|
wp.ShowMainWindow();
|
|
|
|
|
SetForegroundWindow(wp.form.Handle);
|
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-06-20 06:37:08 +02:00
|
|
|
|
|
2014-11-18 22:23:41 +01:00
|
|
|
|
SetForegroundWindow(frm.Handle);
|
2014-03-28 02:50:40 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-11-18 22:23:41 +01:00
|
|
|
|
}
|