There is a bug in dgen which causes usb joysticks to fail of they are /dev/uhid>=1.
Fix below, already applied upstream, OK? Index: Makefile =================================================================== RCS file: /cvs/ports/emulators/dgen-sdl/Makefile,v retrieving revision 1.2 diff -u -p -r1.2 Makefile --- Makefile 18 Feb 2012 01:16:08 -0000 1.2 +++ Makefile 29 Feb 2012 21:03:23 -0000 @@ -2,6 +2,7 @@ COMMENT = Sega Megadrive/Genesis emulator DISTNAME = dgen-sdl-1.29 +REVISION = 0 CATEGORIES = emulators games HOMEPAGE = http://dgen.sourceforge.net/ MAINTAINER = Edd Barrett <e...@openbsd.org> Index: patches/patch-md-phil_cpp =================================================================== RCS file: patches/patch-md-phil_cpp diff -N patches/patch-md-phil_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-md-phil_cpp 29 Feb 2012 21:03:23 -0000 @@ -0,0 +1,39 @@ +$OpenBSD$ + +Fix joystick when not /dev/uhid0 +From zamaz (upstream), many thanks. + +--- md-phil.cpp.orig Sun Jan 29 20:58:52 2012 ++++ md-phil.cpp Wed Feb 29 20:45:29 2012 +@@ -168,11 +168,12 @@ void md::read_joysticks() + #include <SDL_joystick.h> + + static SDL_Joystick *js_handle[2] = { NULL, NULL }; ++int js_index[2] = { -1, -1 }; + + void md::init_joysticks(int js1, int js2) { + // Initialize the joystick support + // Thanks to Cameron Moore <came...@unbeatenpath.net> +- if(SDL_Init(SDL_INIT_JOYSTICK) < 0) ++ if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) + { + fprintf(stderr, "joystick: Unable to initialize joystick system\n"); + return; +@@ -191,9 +192,15 @@ void md::init_joysticks(int js1, int js2) { + + // Print the joystick names + printf("joystick: Using "); +- if(js_handle[0]) printf("%s (#%d) as pad1 ", SDL_JoystickName(js1), js1); ++ if(js_handle[0]) { ++ printf("%s (#%d) as pad1 ", SDL_JoystickName(js1), js1); ++ js_index[0] = js1; ++ } + if(js_handle[0] && js_handle[1]) printf("and "); +- if(js_handle[1]) printf("%s (#%d) as pad2 ", SDL_JoystickName(js2), js2); ++ if(js_handle[1]) { ++ printf("%s (#%d) as pad2 ", SDL_JoystickName(js2), js2); ++ js_index[1] = js2; ++ } + printf("\n"); + + // Enable joystick events Index: patches/patch-sdl_sdl_cpp =================================================================== RCS file: patches/patch-sdl_sdl_cpp diff -N patches/patch-sdl_sdl_cpp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-sdl_sdl_cpp 29 Feb 2012 21:03:23 -0000 @@ -0,0 +1,120 @@ +$OpenBSD$ + +Fix joystick when not /dev/uhid0 +From zamaz (upstream), many thanks. + +--- sdl/sdl.cpp.orig Sun Jan 29 20:58:52 2012 ++++ sdl/sdl.cpp Wed Feb 29 20:45:29 2012 +@@ -1822,56 +1822,62 @@ int pd_handle_events(md &megad) + switch(event.type) + { + #ifdef WITH_SDL_JOYSTICK +- case SDL_JOYAXISMOTION: +- // x-axis +- if(event.jaxis.axis == 0) +- { +- if(event.jaxis.value < -16384) +- { +- megad.pad[event.jaxis.which] &= ~0x04; +- megad.pad[event.jaxis.which] |= 0x08; +- break; +- } +- if(event.jaxis.value > 16384) +- { +- megad.pad[event.jaxis.which] |= 0x04; +- megad.pad[event.jaxis.which] &= ~0x08; +- break; +- } +- megad.pad[event.jaxis.which] |= 0xC; +- break; +- } +- // y-axis +- if(event.jaxis.axis == 1) +- { +- if(event.jaxis.value < -16384) +- { +- megad.pad[event.jaxis.which] &= ~0x01; +- megad.pad[event.jaxis.which] |= 0x02; +- break; +- } +- if(event.jaxis.value > 16384) +- { +- megad.pad[event.jaxis.which] |= 0x01; +- megad.pad[event.jaxis.which] &= ~0x02; +- break; +- } +- megad.pad[event.jaxis.which] |= 0x3; +- break; +- } +- break; +- case SDL_JOYBUTTONDOWN: +- // Ignore more than 16 buttons (a reasonable limit :) +- if(event.jbutton.button > 15) break; +- megad.pad[event.jbutton.which] &= ~js_map_button[event.jbutton.which] +- [event.jbutton.button]; +- break; +- case SDL_JOYBUTTONUP: +- // Ignore more than 16 buttons (a reasonable limit :) +- if(event.jbutton.button > 15) break; +- megad.pad[event.jbutton.which] |= js_map_button[event.jbutton.which] +- [event.jbutton.button]; +- break; ++ extern int js_index[2]; ++ int pad; ++ ++ case SDL_JOYAXISMOTION: ++ if ((pad = 0, event.jaxis.which != js_index[pad]) && ++ (pad = 1, event.jaxis.which != js_index[pad])) ++ break; ++ // x-axis ++ if (event.jaxis.axis == 0) { ++ if (event.jaxis.value < -16384) { ++ megad.pad[pad] &= ~0x04; ++ megad.pad[pad] |= 0x08; ++ break; ++ } ++ if (event.jaxis.value > 16384) { ++ megad.pad[pad] |= 0x04; ++ megad.pad[pad] &= ~0x08; ++ break; ++ } ++ megad.pad[pad] |= 0xc; ++ break; ++ } ++ // y-axis ++ else if (event.jaxis.axis == 1) { ++ if (event.jaxis.value < -16384) { ++ megad.pad[pad] &= ~0x01; ++ megad.pad[pad] |= 0x02; ++ break; ++ } ++ if (event.jaxis.value > 16384) { ++ megad.pad[pad] |= 0x01; ++ megad.pad[pad] &= ~0x02; ++ break; ++ } ++ megad.pad[pad] |= 0x3; ++ break; ++ } ++ break; ++ case SDL_JOYBUTTONDOWN: ++ // Ignore more than 16 buttons (a reasonable limit :) ++ if (event.jbutton.button > 15) ++ break; ++ if ((pad = 0, event.jaxis.which != js_index[pad]) && ++ (pad = 1, event.jaxis.which != js_index[pad])) ++ break; ++ megad.pad[pad] &= ~js_map_button[pad][event.jbutton.button]; ++ break; ++ case SDL_JOYBUTTONUP: ++ // Ignore more than 16 buttons (a reasonable limit :) ++ if (event.jbutton.button > 15) ++ break; ++ if ((pad = 0, event.jaxis.which != js_index[pad]) && ++ (pad = 1, event.jaxis.which != js_index[pad])) ++ break; ++ megad.pad[pad] |= js_map_button[pad][event.jbutton.button]; ++ break; + #endif // WITH_SDL_JOYSTICK + case SDL_KEYDOWN: + ksym = event.key.keysym.sym; -- Best Regards Edd Barrett http://www.theunixzoo.co.uk