Advertisement

mouse input question

Started by June 17, 2001 11:18 AM
6 comments, last by omegasyphon 23 years, 7 months ago
ok i have my rendering portion down in my program and i want to use the mouse to move around a grid and have like a box as a cursor that would highlight any points on the grid to change. im using opengl but should i use directinput for this part?
You can, but you don''t have to use it...
You can also use windows'' messages to monitor mouse movement (Messages like WM_MOUSEMOVE and such).
It''s up to you



- Goblineye Entertainment
The road to success is always under construction
Goblineye EntertainmentThe road to success is always under construction
Advertisement
what would be the easiest way to do it?
I agree with Tornado that you should just use the Windows messages, all things microsoft aren''t bad...
well what are the windows messages? is their an article on this?



Edited by - omegasyphon on June 17, 2001 9:08:29 PM
I just use GetCursorPos in my code - it returns an xy struct.

As for the Windows messages...assuming your code as it is does anything at all - you should have a function looking something like:
LRESULT CALLBACK WndProc(	HWND	hWnd,					// Handle For This Window				UINT	uMsg,					// Message For This Window				WPARAM	wParam,					// Additional Message Information				LPARAM	lParam)					// Additional Message Information{	switch (uMsg)								// Check For Windows Messages	{		case WM_CLOSE:							// Did We Receive A Close Message?		{			PostQuitMessage(0);					// Send A Quit Message			return 0;						// Jump Back		}		case WM_KEYDOWN:						// Is A Key Being Held Down?		{			app.keyDown(wParam);				// If So, Mark It As TRUE			return 0;						// Jump Back		}		case WM_KEYUP:							// Has A Key Been Released?		{			app.keyUp(wParam);					// If So, Mark It As FALSE			return 0;						// Jump Back		}.... 


Each of those WM_KEYUP (or whatever) parameters is a windows message. You just add into your case statement the WM_MOUSEMOVE value, and whatever handler you want to call when it occurs...

.fishy
Advertisement
If you use DirectInput you can setup the mouse in buffered mode - which mean you are far, far, far, far less likely to miss mouse events. The message pump is rather unreliable.

Since the mouse uses an interruapt it''s entirely possible to set it up so that you *never* miss and motion or button clicks; and this is nearly possible with DirectInput. The only exception is if another program takes focus of the mouse, you will stop getting events.

You can also use GetKeyState to poll the keyboard and mouse at the same time (the mouse appears as seven or so more keys)

Magmai Kai Holmlor
- The disgruntled & disillusioned
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
do i need to check for windows messages if im using directx?

This topic is closed to new replies.

Advertisement