From 88a9e638e6505abb2a587cb98c5fc60e393682bc Mon Sep 17 00:00:00 2001 From: n-a-c-h <> Date: Sat, 25 Mar 2006 18:06:21 +0000 Subject: [PATCH] Update ManyMouse lib to latest SVN. --- zsnes/src/mmlib/linux.c | 49 +++++++++++++++++++++++-------- zsnes/src/mmlib/mm.c | 62 +++++++++++++++++++++++++-------------- zsnes/src/mmlib/mm.h | 32 ++++++++++++++++---- zsnes/src/mmlib/windows.c | 47 ++++++++++++++++++++++------- 4 files changed, 139 insertions(+), 51 deletions(-) diff --git a/zsnes/src/mmlib/linux.c b/zsnes/src/mmlib/linux.c index 665dae1f..9264c529 100644 --- a/zsnes/src/mmlib/linux.c +++ b/zsnes/src/mmlib/linux.c @@ -1,10 +1,32 @@ /* - * Support for Linux evdevs...the /dev/input/event* devices. - * - * Please see the file LICENSE in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ +Copyright (c) 2003-2006 Ryan C. Gordon and others. + +http://icculus.org/manymouse/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from +the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not +claim that you wrote the original software. If you use this software in a +product, an acknowledgment in the product documentation would be +appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. + + Ryan C. Gordon +*/ + +//Support for Linux evdevs...the /dev/input/event* devices. + +#include "mm.h" #ifdef __linux__ @@ -21,8 +43,6 @@ #include /* evdev interface... */ -#include "mm.h" - #define test_bit(array, bit) (array[bit/8] & (1<<(bit%8))) /* linux allows 32 evdev nodes currently. */ @@ -256,7 +276,7 @@ static int linux_evdev_init(void) dirp = opendir("/dev/input"); if (!dirp) - return 0; + return -1; while ((dent = readdir(dirp)) != NULL) { @@ -322,6 +342,14 @@ static int linux_evdev_poll(ManyMouseEvent *event) return(0); /* no new events */ } /* linux_evdev_poll */ +#else + +static int linux_evdev_init(void) { return(-1); } +static void linux_evdev_quit(void) {} +static const char *linux_evdev_name(unsigned int index) { return(0); } +static int linux_evdev_poll(ManyMouseEvent *event) { return(0); } + +#endif /* defined __linux__ */ ManyMouseDriver ManyMouseDriver_evdev = { @@ -331,7 +359,4 @@ ManyMouseDriver ManyMouseDriver_evdev = linux_evdev_poll }; -#endif /* defined __linux__ */ - /* end of linux_evdev.c ... */ - diff --git a/zsnes/src/mmlib/mm.c b/zsnes/src/mmlib/mm.c index e55fe6ae..7a91cd54 100644 --- a/zsnes/src/mmlib/mm.c +++ b/zsnes/src/mmlib/mm.c @@ -1,21 +1,40 @@ /* - * ManyMouse foundation code; apps talks to this and it talks to the lowlevel - * code for various platforms. - * - * Please see the file LICENSE in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ +Copyright (c) 2003-2006 Ryan C. Gordon and others. + +http://icculus.org/manymouse/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from +the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not +claim that you wrote the original software. If you use this software in a +product, an acknowledgment in the product documentation would be +appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. + + Ryan C. Gordon +*/ + +//ManyMouse foundation code; apps talks to this and it talks to the lowlevel +//code for various platforms. #include #include "mm.h" static const char *manymouse_copyright = - "ManyMouse " MANYMOUSE_VERSION " (c) 2005 Ryan C. Gordon."; + "ManyMouse " MANYMOUSE_VERSION " (c) 2003-2006 Ryan C. Gordon."; extern const ManyMouseDriver ManyMouseDriver_windows; extern const ManyMouseDriver ManyMouseDriver_evdev; -extern const ManyMouseDriver ManyMouseDriver_mousedev; extern const ManyMouseDriver ManyMouseDriver_hidmanager; extern const ManyMouseDriver ManyMouseDriver_xinput; @@ -24,14 +43,13 @@ static const ManyMouseDriver *mice_drivers[] = #if SUPPORT_XINPUT &ManyMouseDriver_xinput, #endif + #ifdef __linux__ + &ManyMouseDriver_evdev, + #endif #if ((defined _WIN32) || defined(__CYGWIN__)) &ManyMouseDriver_windows, #endif - #ifdef __linux__ - &ManyMouseDriver_evdev, - /*&ManyMouseDriver_mousedev,*/ - #endif - #if ( (defined(__MACH__)) && (defined(__APPLE__)) ) + #if ((defined(__MACH__)) && (defined(__APPLE__))) &ManyMouseDriver_hidmanager, #endif NULL @@ -43,9 +61,10 @@ static const ManyMouseDriver *driver = NULL; int ManyMouse_Init(void) { int i; + int retval = -1; /* impossible test to keep manymouse_copyright linked into the binary. */ - if ((char *) driver == (const char *) manymouse_copyright) + if (manymouse_copyright == NULL) return(-1); if (driver != NULL) @@ -54,18 +73,18 @@ int ManyMouse_Init(void) for (i = 0; mice_drivers[i]; i++) { int mice = mice_drivers[i]->init(); + + if (mice > retval) + retval = mice; /* may just move from "error" to "no mice found". */ + if (mice > 0) { driver = mice_drivers[i]; - return(mice); + break; } /* if */ - else - { - return(0); - } } /* for */ - return(-1); + return(retval); } /* ManyMouse_Init */ @@ -93,4 +112,3 @@ int ManyMouse_PollEvent(ManyMouseEvent *event) } /* ManyMouse_PollEvent */ /* end of manymouse.c ... */ - diff --git a/zsnes/src/mmlib/mm.h b/zsnes/src/mmlib/mm.h index c854d0bd..d508d7b1 100644 --- a/zsnes/src/mmlib/mm.h +++ b/zsnes/src/mmlib/mm.h @@ -1,10 +1,30 @@ /* - * ManyMouse main header. Include this from your app. - * - * Please see the file LICENSE in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ +Copyright (c) 2003-2006 Ryan C. Gordon and others. + +http://icculus.org/manymouse/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from +the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not +claim that you wrote the original software. If you use this software in a +product, an acknowledgment in the product documentation would be +appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. + + Ryan C. Gordon +*/ + +//ManyMouse main header. Include this from your app. #ifndef _INCLUDE_MANYMOUSE_H_ #define _INCLUDE_MANYMOUSE_H_ diff --git a/zsnes/src/mmlib/windows.c b/zsnes/src/mmlib/windows.c index 492145dd..a164cd93 100644 --- a/zsnes/src/mmlib/windows.c +++ b/zsnes/src/mmlib/windows.c @@ -1,10 +1,32 @@ /* - * Support for Windows via the WM_INPUT message. - * - * Please see the file LICENSE in the source's root directory. - * - * This file written by Ryan C. Gordon. - */ +Copyright (c) 2003-2006 Ryan C. Gordon and others. + +http://icculus.org/manymouse/ + +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from +the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not +claim that you wrote the original software. If you use this software in a +product, an acknowledgment in the product documentation would be +appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. + +3. This notice may not be removed or altered from any source distribution. + + Ryan C. Gordon +*/ + +//Support for Windows via the WM_INPUT message. + +#include "mm.h" #if (defined(_WIN32) || defined(__CYGWIN__)) @@ -22,8 +44,6 @@ #define WM_INPUT 0x00FF #endif -#include "mm.h" - /* that should be enough, knock on wood. */ #define MAX_MICE 32 @@ -719,6 +739,14 @@ static int windows_wminput_poll(ManyMouseEvent *ev) return(found); } /* windows_wminput_poll */ +#else + +static int windows_wminput_init(void) { return(-1); } +static void windows_wminput_quit(void) {} +static const char *windows_wminput_name(unsigned int index) { return(0); } +static int windows_wminput_poll(ManyMouseEvent *event) { return(0); } + +#endif /* ifdef WINDOWS blocker */ ManyMouseDriver ManyMouseDriver_windows = { @@ -728,7 +756,4 @@ ManyMouseDriver ManyMouseDriver_windows = windows_wminput_poll }; -#endif /* ifdef WINDOWS blocker */ - /* end of windows_wminput.c ... */ -