- Joined
- Aug 6, 2011
- Messages
- 405
- Reaction score
- 2
- Points
- 18
I have created a working DGIV simpit, ableit not completed, that uses pushbuttons and toggle switches to simulate the buttons (such as airlock, thruster doors, apu power, etc).
Due to time limitations, it isn't finished but here are some pictures of what I have done so far.
Image of front MFD panel with fuel display
Overall simulator without side panels
Wiring of MFD panel
The MFD's are run using ExternalMFD and AutoHotKey. The script creates two externalMFD's and simulates keypresses on them.
The fuel display is also done using AutoHotKey.
To simulate all of the DGIV buttons, I use the following basic function.
In my code, I replaced shipName with "DGIV_SIM"; to control a dgiv, I just rename it DGIV_SIM in the scenerio.
To simulate a "mouse event" on the panel, I had to find out the id,event,mx, and my values for all of the DGIV switches. To do this, I did the following.
This uses Face's VesselHook and HookMethods, to which I edited the line 299, the print line inside HookMethods::clbkPanelMouseEvent from
to
This meant that any mouse click on the DGIV' panel would be outputted to the log file at Your_Orbiter_Folder\Modules\Plugin\Events.log in a simple line format.
Sample Events.log
From this, I could extract the event,id,mx,and my value for every switch on the DGIV.
Here is a quick spreadsheet I made with the event,id,mx,and my values for every switch on the DGIV.
https://dl.dropbox.com/u/4618573/DGIV%20Sim%20Switches.xlsx
To wire the switches, I used an Arduino and two mulitplexers (https://www.sparkfun.com/products/299), wired a push button or toggle switch to the multiplexers, and programmed the Arduino to output when a switch's state changes to the computer, which is intercepted by my Orbiter module. If anyone wants to see my Arduino code, I'll post it.
My Orbiter module (I will post it as soon as I finish it) takes a updated switch state from the Arduino, finds which DGIV switch it corresponds to using a config file, and sends the DGIV the correct panelMouseEvent code.
After I finish wiring all of the panels, I plan on adding LED's to change with different states of the DGIV.
Hopefully this is helpful for other simpit builders, as we can now simulate any panel switch in our simpits.
Also, thanks Face for the vessel hooking code! I couldn't have done it without your help :tiphat:
Due to time limitations, it isn't finished but here are some pictures of what I have done so far.
Image of front MFD panel with fuel display
Overall simulator without side panels
Wiring of MFD panel
The MFD's are run using ExternalMFD and AutoHotKey. The script creates two externalMFD's and simulates keypresses on them.
The fuel display is also done using AutoHotKey.
To simulate all of the DGIV buttons, I use the following basic function.
Code:
OBJHANDLE hsimVessel = oapiGetVesselByName(shipName);
((VESSEL2 *)oapiGetVesselInterface(hsimVessel))->clbkPanelMouseEvent(id,event,mx,my)
To simulate a "mouse event" on the panel, I had to find out the id,event,mx, and my values for all of the DGIV switches. To do this, I did the following.
Code:
DLLCLBK void opcFocusChanged (OBJHANDLE hGainsFocus, OBJHANDLE hLosesFocus)
{
OBJHANDLE hVessel = oapiGetVesselByName("DGIV_SIM");
if (hGainsFocus == hVessel && oapiIsVessel(hVessel))
{
InstallVesselHook((VESSEL2 *)oapiGetVesselInterface(hGainsFocus));
SetEventsEnabled(true);
}
if (hLosesFocus == hVessel && oapiIsVessel(hVessel))
{
RemoveVesselHook((VESSEL2 *)oapiGetVesselInterface(hGainsFocus));
SetEventsEnabled(false);
}
}
This uses Face's VesselHook and HookMethods, to which I edited the line 299, the print line inside HookMethods::clbkPanelMouseEvent from
Code:
fprintf(l, "%d[%s]M(%d) %d: %d %d\n", GetTickCount(), this->GetName(), ev, id, mx, my);
Code:
fprintf(l,"%d,%d,%d,%d\n",ev,id,mx,my);
This meant that any mouse click on the DGIV' panel would be outputted to the log file at Your_Orbiter_Folder\Modules\Plugin\Events.log in a simple line format.
Code:
(Vessel hooking system initiated)
(Class table was empty)
(Vessel table was empty)
Vessel hooked
Class hooked
1,233,10,8
1,233,13,30
From this, I could extract the event,id,mx,and my value for every switch on the DGIV.
Here is a quick spreadsheet I made with the event,id,mx,and my values for every switch on the DGIV.
https://dl.dropbox.com/u/4618573/DGIV%20Sim%20Switches.xlsx
To wire the switches, I used an Arduino and two mulitplexers (https://www.sparkfun.com/products/299), wired a push button or toggle switch to the multiplexers, and programmed the Arduino to output when a switch's state changes to the computer, which is intercepted by my Orbiter module. If anyone wants to see my Arduino code, I'll post it.
My Orbiter module (I will post it as soon as I finish it) takes a updated switch state from the Arduino, finds which DGIV switch it corresponds to using a config file, and sends the DGIV the correct panelMouseEvent code.
After I finish wiring all of the panels, I plan on adding LED's to change with different states of the DGIV.
Hopefully this is helpful for other simpit builders, as we can now simulate any panel switch in our simpits.
Also, thanks Face for the vessel hooking code! I couldn't have done it without your help :tiphat: