How to get the number of buttons on the mouse. [How Many buttons on a mouse]

Hi all

Is there a way to read how many buttons are on a mouse.
And put all these mousestates into a list.

Want to be able to turn off mouse buttons or on.

I disabled the right mouse button in options.

I do not want to hard code since you cannot know what kind of mouse people are using.

There are 1, 2 , 3 even 12 buttons on some.

Thanks

Unfortunately (or fortunately) the default configuration for xna/monogame is to have 3 buttons (lmb, rmb and middle) plus x1,x2.
https://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.mousestate_members.aspx

However i found that only the 3 work for me

If you are talking about Gamer mice or special types of mice, those extra buttons tend to be programmable only through their own software so you can ignore them and stick with the standard 3- L,M,R and Wheel Axis as an extra… [but give your users the mapping schematics for other keyboard press button commands in your application so that they can remap those buttons on their mice to suit their use, you should program for the majority and never the minority…] it can be used as a button you know… I use it in games like BF3 to change posture from standing to crouch etc… so consider this if not using zoom via the mouse wheel…

Actually I was asking how to get the number of buttons on the mouse.

Say using a for loop how to read all the buttons.

I don’t think there is any query methods for mouse features, though you should be designing for possibilities with stages of requirement, such as if there is no middle mouse available place an not so important but handy function there, you should design for the minimum of inputs otherwise place requirements upon your users…

Anyway, with that being said, these should be helpful…

Good Luck.

For an idea of Input design, consider Blender3D, they design Middle Mouse and ‘cough’ right mouse for Windows and Linux but for Mac they subside the functionality to a keyboard input…

Also Welcome to the forums.

Adjusted your title and category.

You can’t query the buttons, but there are 5 usable buttons on a mouse, Left, Right, Middle and XBUTTON1 AND XBUTTON2

Call Mouse.GetState() to get the state of either one. The OS will support all five and can recieve an input from all 5, but not all mice send data from all the buttons and provide just the basic 2 button setup.
it would be best to expect a 2 button mouse then allow the user to configure the other buttons if they are available.

Unless the target platform is Mac… :joy:

1 Like

The 4-th and 5th buttons are known as XButton1 and XButton2 in Monogame and are available as properties on MouseState, either through Mouse.GetState or Window.MouseState

Old XNA documentation links and since I can’t find any Monogame docs, a link to the source:

Maybe you want to a gaming mouse with more buttons like these https://10hightech.com/best-gaming-mouse/

1 Like

I have been using MadCatz R.A.T.7 and I am enjoying this so far. However, a normal user can’t be familiar with this.

You can’t query the buttons, but there are 5 usable buttons on a mouse, Left, Right, Middle and XBUTTON1 AND XBUTTON2