[bug report] Mouse Double and Triple Click needs fixing

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Ulf
Posts: 281
Joined: Mon Jun 15, 2009 8:53 am
Location: Australia

Post by Ulf »

@CuteAlien

Ok, cool.

It's obviously not going to happen tomorrow.
As I get some time, I'll work on an implementation of it, and I'll submit it later... to help, not just request stuff! Now that the event handling is a bit different in 1.6, I'll have to look over it again.

Is this something that could come out in a minor release?
What sort of time frame for getting this done?
So I know how long I have to make a proposal.
I can always implement it for myself for now anyway.
I can hear birds chirping
:twisted:

I live in the Eye of Insanity.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Don't worry, implementation won't be a problem. I will leave the current enum in and set EMIE_LMOUSE_DOUBLE_CLICK to EMIE_MOUSE_DOUBLE_CLICK so they have the same value and the others just work the same. Not sure if I put it into 1.6 or 1.7, basically it should be 1.7 because it's an interface change, but then again it's nothing that should possibly break anything so I guess I can also put it into 1.6 (and then again nothing that should possibly break anyhting stuff is 99% guaranteed to break something...).

And as I messed up so badly, I will try to fix it next. Which means this weekend if I have a free day this weekend (not sure yet).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Please put it into 1.7, because the binary compatibility is not kept at all with this change. We have to become more strict with those changes, now that Irrlicht is present in many distributions and frameworks.
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

EMIE_MOUSE_DOUBLE_CLICK should probably remain a separate value from EMIE_LMOUSE_DOUBLE_CLICK, again in case of left-handed or such, better just trigger them at the same time with a switch to choose which button(s) it'll accept to trigger it or something the like.
Ulf
Posts: 281
Joined: Mon Jun 15, 2009 8:53 am
Location: Australia

Post by Ulf »

Dorth wrote: EMIE_MOUSE_DOUBLE_CLICK should probably remain a separate value from EMIE_LMOUSE_DOUBLE_CLICK, again in case of left-handed or such, better just trigger them at the same time with a switch to choose which button(s) it'll accept to trigger it or something the like.
Ok, to maintain backward compatibility, if we can not just throw away EMIE_MOUSE_DOUBLE_CLICK.

To make a few points I need to show the code from the WndProc function in CIrrDeviceWin32.cpp.

Code: Select all

dev = getDeviceFromHWnd(hWnd);
if (dev)
{
	dev->postEventFromUser(event);

	if ( event.MouseInput.Event == irr::EMIE_LMOUSE_PRESSED_DOWN )
	{
		irr::u32 clicks = dev->checkSuccessiveClicks(event.MouseInput.X, event.MouseInput.Y);
		if ( clicks == 2 )
		{
			event.MouseInput.Event = irr::EMIE_MOUSE_DOUBLE_CLICK;
			dev->postEventFromUser(event);
		}
		else if ( clicks == 3 )
		{
			event.MouseInput.Event = irr::EMIE_MOUSE_TRIPLE_CLICK;
			dev->postEventFromUser(event);
		}
	}
}
1.
Instead of only

Code: Select all

if ( event.MouseInput.Event == irr::EMIE_LMOUSE_PRESSED_DOWN )
it needs to do a separate check (if) for each mouse button.

2.
The function checkSuccessiveClicks in CIrrDeviceStub.cpp needs to keep track of which button made the previous click. Only when the same button is consecutively clicked is it a multi-click.
Unless (using Windows as example) the WndProc function can check which button was previously clicked, and only call the checkSuccessiveClicks function if its the same button as last time. Doing it that way though, would mean more coding for each platform. Putting it in the checkSuccessiveClicks function would make it all in one place at the possible expense of some extra unnecessary function calls.

3. Because of (2) checkSuccessiveClicks needs to take an extra parameter (event.MouseInput.Event).

Now, because we will have 6 new multi-click events (3 for double, 3 for triple, e.g. EMIE_LMOUSE_DOUBLE_CLICK) we need to send separate events for each type.

To maintain backward compatibility, as Dorth was speaking of, we simply need to remove EMIE_MOUSE_DOUBLE_CLICK and EMIE_MOUSE_TRIPLE_CLICK from the enum EMOUSE_INPUT_EVENT in IEventReceiver.h and replace them with the new values for each button (left, right, middle and possibly X (extra))

Then make EMIE_MOUSE_DOUBLE_CLICK a #define or something like.

Code: Select all

#define EMIE_MOUSE_DOUBLE_CLICK EMIE_LMOUSE_DOUBLE_CLICK
likewise with EMIE_MOUSE_TRIPLE_CLICK.

Then the standard double and triple click can be set pre-compilation.
Or probably should do it slightly differently so it can be changed during execution.
I can hear birds chirping
:twisted:

I live in the Eye of Insanity.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Now I'm no longer sure...

If I don't put it in 1.6 then I don't have to care that much about downward compatibility. Which means I would actually rather prefer kicking the old enum values. I added them based on some wrong idea and so now I've seen the ugly truth I think they should rather be removed.

Isn't there some OS-support for left-handed to switch right-left clicks at OS level so that applications already receive that switched?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Ulf
Posts: 281
Joined: Mon Jun 15, 2009 8:53 am
Location: Australia

Post by Ulf »

CuteAlien wrote:Now I'm no longer sure...

If I don't put it in 1.6 then I don't have to care that much about downward compatibility. Which means I would actually rather prefer kicking the old enum values. I added them based on some wrong idea and so now I've seen the ugly truth I think they should rather be removed.
I don't really care either especially because I haven't made anything yet with Irrlicht. But I wouldn't want to break anything.

Anyway, I don't think it's much of a problem for backward compatibility if we do remove them.
All anyone must do in their project is change every EMIE_MOUSE_DOUBLE_CLICK to EMIE_LMOUSE_DOUBLE_CLICK. Isn't that all? Then they'd maintain the left handedness as well.

CuteAlien wrote:Isn't there some OS-support for left-handed to switch right-left clicks at OS level so that applications already receive that switched?
We are obviously speaking about double clicks here, I gather..

I don't believe so. Not in Windows anyway. Because in Windows each mouse button has its own double click event variable.
There is no "double click". It's left, right, middle, and X double click.
They are all #define variables.

Besides, the OS doesn't define any handedness.
Left or right handedness is just a concept that is implemented in the commonly accepted way.
Some people may actually prefer to double click the right button when right handed. Maybe it's just because they have a sore finger.
The point is we all use left button because that is what became standardized. Maybe it is most comfortable, but not necessarily.

It's up to the application (hence app developer) to define the handedness of the application, i.e. left or right handed.
Generally everything is programmed in a right handed fashion that's all.
So in general since most programs only need the functionality of a double click for 1 button, the left button double click is implemented.

But the OS libraries have the option to use double click with every button. At least, Windows does. The others should too.
I can hear birds chirping
:twisted:

I live in the Eye of Insanity.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Ulf wrote:
CuteAlien wrote:Isn't there some OS-support for left-handed to switch right-left clicks at OS level so that applications already receive that switched?
We are obviously speaking about double clicks here, I gather..
Hm, no I meant generally. I just googled for left handed mouse and it seems you can simply switch the buttons in Windows. So no need for applications to care about that.

edit: And don't worry - I got that with double-click per button already. I don't forget that again 2 days later ^^. And it will be changed - only open question is if I keep the old enum values or if I kick them.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Ulf
Posts: 281
Joined: Mon Jun 15, 2009 8:53 am
Location: Australia

Post by Ulf »

CuteAlien wrote:Hm, no I meant generally. I just googled for left handed mouse and it seems you can simply switch the buttons in Windows. So no need for applications to care about that.
Interesting and true.
I just tested it.

That makes sense actually. What I was saying about not having a handedness only applies to the C library (kernel). The OS is just an application.
So the OS may swap the left and right button mouse events, sending a left mouse event when receiving a right and vice versa.

Irrlicht doesn't need to worry about that. The user can set up their OS and Irrlicht will receive the appropriate event from the OS.

So we just need to be concerned with access to all the double click events.
only open question is if I keep the old enum values or if I kick them.
I agree, and I already said what I think about it in my last post.
I can hear birds chirping
:twisted:

I live in the Eye of Insanity.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

I've now added changed for that to svn trunk. Kicked old events and added events per mouse-button. Still some time to complain until 1.7 release so check it out!
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Ulf
Posts: 281
Joined: Mon Jun 15, 2009 8:53 am
Location: Australia

Post by Ulf »

It looks perfect to me.
The work is done in CIrrDeviceStub so it's exactly the same in Linux, Windows and SDL versions.
I believe it's effective and as efficient as possible.

After having already included the multiclick function in 1.6, it was a simple change.
I don't think that should affect anyone. I can't see how it could, besides having to change the name double click to left double click.

I looked in CSceneNodeAnimatorCameraMaya.cpp because I noticed you needed to change that. Same thing there, the change doesn't affect anything in operation.

All looks well.
I can hear birds chirping
:twisted:

I live in the Eye of Insanity.
Post Reply