General mouse movement input design

Started by
0 comments, last by Shambles 21 years, 6 months ago
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.
"Everything has a reason."
Advertisement
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.

This topic is closed to new replies.

Advertisement