Author |
Message |
JulianR
One Eyed Hopeful
Joined: Mon Jun 17, 2013 11:58 am Posts: 5
|

The back story: After the remake of Age of Empires II I searched for my old Sidewinder Strategic Commander and found it in old box. Sadly the drivers don't work with Windows 7 but the device registers a regular USB HID Device. So I started reverse engineering the protocol and I started writing a small replacement for the original Sidewinder Tool in C#. I managed to read the Device but never finished the complete readout or the button emulation part. Today, by sheer luck, I discovered the wonderful FreePIE project. It took me the afternoon but I adopted my early unfinished work to FreePIE and finished it. The Plugin: Attached in the archive is the plugin including the source files, a binary, a sample script and my revers engineering results. Just copy the dll to the plugins directory and you are good to go. I used ILMerge to bind the HidLibrary into the dll so if you build it yourself you have to copy the HidLibrary.dll to the FreePIE root directory. Known Bugs: - FreePIE 0.6.277.0 crashes when no SideWinder is connected. Works in GIT Version
- FreePIE does not close after using the plugin (does not happen when I build it as Debug) seems to be a local issue, see my reply below
PS: I am from Germany so sorry for the bad English.
You do not have the required permissions to view the files attached to this post.
Last edited by JulianR on Sat Jun 22, 2013 6:25 am, edited 2 times in total.
|
Mon Jun 17, 2013 12:16 pm |
|
 |
CyberVillain
Petrif-Eyed
Joined: Mon Jun 22, 2009 8:36 am Posts: 2160 Location: Stockholm, Sweden
|
Welcome to the forum Julian and thanks for trying out FreePIE's plugin API! Nice work on integrating that old thing into FreePIE  About your problems 1) Start method should be protected, meaning any errors thrown here should not crash FreePIE. But... If the error is thrown from unmanaged code (C library etc) it can take FreePIE with it. Managed code (C# etc) should work. 2) Again sounds like some unmanaged code not being disposed correctly, or if you have a background thread not being aborted. I will have to look at the code to know more, will let you know what I find
_________________FreePIEMy blog
|
Tue Jun 18, 2013 1:18 am |
|
 |
CyberVillain
Petrif-Eyed
Joined: Mon Jun 22, 2009 8:36 am Posts: 2160 Location: Stockholm, Sweden
|
https://github.com/mikeobrien/HidLibrary is unmanaged? Maybe if you through a error in Start and the library is half initialized it wont exit correctly? Maybe you need to call some sort of dispose function on it? Im just guessing here.
_________________FreePIEMy blog
|
Tue Jun 18, 2013 1:24 am |
|
 |
JulianR
One Eyed Hopeful
Joined: Mon Jun 17, 2013 11:58 am Posts: 5
|

Thanks for the reply The error is thrown by my plugin, so the code is managed: Code: public Action Start() { device = HidDevices.Enumerate(VendorId, ProductId).FirstOrDefault();
if (device != null) { connectedToDriver = true; device.OpenDevice();
device.MonitorDeviceEvents = true;
device.ReadReport(OnReport);
//reset LEDs device.WriteFeatureData(new byte[] { 0x01, 0x00, 0x00 }); //request initial State device.WriteFeatureData(new byte[] { 0x02, 0x10 ,0x10 }); } //trowing an exception crashes FreePIE else { throw new Exception("Unable to Connection to Sidewinder"); } return null; The method needs to be public otherwise the IPlugin Interface is implemented incorrect and it won't build. The "not closing" Bug seems to be a Problem with my PC and/or having freePIE in the Windows Programs directory. I removed it completely, reinstallied it (without my Plugin) but the Problem is still there (just starting an empty script with only a comment line). The copy of freePIE in my VS Project directory (I used for debugging) works great even with the Release Build DLL attached in this thread.
|
Tue Jun 18, 2013 9:12 am |
|
 |
CyberVillain
Petrif-Eyed
Joined: Mon Jun 22, 2009 8:36 am Posts: 2160 Location: Stockholm, Sweden
|
If you remove all code from start and just throw an exception, does thst work?
_________________FreePIEMy blog
|
Tue Jun 18, 2013 10:18 am |
|
 |
JulianR
One Eyed Hopeful
Joined: Mon Jun 17, 2013 11:58 am Posts: 5
|
No freePIE still crashes with only the exception throwing and no USB Code. I get and System.InvalidOperationException which can not be traced. My plugin (the attached version) works fine when no device is connected. In this case the readouts are all zero and setting an LED won't do anything. I just thought it would be nice to print an error in freePIE when no device could be found.
|
Tue Jun 18, 2013 10:59 am |
|
 |
CyberVillain
Petrif-Eyed
Joined: Mon Jun 22, 2009 8:36 am Posts: 2160 Location: Stockholm, Sweden
|
Just tried with throwing a Exception in the Start, works as it should and a error is presented in the Error window.
You use the installer versions or the latest version from Github by the way? If UAC is turned on then the installer versions need admin rights. This is fixed in latest version, its caused because we saved the settings file in the FreePIE folder, programs are not allowed todo this without admin rights in W7. Current version on Github saves the data to the app_data folder instead.
_________________FreePIEMy blog
|
Tue Jun 18, 2013 3:24 pm |
|
 |
JulianR
One Eyed Hopeful
Joined: Mon Jun 17, 2013 11:58 am Posts: 5
|
You are correct. It is a Problem with the installer Version. With the GIT Version it works great. I updated my plugin and attached the new version in the first post. I also added the option to use the shift buttons as an integer as it was intended by the original Software.
|
Sat Jun 22, 2013 6:27 am |
|
 |
CyberVillain
Petrif-Eyed
Joined: Mon Jun 22, 2009 8:36 am Posts: 2160 Location: Stockholm, Sweden
|
Nice that that works, strange thing is I cant find anything in the git log suggestion any differences in the code regarding the python engine  The other problem with FreePIE not exiting correctly still remains?
_________________FreePIEMy blog
|
Sat Jun 22, 2013 6:44 am |
|
 |
JulianR
One Eyed Hopeful
Joined: Mon Jun 17, 2013 11:58 am Posts: 5
|
The closing problem still exists. But only on the installer version and even without a script and my plugin. Just starting and closing freezes FreePIE. I am pretty sure its a permission problem. It works when I start FreePIE as Administrator.
|
Sat Jun 22, 2013 10:24 am |
|
 |
CyberVillain
Petrif-Eyed
Joined: Mon Jun 22, 2009 8:36 am Posts: 2160 Location: Stockholm, Sweden
|
ah ok so then all is solved with latest version then, good
_________________FreePIEMy blog
|
Sat Jun 22, 2013 2:19 pm |
|
 |
|