Mouse Double Click - MOUSE MULTI CLICK !

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Ulf
Posts: 281
Joined: Mon Jun 15, 2009 8:53 am
Location: Australia

Post by Ulf »

bitplane wrote:
But what about that person with Parkinson's, who set up his operating system's double click speed so he can easily double click. Shouldn't we respect that? It does mean more work by supporting it in all the different devices, but I reckon it's better than ignoring the OS values.
No not really. The speed is accessible and so the programmer can make it accessible in the application. If the user uses the app, they will set it up.
I think it's better. It's more flexible. It doesn't get affected by operating system changes.
Also I think the Mac idea of multiple clicks is another instance of all n's are equally likely. I can't think of a single example of when you'd need a triple or quadruple click.
Ok. I didn't really see a need for it either. I think I worked out how to basically do it though.. but if nobody wants it I won't bother.

Maybe I'd use it in special cases in the future
I can hear birds chirping
:twisted:

I live in the Eye of Insanity.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Ulf wrote:Also, why don't we change the EMOUSE_INPUT_EVENT types to irr::u32 ?

It's the same thing in a counting way.

Is enum some benefit over u32 for this case?
With an enumeration we know all the possible values, your IDE can provide a nice drop down list, the compiler can offer warnings when switch blocks don't explicitly contain all options, it works well with automatic documentation, an enumeration is only as wide as its largest value which helps keep the size of the SEvent struct to a minimum. It's the C++ way.
Ulf wrote:No not really. The speed is accessible and so the programmer can make it accessible in the application. If the user uses the app, they will set it up.
I think it's better. It's more flexible. It doesn't get affected by operating system changes.
I agree that it does sound better and it will be easier to write, but mostly for emotional reasons and not invented here syndrome.
Every program will need an options screen, most won't so we'll be making user-end software less accessible. Also people expect their double-click speeds to be the same as their operating system, any deviation from this makes it feel awkward (read Joel's UI book, it makes a lot of sense).

I'd like to hear what others think about this though.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

bitplane wrote:Also I think the Mac idea of multiple clicks is another instance of all n's are equally likely. I can't think of a single example of when you'd need a triple or quadruple click.
Hehe, I also only started finding out _how many_ applications actually support triple click since I noticed that there is a window event for that. Just try it occasionally in different applications - you will be surprised (for example it works right here in this edit-field for me).

The other thing - about using system settings for double-clicks: I basically aggree that it wouldn't be bad to use user-settings. That's why I asked if it is possible to get that value from the system, so we could use it for default initialization. And using the events themselves (when available - not available for example on X11) has certainly also some advantages. For example it would still work for people using some double-click emulation. Or when MS decides to introduce a new keyboard with a "double-click" button.

It's basically the awt vs. swing discussion. Do you do use native stuff or implement your own stuff on top of it.I think for Irrlicht which is always more game-ui like than trying to emulate systems it actually _is_ ok to implement stuff itself. Also that's the way it's handled so far all over the place anyway :-) We use own gui-elements already - and I think using an own double-click with a customizable time setting is also fine for games.
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 »

bitplane said:
With an enumeration we know all the possible values, your IDE can provide a nice drop down list, the compiler can offer warnings when switch blocks don't explicitly contain all options, it works well with automatic documentation, an enumeration is only as wide as its largest value which helps keep the size of the SEvent struct to a minimum. It's the C++ way.
Ok. Is it safe to do a cast if you want to add an integer to an enum then? When working out extra mouse buttons. e.g.

Code: Select all

if (XButton & XBUTTON2)
      XButtonModifier = 1;
   else if (XButton & XBUTTON3)
      XButtonModifier = 2;
   else if (XButton & XBUTTON4)
      XButtonModifier = 3;
   else if (XButton & XBUTTON5)
      XButtonModifier = 4;
   else // if (XButton & XBUTTON1) // else just treat it as first extra mouse button
      XButtonModifier = 0;

   event.MouseInput.Event = (irr::EMOUSE_INPUT_EVENT)(irr::EMIE_4MOUSE_PRESSED_DOWN + XButtonModifier); 
*EDITED* No. I thought about it. It's not safe, but it is as long as you do an extra check. In the enum, you need to put a MAX value variable and check against it like so:

Code: Select all

irr::EMOUSE_INPUT_EVENT eventValue = (irr::EMOUSE_INPUT_EVENT) (irr::EMIE_4MOUSE_PRESSED_DOWN + XButtonModifier)
event.MouseInput.Event = (eventValue < irr::EMIE_MAX ? eventValue : irr::EMIE_MAX - 1); 
If it goes over the bounds, it just returns the last button value.
Every program will need an options screen, most won't so we'll be making user-end software less accessible. Also people expect their double-click speeds to be the same as their operating system, any deviation from this makes it feel awkward (read Joel's UI book, it makes a lot of sense).

I'd like to hear what others think about this though.
That's the question we all want to know huh? What do most users of irrlicht want? Then it can be patched.

CuteAlien:
I basically aggree that it wouldn't be bad to use user-settings. That's why I asked if it is possible to get that value from the system, so we could use it for default initialization. And using the events themselves (when available - not available for example on X11) has certainly also some advantages. For example it would still work for people using some double-click emulation. Or when MS decides to introduce a new keyboard with a "double-click" button.


I've searched a little, haven't found how to access the value in Windows yet.

I'd like to know what others think about it: Irrlicht's own settings all round?
Or using system settings and WM_LBUTTONDBLCLK, instead of Irrlichts own double/multi click.

I think for Irrlicht which is always more game-ui like than trying to emulate systems it actually _is_ ok to implement stuff itself. Also that's the way it's handled so far all over the place anyway :-) We use own gui-elements already - and I think using an own double-click with a customizable time setting is also fine for games.


That's the line I was taking. It's basically for games, simulators etc.

Even if it's for some gui type application like a paint program I think it's ok to force the application programmer to discover the system default if that's what they want to do for different operating systems.

If irrlicht can access it, then the user will be able to access it since irrlicht is open source.
I can hear birds chirping
:twisted:

I live in the Eye of Insanity.
Ulf
Posts: 281
Joined: Mon Jun 15, 2009 8:53 am
Location: Australia

How do I contribute suggestions to the SVN?

Post by Ulf »

As seen in this thread, I have patched "my" Irrlicht to be able to use double click.
I want to complete my double click changes and post it on the SVN.

Can anyone guide me a little on how to go about this?
CuteAlien" wrote: The part with "case WM_LBUTTONDOWN" does no longer exist in the engine, that stuff was rewritten in current trunk. So have to see how that must be added in current Irrlicht.
BTW, I noticed the changes to the CIrrDevice classes. The mouse events have been changed. I can easily incorporate it into those changes. It looks much nicer now how those events are handled (referring to the Windows version at least).

I have already downloaded the latest version from the SVN.
So do I start from there? Should I edit those files?

And how does it work?
Do I just change the file by deleting anything no longer needed, and adding what is needed?
Or do I need to put tags in there to indicate the changes?

And then how do I upload it for checking?

I wanted to add extra mouse buttons, but I noticed it's already done. Well, it's done for 2 extra mouse buttons in Windows only.

Doesn't Linux and Mac have possibility of more mouse buttons? Or we just don't know yet?
Also, isn't Windows capable of having more than 2 extra mouse buttons? I thought it had up to 5 more! It's not documented in the API but I thought there were Mice with more than 5 buttons.
I figured that you just need to keep doubling the value of the extra mouse button e.g. EMBSM_EXTRA2 = 0x10, so EMBSM_EXTRA3 = 0x20. But I haven't been able to test it yet until I get a Mouse with all those buttons!

**EDIT**
Just thought about something. You guys were sort of arguing on the side of using operating system parameters etc..

But the appropriate changes haven't been made yet.
WM_LBUTTONDBLCLK (and the other 2) hasn't been added to:

Code: Select all

static messageMap mouseMap[] =
{
	{0, WM_LBUTTONDOWN, irr::EMIE_LMOUSE_PRESSED_DOWN},
	{1, WM_LBUTTONUP,   irr::EMIE_LMOUSE_LEFT_UP},
	{0, WM_RBUTTONDOWN, irr::EMIE_RMOUSE_PRESSED_DOWN},
	{1, WM_RBUTTONUP,   irr::EMIE_RMOUSE_LEFT_UP},
	{0, WM_MBUTTONDOWN, irr::EMIE_MMOUSE_PRESSED_DOWN},
	{1, WM_MBUTTONUP,   irr::EMIE_MMOUSE_LEFT_UP},
	{2, WM_MOUSEMOVE,   irr::EMIE_MOUSE_MOVED},
	{3, WM_MOUSEWHEEL,  irr::EMIE_MOUSE_WHEEL},
	{-1, 0, 0}
};
Also, the Extra Mouse Buttons are not there either.
No point having them if they're not used is there? We'll all have to implement it ourselves.
bitplane wrote: Also people expect their double-click speeds to be the same as their operating system, any deviation from this makes it feel awkward
I'm still wondering what people want in this case?

Same for allowable mouse movement for double click?

And do we want a triple click or just double click?

Cause I'll do it!
:twisted:

Best as I can anyway.
I can hear birds chirping
:twisted:

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

Re: How do I contribute suggestions to the SVN?

Post by CuteAlien »

Ulf wrote:As seen in this thread, I have patched "my" Irrlicht to be able to use double click.
I want to complete my double click changes and post it on the SVN.

Can anyone guide me a little on how to go about this?

I have already downloaded the latest version from the SVN.
So do I start from there? Should I edit those files?

And how does it work?
Do I just change the file by deleting anything no longer needed, and adding what is needed?
Or do I need to put tags in there to indicate the changes?

And then how do I upload it for checking?
You can post on the trackers (like feature tracker or patch tracker). You add an entry there and attack the patch-file. SVN write access is restricted to the Irrlicht team.

To create patches you use the "patch" program. I'm not having too much experience using that on windows - maybe windiff or similar tools allow creating patches. Otherwise install cygwin or mingw which both come with patch.

For a "patch" you always need 2 versions of the sources. If you change your svn-version then you can for example do a "svn diff" to create a patch for all changes to the unchanged svn version on the server. If you have more than one patch then it starts to get tricky. You can have for example several versions of Irrlicht on your hd. Or you can use a distributed version control system like mercurial which makes it easier having a local version control so you can always do new patches for your last changes. The most important thing anyway is - make a separate patch for every(!) local change to your engine (I didn't do that when I started and that caused lots of work for me down the road).

I don't expect patches on the tracker to always be for latest svn - the engine changes too fast for that and it often takes some months until we get around reviewing them. But certainly - the more current it is the easier is it to review a patch.
Ulf wrote: I wanted to add extra mouse buttons, but I noticed it's already done. Well, it's done for 2 extra mouse buttons in Windows only.

Doesn't Linux and Mac have possibility of more mouse buttons? Or we just don't know yet?
I don't know about Mac. I remember that on X11 (linux) Button 4 and 5 did refer to the mouse-wheel (but maybe only on my system - I don't know how mice with more buttons map that as I also just have a 3 button mouse).
Ulf wrote: Also, isn't Windows capable of having more than 2 extra mouse buttons? I thought it had up to 5 more! It's not documented in the API but I thought there were Mice with more than 5 buttons.
Not sure, maybe those need a custom API to access the extra-buttons. I don't think it is that important to us - supporting as much buttons as the OS should be enough.
Ulf wrote: I figured that you just need to keep doubling the value of the extra mouse button e.g. EMBSM_EXTRA2 = 0x10, so EMBSM_EXTRA3 = 0x20. But I haven't been able to test it yet until I get a Mouse with all those buttons!
Guessing is usually a bad idea in programming - better check docs/headers when looking for constants.
Ulf wrote: **EDIT**
Just thought about something. You guys were sort of arguing on the side of using operating system parameters etc..

But the appropriate changes haven't been made yet.
WM_LBUTTONDBLCLK (and the other 2) hasn't been added to:

Code: Select all

static messageMap mouseMap[] =
{
	{0, WM_LBUTTONDOWN, irr::EMIE_LMOUSE_PRESSED_DOWN},
	{1, WM_LBUTTONUP,   irr::EMIE_LMOUSE_LEFT_UP},
	{0, WM_RBUTTONDOWN, irr::EMIE_RMOUSE_PRESSED_DOWN},
	{1, WM_RBUTTONUP,   irr::EMIE_RMOUSE_LEFT_UP},
	{0, WM_MBUTTONDOWN, irr::EMIE_MMOUSE_PRESSED_DOWN},
	{1, WM_MBUTTONUP,   irr::EMIE_MMOUSE_LEFT_UP},
	{2, WM_MOUSEMOVE,   irr::EMIE_MOUSE_MOVED},
	{3, WM_MOUSEWHEEL,  irr::EMIE_MOUSE_WHEEL},
	{-1, 0, 0}
};
Also, the Extra Mouse Buttons are not there either.
No point having them if they're not used is there? We'll all have to implement it ourselves.
Well, yes we haven't made changes yet because we still were arguing :-). Also because I'm a little short on time these weeks...
Ulf wrote:
bitplane wrote: Also people expect their double-click speeds to be the same as their operating system, any deviation from this makes it feel awkward
I'm still wondering what people want in this case?

Same for allowable mouse movement for double click?

And do we want a triple click or just double click?
You start to see the difficult questions now :-)
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 »

Thanks CuteAlien. I'll look into this soon.
CuteAlien wrote: Well, yes we haven't made changes yet because we still were arguing :-). Also because I'm a little short on time these weeks...
Yea I understand. I been short on time too... spent more time on the forum than coding during this week.
I can hear birds chirping
:twisted:

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

Post by CuteAlien »

It's been added now to the svn trunk. It's working mostly similar to your version. I have added double-click and triple-click and Irrlicht checks time itself, but initalizes it on Windows with the system settings. Not yet completely finished - WinCE and OsX support are still missing. I can't do those due to missing development environments (or does anyone know a free way to do WinCE development?).

And sorry I forgot mentioning you when checking-in, will add your name to the changelist next time.

Some test:

Code: Select all

#include <irrlicht.h>
#include <iostream>

using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif

struct SAppContext
{
	IrrlichtDevice * device;
	irr::gui::IGUIStaticText * infoStatic;
	irr::gui::IGUIListBox * infoBox;
};

void PrintMouseEventName(const SEvent& event, irr::core::stringw &result)
{
	switch ( event.MouseInput.Event )
	{
		case EMIE_LMOUSE_PRESSED_DOWN: 	result += stringw(L"EMIE_LMOUSE_PRESSED_DOWN"); break;
		case EMIE_RMOUSE_PRESSED_DOWN: 	result += stringw(L"EMIE_RMOUSE_PRESSED_DOWN"); break;
		case EMIE_MMOUSE_PRESSED_DOWN: 	result += stringw(L"EMIE_MMOUSE_PRESSED_DOWN"); break;
		case EMIE_LMOUSE_LEFT_UP: 		result += stringw(L"EMIE_LMOUSE_LEFT_UP"); break;
		case EMIE_RMOUSE_LEFT_UP: 		result += stringw(L"EMIE_RMOUSE_LEFT_UP"); break;
		case EMIE_MMOUSE_LEFT_UP: 		result += stringw(L"EMIE_MMOUSE_LEFT_UP"); break;
		case EMIE_MOUSE_MOVED: 			result += stringw(L"EMIE_MOUSE_MOVED"); break;
		case EMIE_MOUSE_WHEEL: 			result += stringw(L"EMIE_MOUSE_WHEEL"); break;
		case EMIE_MOUSE_DOUBLE_CLICK: 	result += stringw(L"EMIE_MOUSE_DOUBLE_CLICK"); break;
		case EMIE_MOUSE_TRIPLE_CLICK: 	result += stringw(L"EMIE_MOUSE_TRIPLE_CLICK"); break;
		default:
		break;
	}
}

void PrintMouseState(const SEvent& event, irr::core::stringw &result)
{
	result += stringw(L"X: ");
	result += stringw(event.MouseInput.X);
	result += stringw(L"\n");
		
	result += stringw(L": ");
	result += stringw(event.MouseInput.Y);
	result += stringw(L"\n");


	result += stringw(L"Wheel: ");
	result += stringw(event.MouseInput.Wheel);
	result += stringw(L"\n");
	
	result += stringw(L"Shift: ");
	if ( event.MouseInput.Shift )
		result += stringw(L"true\n");
	else
		result += stringw(L"false\n");

	result += stringw(L"Control: ");
	if ( event.MouseInput.Control )
		result += stringw(L"true\n");
	else
		result += stringw(L"false\n");

	result += stringw(L"ButtonStates: ");
	result += stringw(event.MouseInput.ButtonStates);
	result += stringw(L"\n");

	result += stringw(L"isLeftPressed: ");
	if ( event.MouseInput.isLeftPressed() )
		result += stringw(L"true\n");
	else
		result += stringw(L"false\n");

	result += stringw(L"isRightPressed: ");
	if ( event.MouseInput.isRightPressed() )
		result += stringw(L"true\n");
	else
		result += stringw(L"false\n");

	result += stringw(L"isMiddlePressed: ");
	if ( event.MouseInput.isMiddlePressed() )
		result += stringw(L"true\n");
	else
		result += stringw(L"false\n");

	result += stringw(L"Event: ");
	
	PrintMouseEventName(event, result);
	
	result += stringw(L"\n");
}

class MyEventReceiver : public IEventReceiver
{
public:
	MyEventReceiver(SAppContext & context) : Context(context) { }

	virtual bool OnEvent(const SEvent& event)
	{
		if (event.EventType == EET_MOUSE_INPUT_EVENT)
		{
			irr::core::stringw infoText;
			PrintMouseState(event, infoText);
			Context.infoStatic->setText(infoText.c_str());
			if ( event.MouseInput.Event != EMIE_MOUSE_MOVED && event.MouseInput.Event != EMIE_MOUSE_WHEEL ) // no spam
			{
				infoText = L"";
				PrintMouseEventName(event, infoText);
				Context.infoBox->addItem(infoText.c_str());
			}
		}

		return false;
	}

private:
	SAppContext & Context;
};


int main()
{
	video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
	IrrlichtDevice * device = createDevice(driverType, core::dimension2d<u32>(640, 480));
	if (device == 0)
		return 1; // could not create selected driver.

	video::IVideoDriver* driver = device->getVideoDriver();
	IGUIEnvironment* env = device->getGUIEnvironment();
	
	SAppContext context;
	context.device = device;
	
	core::rect< s32 > rectInfoStatic(10,10, 200, 400);
	context.infoStatic = env->addStaticText (L"", rectInfoStatic, true, true);
	core::rect< s32 > rectInfoBox(210,10, 400, 400);
	context.infoBox = env->addListBox(rectInfoBox);
	
	MyEventReceiver receiver(context);
	device->setEventReceiver(&receiver);
	

	while(device->run() && driver)
	{
		if (device->isWindowActive())
		{
			driver->beginScene(true, true, SColor(0,200,200,200));
	
			env->drawAll();
		
			driver->endScene();
		}
	}

	device->drop();

	return 0;
}

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
Post Reply