Idea Mouse control for the joystick-less

Jarvitä

New member
Joined
Aug 5, 2008
Messages
2,030
Reaction score
3
Points
0
Location
Serface, Earth
With the widespread adoption of addons that feature atmospheric flight and therefore allow a much greater degree of control with a joystick - such as the various space shuttle addons, the X-15, the XR series and the DGIV, I believe an addon that would allow for mouse control of flight control surfaces and RCS/BCS thrusters would greatly benefit those of us too cheap to get a joystick.
 

Jake

Deorbinaut
Joined
Jun 22, 2008
Messages
73
Reaction score
0
Points
0
Location
Location: Location: Location:
A mouse control add-on would definitely be nice. I play Orbiter entirely from the keyboard (but then again I don't do much atmospheric flight, just climbing out of it and reentering when the job is done). If it can be done then it will surely be of help.
 

Dambuster

Member
Joined
Sep 13, 2008
Messages
790
Reaction score
1
Points
18
Location
UK
This would definitely be nice, however bear in mind that trying to use RCS with a mouse might quickly turn messy...:p
 

Jarvitä

New member
Joined
Aug 5, 2008
Messages
2,030
Reaction score
3
Points
0
Location
Serface, Earth
This would definitely be nice, however bear in mind that trying to use RCS with a mouse might quickly turn messy...:p

True, the primary use for this would of course be aerodynamic surface control, possibly with RCS assist in the upper atmosphere, to allow for more precise atmospheric flight and re-entry.
 

n122vu

Addon Developer
Addon Developer
Donator
Joined
Nov 1, 2007
Messages
3,196
Reaction score
51
Points
73
Location
KDCY
There's a utility that just might do the trick. It's called Mouse Raider. It converts mouse movements to keystrokes. Originally designed for use with the old Tomb Raider games, but it might just work for Orbiter. Haven't tested it though.

You can get it here;
http://mouseraider.homepage.t-online.de/
 

Dambuster

Member
Joined
Sep 13, 2008
Messages
790
Reaction score
1
Points
18
Location
UK
You could only control pitch and roll, but not yaw, since you have only two axis on your mouse.

Well Flightgear does get around that issue. In that sim, if you hold down your left mouse button, and move your mouse left/right, that controls the rudder (and holding down the middle mouse button whilst moving mouse up/down controls throttle). A bit clumsy perhaps, but still effective.
 

computerex

Addon Developer
Addon Developer
Joined
Oct 16, 2007
Messages
1,282
Reaction score
17
Points
0
Location
Florida
Quick and dirty: Dump the .dll in the modules\plugin folder, activate it in the launch pad. Press ALT+M to toggle between mouse input/keyboard input. Only supports rotational RCS mode+Atmospheric control surfaces. Hold down left mouse button for yaw.

Code:
#define STRICT
#define ORBITER_MODULE

#include <orbitersdk.h>

HWND hwnd = 0;
float width, height;
bool enable = false;
NOTEHANDLE title;

DLLCLBK void opcOpenRenderViewport(HWND hWnd, DWORD w, DWORD h, BOOL fc)
{
	hwnd=hWnd;
	width=(float)w;height=(float)h;
	title = oapiCreateAnnotation(false, 0.8, _V(0.0, 1.0, 0.0));
	oapiAnnotationSetPos(title, 0.84, 0.06, 1.0, 0.3);
	oapiAnnotationSetText(title, "Attitude: Standard");
}

double lpt = 0;
DLLCLBK void opcPreStep(double simt, double simdt, double mjd)
{
	if ( GetAsyncKeyState(VK_MENU) && GetAsyncKeyState(0x4D) && simt > lpt){
		enable = !enable;
		if ( !enable )
		{
			VESSEL * v = oapiGetFocusInterface();
			DWORD cnt = v->GetThrusterCount();
			THRUSTER_HANDLE th;
			for ( unsigned int i = 0; i < cnt; i++ )
			{
				th = v->GetThrusterHandleByIndex(i);
				v->SetThrusterLevel(th, 0);
			}
			v->SetADCtrlMode(7);
			oapiAnnotationSetText(title, "Attitude: Standard");
		}else oapiAnnotationSetText(title, "Attitude: Mouse");
		lpt = simt+0.2;
	}
	if ( !enable ) return;
	RECT rect;
	POINT cpos, crpos;
	GetWindowRect(hwnd, &rect);
	GetCursorPos(&cpos);

	if ( cpos.x > rect.right  || cpos.x < rect.left ) return;
	if ( cpos.y > rect.bottom || cpos.y < rect.top  ) return;

	crpos.x = cpos.x-rect.left;
	crpos.y = cpos.y-rect.top;

	float cx = width/2.0f, cy = height/2.0f;
	float pi = (crpos.y-cy)/cy;
	float bi = (crpos.x-cx)/cx;

	bool mbd = GetAsyncKeyState(0x01);
	VESSEL * v = oapiGetFocusInterface();

	int atmode = v->GetAttitudeMode();
	v->SetADCtrlMode( 7 );
	v->SetControlSurfaceLevel(AIRCTRL_ELEVATOR, pi);
	v->SetControlSurfaceLevel((mbd?AIRCTRL_RUDDER:AIRCTRL_AILERON),  bi);
	
	if ( atmode == ATTMODE_ROT ){
	v->SetThrusterGroupLevel((pi>0?THGROUP_ATT_PITCHUP:THGROUP_ATT_PITCHDOWN), (pi>0?pi:-pi));
	v->SetThrusterGroupLevel((mbd?(bi>0?THGROUP_ATT_YAWLEFT:THGROUP_ATT_YAWRIGHT):
							 (bi>0?THGROUP_ATT_BANKRIGHT:THGROUP_ATT_BANKLEFT)), (bi>0?bi:-bi));
	}else
	{
		
		v->SetThrusterGroupLevel(THGROUP_ATT_PITCHUP,  0);
		v->SetThrusterGroupLevel(THGROUP_ATT_PITCHDOWN,0);
		v->SetThrusterGroupLevel(THGROUP_ATT_YAWLEFT,  0);
		v->SetThrusterGroupLevel(THGROUP_ATT_YAWRIGHT, 0);
		v->SetThrusterGroupLevel(THGROUP_ATT_BANKLEFT, 0);
		v->SetThrusterGroupLevel(THGROUP_ATT_BANKRIGHT,0);
	}

	if ( !mbd ) {
		v->SetControlSurfaceLevel(AIRCTRL_RUDDER, 0);
		if ( atmode == ATTMODE_ROT ){
		v->SetThrusterGroupLevel(THGROUP_ATT_YAWLEFT, 0);
		v->SetThrusterGroupLevel(THGROUP_ATT_YAWRIGHT, 0);
		}
	}else
	{
		v->SetControlSurfaceLevel(AIRCTRL_AILERON, 0);
		if ( atmode == ATTMODE_ROT ){
		v->SetThrusterGroupLevel(THGROUP_ATT_BANKLEFT, 0);
		v->SetThrusterGroupLevel(THGROUP_ATT_BANKRIGHT, 0);
		}
	}
	v->SetADCtrlMode(0);

}
 

Attachments

  • mouseinput.zip
    34.8 KB · Views: 146

RisingFury

OBSP developer
Addon Developer
Joined
Aug 15, 2008
Messages
6,427
Reaction score
492
Points
173
Location
Among bits and Bytes...
Well Flightgear does get around that issue. In that sim, if you hold down your left mouse button, and move your mouse left/right, that controls the rudder (and holding down the middle mouse button whilst moving mouse up/down controls throttle). A bit clumsy perhaps, but still effective.

Yea, I though of click-n-hold method... but you'd lose control of the axis while you're doing that.



I don't have a joystick... I'll try interfacing my RC radio though...
 

Jarvitä

New member
Joined
Aug 5, 2008
Messages
2,030
Reaction score
3
Points
0
Location
Serface, Earth
Quick and dirty: Dump the .dll in the modules\plugin folder, activate it in the launch pad. Press ALT+M to toggle between mouse input/keyboard input. Only supports rotational RCS mode+Atmospheric control surfaces. Hold down left mouse button for yaw.

Works. Could use some kind of indicator of the current "position" of the joystick (could be something as simple as a square with an X to indicate the pitch/bank position), and a button to move the controls to the central position.
 

computerex

Addon Developer
Addon Developer
Joined
Oct 16, 2007
Messages
1,282
Reaction score
17
Points
0
Location
Florida
Works. Could use some kind of indicator of the current "position" of the joystick (could be something as simple as a square with an X to indicate the pitch/bank position), and a button to move the controls to the central position.

There is no easy way to draw on the HUD with a plug-in like this. It could be done with an MFD, but I don't think it makes sense to have an MFD just for this purpose. If anyone wants I can put this up on OH....(BTW as for an indicator for the 'position of the joystick', the mouse pointer in the Orbiter window does just that)
 

Bitmag

New member
Joined
Oct 31, 2009
Messages
2
Reaction score
0
Points
0
DG XR-1 repeatly says "on, on, on, on..." when activating mouse control...

DG XR-1 repeatly says "on, on, on, on..." when activating mouse control...
 

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,924
Reaction score
232
Points
138
Location
Cape
Sorry, I know this is an old thread, but I was wondering, if there was a way to go the other way with this, to allow hat-switches to mimic mouse movement, to allow head movement(look around) in cockpit, so you don't have to take your hands of the stick.
 

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,924
Reaction score
232
Points
138
Location
Cape
A CH throttle USB
 

Ripley

Tutorial translator
Donator
Joined
Sep 12, 2010
Messages
3,135
Reaction score
409
Points
123
Location
Rome
Website
www.tuttovola.org
CH? Well, you're lucky then, CH Control Manager software is well known for its power.
I don't see a reason why it wouldn't be able to accomplish such an easy task.

http://www.chproducts.com/retail/tech_control_manager.html

The only issue I see (but there must be a way to circumvent it) is that Orbiter's view system needs the mouse button to be pressed down and dragged.

http://www.ch-hangar.com/forum/show...o-Throttle-ministick-operate-the-mouse-cursor

For example, IL-2's view system is simpler, you move the mouse and you rotate pilot's head.
 
Last edited:

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,924
Reaction score
232
Points
138
Location
Cape
Could you elaborate on this. I got how to set up the micro stick for the mouse, but how do you use it with Orbiter.
 

Ripley

Tutorial translator
Donator
Joined
Sep 12, 2010
Messages
3,135
Reaction score
409
Points
123
Location
Rome
Website
www.tuttovola.org
I don't have CH hardware, so it's just theory...

If you already mapped "something" (be it a microstick, a coolie, castle switch, etc...) to act as a mouse, you need to map another button as Right Mouse Button.

I guess that you move this "mouse" control with your left thumb, so it would be ideal to have a spare button at the index finger.
You keep this button pressed and it simulates the RMB being held down.
This way you move the "mouse" and the Orbiter view rotates.

Well...at least it should...

Map another button to the "home" key, so you can reset the central view.
 
Top