mouse button 4 and 5?

Posted By: Reconnoiter

mouse button 4 and 5? - 08/02/15 11:18

Hi,

Is it possible to set a function for other mouse buttons besides left, right and middle (so besides on_mouse_left, on_mouse_right, on_mouse_middle)?

Some mouses have e.g. 2 extra buttons, would be nice to make use of them for shortcuts / hotkeys.
Posted By: Anonymous

Re: mouse button 4 and 5? - 08/02/15 15:43

No other buttons are in the manuals key map, try find the scan code for the buttons and writing your own check with key_pressed(scancodeX)
Posted By: Reconnoiter

Re: mouse button 4 and 5? - 08/02/15 18:48

Cool, I will try key_pressed. thanks laugh
Posted By: Anonymous

Re: mouse button 4 and 5? - 08/02/15 20:01

If that doesn't work... You need to jump out of the 3dgs and into the winapi to achieve the goal. There are a many people here that could speak on that, I am not one of them.
Posted By: Reconnoiter

Re: mouse button 4 and 5? - 08/03/15 10:20

Yeah it doesn't seem to work for scancode above ~280. I will check the winapi, have a little experience with it (hopefully enough grin ).
Anyway thanks for taking the time to reply here. laugh
Posted By: Kartoffel

Re: mouse button 4 and 5? - 08/03/15 18:54

I've got a code snippet, I'll see if I can find it.

Edit: here:
Code:
#define mouse_4 (GetKeyState(5) > 1)
#define mouse_5 (GetKeyState(6) > 1)


Tiny but works. but remember to include windows.h.

Edit2: forgot to say: you can use it exactly like the vars mouse_left, mouse_right, etc.
Posted By: Ch40zzC0d3r

Re: mouse button 4 and 5? - 08/03/15 19:34

better use if(GetKeyState(5) & 0x8000)
msdn says thats high order bit and its set when the key is pressed
Posted By: Kartoffel

Re: mouse button 4 and 5? - 08/03/15 20:48

Yeah, there are two bits used. One for pressed/not pressed and one as a button toggle (pressing the key switches between on and off)
Posted By: Reconnoiter

Re: mouse button 4 and 5? - 08/04/15 13:37

It works very nicely, thanks! And I learned something extra about define laugh
© 2024 lite-C Forums