mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-15 16:41:22 +00:00
tidy up osx mouse acceleration hack a bit more.
git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@602 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
5e9d475661
commit
9dd8339eee
1 changed files with 51 additions and 47 deletions
|
@ -53,11 +53,6 @@ static int buttonremap[] =
|
||||||
/* mouse variables */
|
/* mouse variables */
|
||||||
cvar_t m_filter = {"m_filter","0",CVAR_NONE};
|
cvar_t m_filter = {"m_filter","0",CVAR_NONE};
|
||||||
|
|
||||||
#ifdef MACOS_X_ACCELERATION_HACK
|
|
||||||
static cvar_t in_disablemacosxmouseaccel = {"in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE};
|
|
||||||
static double originalMouseSpeed = -1.0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* total accumulated mouse movement since last frame,
|
/* total accumulated mouse movement since last frame,
|
||||||
* gets updated from the main game loop via IN_MouseMove */
|
* gets updated from the main game loop via IN_MouseMove */
|
||||||
static int total_dx, total_dy = 0;
|
static int total_dx, total_dy = 0;
|
||||||
|
@ -76,12 +71,15 @@ static int FilterMouseEvents (const SDL_Event *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MACOS_X_ACCELERATION_HACK
|
#ifdef MACOS_X_ACCELERATION_HACK
|
||||||
|
static cvar_t in_disablemacosxmouseaccel = {"in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE};
|
||||||
|
static double originalMouseSpeed = -1.0;
|
||||||
|
|
||||||
static io_connect_t IN_GetIOHandle(void)
|
static io_connect_t IN_GetIOHandle(void)
|
||||||
{
|
{
|
||||||
io_connect_t iohandle = MACH_PORT_NULL;
|
io_connect_t iohandle = MACH_PORT_NULL;
|
||||||
kern_return_t status;
|
|
||||||
io_service_t iohidsystem = MACH_PORT_NULL;
|
io_service_t iohidsystem = MACH_PORT_NULL;
|
||||||
mach_port_t masterport;
|
mach_port_t masterport;
|
||||||
|
kern_return_t status;
|
||||||
|
|
||||||
status = IOMasterPort(MACH_PORT_NULL, &masterport);
|
status = IOMasterPort(MACH_PORT_NULL, &masterport);
|
||||||
if (status != KERN_SUCCESS)
|
if (status != KERN_SUCCESS)
|
||||||
|
@ -96,7 +94,50 @@ static io_connect_t IN_GetIOHandle(void)
|
||||||
|
|
||||||
return iohandle;
|
return iohandle;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
static void IN_DisableOSXMouseAccel (void)
|
||||||
|
{
|
||||||
|
io_connect_t mouseDev = IN_GetIOHandle();
|
||||||
|
if (mouseDev != 0)
|
||||||
|
{
|
||||||
|
if (IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
|
||||||
|
{
|
||||||
|
if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
|
||||||
|
{
|
||||||
|
Cvar_Set("in_disablemacosxmouseaccel", "0");
|
||||||
|
Con_Printf("WARNING: Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Cvar_Set("in_disablemacosxmouseaccel", "0");
|
||||||
|
Con_Printf("WARNING: Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n");
|
||||||
|
}
|
||||||
|
IOServiceClose(mouseDev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Cvar_Set("in_disablemacosxmouseaccel", "0");
|
||||||
|
Con_Printf("WARNING: Could not disable mouse acceleration (failed at IO_GetIOHandle).\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void IN_ReenableOSXMouseAccel (void)
|
||||||
|
{
|
||||||
|
io_connect_t mouseDev = IN_GetIOHandle();
|
||||||
|
if (mouseDev != 0)
|
||||||
|
{
|
||||||
|
if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
|
||||||
|
Con_Printf("WARNING: Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
|
||||||
|
IOServiceClose(mouseDev);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Con_Printf("WARNING: Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
|
||||||
|
}
|
||||||
|
originalMouseSpeed = -1;
|
||||||
|
}
|
||||||
|
#endif /* MACOS_X_ACCELERATION_HACK */
|
||||||
|
|
||||||
|
|
||||||
void IN_Activate (void)
|
void IN_Activate (void)
|
||||||
|
@ -107,31 +148,7 @@ void IN_Activate (void)
|
||||||
#ifdef MACOS_X_ACCELERATION_HACK
|
#ifdef MACOS_X_ACCELERATION_HACK
|
||||||
/* Save the status of mouse acceleration */
|
/* Save the status of mouse acceleration */
|
||||||
if (originalMouseSpeed == -1 && in_disablemacosxmouseaccel.value)
|
if (originalMouseSpeed == -1 && in_disablemacosxmouseaccel.value)
|
||||||
{
|
IN_DisableOSXMouseAccel();
|
||||||
io_connect_t mouseDev = IN_GetIOHandle();
|
|
||||||
if (mouseDev != 0)
|
|
||||||
{
|
|
||||||
if (IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
|
|
||||||
{
|
|
||||||
if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
|
|
||||||
{
|
|
||||||
Con_Printf("WARNING: Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
|
|
||||||
Cvar_Set ("in_disablemacosxmouseaccel", "0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Con_Printf("WARNING: Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n");
|
|
||||||
Cvar_Set ("in_disablemacosxmouseaccel", "0");
|
|
||||||
}
|
|
||||||
IOServiceClose(mouseDev);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Con_Printf("WARNING: Could not disable mouse acceleration (failed at IO_GetIOHandle).\n");
|
|
||||||
Cvar_Set ("in_disablemacosxmouseaccel", "0");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON)
|
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON)
|
||||||
|
@ -161,21 +178,8 @@ void IN_Deactivate (qboolean free_cursor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef MACOS_X_ACCELERATION_HACK
|
#ifdef MACOS_X_ACCELERATION_HACK
|
||||||
if (originalMouseSpeed != -1.0)
|
if (originalMouseSpeed != -1)
|
||||||
{
|
IN_ReenableOSXMouseAccel();
|
||||||
io_connect_t mouseDev = IN_GetIOHandle();
|
|
||||||
if (mouseDev != 0)
|
|
||||||
{
|
|
||||||
if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
|
|
||||||
Con_Printf("WARNING: Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
|
|
||||||
IOServiceClose(mouseDev);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Con_Printf("WARNING: Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
|
|
||||||
}
|
|
||||||
originalMouseSpeed = -1;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (free_cursor)
|
if (free_cursor)
|
||||||
|
|
Loading…
Reference in a new issue