For those that don't know, SwitchMon is a program that lets you assign a button on your controller to cycle through your windowed game instances.
In short, I'm trying to modify its 10+ year old source code, since after adding a 4th & 5th account, I find it's random window order to be almost unusable (with 3 accounts, it was easy to get the order I wanted). So I figured I'd try to add up/down arrows next to the list of window handles to reorder them. Using the code here: https://sourceforge.net/p/ffxiswitchmon/code/HEAD/tree/
I'm not really a developer, and am completely new to C#, so I'm feeling a bit in over my head, but... I've read through much of the source code and understand the relevant parts that I want to change. But before making any changes, I figured I should see if I can even build a functional copy.
Using Visual Studio 2019 (also completely new to me), on a Windows 10 machine, I've gotten it to build successfully, and parts function fine (like enumerating the FFXI windows), but I can't get any of the Joystick code to work.
Here are the last 2 lines of Main():
Code
fMonitor app = new fMonitor(); Application.Run();
If I leave fMonitor's constructor as-is, I can't even step into it (just gets stuck on the fMonitor app = new fMonitor() line). Among others, it doesn't like this first line:
Code
joys = new Joy.Joysticks();
...unless I comment out the 2nd line in the Joysticks() constructor:
Code
public Joysticks() { //DirectX requires a host window to set the cooperation levels of devices m_form = new System.Windows.Forms.Form(); //m_joysticks = new List<Joystick>(); EnumJoysticks(); }
Probably my lack of C# knowledge, but I don't understand why it gets hung up on that 2nd line... isn't it just initializing an empty list?
Regardless, I get stuck soon after in EnumJoysticks(), on the 1st line (Manager.GetDevices):
Code
private void EnumJoysticks() { try { DeviceList dlJoyList = Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly); foreach(DeviceInstance diJoystick in dlJoyList) { Joystick item = new Joystick(this, diJoystick, m_form.Handle); m_joysticks.Add(item); } } #if DEBUG catch(Exception ex) { System.Diagnostics.Trace.WriteLine("EnumJoysticks: " + ex.Message); } #else catch {} #endif }
Manager.GetDevices is calling into Microsoft.DirectX.DirectInput.dll, and I have no idea how to debug what is going wrong. If I step into the program, it just sticks on this line without ever entering the catch block to print an exception. I have the original dll that comes with the release version, which seems to be the same version that comes in the last standalone DirectX SDK release (June 2010, file is dated 3/18/2005).
Any advice on where to go from here?
Is there some setting in Visual Studio that isn't playing nice with that old dll? Is there a newer dll I should try (my understanding is that the DirectX SDK has been included with the Windows SDK since Windows 8, but I don't find either Microsoft.DirectX.dll or Microsoft.DirectX.DirectInput.dll anywhere in my Windows Kits folder). Not sure if that functionality has moved to other dlls or what.
Would I have better luck trying this whole exercise on my old Windows 7 machine?