Menu

#3 adding ANALOG INPUT: howto

open
nobody
None
5
2011-09-30
2011-09-30
No

written for the 2.1 code (in which About box still says 2.0)

I can't contribute to the project, so here's how to roll your own fix:
1) get Visual Studio (or anything else that can handle the code)
2) download the source for this project and open it
3) in JoyMouse.cpp, find the RefreshState function, and change its beginning as follows:

(this will change the inputs to analog - the harder you tilt the stick, the faster your mouse moves! change value of base_multiplier to control the maximum speed, which then gets multiplied by the configured values anyway)

BOOL RefreshState()
{

int i;

// Get Joystick info
JOYINFOEX ji;
ji.dwSize = sizeof(ji);
ji.dwFlags = JOY_RETURNX | JOY_RETURNY | JOY_RETURNBUTTONS; // | JOY_USEDEADZONE; /* NEW - does not work for me with USEDEADZONE enabled, yours may work with it */
if ( joyGetPosEx(JOYSTICKID1,&ji) != JOYERR_NOERROR)
return false;

double base_multiplier = 5.0; /* NEW */

if (g_bEnabled) {
double dx = 0; /* NEW */
double dy = 0; /* NEW */
long mult = 0;

DWORD dwXmid = ((g_jc.wXmax - g_jc.wXmin)/2);
DWORD dwYmid = ((g_jc.wYmax - g_jc.wYmin)/2);

double dwXPosOffset = double(ji.dwXpos) - double(dwXmid); /* NEW */
double dwYPosOffset = double(ji.dwYpos) - double(dwYmid); /* NEW */

dx = base_multiplier * dwXPosOffset / (double)dwXmid; /* NEW */
dy = base_multiplier * dwYPosOffset / (double)dwYmid; /* NEW */

/*
if (ji.dwXpos < (dwXmid - g_Step)) dx = -1; // DELETED
if (ji.dwXpos > (dwXmid + g_Step)) dx = 1; // DELETED

if (ji.dwYpos < (dwYmid - g_Step)) dy = -1; // DELETED
if (ji.dwYpos > (dwYmid + g_Step)) dy = 1; // DELETED
*/
if (g_bAccel)
mult = g_Speed2;
else
mult = g_Speed;

// Update cursor pos
POINT p;
GetCursorPos(&p);
p.x += long(dx * mult); /* NEW */
p.y += long(dy * mult); /* NEW */
SetCursorPos(p.x,p.y);
}

Discussion


Log in to post a comment.