Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Adding mouse flags

Featured Replies

  • Commercial Member

I'm trying to detect two mouse buttons selected at the same time:

 

if((mouse_flags & MOUSE_RIGHTSINGLE) && (mouse_flags & MOUSE_MIDDLESINGLE))

 

- but it never triggers. The MOUSE_CHILD_FUNCT listing is correct:

 

(...)MOUSE_LEFTSINGLE | MOUSE_RIGHTSINGLE | MOUSE_DOWN_REPEAT | MOUSE_MIDDLESINGLE, ap_ias_select_mcb

 

So, a simple question - what has eejit here overlooked?

 

-Dai

Dai,

 

You're dealing with a callback function, so the value of the mouse_flags variable is a reflection of action, not state.

Declare a couple of variables:

BOOL bLeftButton, bMiddleButton;

Then use if statements, similar to the one you have, to determine the current position of each button.

Once the position of each button has been determined, you can then take action as required.

 

Doug

  • Author
  • Commercial Member

Thanks Doug - that definately fixed the immediate problem. I don't really need an answer to the following in that I've figured out a way around it, but do you know if it's possible to inject directly into a mouse callback e.g. if I had a variable set then that variable will keep calling the mouse callback until the variable is unset?

 

-Dai

Not sure what you're trying to achieve here. Are you trying to increase the rate at which the function is called, or are you trying to prevent the function from being called? Neither is really possible.

You can invoke the callback function as often as you like from within your own code, but then you would have to deal with setting the bits within the mouse_flags variable. Not terribly useful, unless you have independently retrieved state information from the mouse.

If you're looking to limit calls to the callback function, the only way to do so is to deregister the callback function. This approach would likely be a PITA compared to simply using a global variable and an if statement to limit what the callback function actually does when it is called.

 

Doug

  • Author
  • Commercial Member

I've taken the easy way out and rather than try to keep poking the mouse callback function to read the button state, I've assigned global variables to all of the mouse buttons and I'm dealing with the resulting required actions in the gauge callback - which led to a very unexpected result when using the information to rotate a control. I had assumed that the mouse callback was polled at tick18 intervals but I've just been very rudely informed by FS that it's not so. In comparison to rotating controls in the mouse callback, the same code in the gauge callback has them turning on steroids.... :shok:. I'm about to wrap that part of the code in a tick18 clock to slow the actions down again.

 

All this because in the mouse callback, if I selected (say) the left button for one action, then selected both buttons to change the action, releasing the right button did not return to the initial left button action. It is as if the initial button action has 'expired'.

 

-Dai

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.