IN_Accumulate
Moderator: InsideQC Admins
3 posts
• Page 1 of 1
IN_Accumulate
Can anyone really tell me what's the purpose of this function? It's called every frame in snd_ExtraUpdate...
so within in_win.c we use it ..
So, each frame it looks like
mx = (current_pos.x - window_center_x) + (current_pos.x - window_center_x)
my = (current_pos.y - window_center_y) + (current_pos.y - window_center_y);
?!?!?
- Code: Select all
void IN_Accumulate (void)
{
if (mouseactive)
{
if (!dinput)
{
GetCursorPos (¤t_pos);
if (key_dest == key_game)
{
mx_accum += current_pos.x - window_center_x;
my_accum += current_pos.y - window_center_y;
}
else
{
mx_accum = 0;
my_accum = 0;
}
// Force the mouse to the center, so there's room to move.
if (key_dest == key_game)
SetCursorPos (window_center_x, window_center_y);
}
}
}
so within in_win.c we use it ..
- Code: Select all
...
{
GetCursorPos (¤t_pos);
mx = current_pos.x - window_center_x + mx_accum;
my = current_pos.y - window_center_y + my_accum;
mx_accum = my_accum = 0;
}
if (m_filter.value)
{
mouse_x = (mx + old_mouse_x * 0.5);
mouse_y = (my + old_mouse_y * 0.5);
}
...
So, each frame it looks like
mx = (current_pos.x - window_center_x) + (current_pos.x - window_center_x)
my = (current_pos.y - window_center_y) + (current_pos.y - window_center_y);
?!?!?
- r00k
- Posts: 1110
- Joined: Sat Nov 13, 2004 10:39 pm
Best guess.
Because Snd_ExtraUpdate is for handling the case where you're running slow, IN_Accumulate is also for handling the same case for input. It's purpose therefore is to accumulate mouse movement and re-center the cursor in such a scenario. Otherwise, when running slow there is a possibility that mouse movement may go beyond the window bounds, therefore get clipped to the window, and therefore you won't get a full move reflecting how far you actually moved the mouse. (Alternatively, if running slow you might go outside the window bounds temporarily before windows can clip your movement to back inside the bounds, and therefore lose the mouse in-game - haven't tested this and it would only be relevant for windowed modes).
It doesn't get called with DirectInput because if using DirectInput - at least on XP or earlier - mouse cursor clipping is not an issue; DirectInput will handle that automatically for you.
The net movement should be the very same if not running slow, so it should be safe to call at any time. There may be a perfomance decrease from sampling the mouse so many times per frame (particularly in software Quake) but I doubt if it's measurable on modern PCs.
Because Snd_ExtraUpdate is for handling the case where you're running slow, IN_Accumulate is also for handling the same case for input. It's purpose therefore is to accumulate mouse movement and re-center the cursor in such a scenario. Otherwise, when running slow there is a possibility that mouse movement may go beyond the window bounds, therefore get clipped to the window, and therefore you won't get a full move reflecting how far you actually moved the mouse. (Alternatively, if running slow you might go outside the window bounds temporarily before windows can clip your movement to back inside the bounds, and therefore lose the mouse in-game - haven't tested this and it would only be relevant for windowed modes).
It doesn't get called with DirectInput because if using DirectInput - at least on XP or earlier - mouse cursor clipping is not an issue; DirectInput will handle that automatically for you.
The net movement should be the very same if not running slow, so it should be safe to call at any time. There may be a perfomance decrease from sampling the mouse so many times per frame (particularly in software Quake) but I doubt if it's measurable on modern PCs.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest