Page 2 of 2

Re: Quake's mouse code is written stupidly

Posted: Wed Jul 18, 2012 11:51 pm
by Baker
Spike wrote:q3 supposedly has a much cleaned up input system. events are shoved into a queue by whatever windowing system code is active, and handled in a single unified place. instead of different input code on every single platform.
which reminds me that I need to do the same thing myself some time. hrmph.
Interesting. I hate working on the input code on multiple (video is usually easy, but the input portion is always highly different and usually its own source file for no reason).

This has been an extremely useful thread bump.

Re: Quake's mouse code is written stupidly

Posted: Mon Jul 23, 2012 4:51 pm
by r00k
Im kinda confused why in vid_svga.c we have

Code: Select all

	if (m_filter.value)
	{
		mouse_x = (mx + old_mouse_x) * 0.5;
		mouse_y = (my + old_mouse_y) * 0.5;
	}
	else
	{
		mouse_x = mx;
		mouse_y = my;
	}

	old_mouse_x = mx;
	old_mouse_y = my;
	mx = my = 0;	// clear for next update
while in vid_x11 we have this

Code: Select all

	tx = mouse_x;
	ty = mouse_y;

	if (m_filter.value)
	{
		mouse_x = (mouse_x + old_mouse_x) * 0.5;
		mouse_y = (mouse_y + old_mouse_y) * 0.5;
	}

	old_mouse_x = mouse_x;
	old_mouse_y = mouse_y;
Then in vid_glx.c I have this

Code: Select all

	tx = mouse_x;
	ty = mouse_y;

	if (m_filter.value)
	{
		mouse_x = (tx + old_mouse_x) * 0.5;
		mouse_y = (ty + old_mouse_y) * 0.5;
	}

	old_mouse_x = tx;
	old_mouse_y = ty;
UGH!

is i tried this for testing

Code: Select all

	if (m_filter.value) 
	{
		mouse_x = ((float)mx + (float)old_mouse_x) * 0.5f;
		mouse_y = ((float)my + (float)old_mouse_y) * 0.5f;
		
		if (m_filter.value == 1) 
		{
			old_mouse_x = mx;
			old_mouse_y = my;
		}
		else
		{
			old_mouse_x = mouse_x;
			old_mouse_y = mouse_y;
		}
	} 
	else 
	{
		mouse_x = mx;
		mouse_y = my;
	}
What's the difference? I really cant tell...

Re: Quake's mouse code is written stupidly

Posted: Mon Jul 23, 2012 7:03 pm
by Baker
Things that affect the input state (is mouse on or off. Can also affect keyboard)
ActiveApp - Is the application active
Minimized - Is the application minimized
key_dest - is the key (input) destination the console or menu (mouse is released in windowed mode)
con_forcedup - key_dest might be key_game, but cl.worldmodel is null or cls.signon isn't completed (so we get console)
scr_disabled_for_loading ... because we don't draw the console no matter what (key_dest and conforcedup don't matter)
[except I think this should allow drawing the console anyway if key_dest really is key_console?]
Windowed - To know if we are in windowed mode
_windowed_mouse - If mouse is even supposed to be available in _windowed_mode

Command line params: -nomouse, -nojoy, -dinput

Other circumstances: pre-initialization, shutdown

Extra: Video mode restart, m_directinput cvar if an engine supports that

Mouseclip region has to be updated if window is moved, resized.
Connection state. If not running a map or connected to a server, DirectInput isn't run meaning mouse messages (mouse wheel in particular) is lost.