mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
OS X mouse hack, must remove when SDL adds it internally.
Please see bugzilla case: http://bugzilla.icculus.org/show_bug.cgi?id=3206 and http://bugzilla.libsdl.org/show_bug.cgi?id=445
This commit is contained in:
parent
20e71c7dff
commit
3d70f2ccff
2 changed files with 84 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -393,7 +393,7 @@ ifeq ($(PLATFORM),darwin)
|
|||
# the file has been modified by each build.
|
||||
LIBSDLMAIN=$(B)/libSDLmain.a
|
||||
LIBSDLMAINSRC=$(LIBSDIR)/macosx/libSDLmain.a
|
||||
CLIENT_LDFLAGS += -framework Cocoa -framework OpenGL \
|
||||
CLIENT_LDFLAGS += -framework Cocoa -framework IOKit -framework OpenGL \
|
||||
$(LIBSDIR)/macosx/libSDL-1.2.0.dylib
|
||||
else
|
||||
# !!! FIXME: frameworks: OpenGL, Carbon, etc...
|
||||
|
|
|
@ -83,6 +83,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
/* Just hack it for now. */
|
||||
#ifdef MACOS_X
|
||||
#include <IOKit/hidsystem/IOHIDLib.h>
|
||||
#include <IOKit/hidsystem/IOHIDParameter.h>
|
||||
#include <drivers/event_status_driver.h>
|
||||
typedef CGLContextObj QGLContext;
|
||||
#define GLimp_GetCurrentContext() CGLGetCurrentContext()
|
||||
#define GLimp_SetCurrentContext(ctx) CGLSetCurrentContext(ctx)
|
||||
|
@ -116,6 +119,8 @@ static qboolean mouse_active = qfalse;
|
|||
static qboolean sdlrepeatenabled = qfalse;
|
||||
|
||||
static cvar_t *in_mouse;
|
||||
static cvar_t *in_disablemacosxmouseaccel;
|
||||
static double originalMouseSpeed = -1.0;
|
||||
cvar_t *in_subframe;
|
||||
cvar_t *in_nograb; // this is strictly for developers
|
||||
|
||||
|
@ -432,11 +437,69 @@ void KBD_Close(void)
|
|||
{
|
||||
}
|
||||
|
||||
#ifdef MACOS_X
|
||||
io_connect_t IN_GetIOHandle() // 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_ActivateMouse( void )
|
||||
{
|
||||
if (!mouse_avail || !screen)
|
||||
return;
|
||||
|
||||
#ifdef MACOS_X
|
||||
if (!mouse_active && mouse_avail) // mac os x mouse accel hack
|
||||
{
|
||||
// Save the status of mouse acceleration
|
||||
originalMouseSpeed = -1.0; // in case of error
|
||||
if(in_disablemacosxmouseaccel->integer)
|
||||
{
|
||||
io_connect_t mouseDev = IN_GetIOHandle();
|
||||
if(mouseDev != 0)
|
||||
{
|
||||
if(IOHIDGetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), &originalMouseSpeed) == kIOReturnSuccess)
|
||||
{
|
||||
Com_Printf("previous mouse acceleration: %f\n", originalMouseSpeed);
|
||||
if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), -1.0) != kIOReturnSuccess)
|
||||
{
|
||||
Com_Printf("Could not disable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
|
||||
Cvar_Set ("in_disablemacosxmouseaccel", 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_Printf("Could not disable mouse acceleration (failed at IOHIDGetAccelerationWithKey).\n");
|
||||
Cvar_Set ("in_disablemacosxmouseaccel", 0);
|
||||
}
|
||||
IOServiceClose(mouseDev);
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_Printf("Could not disable mouse acceleration (failed at IO_GetIOHandle).\n");
|
||||
Cvar_Set ("in_disablemacosxmouseaccel", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!mouse_active)
|
||||
{
|
||||
if (!in_nograb->value)
|
||||
|
@ -449,6 +512,25 @@ void IN_DeactivateMouse( void )
|
|||
{
|
||||
if (!mouse_avail || !screen)
|
||||
return;
|
||||
|
||||
#ifdef MACOS_X
|
||||
if (mouse_active) // mac os x mouse accel hack
|
||||
{
|
||||
if(originalMouseSpeed != -1.0)
|
||||
{
|
||||
io_connect_t mouseDev = IN_GetIOHandle();
|
||||
if(mouseDev != 0)
|
||||
{
|
||||
Com_Printf("restoring mouse acceleration to: %f\n", originalMouseSpeed);
|
||||
if(IOHIDSetAccelerationWithKey(mouseDev, CFSTR(kIOHIDMouseAccelerationType), originalMouseSpeed) != kIOReturnSuccess)
|
||||
Com_Printf("Could not re-enable mouse acceleration (failed at IOHIDSetAccelerationWithKey).\n");
|
||||
IOServiceClose(mouseDev);
|
||||
}
|
||||
else
|
||||
Com_Printf("Could not re-enable mouse acceleration (failed at IO_GetIOHandle).\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mouse_active)
|
||||
{
|
||||
|
@ -1357,6 +1439,7 @@ void IN_Init(void) {
|
|||
Com_Printf ("\n------- Input Initialization -------\n");
|
||||
// mouse variables
|
||||
in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
|
||||
in_disablemacosxmouseaccel = Cvar_Get ("in_disablemacosxmouseaccel", "1", CVAR_ARCHIVE);
|
||||
|
||||
// turn on-off sub-frame timing of X events
|
||||
in_subframe = Cvar_Get ("in_subframe", "1", CVAR_ARCHIVE);
|
||||
|
|
Loading…
Reference in a new issue