mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
Applied patch to disable mouse acceleration in Mac OS X.
git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@599 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
e27c150194
commit
cce245b688
2 changed files with 109 additions and 0 deletions
|
@ -96,6 +96,7 @@
|
|||
48B9E7C00D340EA80001CACF /* SDLApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 48B9E7BF0D340EA80001CACF /* SDLApplication.m */; };
|
||||
48C85E3B0D3AD10E00797678 /* QuakeArgument.m in Sources */ = {isa = PBXBuildFile; fileRef = 48C85E3A0D3AD10E00797678 /* QuakeArgument.m */; };
|
||||
48FE585B0D3A82C8006BB491 /* QuakeArguments.m in Sources */ = {isa = PBXBuildFile; fileRef = 48FE585A0D3A82C8006BB491 /* QuakeArguments.m */; };
|
||||
6649639F14AA71250084BF0D /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6649639E14AA71250084BF0D /* IOKit.framework */; };
|
||||
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
|
||||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
|
||||
B021C20914A5FF7E003F18D6 /* cfgfile.c in Sources */ = {isa = PBXBuildFile; fileRef = B021C20714A5FF7E003F18D6 /* cfgfile.c */; };
|
||||
|
@ -274,6 +275,7 @@
|
|||
48C85E3A0D3AD10E00797678 /* QuakeArgument.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuakeArgument.m; sourceTree = "<group>"; };
|
||||
48FE58590D3A82C8006BB491 /* QuakeArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuakeArguments.h; sourceTree = "<group>"; };
|
||||
48FE585A0D3A82C8006BB491 /* QuakeArguments.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QuakeArguments.m; sourceTree = "<group>"; };
|
||||
6649639E14AA71250084BF0D /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = ../../../../System/Library/Frameworks/IOKit.framework; sourceTree = "<group>"; };
|
||||
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||
8D1107320486CEB800E47090 /* QuakeSpasm.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = QuakeSpasm.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B021C20714A5FF7E003F18D6 /* cfgfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = cfgfile.c; path = ../Quake/cfgfile.c; sourceTree = SOURCE_ROOT; };
|
||||
|
@ -285,6 +287,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
6649639F14AA71250084BF0D /* IOKit.framework in Frameworks */,
|
||||
002F39FA09D0881F00EBEB88 /* SDL.framework in Frameworks */,
|
||||
002F3C6109D0951E00EBEB88 /* GLUT.framework in Frameworks */,
|
||||
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
|
||||
|
@ -330,6 +333,7 @@
|
|||
29B97314FDCFA39411CA2CEA /* QuakeSpasm */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6649639E14AA71250084BF0D /* IOKit.framework */,
|
||||
48243B060D33ED0A00C29F8F /* MacOSX */,
|
||||
483A77D80D2EE8C500CB2E4C /* Quake */,
|
||||
29B97317FDCFA39411CA2CEA /* Resources */,
|
||||
|
|
105
Quake/in_sdl.c
105
Quake/in_sdl.c
|
@ -23,6 +23,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "quakedef.h"
|
||||
#include "SDL.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
// Mouse acceleration needs to be disabled
|
||||
#define MACOS_X_ACCELERATION_HACK
|
||||
#endif
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
#include <IOKit/IOTypes.h>
|
||||
#include <IOKit/hidsystem/IOHIDLib.h>
|
||||
#include <IOKit/hidsystem/IOHIDParameter.h>
|
||||
#include <IOKit/hidsystem/event_status_driver.h>
|
||||
#endif
|
||||
|
||||
static keydest_t prev_key_dest;
|
||||
|
||||
static qboolean no_mouse = false;
|
||||
|
@ -41,6 +53,11 @@ static int buttonremap[] =
|
|||
/* mouse variables */
|
||||
cvar_t m_filter = {"m_filter","0",CVAR_NONE};
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
cvar_t in_disablemacosxmouseaccel = {"in_disablemacosxmouseaccel", "1", true};
|
||||
static double originalMouseSpeed = -1.0;
|
||||
#endif
|
||||
|
||||
/* total accumulated mouse movement since last frame,
|
||||
* gets updated from the main game loop via IN_MouseMove */
|
||||
static int total_dx, total_dy = 0;
|
||||
|
@ -58,11 +75,74 @@ static int FilterMouseEvents (const SDL_Event *event)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
/*
|
||||
===============
|
||||
IN_GetIOHandle
|
||||
===============
|
||||
*/
|
||||
static io_connect_t IN_GetIOHandle(void) // mac os x mouse accel hack
|
||||
{
|
||||
io_connect_t iohandle = MACH_PORT_NULL;
|
||||
kern_return_t status;
|
||||
io_service_t iohidsystem = MACH_PORT_NULL;
|
||||
mach_port_t masterport;
|
||||
|
||||
status = IOMasterPort(MACH_PORT_NULL, &masterport);
|
||||
if(status != KERN_SUCCESS)
|
||||
return 0;
|
||||
|
||||
iohidsystem = IORegistryEntryFromPath(masterport, kIOServicePlane ":/IOResources/IOHIDSystem");
|
||||
if(!iohidsystem)
|
||||
return 0;
|
||||
|
||||
status = IOServiceOpen(iohidsystem, mach_task_self(), kIOHIDParamConnectType, &iohandle);
|
||||
IOObjectRelease(iohidsystem);
|
||||
|
||||
return iohandle;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void IN_Activate (void)
|
||||
{
|
||||
if (no_mouse)
|
||||
return;
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
// mac os x mouse accel hack
|
||||
{
|
||||
// Save the status of mouse acceleration
|
||||
|
||||
if (originalMouseSpeed == -1 && in_disablemacosxmouseaccel.value)
|
||||
{
|
||||
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
|
||||
|
||||
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON)
|
||||
{
|
||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||
|
@ -89,6 +169,27 @@ void IN_Deactivate (qboolean free_cursor)
|
|||
if (no_mouse)
|
||||
return;
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
// mac os x mouse accel hack
|
||||
{
|
||||
if(originalMouseSpeed != -1.0)
|
||||
{
|
||||
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
|
||||
|
||||
if (free_cursor)
|
||||
{
|
||||
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_OFF)
|
||||
|
@ -124,6 +225,10 @@ void IN_Init (void)
|
|||
SDL_SetEventFilter(FilterMouseEvents);
|
||||
}
|
||||
|
||||
#ifdef MACOS_X_ACCELERATION_HACK
|
||||
Cvar_RegisterVariable(&in_disablemacosxmouseaccel);
|
||||
#endif
|
||||
|
||||
IN_Activate();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue