Jump to content
The simFlight Network Forums

Lua Script to swap mouse buttons (for touchscreen users)


Recommended Posts

Dear Pete,

I use registered FSUIPC 3.999c and 4.802 with WideFS 6.94 on a network of 7 computers:

(1) Server PC (Win7-64): FS9.1, FSX SP2, FSUIPC, WidevieW Server, WideFS Server: 4 touchscreen monitors: used for Instrument panels exclusively

(2) Client PC (Win Vista-32): WideClient, Jeppesen Navigation Suite, Instructor Station: 2 touchscreen monitors: used for Jeppesen Nav Tracking and wx injection

(3) FIVE Client notebook PC's (Win7-64): FS9.1, FSX SP2, WidevieW Client, FSUIPC: used for Outside Scenery views exclusively: driving 5 widescreen monitors across 180 degrees fov.

This is in the context of my Server touchscreens used for instrument panels. For aircraft which require L and R mouse clicks to operate cockpit switches and knobs (virtually all of the PMDG aircraft), I use a floating toolbar utility called SWAPLR.exe which interchanges the mouse buttons when you need to. The only problem is that since this is a non-FS utility which sits outside FS, each time you make the utility window active, FS loses focus and you lose the cockpit sounds. Which is annoying. I have been wondering if there was any way to incorporate such an external utility into FS as a gauge, so that the utility can be operated within FS, thus retaining focus and sound?

And now that you have introduced the Lua Mouse Library, I was wondering if a Lua script might be written to solve the problem. Could such a script be activated by a joystick button press within FS to convert the next mouse click (wherever it is placed) into a R-click rather than a (default) L-click? If so, I would be very grateful to anyone who might have the knowledge and time to write such a script. It would be a boon to anyone using touchscreens to turn knobs and operate switches within FS panels.

Thank you for all that you are doing to support our hobby!

Regards,

Chakko.

Link to comment
Share on other sites

This is in the context of my Server touchscreens used for instrument panels. For aircraft which require L and R mouse clicks to operate cockpit switches and knobs (virtually all of the PMDG aircraft), I use a floating toolbar utility called SWAPLR.exe which interchanges the mouse buttons when you need to.

If this because the touchscreen support has no middle or right button methods?

And now that you have introduced the Lua Mouse Library, I was wondering if a Lua script might be written to solve the problem. Could such a script be activated by a joystick button press within FS to convert the next mouse click (wherever it is placed) into a R-click rather than a (default) L-click?

Not at present. I carefully avoided adding any facilities to detect mouse button clicks or moves, primarily because this presents very nasty problems involving recursion. I cannot see any way, for instance, of distinguishing between a mouse click made by the user from one sent by my code. If I trap the messages I trsp them all. You can imagine what that would end up like!

If I implemented such a facility it would have to be built into the main code, not programmable via Lua. That wouldn't be difficult.

If so, I would be very grateful to anyone who might have the knowledge and time to write such a script. It would be a boon to anyone using touchscreens to turn knobs and operate switches within FS panels.

FS itself never uses anything other than left clicks for panels -- right click produces pop-up menus. I know PMDG introduced the idea of left/right clciks for turning knobs different ways. Are others copying this now?

Anyway, I'll put it on my list. i've a couple of other things to sort out first.

Regards

Pete

Link to comment
Share on other sites

If this because the touchscreen support has no middle or right button methods?

Not at present. I carefully avoided adding any facilities to detect mouse button clicks or moves, primarily because this presents very nasty problems involving recursion. I cannot see any way, for instance, of distinguishing between a mouse click made by the user from one sent by my code. If I trap the messages I trsp them all. You can imagine what that would end up like!

If I implemented such a facility it would have to be built into the main code, not programmable via Lua. That wouldn't be difficult.

FS itself never uses anything other than left clicks for panels -- right click produces pop-up menus. I know PMDG introduced the idea of left/right clciks for turning knobs different ways. Are others copying this now?

Anyway, I'll put it on my list. i've a couple of other things to sort out first.

Regards

Pete

Dear Pete,

Thank you for your prompt response.

To answer your questions:

Yes, although the touchscreen support does offer right-click methods, they are either clumsy, or unworkable in the context of FS. After experimenting with various alternatives, I found this SWAPLR.exe floating toolbar option to be the most practical.

Yes, the PMDG aircraft use this method of L/R clicks for turning knobs and also moving multi-position switches; also the Flight-One ATR72 and DA Fokker 100. Others like the LSH MD82, the LD B767, and the iFly B737, mercifully, do not.

Thank you anyway for your comments, and I wait in hope! ;-)

Regards,

Chakko.

Link to comment
Share on other sites

Thank you anyway for your comments, and I wait in hope! ;-)

It was easy to do, and i had to make bug-fix releases, so the facility ("mousebutton swap") is now available -- get versions 4.803 and/or 3.999d from the Download Links subforum. I've tested it in FSX with the PMDG 737NGX and it works quite well.

Just assign a button to that added control. It lasts from the next left button down to the subsequent left button up.

Regards

Pete

Link to comment
Share on other sites


It was easy to do, and i had to make bug-fix releases, so the facility ("mousebutton swap") is now available -- get versions 4.803 and/or 3.999d from the Download Links subforum. I've tested it in FSX with the PMDG 737NGX and it works quite well.

Just assign a button to that added control. It lasts from the next left button down to the subsequent left button up.

Regards
Pete



Dear Pete,

This is FANTASTIC! Thank you so very much!
I have not been able to try the control out myself because the download links to 3.999d and 4.803 appear to be broken, so I look forward to your restoring those.
Thank you again!

Regards,

Chakko.
Link to comment
Share on other sites

Fixed now.

Regards

Pete

Dear Pete,

I tested the 4.803 Mousebutton Swap with the PMDG 737 NGX and the Flight One ATR72 and it is working fine. As it stands, the Mousebutton Swap control is one-off and will work only for the next mouse-click/screen-touch. I was initially planning to request that you add another control wherein the swap could be held indefinitely or until toggled back: this would be useful in case of turning say a heading knob through many revolutions, but I find that one can achieve the same objective by activating the "control to repeat while held" option. If indeed you do add an option to hold the swap it might be a good idea that it be accompanied by a displayed warning (perhaps in the FSUIPC window) that the mouse button had been swapped.

The 3.999d Mousebutton Swap, however, appears not to be working when I tested it with the PMDG MD-11 in FS9.1.

I truly admire your genius in implementing the whole range of options that FSUIPC makes available to us, and your willingness to add/create new options when we request them. This new control greatly enhances the touchscreen experience with some of the finest add-on aircraft there are. Thank you once again, Pete!

Regards,

Chakko.

Link to comment
Share on other sites

I tested the 4.803 Mousebutton Swap with the PMDG 737 NGX and the Flight One ATR72 and it is working fine. As it stands, the Mousebutton Swap control is one-off and will work only for the next mouse-click/screen-touch. I was initially planning to request that you add another control wherein the swap could be held indefinitely or until toggled back: this would be useful in case of turning say a heading knob through many revolutions, but I find that one can achieve the same objective by activating the "control to repeat while held" option.

You shouldn't need to do that. Here it works by simply holding the button down -- the PMDG NGX keeps updating the dials until the button is released! On a touchscreen I assumed you'd simply keep the dial "touched".

If indeed you do add an option to hold the swap it might be a good idea that it be accompanied by a displayed warning (perhaps in the FSUIPC window) that the mouse button had been swapped.

I don't see any point in such an option when it holds whilst the button is pressed in any case.

The 3.999d Mousebutton Swap, however, appears not to be working when I tested it with the PMDG MD-11 in FS9.1.

I'm afraid I don't have any FS9 aaircraft which uses this sort of facility, but it might happen if the aircraft uses a child window not the main FS window. I don't hook child windows in FSUIPC3 because there was never any need to. I'll check into that, but without the aircraft it isn't going to be easy -- or just a lot more code to intercept all the needed windows.

I was going to say earlier that I'd rather only add new facilities to FSUIPC4, looking more to the current and future sims, rather than encourage folks even more to stay on FS9 (for which I'd originally ceased development several years ago, after al it is now over eight years old!), but I added it there too because the code was so simple.

Regards

Pete

Link to comment
Share on other sites

Dear Pete,

Thank you for your comments.

You shouldn't need to do that. Here it works by simply holding the button down -- the PMDG NGX keeps updating the dials until the button is released! On a touchscreen I assumed you'd simply keep the dial "touched".

You are absolutely right. I don't know how I came to my earlier conclusion, but I stand corrected. The behaviour is exactly as you describe.

I'm afraid I don't have any FS9 aaircraft which uses this sort of facility, but it might happen if the aircraft uses a child window not the main FS window. I don't hook child windows in FSUIPC3 because there was never any need to. I'll check into that, but without the aircraft it isn't going to be easy -- or just a lot more code to intercept all the needed windows.

I was going to say earlier that I'd rather only add new facilities to FSUIPC4, looking more to the current and future sims, rather than encourage folks even more to stay on FS9 (for which I'd originally ceased development several years ago, after al it is now over eight years old!), but I added it there too because the code was so simple.

I tested the 3.999d Mousebutton Swap once again with the FS9.1 PMDG MD11 and the F1 ATR72, and can confirm that it does not work. The main panels were opened in the Main FS window in both cases.

Thank you once again.

Regards,

Chakko.

Link to comment
Share on other sites

I tested the 3.999d Mousebutton Swap once again with the FS9.1 PMDG MD11 and the F1 ATR72, and can confirm that it does not work.

Try version 3.999e, now available. I added the same mouse code to the two hooked child windows as well as the main one.

I've also put a small improvement in to make it easier to get out of a "stuck right button" situation, which can happen if you use the feature on a part of the screen which induces a pop-up menu on right button press. This is a problem because I then don't see the button up (all messages are diverted to the popup menu). After you've dealt with the popup, or escaped from it, I cancel the swap on the next left button press (provided of course that you've not re-selected the swap action).

That improvement is also in 4.804, so you'll need to update.

Regards

Pete

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.