Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie
-
@dankcushions said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
a wii mote should work as a mouse, but i'm not sure if it updates the pointer in linux.
It does if used in conjunction with the Mayflash DolphinBar. When used this way, the Wiimote will actually pair with the DolphinBar rather that the computer. The DolphinBar will in-turn translate the readings to absolute mouse coordinates that are read by the computer no differently than a standard pointer device. In a landscape of limited options for computer light guns, it not only works very well, but is quite affordable and when combined with a gun casing like the one below, it looks and feels great in use.
-
@mediamogul said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
@dankcushions said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
a wii mote should work as a mouse, but i'm not sure if it updates the pointer in linux.
It does if used in conjunction with the Mayflash DolphinBar. When used this way, the Wiimote will actually pair with the DolphinBar rather that the computer. The DolphinBar will in-turn translate the readings to absolute mouse coordinates that are read by the computer no differently than a standard pointer device. In a landscape of limited options for computer light guns, it not only works very well, but is quite affordable and when combined with a gun casing like the one below, it looks and feels great in use.
That's slick!
Keep in mind though my goal for this challenge is to keep this as low-tech / low-cost as possible for others who can't afford something like a Perfect Shot or even a Wiimote Plus (they're usually around $40'ish at Walmart, which is a little pricey for a low income family).
For me personally though, it would be awesome if there were a way to connect that up somehow to a recoil mechanism for kickback, maybe I should look into one of those Guncon 2 guns and see if they can somehow sync up if I made some middleman tech like an Arduino -> USB HID controller setup (which I have somewhat working but I wanted to change over to an mbed controlled STM32 NUCLEO and that's when I ran into problems trying to find a good HID implementation library without rolling my own as I'm still learning about HID Report Descriptors).
-
It'll be tough to find a computer light gun solution for under $50. Outside of the Wiimote option, every gun setup I've ever seen hovers in the neighborhood of $150-200 a gun. I did a quick search through Amazon for the lowest cost with free Prime shipping and came up with:
For a total of $50.83
Edit: Of course if the DolphinBar could be removed from the equation by way of a linux driver, that price comes down to $36.43.
-
For the sake of testing I wondered if I could possibly use my STM32 NUCLEO F103RB with a thumbstick (pictured), and emulate a USB HID game controller that reports absolute positioning. It will just start out at "center" and go out to some arbitrary coordinates on each axis controlled by software. All of that I got at a local surplus electronics store for <$20.
Also I have a 4.3" Sainsmart LCD screen I couldn't find much use for before because it used a different pinout than the Arduino Mega2560 (even though it claims to be compatible it has 4 more pins and needs an adapter from Sainsmart...), maybe could be used through the Nucleo as an absolute positioning device. Although I think it was about $35 when I bought it, but this was just for custom proof of concept hardware testing.
EDIT: Picture won't link from Imgur, is that a forum rule?
-
@mediamogul said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
@dankcushions said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
a wii mote should work as a mouse, but i'm not sure if it updates the pointer in linux.
It does if used in conjunction with the Mayflash DolphinBar. When used this way, the Wiimote will actually pair with the DolphinBar rather that the computer. The DolphinBar will in-turn translate the readings to absolute mouse coordinates that are read by the computer no differently than a standard pointer device. In a landscape of limited options for computer light guns, it not only works very well, but is quite affordable and when combined with a gun casing like the one below, it looks and feels great in use.
are you sure this works with linux + retroarch + as a pointer, though? if you check out my link, we can see it updates Mouse0, but we didn't get as far to see if it's updating RETRO_DEVICE_POINTER. it SHOULD, but i don't want to promise anything. if it only updates RETRO_DEVICE_MOUSE, then that won't help in genesis-plus-gx :(
-
@dankcushions said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
it SHOULD, but i don't want to promise anything.
I'll do some testing with it this evening to see. Also, I just read through both your links and the idea to spoof coordinate types is inspired. Here's hoping it pays off.
-
I don't know enough about udev/RetroArch yet to weigh in on the conversation about spoofing absolute coordinates, where's a good place to start? Is the problem actually in udev itself or is it in RetroArch or is it in lr-genesis-plus-gx?
As for me this seems like a great motivation for me to pick back up on building hardware devices that respect USB HID compliancy. Maybe I can make some support for the mbed crowd.
-
OK, so color me surprised. I tried out the Wiimote and DolphinBar combination with all the applicable RetroArch cores and came up empty every time. Altogether, I tried lr-picodrive, lr-genesis-plus-gx, lr-snes9x-next, lr-nestopia and lr-mame2003. With each core I tested with both the udev and sdl input drivers and with lr-mame2003 specifically, I tested both 'mouse' and 'pointer' mouse types.
While I was there I tested out a high-end PC light gun that I recently picked up for my arcade cabinet. Sadly, it suffered the same impotence in every test. For one last go, I tested an air mouse I use for Kodi and other than the inability to see cross hairs in a few cores, it seemed to work everywhere.
Normally I have the high-end guns attached to my cabinet and the DolphinBar attached to an older Mac, so I guess I've just been taking for granted that these would work in some capacity with RetroPie as well, given the wide array of input options. So, while I have no doubt that gun support will come over time, I guess there's just no current pathway to gun gaming at the moment.
-
@mediamogul said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
OK, so color me surprised. I tried out the Wiimote and DolphinBar combination with all the applicable RetroArch cores and came up empty every time. Altogether, I tried lr-picodrive, lr-genesis-plus-gx, lr-snes9x-next, lr-nestopia and lr-mame2003. With each core I tested with both the udev and sdl input drivers and with lr-mame2003 specifically, I tested both 'mouse' and 'pointer' mouse types.
While I was there I tested out a high-end PC light gun that I recently picked up for my arcade cabinet. Sadly, it suffered the same impotence in every test. For one last go, I tested an air mouse I use for Kodi and other than the inability to see cross hairs in a few cores, it seemed to work everywhere.
Normally I have the high-end guns attached to my cabinet and the DolphinBar attached to an older Mac, so I guess I've just been taking for granted that these would work in some capacity with RetroPie as well, given the wide array of input options. So, while I have no doubt that gun support will come over time, I guess there's just no current pathway to gun gaming at the moment.
For the time being just in testing, an air mouse may be the way to go. What model and brand is it, and does it work specifically in lr-genesis-plus-gx on RPI3? (Preferably on Missile Defense 3-D is what I'm wanting to play, and I need it to run in that emulator because it knows to only show one side of the SegaScope 3D frames otherwise it will be unplayable.)
-
@johne79 said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
does it work specifically in lr-genesis-plus-gx on RPI3?
It is recognized and will fire, but just like your initial experience, it doesn't track past the center of the screen.
-
@mediamogul said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
OK, so color me surprised. I tried out the Wiimote and DolphinBar combination with all the applicable RetroArch cores and came up empty every time. Altogether, I tried lr-picodrive, lr-genesis-plus-gx, lr-snes9x-next, lr-nestopia and lr-mame2003. With each core I tested with both the udev and sdl input drivers and with lr-mame2003 specifically, I tested both 'mouse' and 'pointer' mouse types.
did you try it in a non-retroarch application? the best test is maybe a simple mouse script i mention here: https://github.com/libretro/RetroArch/issues/4333#issuecomment-269702220
if it updates the system mouse, we should be able to get something from it.
it might be that the kernel in retropie/raspian doesn't support the dolphinbar yet :(
-
@johne79 said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
For the sake of testing I wondered if I could possibly use my STM32 NUCLEO F103RB with a thumbstick (pictured), and emulate a USB HID game controller that reports absolute positioning. It will just start out at "center" and go out to some arbitrary coordinates on each axis controlled by software. All of that I got at a local surplus electronics store for <$20.
an analog joystick (like an xbox 360 controller, etc) should be usable in any retroarch core that wants an absolute mouse coordinate (like a lightgun game), but it has to be coded in. mame2003 supports it, and i think genesis-plus-gx (i should test this later!)
however, if you're creating your own analog stick it would have to appear as a valid HID game controller in linux.
-
@johne79 said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
I don't know enough about udev/RetroArch yet to weigh in on the conversation about spoofing absolute coordinates, where's a good place to start? Is the problem actually in udev itself or is it in RetroArch or is it in lr-genesis-plus-gx?
the problem is potentially fixable in either retroarch's UDEV driver, or lr-genesis-plus-gx, but the former makes it something all cores can use.
the basic flow (as i understand it is)
- linux has access to your hardware (eg, pointer device) via UDEV
- retroarch's UDEV input driver provides access to the UDEV information (eg, a UDEV pointer device)
- the core (emulator) asks retroarch for status of a generic RETRO_DEVICE_POINTER, which the UDEV input driver provides
here is where the UDEV input driver updates the RETRO_DEVICE_POINTER's state (coordinates): https://github.com/libretro/RetroArch/blob/master/input/drivers/udev_input.c#L460
it's at this point i'd have to start debugging to work out what's going on!note, you can might see some references to RETRO_DEVICE_LIGHTGUN, but as far as i can tell this is just another way of looking at the mouse: https://github.com/libretro/RetroArch/blob/master/input/drivers/udev_input.c#L420
i guess UDEV/linux doesn't see lightgun's as anything other than mice. also, i don't know of many (any?) cores that actually use RETRO_DEVICE_LIGHTGUN - they normally ask for a POINTER or maybe a MOUSE. -
@dankcushions said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
it might be that the kernel in retropie/raspian doesn't support the dolphinbar yet :(
That could be the case, and seeing as how I've also tested the high-end offerings from AimTrak previously and those from ArcadeGuns last night, the issue most likely extends further to whatever this particular class of pointer device is classified as, making any kind PC light gun an impossibility.
I have three different emulation gaming rigs for when I want to play light gun games, so this isn't really a big issue for me, but I realize there are many people who would like to play these games on the Pi. If you should ever need someone to help test gun peripherals against any changes made to RetroArch or RetroPie, just give me a shout.
-
@dankcushions said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
@johne79 said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
I don't know enough about udev/RetroArch yet to weigh in on the conversation about spoofing absolute coordinates, where's a good place to start? Is the problem actually in udev itself or is it in RetroArch or is it in lr-genesis-plus-gx?
the problem is potentially fixable in either retroarch's UDEV driver, or lr-genesis-plus-gx, but the former makes it something all cores can use.
the basic flow (as i understand it is)
- linux has access to your hardware (eg, pointer device) via UDEV
- retroarch's UDEV input driver provides access to the UDEV information (eg, a UDEV pointer device)
- the core (emulator) asks retroarch for status of a generic RETRO_DEVICE_POINTER, which the UDEV input driver provides
here is where the UDEV input driver updates the RETRO_DEVICE_POINTER's state (coordinates): https://github.com/libretro/RetroArch/blob/master/input/drivers/udev_input.c#L460
it's at this point i'd have to start debugging to work out what's going on!note, you can might see some references to RETRO_DEVICE_LIGHTGUN, but as far as i can tell this is just another way of looking at the mouse: https://github.com/libretro/RetroArch/blob/master/input/drivers/udev_input.c#L420
i guess UDEV/linux doesn't see lightgun's as anything other than mice. also, i don't know of many (any?) cores that actually use RETRO_DEVICE_LIGHTGUN - they normally ask for a POINTER or maybe a MOUSE.Considering that the buttons actually do work, i.e. when playing Missile Defense 3-D pressing the left mouse button does actually make it shoot in the middle of the screen and can kill some of the projectile missiles coming at you, I think it's safe to say that at least the RETRO_DEVICE_ID_LIGHTGUN_TRIGGER aspects of RETRO_DEVICE_LIGHTGUN are working properly.
It dawned on me while looking through the code of both RetroArch that you pointed to and in the following:
https://github.com/libretro/Genesis-Plus-GX/blob/master/libretro/libretro.c#L328&L344
https://github.com/libretro/Genesis-Plus-GX/blob/master/libretro/libretro.h#L2061&L2062So the first thing that's wrong with lr-genesis-plus-gx, look on line 330 and 331 and you'll see that ekeeke is using RETRO_DEVICE_POINTER's RETRO_DEVICE_ID_POINTER_X and RETRO_DEVICE_ID_POINTER_Y directly instead of RETRO_DEVICE_LIGHTGUN's RETRO_DEVICE_ID_LIGHTGUN_X and RETRO_DEVICE_ID_LIGHTGUN_Y respectively. That needs to change, mixing and matching input paradigms like that may have been needed at one point but it needs to be updated to match what's coming downstream from RetroArch.
If ekeeke is not going to budge on strict adherence to design i.e. he wants only a RETRO_DEVICE_POINTER to be able to be used with his core, the only places it CAN change I think are in RetroArch and udev. So right now in the game if I move the mouse by a LARGE amount on the X or Y axis I'll see some movement in the upper left. That tells me that in udev_input.c on lines 424-427 that you referenced that udev->mouse_x and udev->mouse_y are bringing back values, it's giving you the delta each time, so a big large movement has a big delta and that's the only way I can see that it's actually doing its job because it's treating those relative coordinates as absolute in this case.
So... if a udev rule (I don't know if this is possible because I haven't had to write my own custom udev rules before) were to change the mouse to an absolute pointer device it would change it system-wide I guess and that would mess up anything that needs the mouse in relative coordinates.
Barring all of that craziness, the first thing that absolutely needs to change is that lr-genesis-plus-gx needs to be using the lightgun x/y instead of pointer x/y. It should be up to RetroArch to tell what is and is not a lightgun.
Let's think about this here, I could theoretically (and IDEALLY, in fact, I was literally FRUSTRATED as a new end user the other day that I couldn't make this happen, and so it's probably going to eventually frustrate other end users who actually use the system) use a d-pad controller as an absolute positioning device in the absence of a mouse or absolute positioning device. It may not be the most usable choice, but it gives way to more accessibility options for end users. It at least lets you play without needlessly spending more money on hardware.
RetroArch needs to tell the cores downstream what is and isn't a lightgun, and the cores should adhere to that, instead of trying to tell me that a lightgun MUST be an absolute positioning device. That's I think going away from the design principles behind RetroArch, I'm just guessing as a new user (I also happen to be a hobbyist intermediate level indie game programmer and beginner level hardware engineer). I should be able to tell RetroArch what constitutes the x and y axes of the lightgun, and then it feeds that to the cores, even if that x/y comes from a gamepad's d-pad.
In fact, I want to design and develop custom open hardware doing embedded development and share those designs with the community so that you can make your own devices, rather than relying on hardware manufacturers. There's a family owned Christian electronics surplus store in my local area (DFW) that I go to that has parts for cheap, STM32 NUCLEOs for around $10-20, buttons, screens, the whole nine yards, we're talking very cheap here like $0.08 resistors and the like. Also there's a local arcade here in my town that actually sells parts to arcade games but they can be pricey on some things like trackballs. There are options though beyond existing hardware manufacturers. What if I made something like an integrated arcade joystick and trackball combo that you could use in a game? I want to use that trackball part of the device as the lightgun. Maybe instead of a trackball it could be an actual touch screen. I have a few touchscreen LCDs laying around that use ILI9341 video drivers, those could theoretically be lightgun devices.
So the gameplan to summarize is...
- Fix the parts in lr-genesis-plus-gx to reference the lightgun x/y instead of pointer x/y, there's no need to continue using pointer x/y as it should come downstream from RetroArch.
- If that doesn't fix all the problems, you'll probably have to implement a fix in RetroArch in udev_input.c around lines 424-427 after that to return an added or subtracted udev->mouse_x(/mouse_y) from 0,0 initialized coordinate variables in the case of a relative device.
- That brings in another piece of complication, will udev give any meta-information about the device if it's relative or absolute, does that come in from the HID report descriptor and get transferred through udev? If not, then the user should be able to at least have a RetroArch option to specify whether the device is absolute or relative, because udev->mouse_x and udev->mouse_y are essentially dumb to what kind of device it is.
- If I want to use a d-pad as a lightgun x and y (and SOMETIMES I DO maybe for testing or for the lack of having peripherals to keep things compact), I should be able to tell RetroArch an option of WHAT to use as the lightgun x and y. Maybe that DOESN'T come from udev->mouse(x/y) but some other arbitrary axes like from a joystick with a specified lower and upper end for each coordinate axis (also movement speed/sensitivity is another factor to account).
-
Hey everyone. I'm also eagerly awaiting some sort of a solution, as I have the same problem with my Wiimote/Dolphinbar setup. On this emulator, it fires, but I can't move the cursor, and the crosshairs don't show on the screen. I know very little about tweaking codes inside emulators, so I was going to ask what I should try tweaking (like the "gun_cursor" code) because I honestly don't know where to start when tweaking code like this
I will say though that, thanks to the AdvMame update from August (I think), my Wiimote/DolphinBar combo does work with quite a few games (Lethal Enforcers, Operation Wolf, Operation Thunderbolt, to name a few), with just a simple Wiimote (and an 8-dollar plastic gun thing) and a Dolphinbar, plugged into the first USB of my Pi. The games that don't work, seem to be actual rom issues instead of gun issues.
I also wanted to add that I was kind of surprised it even half-worked on this emulator, since I was told by someone on a retro gaming FB group that none of the libretro emulators support light guns, even though I've heard that there was gun support on lr-mame2003 and lr-mame2010, although I haven't gotten anything to work on those yet. The games that do work on my setup are largely through AdvMame 1.4., but still, I really want to find a way to get this working on SMS/Genesis and even NES.
I have tried DGen and Osmose for SMS/Genesis gun roms, and those are the opposite of this emulator. I can move the cursor (it shows up as an actual mouse cursor, not a crosshairs), but I can't shoot. If anyone has any updates/fixes, I'd be eternally grateful!:)
-
@BGallagherLA said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
Hey everyone. I'm also eagerly awaiting some sort of a solution, as I have the same problem with my Wiimote/Dolphinbar setup. On this emulator, it fires, but I can't move the cursor, and the crosshairs don't show on the screen. I know very little about tweaking codes inside emulators, so I was going to ask what I should try tweaking (like the "gun_cursor" code) because I honestly don't know where to start when tweaking code like this
I will say though that, thanks to the AdvMame update from August (I think), my Wiimote/DolphinBar combo does work with quite a few games (Lethal Enforcers, Operation Wolf, Operation Thunderbolt, to name a few), with just a simple Wiimote (and an 8-dollar plastic gun thing) and a Dolphinbar, plugged into the first USB of my Pi. The games that don't work, seem to be actual rom issues instead of gun issues.
I also wanted to add that I was kind of surprised it even half-worked on this emulator, since I was told by someone on a retro gaming FB group that none of the libretro emulators support light guns, even though I've heard that there was gun support on lr-mame2003 and lr-mame2010, although I haven't gotten anything to work on those yet. The games that do work on my setup are largely through AdvMame 1.4., but still, I really want to find a way to get this working on SMS/Genesis and even NES.
I have tried DGen and Osmose for SMS/Genesis gun roms, and those are the opposite of this emulator. I can move the cursor (it shows up as an actual mouse cursor, not a crosshairs), but I can't shoot. If anyone has any updates/fixes, I'd be eternally grateful!:)
If you can actually believe this, I had a solution, and then the MicroSD card I had RetroPie and did my code updates on literally BURNED UP when I brought my Raspberry Pi 3 to a friend's house Sunday night to show off RetroPie. The card I guess shorted when I tried to put the RPI3 in a plastic case that pressed up against the MicroSD card and may have bent/shorted it, causing it to just get extremely hot and die when plugged in.
Guess I should have bought that extra Logitech f310 gamepad for the guys, God's telling me something here. :-P
It's actually an easy fix, unfortunately ekeeke the developer is of the mindset that from a design perspective only an absolute pointer touchscreen should be used, and in a perfect world where there are no driver issues with Linux recognizing touchscreen devices that's great, but in my experience that's not the case so I respectfully disagree. Theoretically even a joypad analog thumb stick could/should be used as a lightgun pointer in a pinch when other hardware options are not available IMHO.
I just changed the code in lr-genesis-plus-gx to reference RETRO_DEVICE_LIGHTGUN instead of RETRO_DEVICE_POINTER on my end, and also put in some code to check the screen position. Although I put in a constant for the screen bounds checking instead of actually looking at a variable, so it worked fine on Missile Defense 3-D, but then when I played T2: The Arcade Game on Genesis my cursor would only go over half the screen (because the Genesis runs at a larger resolution). Easy fix, but I have to rework those sections of code, maybe I'll fork their repo into my own and just share that. I put a VirtualBox VM on this MacBook so I can have a more reliable machine to do code edits from, although VirtualBox isn't giving me Hardware Acceleration over Debian for RetroPie, so... to be continued... Hopefully I'll have that back up within a few days or weeks (I'm in an aggressive job hunt right now trying to find a part time job in programming/support that won't kill me physically because of all that smoking I used to do ended me up pre-diabetic) :( ).
-
@johne79 said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
Easy fix, but I have to rework those sections of code, maybe I'll fork their repo into my own and just share that.
That is fantastic news. I look forward to hearing more on this. Good luck on your job search.
-
@johne79 said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
It's actually an easy fix, unfortunately ekeeke the developer is of the mindset that from a design perspective only an absolute pointer touchscreen should be used, and in a perfect world where there are no driver issues with Linux recognizing touchscreen devices that's great, but in my experience that's not the case so I respectfully disagree.
i'm sort of with ekeeke here. the retroarch udev driver should be able to translate from an absolute device to a relative device and vice versa, if either doesn't exist. i've done this in mame2003 for one purpose.. i would personally prefer to fix it in udev driver eventually, then it helps all cores.
that said, when i got someone to test with a wii mote and sensor bar and a debug version of mame2003, they weren't getting any updates to RETRO_DEVICE_MOUSE, _POINTER, or _LIGHTGUN. this is for some other fault of the udev driver, and in this case you will not be able to work around it without looking into the driver.
-
@johne79 said in Light Gun (Sega Master System) on lr-genesis-plus-gx for RetroPie:
It's actually an easy fix, unfortunately ekeeke the developer is of the mindset that from a design perspective only an absolute pointer touchscreen should be used, and in a perfect world where there are no driver issues with Linux recognizing touchscreen devices that's great, but in my experience that's not the case so I respectfully disagree. Theoretically even a joypad analog thumb stick could/should be used as a lightgun pointer in a pinch when other hardware options are not available IMHO.I just changed the code in lr-genesis-plus-gx to reference RETRO_DEVICE_LIGHTGUN instead of RETRO_DEVICE_POINTER on my end, and also put in some code to check the screen position. Although I put in a constant for the screen bounds checking instead of actually looking at a variable, so it worked fine on Missile Defense 3-D, but then when I played T2: The Arcade Game on Genesis my cursor would only go over half the screen (because the Genesis runs at a larger resolution). Easy fix, but I have to rework those sections of code, maybe I'll fork their repo into my own and just share that.
See, that's the thing... I don't know where to change the RETRO_DEVICE_LIGHTGUN setting. I know next to nothing about tweaking code for emulators.
Plus I saw here (https://wiki.libretro.com/index.php?title=Genesis_Plus_GX) there is an option to turn the crosshairs on, but again, I don't know how to change this. If you could help me out a bit on where to change this code, and the other codes you tweaked, I'd be very grateful.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.