Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter Web Forum > Simpit Forum
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Simpit Forum Share & discuss simpit projects for Orbiter here!

Reply
 
Thread Tools
Old 07-30-2012, 01:46 AM   #16
yagni01
Addon Developer

Default

You can look at this image of my flight deck using 2 instances of RemoteMFD each holding 2 displays http://imageshack.us/photo/my-images...bemfdops2.jpg/, but essentially it means sending 2 mfds in one vnc window to make it "appear" to be a single display. Picture a surfaceMFD above and orbitMFD aligned vertically below, with the orbitMFD moved up to cover the upper PWR/SEL/MNU buttons, and without the second window bar. The "hidden" SEL button(s) for the surfaceMFD would be painted alongside the ones for the lower orbitMFD. Hope this was clearer than mud.
yagni01 is offline   Reply With Quote
Old 07-30-2012, 08:52 AM   #17
kamaz
Unicorn hunter
 
kamaz's Avatar
Default

This can be done client-side.

1. Configure the server to send just the MFD screen image without rendering buttons. This functionality will be provided soon.

2. Write a client rendering two VNC framebuffers in one window producing the geometry you want (i.e. a client which instantiates a VNC viewer class twice in one window). There is a multitude of embeddable VNC client classes:
- Java applet for web pages;
- Java class;
- SDL: http://www.ferzkopp.net/Software/SDL_vnc/
- MFC: http://www.pjtec.com/Products/GovVNC/index.htm
- .NET: http://dotnetvnc.sourceforge.net/

3. Then we just need some socket interface to transmit button presses and labels between the server and client.

In principle, the server could render two or more MFDs into the same VNC server, but the code handling button presses is currently built on assumption that each MFD has its own VNC server.

Last edited by kamaz; 07-30-2012 at 09:02 AM.
kamaz is offline   Reply With Quote
Old 07-31-2012, 10:14 PM   #18
kamaz
Unicorn hunter
 
kamaz's Avatar
Default

New version with Cougar support

Attached is a new version of the plug-in (rev 25), with Cougar support included.

Changes:

- VNC servers keep running between simulations. No need to reconnect the client.

- Panel layout and buttons are fully configurable via the VNCMFD.ini file. This file must be placed in Orbiter's root directory. See comments in the file for details.

- Number of MFDs is set using the config file. There is no hard limit.

- Thrustmaster Cougar MFD support is added. If you don't have Cougars, please use VNCMFD-noCougars.ini file instead (i.e. rename it to VNCMFD.ini).

Have fun
Attached Thumbnails
transx_1280.jpg   iss_docking_1280.jpg  
Attached Files
File Type: zip VNCMFD-rev25.zip (2.13 MB, 36 views)
kamaz is offline   Reply With Quote
Thanked by:
Old 07-31-2012, 10:22 PM   #19
SolarLiner
It's necessary, TARS.
 
SolarLiner's Avatar
Default

There is a way to put the input box into the VNC client ? Because, for example I'm on IMFD, setting target, and I must go on my computer to enter the target. In the case of a "Mission Central Command" addon witch takes your VNC support, this couldn't be a realistic way.
SolarLiner is offline   Reply With Quote
Old 07-31-2012, 11:17 PM   #20
kamaz
Unicorn hunter
 
kamaz's Avatar
Default

Note on API access and Orb::Connect support

MFDs running under VNCMFD can be accessed using Orbiter's API calls, e.g. oapiOpenMFD() and remotely via Orb::Connect. Orb::Connect access to MFDs running under VNCMFD has been tested by me and it works, subject to one caveat below.

Orbiter API requires MFD identifier to be passed to the function call. In case of MFDs embedded on spacecraft panels, these identifiers are known (0 for the left MFD, 1 for the right MFD). In case of MFD displays derived from ExternMFD class (including VNCMFD), these MFD identifiers are unpredictable 32-bit numbers (it is simply an object pointer cast to UINT, if you are really interested in such details). To my knowledge, there is no API function which can be used to obtain the list of identifiers of all MFDs currently running.

For debugging and testing purposes, the MFD identifier can be obtained from the VNCMFD.log file, where a line like the following is written for each MFD instance:

Code:
2012-07-31 23:56:14.025 Thread 4724 MFDPanel.cpp:  26:MFDPanel(1001)::MFDPanel Creating instance Id()=85388328
where 85388328 is the MFD identifier.

Of course, this is no solution for programming. For this reason, VNCMFD.dll provides two extra DLL entry points, which allow other modules to obtain the identifiers in question. The export definition is:

Code:
extern "C" __declspec(dllexport) UINT *GetMfdIds(void);
extern "C" __declspec(dllexport) LPSTR *GetMfdNames(void);
Calling GetMfdIds() returns a NULL-terminated array of MFD identifiers.
Calling GetMfdNames() returns a NULL-terminated array of corresponding MFD names.

The following drop-in function can be used in another module to obtain the identifiers (no need to mess with linker settings):

Code:
UINT *GetVncMfdIds(void) {
	HMODULE hMod = GetModuleHandle("VNCMFD.dll");
	if ( ! hMod )
		return NULL;

	if ( hMod ) {
		FARPROC lpfnGetMfdIds = GetProcAddress(hMod, "GetMfdIds");
		if ( ! lpfnGetMfdIds )
			return NULL;

		return (UINT*) lpfnGetMfdIds();
	}
}
Here is usage example:

Code:
	UINT *ids = GetVncMfdIds();
	UINT *id = ids;
	while (*id) {
		Log("Panel id=%d", *id);
		id++;
	}


---------- Post added at 11:17 PM ---------- Previous post was at 10:37 PM ----------

Quote:
Originally Posted by SolarLiner View Post
 There is a way to put the input box into the VNC client ?
No. This is a limitation of the Orbiter core.

MFDs call oapiOpenInputBox() to read user data, and oapiOpenInputBox() always renders the dialog box into the main window.
kamaz is offline   Reply With Quote
Old 08-01-2012, 03:14 AM   #21
yagni01
Addon Developer

Default

Quote:
Originally Posted by kamaz View Post
 MFDs call oapiOpenInputBox() to read user data, and oapiOpenInputBox() always renders the dialog box into the main window.
Is there a way to hook it?

I look forward to the next evolution
yagni01 is offline   Reply With Quote
Old 08-01-2012, 07:35 PM   #22
kamaz
Unicorn hunter
 
kamaz's Avatar
Default

Actually, I think this add-on is complete as far as I am concerned.

The basic functionality (i.e. viewing the MFD on another device) works. Touch screen device can be used. The panel layout is user configurable. As an icing on the cake, the Cougar frames can be used to control the MFDs. So, this completes support for my setup. Also, given that MFDs are the most problematic thing in the simpit, I think I have made a small breakthrough by demonstrating how to make 2 MFDs for a mere 180 EUR

Hooks in the DLL for integration with Orb::Connect etc. are provided. It's now left to add VNCMFD support in Orb::Connect, so Orb::Connect can be used for controllling the MFD buttons in a simpit environment, if you want to use something other then Cougars.

So, basically, I do not see any missing features

I now have some ideas about what to do with unused buttons on the Cougars, but this will likely take form of a separate add-on.
kamaz is offline   Reply With Quote
Old 08-01-2012, 08:33 PM   #23
Zatnikitelman
Addon Developer
 
Zatnikitelman's Avatar
Default

I've been lurking in this topic, following your progress since you first posted this and I must say, I'm impressed. I tried this out on my phone and have no problems with it. This looks great for simpit builders!
Zatnikitelman is offline   Reply With Quote
Old 08-01-2012, 11:49 PM   #24
yagni01
Addon Developer

Default

Quote:
Originally Posted by kamaz View Post
 Actually, I think this add-on is complete as far as I am concerned.

The basic functionality (i.e. viewing the MFD on another device) works. Touch screen device can be used. The panel layout is user configurable. As an icing on the cake, the Cougar frames can be used to control the MFDs. So, this completes support for my setup. Also, given that MFDs are the most problematic thing in the simpit, I think I have made a small breakthrough by demonstrating how to make 2 MFDs for a mere 180 EUR

Hooks in the DLL for integration with Orb::Connect etc. are provided. It's now left to add VNCMFD support in Orb::Connect, so Orb::Connect can be used for controllling the MFD buttons in a simpit environment, if you want to use something other then Cougars.

So, basically, I do not see any missing features

I now have some ideas about what to do with unused buttons on the Cougars, but this will likely take form of a separate add-on.
For 'readonly' MFDs you pretty much have it. I would like a config value to set the default frame rate (I would like to start with it high).

As SolarLiner suggests, for MFDs that require target input (Orbit, IMFD, etc.), a way to provide that input box remotely would be extremely valuable. Please give it some thought.

Last edited by yagni01; 08-05-2012 at 12:20 AM.
yagni01 is offline   Reply With Quote
Old 08-05-2012, 12:23 AM   #25
yagni01
Addon Developer

Default

I just had a thought that could take this tablet idea to the next level. . . replicating the multifunction display in the XR-series vessels. It's baked into the XR panels, but the autopilots are all available via Orb:Connect subscriptions, as would be the ability to update them. . . Now that would be cool.
yagni01 is offline   Reply With Quote
Old 08-05-2012, 03:40 PM   #26
kamaz
Unicorn hunter
 
kamaz's Avatar
Default

All hail the Probe!



I have solved the dialog box problem. Here is an addon which allows you to enter the needed values through a network socket instead.

The reason I used a socket, is that (1) you cannot easily tell which MFD triggered the dialog box, so you don't know which client you should render the dialog box to; (2) I did not feel like writing a code which would render the dialog boxes to VNC framebuffer, (3) although VNC can take keyboard input, keyboard input on tablets is not very convenient and (4) by separating this functionality from VNCMFD, you can use it with another display solution (such as WebMFD).

But you can now write a "Mission Control" application which uses a VNC client component for displaying the MFD screen and pops up dialog boxes when it receives data from this add-on.

Usage description (short): install & enable the addon, use e.g. PuTTY to connect to port 31337 (TCP) and have fun



Thanks to:

- Martin Schweiger for Orbiter and for having no objections to this add-on

- cjp, who first reverse engineered the dialog code in Orbiter 2006 ( http://www.orbiter-forum.com/showthr...3&postcount=55 ) and the published the FreeOrbit MFD, which made my disassembly efforts much easier

- Hex-Rays SA for the excellent IDA Pro disassembler / debugger, and providing the freeware version

- Microsoft Research for the excellent Detours Express library which I used for patching the orbiter core

- Microsoft for the excellent Visual Studio Express compiler

Readme file is below; the add-on (source & DLL) is atatched.

Quote:
NetDialog
=========

The NetDialog Orbiter plugin intercepts function calls in Orbiter core
responsinble for drawing MFD dialog boxes and redirects these to a network socket.

The plugin is intended for use with solutions allowing remote display of
MFD screens, such as WebMFD or VNCMFD.

Since the plugin patches the Orbiter binary at run-time, it will only work with
Orbiter version 2010-P1 (100830). Both orbiter.exe and orbiter_ng.exe are supported.

Operation
=========

After the plugin is loaded, a TCP server is started on port 31337.
No function interception is done (yet), and Orbiter operates normally.

After the client connects to the server, the plugin intercepts two core functions,
responsible for drawing the object selector and the input box.

When the MFD code wants to open the body selector box or a dialog box (for example,
if user presses "REF" or "TGT" button in OrbitMFD), the plugin will send the
prompt to the connected network client. It will then wait for the response from the
client (terminated with CRLF) and forward this to the MFD code. It will then send
the status message to the client.

A typical network exchange look like this:

SERVER>QUERY Orbit MFD: Target\r\n
CLIENT>iss\r\n
SERVER>STATUS 1\r\n

(\r\n represents the newline characters. It is sent automatically by a terminal
software when the user presses the "Enter" key.)

The "QUERY" message contains the dialog box title.
The "STATUS" message informs the client if MFD accepted the input.
"1" means that the input was accepted, "0" means that it was not.

If the client response is empty (i.e. contains nothing but the \r\n characters)
the server replies with "ABORT" message.

NOTE: The plugin will NOT accept a new data request before the previous one
is satisfied (i.e. between the QUERY and STATUS/ABORT messages). In other words,
pressing the MFD button which prompts for user input for the second time will
have no effect, until the user response is sent.

For the MapMFD, please enter "[no orbit]" and "[no base]" (without quotes)
to remove the orbit / base selection.

Only one network connection at the time is supported.

After the client disconnects, the function interceptions are removed, and Orbiter
returns to normal operation (i.e. the dialog boxes are drawn in the main window).

Technical details
=================

Runtime function interception is done using the Detours 3.0 library from Microsoft.
Please see Hook.cpp for more information.

License
=======

This add-on uses Detours Express 3.0 library from Microsoft. This library is made
available under the license agreement which includes the following:

<<<<

You may use, copy, reproduce, and distribute this Software for any non-commercial purpose,
subject to the restrictions in this MSR-SSLA. Some purposes which can be non-commercial
are teaching, academic research, public demonstrations and personal experimentation.
You may also distribute this Software with books or other teaching materials,
or publish the Software on websites, that are intended to teach the use of the Software
for academic or other non-commercial purposes.

You may not use or distribute this Software or any derivative works in any form for
commercial purposes. Examples of commercial purposes would be running business operations,
licensing, leasing, or selling the Software, distributing the Software for use with
commercial products, using the Software in the creation or use of commercial products
or any other activity which purpose is to procure a commercial gain to you or others.

>>>>

Please see orbitersdk\samples\netdialog\detours\license.rtf for more information.

Compilation
===========

The add-on was developed using Microsoft Visual C++ 2010 Express.

First, you must compile the Detours library. To do so, run the Visual Studio Command prompt.
cd to orbitersdk\samples\netdialog\detours\license.rtf and run "nmake" to build the library.

Then, open orbitersdk\samples\netdialog\netdialog.sln in Visual Studio and build the project.

Attached Files
File Type: zip NetDialog.zip (533.9 KB, 49 views)

Last edited by kamaz; 08-05-2012 at 03:51 PM.
kamaz is offline   Reply With Quote
Thanked by:
Old 08-05-2012, 05:46 PM   #27
kamaz
Unicorn hunter
 
kamaz's Avatar
Default

I have also noticed that libvncserver has an interesting feature.

Multiple clients can connect to the same server (i.e. the same port) and they will get a shared display.

I believe that someone out there will find that useful One obvious application is an instructor / student setup.
kamaz is offline   Reply With Quote
Old 08-07-2012, 11:41 PM   #28
Thanatox
Orbinaut
 
Thanatox's Avatar
Default

This is great. I have been waiting for this kind of functionality for some time. Your solution is elegant and I applaud you for it. It literally made me smack my forehead and say why didn't I think of that.

I tried it with my asus transformer this morning and it worked great.

For anyone trying to use this add-on:
It's worth noting that once you enable the add-on the VNC server starts automatically when orbiter is running. this confused me for a moment I assumed that I would have to activate them like extmfd

I haven't yet had a chance to look under the hood but I would be interested to see if you could bind keyboard keys to the MFD options client side. it seems like this would make it more compatible with different devices via joy 2 key as well as home brew keyboard hacks.
Thanatox is offline   Reply With Quote
Old 08-08-2012, 01:40 PM   #29
yagni01
Addon Developer

Default

Quote:
Originally Posted by Thanatox View Post
 I haven't yet had a chance to look under the hood but I would be interested to see if you could bind keyboard keys to the MFD options client side. it seems like this would make it more compatible with different devices via joy 2 key as well as home brew keyboard hacks.
For a non-touchpad, you could use AutoHotKey (AHK) to open and position your client windows, then map key presses to a mouse click action at each specific button location. If the keys are really game controller buttons, though, I don't know if his Cougar functionality would be directly usable.

Also, I have had no luck dis-abling the plugin without removing the dll. Trying to uncheck the box immediately shuts down Orbiter, and it's still enabled when re-started.

But I agree - this is very cool.

Last edited by yagni01; 08-08-2012 at 01:44 PM.
yagni01 is offline   Reply With Quote
Old 08-08-2012, 04:30 PM   #30
Thanatox
Orbinaut
 
Thanatox's Avatar
Default

I can reproduce the disabling bug found by yagni01.
When I un-check VNCMFD in the modules window orbiter crashes.

Here is the relevant section of Orbiter.log: (I think)
Code:
Finished initialising world
Module DeltaGliderIV.dll ..... [Build ******, API 060425]
Finished initialising status
Finished initialising camera
Finished initialising panels
OrbConnect::Initializing solar system with 32 bodies
OrbConnect::Found Config File
OrbConnect::Module Initialized
Finished setting up render state
OrbConnect::Module Shutdown
ERROR: DDraw object is still referenced: 22
---------------------------------------------------------------
>>> ERROR: Destroy framework objects failed
>>> [OrbiterGraphics::Exit3DEnvironment | .\OGraphics.cpp | 1034]
---------------------------------------------------------------
**** Closing simulation session
It seemed like it might have somthing to do with orbConnect so I tried disabling that addon but it still crashes. Orbiter.log below:

Code:
Finished initialising world
Module DeltaGliderIV.dll ..... [Build ******, API 060425]
Finished initialising status
Finished initialising camera
Finished initialising panels
Finished setting up render state
ERROR: DDraw object is still referenced: 18
---------------------------------------------------------------
>>> ERROR: Destroy framework objects failed
>>> [OrbiterGraphics::Exit3DEnvironment | .\OGraphics.cpp | 1034]
---------------------------------------------------------------
**** Closing simulation session

Last edited by Thanatox; 08-08-2012 at 04:35 PM. Reason: update
Thanatox is offline   Reply With Quote
Reply

  Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter Web Forum > Simpit Forum


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 10:35 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright 2007 - 2012, Orbiter-Forum.com. All rights reserved.