Trying To Modify FFXISwitchMon (need Help)

言語: JP EN DE FR
2010-06-21
New Items
users online
フォーラム » Windower » Support » Trying to modify FFXISwitchMon (need help)
Trying to modify FFXISwitchMon (need help)
Offline
Posts: 46
By kaiju9 2019-06-09 19:44:07  
Apologies for not being about Windower, but this seemed like an appropriate audience.

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?
[+]
 Bahamut.Neb
Offline
サーバ: Bahamut
Game: FFXI
user: Neb
Posts: 189
By Bahamut.Neb 2019-06-09 21:34:49  
just use AutoHotKey man so much easier

https://www.ffxiah.com/forum/topic/47135/ffxi-switch-monitor
Offline
Posts: 42635
By Jetackuu 2019-06-09 21:41:31  
Well first off what type of controller are you using? Xinput or directinput?

Secondly you may want to inquire in the windower discord, again it not being windower nobody may take the time but there's very knowledgeable persons on there that view it more than here (or typically).
Offline
Posts: 46
By kaiju9 2019-06-09 21:49:37  
Had a bit of a breakthrough.


With all of the joystick code commented out, I was able to get to a point where I was getting an exception like this:
Code
Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in 
the 4.0 runtime without additional configuration information.


After some searching, I was able to get past this by adding an Application Configuration file to the project, and adding this within the <configuration> section:
Code
<startup useLegacyV2RuntimeActivationPolicy="true" > 
</startup>


Then I tried un-commenting the joystick code, and it seems the above configuration allowed me to actually see the exception that was happening with Microsoft.DirectX.DirectInput.dll:
Code
Managed Debugging Assistant 'LoaderLock' : 'DLL 
'C:\Windows\assembly\GAC\Microsoft.DirectX.DirectInput\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.DirectInput.dll' 
is attempting managed execution inside OS Loader lock. 
Do not attempt to run managed code inside a DllMain or 
image initialization function since doing so can cause 
the application to hang.'


I don't know how to fix that, or how bad it is, but the articles I read simply suggested disabling the LoaderLock exception, which I did.

Compiled exe seems to be functional. Now to figure out how to make the changes I want...
Offline
Posts: 46
By kaiju9 2019-06-09 21:53:25  
Bahamut.Neb said: »

I know I've read that thread before, not sure why I didn't pursue it. Maybe I'll give it a try.

Jetackuu said: »
Well first off what type of controller are you using? Xinput or directinput?

Secondly you may want to inquire in the windower discord, again it not being windower nobody may take the time but there's very knowledgeable persons on there that view it more than here (or typically).

Thanks for the Discord suggestion. Will keep it in mind if I keep going and get stuck again.
Offline
Posts: 46
By kaiju9 2019-06-09 22:13:13  
Well the AutoHotKey thing is working great. Also solves the problem I had with FFXISwitchMon where every time my controller shut off, I'd have to reload the program. AHK resumes just fine.
 Bahamut.Neb
Offline
サーバ: Bahamut
Game: FFXI
user: Neb
Posts: 189
By Bahamut.Neb 2019-06-09 23:59:27  
YA i messed with Switchmon forever till i found this is so simple
 Cerberus.Gillesjboulon
Offline
サーバ: Cerberus
Game: FFXI
user: gilles
Posts: 134
By Cerberus.Gillesjboulon 2019-06-10 11:57:17  
ffxi switch monitor use managed directx for .net
you need to download directx sdk (an old version probably)
then you add a reference to C:\Windows\Microsoft.NET\DirectX for Managed Code\directinput.dll
if you didn't did this, this is why you have compilation errors

i already played with the list when i added support for FFXIV
http://forums.windower.net/index.php@sharelink=download%3BaHR0cDovL2ZvcnVtcy53aW5kb3dlci5uZXQvaW5kZXgucGhwPy90b3BpYy8xMDg4LWZmby1zd2l0Y2gtbW9uaXRvci8,%3BRkZPIFN3aXRjaCBNb25pdG9y.html

well, maybe i can do this if i have free time next week-end
Offline
Posts: 3
By Benu 2019-06-13 13:24:21  
If it's only the random order that's annoying you (Sry only flew through the post because I'm at work) all you need to do is clicking on the characters windows in the order you want them before turning switch mon on (with your controller alrdy on if it's not wired)
[+]
 Bismarck.Cloudstrafie
Offline
サーバ: Bismarck
Game: FFXI
user: cloud7886
Posts: 148
By Bismarck.Cloudstrafie 2019-06-13 16:42:00  
Benu said: »
If it's only the random order that's annoying you (Sry only flew through the post because I'm at work) all you need to do is clicking on the characters windows in the order you want them before turning switch mon on (with your controller alrdy on if it's not wired)

Would be nice but one of them randomly crashes or dc's (thanks SE) whole order gets messed up, And noway to change it without having to log everyone off and back in or deal with the new order.
 Ragnarok.Corvinus
Online
サーバ: Ragnarok
Game: FFXI
user: Xiong
Posts: 79
By Ragnarok.Corvinus 2019-06-13 20:29:34  
@Cloudstraie

Nah, you just close switchmon. Log the crashed character back in. Alt-Tab the window order you want, then boot up switchmon again.
 Cerberus.Gillesjboulon
Offline
サーバ: Cerberus
Game: FFXI
user: gilles
Posts: 134
By Cerberus.Gillesjboulon 2019-06-14 20:13:40  
The Alt+Tab order is based on the detection of the POL client windows.
If you want a specific FFXI windows order, you have to start each POL clients in that specific order.
Problem is that if 1 POL client crash, that specific order can become false.
I added a feature which let you manually order at any time :

I added too the title column which identify better a POL client than the hWnd column.
binaries
source
[+]
necroskull Necro Bump Detected! [280 days between previous and next post]
Offline
Posts: 25
By Icydeath 2020-03-20 23:28:24  
{Necro} Just wanted to say this small change is made of win! Tyvm
Log in to post.