Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Analog controls #5

Closed
pacomur77 opened this issue Dec 1, 2023 · 20 comments
Closed

Analog controls #5

pacomur77 opened this issue Dec 1, 2023 · 20 comments
Assignees
Labels
enhancement New feature or request

Comments

@pacomur77
Copy link

support for analog controls used in guns such as the top shot elite

@gustavoalara
Copy link

Agree on that.
The possibility of use analog sticks instead of d-pad (or both) and the choice of change the behaviour from analog to digital (in the case of analog stick) or from digital to analog (in the case of d-pads) could be an amazing features

@SeongGino
Copy link
Owner

Right-o! I don't have a gun with analog inputs yet that I can use to test but I'm happy to implement this anyways.

Just one question: How should the stick be recognized?

  • Digital inputs: Would be easiest and can hook into the existing input systems we have.
  • Analog inputs: Would require adding gamepad output support (which LightgunButtons already seems to provide a stub for, interestingly...).

I know GUN4IR had the ability to use a Wii Nunchuk, but I'm not quite sure if they used analog outputs or just converted stick input to digital. The only reason I hadn't considered this earlier was not having a Top Shot myself, which I now realize only uses sticks for directional input.

@gustavoalara
Copy link

Thanks to take this improvement into account!

Well, I don't only think in guns like the Top Shot Elite gun that has 2 analog sticks as-is, I was thinking in adding mini sticks for Arduino in any lightgun we can modding

I think that could be useful to have the possibility to choice if the analog stick can work as analog or digital. But the digital input could be a good start

When using a Nunchuk in GUN4IR the stick works as digital inputs

@SeongGino
Copy link
Owner

Then I can absolutely match that behavior (digital), should be fairly simple.

Should a stick be mapped/aliased to keyboard cursor keys, like the Guncon 2's d-pad? Or should it go to a gamepad-like output?

I will probably proto a digital-only implementation before writing in analog output, but admittedly it's hard to think of gun games that need an analog stick specifically. The obvious example is TC4 retail's FPS mode, but a Guncon 3 isn't even able to be emulated yet in RPCS3.
(I guess maybe the Link's Crossbow Training fans might benefit, aha)
I only want to be sure so I'm not putting too much effort for an extra something that no games practically use.

@gustavoalara
Copy link

Hi SeongGino,

You're right, maybe mapping the analog stick to a digital d-pad based on keyboard cursor is far enough...

I only remember a few lightgun games that need a stick and I'm not pretty sure if any of them really uses an analog stick...

Metal Gear Arcade, Banzai Scape 2, Epoch, the 2 Resident Evil Chronicles and Dead Space: Extraction on RPCS3, more on Dolphin and Teknoparrot emulators... But probably those games only use a digital implementation

@SeongGino SeongGino self-assigned this Dec 25, 2023
@SeongGino SeongGino added the enhancement New feature or request label Dec 25, 2023
@SeongGino
Copy link
Owner

SeongGino commented Jan 7, 2024

Top Shot is coming in soon, so I can start implementing this shortly.

Since I've added gamepad output support (mainly to support PCSX2), the idea for now is to make any stick respond as either a d-pad, the keyboard arrow keys, or a second stick (currently, analogOutput mode uses axis' X/Y) - no idea if this physical analog stick should be mapped to the right stick or left. Stick-as-cursor is configurable in PCSX2, but apparently games like Railbreak that use gamepad output to support multiplayer with Sindens use a stick in the same way but it isn't clear which axis it's actually checking for that.

It's also safe to say we probably won't need the second stick either--as far as I can tell, RaspPi Pico doesn't even have a fourth analog pin, and I don't think any games outside of Cabela's titles even uses it?

Either way, as the thread has shown thus far, the use of the stick is limited outside of navigation, so it's mostly semantics at this point :P

@cmjdbb
Copy link

cmjdbb commented Jan 12, 2024

The output of the joystick is simulated using the X/Y coordinates from the camera.

@SeongGino
Copy link
Owner

The output of the joystick is simulated using the X/Y coordinates from the camera.

That is indeed what we're doing; I'm just asking to clarify which stick should the camera simulate, and so I know which side to map a gun's available analog stick to.

@SeongGino
Copy link
Owner

4fcf9d6 has added support for any analog stick to be mapped to the output'd left stick, with the right reserved for the camera when analog output mode is ticked. The pins should be set to read at 12-bit precision, but do advise if the sensitivity or the deadzone is too much or not enough (I still have yet to try with an analog stick myself).

Though it seems like we're reaching the limits of what can be safely transmitted with this, as I had to move things around to ensure that camera performance wasn't impacted. For what it's worth, I ran into some strangeness in an early build that caused the board to stall, very much like #3, so please report back if there are any issues.

@cmjdbb
Copy link

cmjdbb commented Jan 13, 2024

I have a suggestion. Both the left joystick and the right joystick should be implemented. In pause mode, use a combination of keys to switch between the left joystick and the right joystick, as some games use the left joystick while others use the right joystick.

@cmjdbb
Copy link

cmjdbb commented Jan 13, 2024

Of course, I have a better suggestion. If it can be switched to the regular relative coordinate mouse mode, it would be unbeatable because there are still many light gun games that only support the regular mouse mode, like "Rambo: The Video Game".

@SeongGino
Copy link
Owner

SeongGino commented Jan 13, 2024

I have a suggestion. Both the left joystick and the right joystick should be implemented. In pause mode, use a combination of keys to switch between the left joystick and the right joystick, as some games use the left joystick while others use the right joystick.

Hmmm, so different games use different sticks for aiming? That's really dumb--but noted. Will see about implementing soon.
It should be noted that analog output right now is exclusively controlled through a MAMEHOOK-like serial command, XA. I'm personally not all that comfortable with making it a shortcut, since it's a workaround I really only implemented for PCSX2 and the problematic few games that don't have multimouse support or an available DemulShooter patch--and at least on Linux, my gun emulation script lets me just send that signal to toggle in and out of cursor-to-stick output mode. :)

(since I forgot to write, just sending:

echo XA > /dev/ttyACM#
// where "#" is the gun's serial port, from 0-3

will do the job. No idea what an equivalent to this would be on Windows.)

As for the mouse, we can only use absolute positioning, since we can only load one type of mouse at a time (and the way mice devices work, they are hard-coded to being either relative or abs at boot)--even then, relative positioning simply doesn't work when lightguns, and the nature of our tracking, are intrinsically based on absolute positioning.

@SeongGino
Copy link
Owner

SeongGino commented Jan 13, 2024

Added stick declaration in 676a69e so the camera & analog stick will swap places when declared. Still exclusively a serial command tho - send XAL for camera as left stick, XAR for camera as right stick, and just XA to toggle it on and off using the last defined output. The default remains camera as right stick/Rx & Ry, and the gun's analog stick as left stick/X & Y.

A reminder though, do advise if the physical gun's analog stick movement isn't quite accurate! It might need some tweaking still.

@cmjdbb
Copy link

cmjdbb commented Jan 14, 2024

How do I switch between joystick and light gun? I have a lot of things to do recently and haven't had time to review the code in detail. You should update the README file to inform everyone how to use the new code.

@SeongGino
Copy link
Owner

Just to clarify, this issue is about adding a physical joystick to the board. The ability to output the camera as a stick was already implemented but not a part of this issue. I've already tested and that part works as expected.

I'm still waiting for feedback on this issue so I can add it to the next release; and because of the scope of what's been added/changed, it will take a while for me to update documentation.

@cmjdbb
Copy link

cmjdbb commented Jan 14, 2024

Sorry,there seems to be a mistake in my description. What I actually meant to ask is how to switch functions between the light gun and the controller. I will find some time to test it out. It seems that there aren't many people who use MAMEHOOK for testing.

@SeongGino
Copy link
Owner

Apologies for the confusion.

It should be noted that it (analog output mode) isn't dependent on Mame Hook but I'm not sure how else Windows users can send one-off serial commands. Like I said earlier, it's relatively easy to do on Linux.

Now that I think about it, I probably should remove the "experimental" label off the Mamehook flag in the sketch code... stability has been fine so long as the patched core is used (and the TinyUSB library is not installed in the IDE--I know, confusing). It'll matter less once binaries are being distributed.

@cmjdbb

This comment was marked as off-topic.

@SeongGino
Copy link
Owner

SeongGino commented Jan 17, 2024

@cmjdbb None of this is related to the issue at hand for the record, so I have no idea what you're on about right now.

Though I'll only comment on this:

The vibration output signal of MAMEHOOK is wrong. Normally, it should output a high level of 30ms and a low level of 60ms, so that the electromagnet can be released after drawing. Now the output is 60ms high level, 30ms low level, so the electromagnet will hold on.

So you're referring to this?

unsigned int serialRumbPulsesLength = 60; // How long each stage of a serial-invoked pulse rumble is, in ms.

If you have any other issues that aren't related to the topic here, please make a separate thread for it to declutter this one.

@SeongGino
Copy link
Owner

Since no one else has opted to comment, I just got around to testing it, and found issues. ef800c4 resolves sticks being inverted, and da80cee resolves stick position update rate. For Cabela's guns, it should be fine now.

And since v4.1 is out, safe to say that release closes this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants