• entries
73
131
• views
55155

DirectInput and absolute coordinates .

371 views

So it looks like the people who don't like DirectInput say that's it's stupid because it can't do absolute positioning.

Though I'm not going to judge a whole API because of that one feature... it really should do it better.

It does have absolute positioning, but the relative coordinate is basically out of this country from the size of the numbers I'm seeing. The whole point of absolute coordinates is that they are relative to the topleft corner of the window! Or at least some part of the window. I want to know exactly where the cursor is over the window by having the (0,0) point at the topleft corner of the rendering screen. Not the topleft corner of the window. Not some random point across the country.

Apparently this is a lot harder with Windows and DirectInput than I thought. This was so simple in SDL. If I use DirectInput, I just can't get absolute coordinates relative to the top left corner of the window. If I use Windows' cursor functions, I can finally get it but it tends to include the border in its calculations, and I'm not confident that it works in all situations (cursor going outside the window screwing it up, etc?).

This is my final function to get relative and absolute coordinates. If anyone knows of a better way, please tell me!

AXResult AXTaskInput::_UpdateMouseState() {	HRESULT hr;	_LastMouseState = _MouseState;	hr = _DXMouse->GetDeviceState(sizeof(DIMOUSESTATE), (void*)&_MouseState);	if(FAILED(hr)) {		AXAppLog->Write(MESSAGE_SYS, "Failed getting device state (mouse): %s", DXGetErrorString9(hr));		AXAppLog->Write(MESSAGE_SYS, "Attempting to re-acquire.");		hr = _DXMouse->Acquire();		while(hr == DIERR_INPUTLOST)			hr = _DXMouse->Acquire();		if(FAILED(hr)) {			AXAppLog->Write(MESSAGE_SYS, "Failed to re-acquire device (mouse): %s", DXGetErrorString9(hr));			return AXFAILURE;		}		else {			AXAppLog->Write(MESSAGE_SYS, "Successfully re-acquired device (mouse)!");			_DXMouse->GetDeviceState(sizeof(DIMOUSESTATE), (void*)&_MouseState);		}	}	MousedX = _MouseState.lX;	MousedY = _MouseState.lY;	// Do some funky Windows stuff to figure out the position of the cursor	POINT p;	GetCursorPos(&p);	ScreenToClient(AXWindow::Instance().GetHWND(), &p);	MouseX = p.x;	MouseY = p.y;	AXAppLog->Write(MESSAGE_APP, "MousedX: %d  MousedY: %d", MousedX, MousedY);	AXAppLog->Write(MESSAGE_APP, "MouseX: %d  MouseY: %d", MouseX, MouseY);	return AXSUCCESS;}

How did you change the color of your journal like that?

-IV

Simple, I looked at the source of the page and overrode some of the CSS styles.

This is exactly what I put in the header of my journal:

<style type="text/css">
.postcell {background-color: #006677}
.altforumcell {background-color: #004455}
.forumcell {background-color: #223339}
</style>


Thought I'd make it a little different [grin]

Create an account

Register a new account