r1108 - trunk trunk/code/unix webspace/include

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Jul 8 21:06:18 EDT 2007


Author: zakk
Date: 2007-07-08 21:06:18 -0400 (Sun, 08 Jul 2007)
New Revision: 1108

Modified:
   trunk/Makefile
   trunk/code/unix/sdl_glimp.c
   webspace/include/help.php
Log:
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


Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2007-07-06 23:04:05 UTC (rev 1107)
+++ trunk/Makefile	2007-07-09 01:06:18 UTC (rev 1108)
@@ -393,7 +393,7 @@
     #  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...

Modified: trunk/code/unix/sdl_glimp.c
===================================================================
--- trunk/code/unix/sdl_glimp.c	2007-07-06 23:04:05 UTC (rev 1107)
+++ trunk/code/unix/sdl_glimp.c	2007-07-09 01:06:18 UTC (rev 1108)
@@ -83,6 +83,9 @@
 
 /* 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 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 @@
 {
 }
 
+#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 @@
 {
   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 @@
 	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);

Modified: webspace/include/help.php
===================================================================
--- webspace/include/help.php	2007-07-06 23:04:05 UTC (rev 1107)
+++ webspace/include/help.php	2007-07-09 01:06:18 UTC (rev 1108)
@@ -44,12 +44,15 @@
 <li><tt>r_customwidth 1280</tt></li>
 </ul>
 <p>then if I'm in-game I would use <tt>vid_restart</tt></p>
+
 <h2>Why can't I run Team Arena or the Mission Pack?!?!?!</h2>
 <p>Did you buy Team Arena? It comes with some modern versions of Quake 3, but most people who
 just have Quake 3, don't have Team Arena (which is the same as the mission pack).</p>
+<p>To install Team Arena, copy the <tt>pak0.pk3</tt> from the <tt>missionpack</tt> directory
+on your cd-rom to the <tt>missionpack</tt> directory in your ioquake3 directory.</p>
 
 <h2 id="cvar">New Cvars &amp; Commands</h2>
-<p>Icculus.org/quake3 has introduced a number of new cvars and commands, mostly
+<p>ioquake3 has introduced a number of new cvars and commands, mostly
 because of new features.</p>
 <table>
 	<caption>Cvar Additions</caption>
@@ -70,6 +73,10 @@
 		<td class="shell">cl_aviMotionJpeg</td> <td>Boolean</td>
 		<td>Use the mjpeg codec when capturing video.</td>
 	</tr>
+	<tr>
+		<td class="shell">in_disablemacosxmouseaccel</td> <td>Integer</td>
+		<td>Disable mouse acceleration when running OS X with a mouse, defaults to 1.</td>
+	</tr>
 	<tr><td colspan="3"></td></tr> <!-- Space -->
 	<tr>
 		<td class="shell">s_useOpenAL</td> <td>Boolean</td>




More information about the quake3-commits mailing list