- Home /
Can you access non-standard mouse buttons?
Specifically, most (non-apple) mouses allow you to click the side of the scroll wheel left or right. I'd like to use those in my game. Input.GetMouseButton(int) seems to only work with 0, 1 or 2. Similarly, gaming mouses that have more buttons. I know they can be mapped to keystrokes with external software, but it'd be nice to be able to handle it from within Unity.
EDIT: I see that Input.Get$$anonymous$$ey() works for $$anonymous$$ouse0-$$anonymous$$ouse6 buttons, so that is great for ga$$anonymous$$g mouses. However clicking right/left scroll wheel does not register on Input.any$$anonymous$$ey.
I'd say try an input with type: $$anonymous$$ouse $$anonymous$$ovement and try some of the other axes in there.
Thanks, I did try that with no luck. Tried '$$anonymous$$ouse $$anonymous$$ovement', and '$$anonymous$$ey or $$anonymous$$ouse Button', with all joystick axis, and they all registered scroll wheel change when they were set to $$anonymous$$ouse $$anonymous$$ovement (not just 3rd axis), and did not register anything when set to $$anonymous$$ey or $$anonymous$$ouse Button. I was not able to get anything to register when the Horizontal Scroll was clicked (right/left scroll wheel).
Do you know if they have added this to the input manager, or if it will be added in unity 5?
Answer by Linus · Nov 05, 2014 at 12:22 PM
I think you will need to reasearch for the spesific hardware you need input from. A manufacturer may have an SDK for their range of products. Like for Logitech http://u3d.as/content/logitech-gaming/logitech-gaming-sdk/43c (Free)
The tool mnetioned here might come in handy to get the name of the buttons: http://stackoverflow.com/questions/23897387/identify-special-key-keycode
Answer by 101chris · Nov 17, 2014 at 05:19 PM
I stumbled upon this -- I think in theory you should be able to accomplish it using the method described here:
but instead of handling WM_TOUCH you handle WM_MOUSEHWHEEL. the basic idea is to create a c++ dll that captures the handle of the game window and can intercept messages. then unity can query that dll if the mouse wheel is side-clicked. (might also be able to do it in c#/.net). Sounds like the long way around the mountain for me, and would only work on windows (vista or newer). So probably not worth it if I have to figure out a similar thing for mac, linux, etc.