Archived

This topic is now archived and is closed to further replies.

Shambles

General mouse movement input design

Recommended Posts

Shambles    122
Hi, I''m having trouble figuring out which input design is best. My target is this: 1. Use the same sensitivity for the mouse as the user uses for the desktop (whichever OS.) 2. All buttons must only receive messages telling them what happened. (eg. EVENT_MOUSEMOVE, EVENT_MOUSEDOWN) Currently I use buffered data to trigger events.
  while (!input_done) {
	Input.GetMouseBuffer(&buffer);

	//check if nothing was gotten from buffer...

	...

	switch (buffer.data_type) {
		case BUTTON0:
		case BUTTON1:
		case BUTTON2:
		case BUTTON3:
			if (buffer.data & 0x80)
				event(EVENT_MOUSEDOWN, buffer.data_type);
			else
				if (event(EVENT_MOUSEUP, buffer.data_type))
						input_done = true; // exit loop

			break;

		case MM_X:
		case MM_Y:
			if (!mousemoved) {
				mousemoved = true;
				Cursor.UpdatePos();
				event(EVENT_MOUSEMOVE, NULL);
			}
			break;
	}
}  
As you see, I''m not using buffered mouse movement like its supposed to be used. Perhaps there is a better way to get mousemove events, because I dont want to update the mouse position every frame (unless that is the real answer.) I also dont want it to be too platform specific unless the method used can be used on practicly all platforms.

Share this post


Link to post
Share on other sites
Oluseyi    2103
quote:
Original post by Shambles
...I dont want to update the mouse position every frame (unless that is the real answer.)

Why not? Every one else does. (And I mean everyone - including OSes).

quote:

I also dont want it to be too platform specific...

Messaging mechanism differ. Some platforms/APIs/languages send event notifications, others use signals and slots... If you don''t want to be platform specific, write to an abstraction layer like SDL.

Share this post


Link to post
Share on other sites