Request Fly by mouse

gertz

Member
Joined
Mar 18, 2010
Messages
104
Reaction score
0
Points
16
Location
Kyiv
I am taking a quote from the http://www.orbiter-forum.com/showthread.php?p=118061&postcount=9:
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);

}

The point behind this was to emulate the joystic control by mouse, allowing us to control airfoils (which is not possible using keyboard numpad (which is lacked on laptops anyways)) and rcs.

In the original post there is a plugin attached, it provides fair usability but could be enriched with features and further finetuned.

To sump up, I request flight by mouse features for Orbiter, which could include different options for keybinding (to not to interfere with other addons), or dialogue input like OGLA has to define options; a small icon or bars to indicate the position and scrolling; an ability to apply 0.1 or 0.5 factor to controls for more precise maneuvers (for instance, Blender's feature: hitting shift while translating, rotating or scaling gives you 0.1 factor from the original mouse movement); possibly, an option to define which controls to affect (AF, RCS, both).

Global joystic emulation or additional hardware is not really an argument to give up on this feature.
 

Ripley

Tutorial translator
Donator
Joined
Sep 12, 2010
Messages
3,133
Reaction score
407
Points
123
Location
Rome
Website
www.tuttovola.org
In that old thread computerex wrote
There is no easy way to draw on the HUD with a plug-in like this.
But now we have Enjo's HudDrawer!
I'd like to see this idea realized, the more the better.
 

Lisias

Space Traveller Wanna-be
Joined
May 31, 2015
Messages
346
Reaction score
3
Points
18
Website
www.youtube.com
Given the extreme low cost of an Arduino and specialized shields, would not be an ideia to implement this using it?

V-USB works fine - a simple shield, and one can plug an USB mouse on it, and then use the embedded USB to emulator a HID joystick. And that's it.
 

RisingFury

OBSP developer
Addon Developer
Joined
Aug 15, 2008
Messages
6,427
Reaction score
492
Points
173
Location
Among bits and Bytes...
Given the extreme low cost of an Arduino and specialized shields, would not be an ideia to implement this using it?

V-USB works fine - a simple shield, and one can plug an USB mouse on it, and then use the embedded USB to emulator a HID joystick. And that's it.

Why not just buy a joystick?
 

Donamy

Addon Developer
Addon Developer
Donator
Beta Tester
Joined
Oct 16, 2007
Messages
6,907
Reaction score
205
Points
138
Location
Cape
"...you have to use your hands ? That's a baby's toy."
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
To sump up, I request flight by mouse features for Orbiter, which could include different options for keybinding (to not to interfere with other addons), or dialogue input like OGLA has to define options; a small icon or bars to indicate the position and scrolling; an ability to apply 0.1 or 0.5 factor to controls for more precise maneuvers (for instance, Blender's feature: hitting shift while translating, rotating or scaling gives you 0.1 factor from the original mouse movement); possibly, an option to define which controls to affect (AF, RCS, both).

Sounds like a plan. Have you tried contacting computerex?
 

gertz

Member
Joined
Mar 18, 2010
Messages
104
Reaction score
0
Points
16
Location
Kyiv
No, I didn't. But if he posted a code, I assume it was meant to be an open source.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
No, I didn't. But if he posted a code, I assume it was meant to be an open source.

Without a license statement it is still default copyright, but that was not my point.

I guess you are making a request here because you can't develop it for yourself. To me, the next obvious step in this case would be to ask the author of the initial addon to enhance it, which would be computerex. Hence my question.
 

Wolf

Donator
Donator
Joined
Feb 10, 2008
Messages
1,091
Reaction score
11
Points
38
Location
Milan
One doesn't have much need of a joystick in Orbiter anyway--except after reentry.

Unless you want to play "Star Wars" :p
but that's not what Orbiter was designed for
 

gertz

Member
Joined
Mar 18, 2010
Messages
104
Reaction score
0
Points
16
Location
Kyiv
We still have atmospherial flight. Being unable to control airfoils makes me unable to use XR gliders, for instance.

And as stated in a message above, I am currently unable to design such plugin myself, and yes, it seems reasonable to contact the author.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
And as stated in a message above, I am currently unable to design such plugin myself, and yes, it seems reasonable to contact the author.

AFAIK, computerex doesn't frequent these forums anymore, so the mere existence of this thread might not catch his attention. I'd suggest emailing him.

The idea itself sounds interesting. I'd perhaps use such an addon myself, but I doubt that you will find a developer interested enough to invest time in it, especially given the majority of dismissive comments here.
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,877
Reaction score
2,131
Points
203
Location
between the planets
Because the guy doesn't wants a joystick, he wants a mouse to do the job. :)

I think his statement was more along the lines of "If I need to buy an arduino and do shenanigans with it to use the mouse, I might be better off just buying a joystick". Which I happen to agree with.
Mouse control would be a good thing because everybody has a mouse as opposed to a joystick, buying additional hardware to make it work would very much defeat that point ;)

especially given the majority of dismissive comments here.

Are we in the same thread? I haven't really seen a dismissive answer...
 
Last edited:

Lisias

Space Traveller Wanna-be
Joined
May 31, 2015
Messages
346
Reaction score
3
Points
18
Website
www.youtube.com
I think his statement was more along the lines of "If I need to buy an arduino and do shenanigans with it to use the mouse, I might be better off just buying a joystick".

On the other hand, since we are sticking with Orbiter instead of Kerbal, there's a chance that some people around here prefers to do the thing themselves than to buy it ready from the shelves.

(hey, we code our own vessels!)

The V-USB stack is really easy to use, there's a lot of HID templates for Arduino already, and speaking frankly - it's easier to code an joystick on Arduino than to write a vessel on Orbiter.

I agree that a device driver for Orbiter would be a cleaner (and better) solution, but since the guy can't (or won't) do it himself, suggesting an plausible alternative should not hurt.
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
Are we in the same thread? I haven't really seen a dismissive answer...

Telling him to "just buy a joystick" or "do some hardware hack to make the mouse emulate a joystick" or "one doesn't have much need of a joystick, anyway" - especially AFTER the guy already stated that "joystick emulation or additional hardware is not really an argument to give up on this feature" TWICE - is a dismissive comment IMHO. Yes, we are in the same thread.
 
Last edited:

gertz

Member
Joined
Mar 18, 2010
Messages
104
Reaction score
0
Points
16
Location
Kyiv
Moreover, I am running an Orbiter under wine (linux), and I am not really spending much time with it because I am a student.

I study for civilian aircraft designer/constructor/engineer, and my skills in CFD (openfoam) and 3D modelling (blender) are comprehensive. I would gladly contribute to Orbiter community myself, and I already did some attempts with stellar systems, but I absolutely lack time because of incoming graduation and permanent research work, which demands a lot of effort in searching, learning and calculating.
This is one more reason for my request. All I want and all I have is my laptop, I have not much funds to spend and definitly lack time to make additional hardware worth purchase.


Orbiter is a heaven for me as an addon developer, which is what I love it for, personally I adore system building and planetary textures developing. I wouldn't miss a chance to undertake this request myself, but my C++ skills are nothing more than a 'compile from source' level. Seeing the code that was provided I can say that it does not seem as hard at first glance, but so far I am useless in attempting to do something similar or develop from it. If I had time I would definitely try.
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,877
Reaction score
2,131
Points
203
Location
between the planets
Telling him to "just buy a joystick" or "do some hardware hack to make the mouse emulate a joystick" or "one doesn't have much need of a joystick, anyway"

Interesting, I interpreted most of those statements completely differently...
 

Face

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 18, 2008
Messages
4,403
Reaction score
581
Points
153
Location
Vienna
Interesting, I interpreted most of those statements completely differently...

Perhaps it is due to my use of the term "dismissive". I always mean it more like in the german word "ablehnend", perhaps with only a slight notch towards "geringschätzend", but not at all like in the more malevolent "herablassend".

In this light, the comments stated show a disinterest in pursuing the solution "mouse driver" as presented, but instead hint towards either using additional hardware as a solution, or not bothering at all. And given this, I was under the impression that nobody will really be interested to pick up the task of implementing the mouse driver, if it seems not to be very welcomed to begin with. Hence my statement:
I doubt that you will find a developer interested enough to invest time in it, especially given the majority of dismissive comments here.

Sorry if this offends anybody, it was not meant that way. :facepalm:

---------- Post added at 09:42 ---------- Previous post was at 09:27 ----------

But back on topic: did you manage to get hold of computerex, gertz?
 
Top