Code Monkey home page Code Monkey logo

Comments (10)

andres-asm avatar andres-asm commented on August 29, 2024 1

I guess mouse button remapping was never considered, since there were just 2, now that there are just 5 we could set descriptors for them on the core to provide nice names for remapping.

Remapping is a frontend feature though, I can try to hook that up once I move gamepad remapping to keymapper.c

from libretro-common.

andres-asm avatar andres-asm commented on August 29, 2024

I don't think it has been used anywhere at all, and since you've been doing the work I think you should go ahead and come up with an implementation.

From the frontend side of things I guess the lightgun is just a pointer device?

I just checked libretro.h and it seems it was modeled after zapper / super scope

from libretro-common.

hiddenasbestos avatar hiddenasbestos commented on August 29, 2024

Okay great, I'm happy to carry on and put something together as a proposal for libretro.h, from the perspective of a core.

One other goal I have is a front-end thing and that is to add a driver for the DolphinBar in it's special 'mode 4'. In this mode it lets you sync up to 4 wiimotes and sends out data over USB as proper input devices, not just mouse emulation. This would let you have multi-player games. I'll need to take a look at the Dolphin source code to see how to access it.

from libretro-common.

hiddenasbestos avatar hiddenasbestos commented on August 29, 2024

I've done a bunch of research into the buttons found on light-guns from the 3rd-6th generation of consoles. The Guncon 2 (for the PlayStation 2) is the peak of lightgun technology before it diverges heavily after the advent of motion controls.

My proposed change to libretro.h are found below.

It breaks the API in the following ways:

  • Deprecating the relative mode X/Y
  • Unifying Start and Pause macros

Other than that I think I've done a good job in extending the API to add the new functionality we'd need for 5th Gen consoles and beyond. Also preserving the legacy SuperScope macros for cursor and turbo buttons.

This will definitely need remapping support in the front-end as there's just a huge amount of variety in what features are supported on each console's gun and if you're limited to emulating via a mouse you'll likely have far fewer buttons available than on a G-Con 2. You will very likely want to map keyboard or controller buttons to secondary actions (such as pause or d-pad, etc.) and make use of the new mouse 4/5 buttons.

/* The LIGHTGUN device is similar to Guncon-2 for PlayStation 2.
 * It reports X/Y coordinates in screen space (similar to the pointer)
 * as well as reporting on/off screen state. It features a trigger, 
 * start/select buttons, four auxiliary action buttons and a 
 * directional pad.
 */
#define RETRO_DEVICE_LIGHTGUN     4

/* Id values for LIGHTGUN types. */
#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X     13 /*Absolute*/
#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y     14 /*Absolute*/
#define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN 15
#define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER       2
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_A         3
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_B         4
#define RETRO_DEVICE_ID_LIGHTGUN_START         5
#define RETRO_DEVICE_ID_LIGHTGUN_SELECT        6
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_C         7
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_D         8
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP       9
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN    10
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT    11
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT   12
/* DEPRECATED LIGHTGUN */
#define RETRO_DEVICE_ID_LIGHTGUN_X             0 /*Relative*/
#define RETRO_DEVICE_ID_LIGHTGUN_Y             1 /*Relative*/
#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR        3 /*= Aux:A*/
#define RETRO_DEVICE_ID_LIGHTGUN_TURBO         4 /*= Aux:B*/
#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE         5 /*Remapped to Start*/

from libretro-common.

hiddenasbestos avatar hiddenasbestos commented on August 29, 2024

Im thinking a dedicated off-screen shot input might be useful too. It'd add the ability to have "auto-reload" which was a feature of many 3rd party guns. However it could also be simulated in the front end (assuming an " is-on-screen " check is done after every shot) which would keep the core a bit cleaner.

from libretro-common.

hiddenasbestos avatar hiddenasbestos commented on August 29, 2024

I revised the new API. Removed AUX_D since this has no meaning for a Guncon 2 or any other gun preceding it (if in future there is need for extra buttons those can be added then).

Also added a forced off-screen shot request. A front-end can request that of a core to perform an auto-reload - or replicate the right-click to reload of Virtua Cop 2 on PC.

/* Id values for LIGHTGUN aiming. */
#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X        12 /*Absolute Position*/
#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y        13 /*Absolute*/
#define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN    14 /*Status Check*/
/* buttons */
#define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER          2
#define RETRO_DEVICE_ID_LIGHTGUN_OFFSCREEN_SHOT  15 /*forced*/
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_A            3
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_B            4
#define RETRO_DEVICE_ID_LIGHTGUN_START            5
#define RETRO_DEVICE_ID_LIGHTGUN_SELECT           6
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_C            7
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP          8
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN        9
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT       10
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT      11
/* deprecated */
#define RETRO_DEVICE_ID_LIGHTGUN_X                0 /*Relative*/
#define RETRO_DEVICE_ID_LIGHTGUN_Y                1 /*Relative*/
#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR           3 /*= Aux:A*/
#define RETRO_DEVICE_ID_LIGHTGUN_TURBO            4 /*= Aux:B*/
#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE            5 /*Remapped to Start*/

from libretro-common.

hiddenasbestos avatar hiddenasbestos commented on August 29, 2024

I've made some good initial progress. The new API has let me strip out a bunch of code from the core and move it to the front-end where it belongs. From a core point of view the code is much cleaner now and I've been able to use 100% light-gun calls to get the input I need. AFAICT the core side is now done.

The second part is to work on a patch for RetroArch to support this work from the front-end side. So far I've disabled any lightgun support on the platforms that have it and am now focusing on bringing the directinput driver back online with the new API - aiming is already working again (since it's just a tweaked copy of the pointer code), but the buttons are currently either hard coded or disabled.

The next step, to complete the first driver 100%, is to add user configurable bindings for all the new gun buttons. This will require being able to map keys, pad buttons and now mouse buttons to a list of 11 virtual gun buttons - same as when you bind inputs to the RetroPad.

Any tips @fr500 ? How does it fit in with other RetroArch plans? should I hold off? should I plow on?

Probably I'd proceed something like this:

  • Add new bindings to the list.
  • Get them displaying on the "User 1,2,3... Binds" sub-menu.
  • Make sure it's saving/loading to the config file properly.
  • Get keyboard and joystick mappings working in the dinput driver.
  • Add in mouse button support.

from libretro-common.

hiddenasbestos avatar hiddenasbestos commented on August 29, 2024

There's a couple of things I wanted to ask about @twinaphex, in terms of avoiding 'breaking ABI'.

  • If a new core requiring this new API (for the extra buttons) is used on an old front-end that only implements the old API then lightguns won't work. Is there anything I can do about this without building a whole suite of input remapping functionality into the core?

Also I'd like to unify the old START and PAUSE controls. I've not encountered any real-world device that has these as separate inputs (happy to be corrected).

I originally decided to do that by changing the value of RETRO_DEVICE_ID_LIGHTGUN_PAUSE, however on reflection that would be bad, e.g. for old core binaries using new front-ends, so I changed it back. The new front-end can just route this to the new unified start/pause input internally to maintain compatibility - assuming of course that the core doesn't think start and pause should be different.

So the new libretro.h section is now:

/* Id values for LIGHTGUN. */
#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X        13 /*Absolute Position*/
#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y        14 /*Absolute*/
#define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN    15 /*Status Check*/
#define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER          2
#define RETRO_DEVICE_ID_LIGHTGUN_RELOAD          16 /*Forced Off-screen Shot*/
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_A            3
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_B            4
#define RETRO_DEVICE_ID_LIGHTGUN_START            6
#define RETRO_DEVICE_ID_LIGHTGUN_SELECT           7
#define RETRO_DEVICE_ID_LIGHTGUN_AUX_C            8
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP          9
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN       10
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT       11
#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT      12
/* deprecated */
#define RETRO_DEVICE_ID_LIGHTGUN_X                0 /*Relative Position*/
#define RETRO_DEVICE_ID_LIGHTGUN_Y                1 /*Relative*/
#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR           3 /*Use Aux:A*/
#define RETRO_DEVICE_ID_LIGHTGUN_TURBO            4 /*Use Aux:B*/
#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE            5 /*Use Start*/

from libretro-common.

hiddenasbestos avatar hiddenasbestos commented on August 29, 2024

I've implemented the binding in RetroArch on my local build and now have ability to bind keyboard/controller inputs to these new controls.

I decided to rename the rather cumbersome "off-screen shot" to just "reload". I've edited the block above to relfect this.

Next to do is make the remapping feature work, so you can setup one gun config for your device and then remap it to the game/core. I got the descriptors coming through but the choices on the menu selections were from the retropad so I'll need to dig into the menu system a bit to figure it out.

The other things left after that are:

  • Ability to bind mouse buttons to controls so you can shoot with the mouse (I have this hard coded atm)
  • Updating the other input drivers to support the new API, based on the dinput implementation.
  • Wait for patch libretro/RetroArch#5762 to be applied, as the extra lightgun inputs break the 64 bind limit.

from libretro-common.

hiddenasbestos avatar hiddenasbestos commented on August 29, 2024

This has been merged now, best to raise new issues for and discovered/remaining problems.

from libretro-common.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.