tidied up whitespace in osx mouse acceleration hack code. fixed declaration

of the new cvar to use the new cvar flags.

git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@601 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2012-01-07 08:50:11 +00:00
parent 31ad97cccd
commit 5e9d475661

View file

@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "SDL.h" #include "SDL.h"
#ifdef __APPLE__ #ifdef __APPLE__
// Mouse acceleration needs to be disabled /* Mouse acceleration needs to be disabled on OS X */
#define MACOS_X_ACCELERATION_HACK #define MACOS_X_ACCELERATION_HACK
#endif #endif
@ -54,7 +54,7 @@ static int buttonremap[] =
cvar_t m_filter = {"m_filter","0",CVAR_NONE}; cvar_t m_filter = {"m_filter","0",CVAR_NONE};
#ifdef MACOS_X_ACCELERATION_HACK #ifdef MACOS_X_ACCELERATION_HACK
cvar_t in_disablemacosxmouseaccel = {"in_disablemacosxmouseaccel", "1", true}; static cvar_t in_disablemacosxmouseaccel = {"in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE};
static double originalMouseSpeed = -1.0; static double originalMouseSpeed = -1.0;
#endif #endif
@ -76,12 +76,7 @@ static int FilterMouseEvents (const SDL_Event *event)
} }
#ifdef MACOS_X_ACCELERATION_HACK #ifdef MACOS_X_ACCELERATION_HACK
/* static io_connect_t IN_GetIOHandle(void)
===============
IN_GetIOHandle
===============
*/
static io_connect_t IN_GetIOHandle(void) // mac os x mouse accel hack
{ {
io_connect_t iohandle = MACH_PORT_NULL; io_connect_t iohandle = MACH_PORT_NULL;
kern_return_t status; kern_return_t status;
@ -89,11 +84,11 @@ static io_connect_t IN_GetIOHandle(void) // mac os x mouse accel hack
mach_port_t masterport; mach_port_t masterport;
status = IOMasterPort(MACH_PORT_NULL, &masterport); status = IOMasterPort(MACH_PORT_NULL, &masterport);
if(status != KERN_SUCCESS) if (status != KERN_SUCCESS)
return 0; return 0;
iohidsystem = IORegistryEntryFromPath(masterport, kIOServicePlane ":/IOResources/IOHIDSystem"); iohidsystem = IORegistryEntryFromPath(masterport, kIOServicePlane ":/IOResources/IOHIDSystem");
if(!iohidsystem) if (!iohidsystem)
return 0; return 0;
status = IOServiceOpen(iohidsystem, mach_task_self(), kIOHIDParamConnectType, &iohandle); status = IOServiceOpen(iohidsystem, mach_task_self(), kIOHIDParamConnectType, &iohandle);
@ -110,18 +105,15 @@ void IN_Activate (void)
return; return;
#ifdef MACOS_X_ACCELERATION_HACK #ifdef MACOS_X_ACCELERATION_HACK
// mac os x mouse accel 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)
{ {
io_connect_t mouseDev = IN_GetIOHandle(); io_connect_t mouseDev = IN_GetIOHandle();
if(mouseDev != 0) if (mouseDev != 0)
{ {
if(IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess) if (IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
{ {
if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess) if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
{ {
Con_Printf("WARNING: Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n"); Con_Printf("WARNING: Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
Cvar_Set ("in_disablemacosxmouseaccel", "0"); Cvar_Set ("in_disablemacosxmouseaccel", "0");
@ -140,7 +132,6 @@ void IN_Activate (void)
Cvar_Set ("in_disablemacosxmouseaccel", "0"); 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)
@ -170,14 +161,12 @@ void IN_Deactivate (qboolean free_cursor)
return; return;
#ifdef MACOS_X_ACCELERATION_HACK #ifdef MACOS_X_ACCELERATION_HACK
// mac os x mouse accel hack if (originalMouseSpeed != -1.0)
{
if(originalMouseSpeed != -1.0)
{ {
io_connect_t mouseDev = IN_GetIOHandle(); io_connect_t mouseDev = IN_GetIOHandle();
if(mouseDev != 0) if (mouseDev != 0)
{ {
if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess) if (IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
Con_Printf("WARNING: Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n"); Con_Printf("WARNING: Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
IOServiceClose(mouseDev); IOServiceClose(mouseDev);
} }
@ -187,7 +176,6 @@ void IN_Deactivate (qboolean free_cursor)
} }
originalMouseSpeed = -1; originalMouseSpeed = -1;
} }
}
#endif #endif
if (free_cursor) if (free_cursor)