[Plib-cvs] plib/src/js js.h,1.22,1.23
Brought to you by:
sjbaker
From: Sebastian U. <ud...@us...> - 2002-09-07 21:57:14
|
Update of /cvsroot/plib/plib/src/js In directory usw-pr-cvs1:/tmp/cvs-serv5414 Modified Files: js.h Log Message: Added alternative method to get joystick name on WIN32 - fixes problems with USB joysticks Index: js.h =================================================================== RCS file: /cvsroot/plib/plib/src/js/js.h,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- js.h 2 Sep 2002 06:05:43 -0000 1.22 +++ js.h 7 Sep 2002 21:57:10 -0000 1.23 @@ -56,6 +56,7 @@ # define FAR /* */ # endif # include <mmsystem.h> +# include <regstr.h> # include <string.h> #else @@ -136,6 +137,7 @@ int id ; #endif*/ #ifdef WIN32 [...78 lines suppressed...] js . dwFlags = JOY_RETURNALL ; js . dwSize = sizeof ( js ) ; @@ -285,7 +346,15 @@ } else { - strncpy ( name, jsCaps.szPname, sizeof(name) ) ; + // Device name from jsCaps is often "Microsoft PC-joystick driver", + // at least for USB. Try to get the real name from the registry. + if ( ! getOEMProductName ( name, sizeof(name) ) ) + { + ulSetError ( UL_WARNING, + "JS: Failed to read joystick name from registry" ) ; + + strncpy ( name, jsCaps.szPname, sizeof(name) ) ; + } // Windows joystick drivers may provide any combination of // X,Y,Z,R,U,V,POV - not necessarily the first n of these. |