BlitterStudio / amiberry

Optimized Amiga emulator for Linux/macOS
https://amiberry.com
GNU General Public License v3.0
656 stars 87 forks source link

Mapping mouse clicks to joypad not working #119

Closed vretro closed 6 years ago

vretro commented 7 years ago

I tried adding left and right mouse clicks to L and R on a USB joypad and the custom controls don't seem to work.

In addition I also tried assigning Joy stick up to the B button, and it doesn't work either.

I have been able to assign space and enter to X and Y, so custom controls seem to work to some degree.

Test platform is Raspberry Pi, built from source on RetroPie.

Thanks

midwan commented 7 years ago

@vretro Thanks for the feedback!

I've been away for a while, due to some personal matters, so work on the project stalled. I'm slowly getting back into it, so this will be looked into soon.

vretro commented 7 years ago

Hi Dimitris / @midwan Thank you for the update.

Take all the time you need, your work on this project is much appreciated.

Voljega commented 7 years ago

@vretro can you tell me what lines you use in your config file for adding custom controls for mouse clicks and space and enter ?

I only have for now in my uae button_for_menu=0 button_for_quit=16

also is this possible in the SDL1 version (2.1) or only the SDL2 ?

vretro commented 7 years ago

Hi @voljega,

I used the Amiberry UAE4Arm GUI to customise configurations as needed.

After saving each configuration, within Retropie, when launching each game I pressed A and selected the appropriate configuration required.

Sorry I don’t know anything about SDL.

As I haven’t been able to get custom controls working, can’t suggest configurations.

Voljega commented 7 years ago

@vretro can you share your saved uae configuration then ? on zippyshare or something ?

vretro commented 7 years ago

Hi @Voljega I have uploaded my Amiberry configuration directory as located at "opt/retropie/configs/amiga/amiberry/conf/adfdir.conf" for you:

https://send.firefox.com/download/b5fcd95009/#zDdGz0Tt8iYl45lDiA0eiQ

Hope this helps

Voljega commented 7 years ago

Thank you @vretro !

But I don't see how you manage to assign space to X and enter to Y unless you also assigned space to gui and enter to quit emulator or something like that ? which would cause trouble given the high number of game requiring pressing either on space or enter to start the game ?

HoraceAndTheSpider commented 7 years ago

I will be looking at the overall approach to mouse mapping to a controller

Darknior commented 6 years ago

I'm interested too if some one found a solution to map mouse on right joystick (x360 pad). For some games we can't play without mouse :(

HoraceAndTheSpider commented 6 years ago

you should be able to set the 'mode' to 'mouse' in the .uae config file, but it will need buttons 0/1 to be used as the mouse buttons, and only an axis will be used for mapping.

This is already fixed on the controller branch, by the use of the custom mapping for input devices.

ghost commented 6 years ago

@HoraceAndTheSpider Does the Joypad Mouse work with Digital only pads (by using the swap thing in custom controls) or does it only work for Analogue gamepads ? I can't read the last few choices in the custom controls drop-down menu because of the character limit.

HoraceAndTheSpider commented 6 years ago

The code does not care regarding Digital or Analogue. It only cares about AXIS/HATS/Buttons. "real" Analogue control can only be achieved on an AXIS, but an AXIS can be suppied it's values from either digital or analogue sources. We don't need "real" analogue control for the mouse though :)

If you are talking about the 'original' method used above (leaving the input port on mouse mode), then what matters is how your digital pad sends its signal. If it uses an AXIS (and this is perfectly valid for a digital input - my DragonRise USB does this) then it can be used as a mouse replacement directly in the master branch of amiberry, but it will probably require you to change parameters via the .uae config file.

If you are using the controller branch, then the recommended route will be to leave the input (port 0 for most games) on joystick or cd32 mode, and then enable left/right/both mousemap for that port also. This will map AXIS 1 and/or AXIS 2 (digital or anlaogue, doesnt matter) to the MOUSE AXIS. There is a small bug on this atm because the left-mode should also map the d-pad as well (if available) using either DPAD 'buttons' (e.g. PS3 pad) or HAT input (e.g. PS4 pad), but currently this does not work, and requires you to use the CUSTOM mapping to achieve the same end.

You wont need to use the swap button function in the drop-down (and tbh, i am probably going to remove it from the list anyway until some kind of OnScreen graphics are available for control changes), since the mouse-map function is now in the input panel :)

Darknior commented 6 years ago

@HoraceAndTheSpider where to found and compile the controller branch ? I only see SDL1 et SDL2-dev branch ? https://github.com/midwan/amiberry/branches Or maybe you will merge to Master branch in a near future for every one ?

HoraceAndTheSpider commented 6 years ago

https://github.com/HoraceAndTheSpider/amiberry/branches

Yes, we will be merging with the master branch once the control improvements are finished :)

ghost commented 6 years ago

I built your latest controller commits but i'm a bit confused by what you said above

the recommended route will be to leave the input (port 0 for most games) on joystick or cd32 mode, and then enable left/right/both mousemap for that port also.

Port 0 is always mouse (unless playing 2 player) and Port 1 is Joystick. Mine looks like this -

Port 0 [Mouse]: Mouse Mouse Port 1 [Joystick]: USB,2-axis 8-button gamepad Joystick

I set Mouse Stick 1: to Left, Right and Both but no luck.

Wouldn't it need a 'Hotkey+Button' to change to mouse mode when using Digital Only pads otherwise it will be controlling the mouse and joystick at the same time ? (Which will also start 2 player games).

HoraceAndTheSpider commented 6 years ago

You must consider that you still need to your controller to act as if it were placed into the Amiga Mouse port, so what i have said above is correct. You are looking to emulate port 0 when you are playing a mouse game. The fact you are using a controller rather than a 'real' mouse does not matter to the 'amiga'.

For all games with the mouse (except a few 2 player mouse games , like Lemmings) you will need your controller to be using port 0.

Select Port 0 as a Joystick (even if you intend it to be a mouse inside Amiga emulation) - then enable the mousemap options. This 'cheats' the joystick into sending mouse signals to the emualtor, instead of joystick signals.

e.g. Port 0 [Mouse]: USB,2-axis 8-button gamepad Joystick

You will not get an instance of it sending both mouse and joystick signals, because each action only sends EITHER a mouse or a Joystick event.

ghost commented 6 years ago

No, it doesn't seem to work. If I set -

Port 0 [Mouse]: USB,2-axis 8-button gamepad Joystick

When going back to the GUI, Port 0 is back to Mouse Mouse again.

HoraceAndTheSpider commented 6 years ago

There is a known bug which we are resolving with ports 'reseting' to the default as you have mentioned (there is unwanted code left over from the Pandora version) - @midwan and myself are still hunting for the rogue code which causes this (and this is one reason we have not merged with the master branch yet)

However.... If you persist and keep trying with changing it, swapping ports (setting port 1 to mouse, or keyboard for example) it will eventually put your controller in port 0. Honest ;) (i have had many arguements with this bug!!!)

The other way around this bug is to have two controllers connected, which for some reason seems to stop this problem.

ghost commented 6 years ago

OK, I finally got it to control the mouse, but now the Gamepad controls the mouse only (South Button = Left Mouse Button, East Button = Right Mouse Button), how do you get it to change to joystick ? (Hotkey+Button ?).

HoraceAndTheSpider commented 6 years ago

Sorry, i'm not sure i understand - what is the use case for needing in-emulator swapping between amiga joystick and mouse inputs?

if you want it on normal joystick mode, you switch off mouse-mapping but need to skip past say, a cracktro, then use a normal joystick mode (no mouse map) but custom-map the left mouse button to NORTH or similar.

If you want to play a mouse game with an controller, do what was suggested above, with mousemapping.

If you want a 'mixture' of the two, (e.g. d-pad on joystick, but analogue on mouse) i suggest using the Custom remapping options.

ghost commented 6 years ago

I thought this was the whole point of this feature, to control the mouse and the joystick from the same joypad. Use case would be,

Joystick works as normal, load a ADF (for example) and you need to move the menu bar with mouse and click to select options/skip cracktro etc, so press Hotkey+Button to switch to mouse mode, exit the cracktro then press Hotkey+Button to switch back to Joystick mode.

EDIT: As I said before, you may be able to do this with an Analogue pad that has two Analogue sticks but with a Digital only pad you would need a button to switch between them. So the joystick will stay as Port 1 and when pressing the Hotkey Swap it will put the Joystick as Port 0 with Mouse stick on.

HoraceAndTheSpider commented 6 years ago

No, sorry, that was never the purpose of the function - it is to enable mouse games etc to be played with a controller, using any of the available input types (buttons/hats/axis).

The added potential of doing both joystick (port 1) and mouse (port 0) on a single controller which has multiple direction controls is an 'unexpected feature' of the custom mapping. Perhaps you could consider using hotkey+dpad to control the mouse, as this would achieve what you require.

Because the purpose you have described would also involve swapping the ports it is considerably more involved, because we are talking about a lot of potential events (all directions + buttons * number of ports) to be changed. This might be on a 'long term' plan, but not currently. There is an existing event for port swapping, but i dont believe this currently works correctly - i would consider fixing this as a first approach to rectifying the problem.

Controlling the mousemap from a hotkey swapping button is also now only a long-term plan, because there are problems caused by 'input re-triggering', which is why i am likely to remove that option, now that the menu can be navigated from a controller.

Voljega commented 6 years ago

This functionnality (mouse/joystick swapping) is used by the Hatari emulator, but I agree the mapping of both on one controller is better.

The only use case I can think of is using a controller where is not enough commands, such as a SNES controller.

BTW are you also cleaning the related inputs in uae config file ? There is a lot of unused verbose stuff in there regarding controllers.

Will there be a doc for that ?

ghost commented 6 years ago

OK, so this "feature" is only really useful for Playstation controllers again or Analogue (I hate that Gamepad, the Analogue sticks are too big and horrible !). This is how it works on the Pandora anyway, and even then you have to use Port 0 which is the mouse port on Amiga and some games probably wont work unless the gamepad is in Port 1. I don't see the point of manually going back and forth to the GUI to swap the Ports etc. May as well just use a real mouse.

HoraceAndTheSpider commented 6 years ago

@Voljega You will be pleased to hear, all of the redundant input items are gone in the new config files, and the order has been restructed to be easier to read.

The SNES controller layout could still use SELECT as hotkey and then the custom mapping mentioned above could still be used...

You only start reaching isues with minimal button devices such as as 9-pin joysticks with USB interfaces (where you might only have 2 buttons), but then I feel it is unrealistic to expect this kind of usage with such a limited input device.

@blinkydoos - sorry, i dont undertand why this

is only really useful for Playstation controllers again or Analogue

As mentioned DPAD and HAT (both digital) input devices will still be mapped to the mouse events using this function.... please avoid confusing the matter by referring to analogue inputs specifically not all Axis inputs are Analogue inputs, as was explained previously.

This has nothing to do with Playstation pads either. One of my test controllers for example is the DragonRise USB controller and i am using only 5 buttons and one digital axis on that.

I don't see the point of manually going back and forth to the GUI to swap the Ports etc. May as well just use a real mouse.

Sorry, i respectfully disagree. It takes only a matter of seconds to do this directly with the controller, whereas the requirement to have an additional peripheral device is considerably more inconvenient, especially where dealing with wireless controllers.

As i have already said, i am not writting-off the option of port swapping, but it is lower on the priority list than, for example, making the keyboard controller remappable.

ghost commented 6 years ago

What I meant was that with a Playstation controller (or dual Analogue) you could use both at the same time, mouse on one Analogue and Joystick on the other (like the Pandora does).

If you don't mind opening the GUI, swapping the controls, going back to game and skip a cracktro, then open the GUI again and switch the controls back then go back to game, then you fill your boots ! I'll just use a real mouse. Don't get me wrong though, I appreciate the custom controls addition.

HoraceAndTheSpider commented 6 years ago

this is all you would need to do to achieve what you are after (assuming your device using HAT or DPAD buttons for its digital input)

http://www.djcresswell.com/amigaonline/input_panel.JPG http://www.djcresswell.com/amigaonline/custom_panel.JPG

You can then navigate the cractro menu with hotkey+directions, but ensure that in-game you are still using the joystick port.

ghost commented 6 years ago

I didn't know you could actually map the mouse movements in the Custom Controls (I didn't look to be honest!). Although my RetroArch hotkey is 'Select', it will be a bit difficult to use but better than nothing I guess, thanks.

ghost commented 6 years ago

No, it won't let me map the D-Pad !! So my custom controls are limited to only the buttons even with a hotkey ? I give up !

Also, I notice your version actually tells you the hardcoded hotkeys Menu, Reset & Quit (like RetroArch). Mine doesn't say that.

HoraceAndTheSpider commented 6 years ago

That means that your 'digital' control is in fact an AXIS, just like an analogue stick, so you would need to use the mousemap function, (which is why that function was added) ... yes.. looking at your previously provided cfg file confirms this is the case.

The menu you mentioned wanting this function for ... does it need all 4 mouse directions? You could map up/down to HOTKEY+Left_shoulder and HOTKEY+Right_shoulder to achieve the same effect. Or you could use HOTKEY + A/B/X/Y ?
(if you use this, remember to add ENTERGUI to another button, such as START)

The mentioned extra keys will show if you have downloaded the latest commits from today. They will not be hardcoded, but taken from the RetroArch config file. I am currently implementing this further in game-running as we speak.

ghost commented 6 years ago

OK, so i've gone with HOTKEY + A/B/X/Y/L/R. Is there any way to slow down the mouse when using the joypad to control ? The mouse speed slider in the GUI has no effect.

Did you say that we can navigate the GUI using the joypad ? It's not working for me. I can open and close the GUI with a custom control but the joypad d-pad does nothing.

HoraceAndTheSpider commented 6 years ago

Mouse speed I think (currently) only works with axis mapping; along with adding axis control of the menu (hats and buttons only atm), this is on the list of WIP items.

Darknior commented 6 years ago

WOAW i will kill myself AMIGA make me sealy :( I lost all my day on it :( ... i have many problems with WHDLOAD that not working fine with all games and i read all the tutorial and also use your RetroPieAmigaSetup ! Now i compile this build to try better joystick configuration and mouse, and nothing working fine :( The key to use menu not working and to exit too ? I read you have hard coded keys, where can i found a doc or something to help ? Thanks

HoraceAndTheSpider commented 6 years ago

I cannot write documentation whilst I am still working on coding, sorry.

The quit_button option is removed from the latest version, because it is no longer needed: the RetroArch hitkey/quit key functions are used.

Probably you need to set the controllers path in the paths Panel to “/opt/retropie/configs/all/retroarch/autoconfig”

This will be done by default on the final release but please keep in mind you are using a development version and if you are not comfortable with that, please stick to the release versions.

Darknior commented 6 years ago

I understand, i know i try a beta version. I try to access the emulator menu to configure joystick or exit but i can't find it. I must access it to set controller path. Only tel me how to access it This : http://www.djcresswell.com/amigaonline/input_panel.JPG And after i will make my test myself, no problems.

Voljega commented 6 years ago

"The quit_button option is removed from the latest version, because it is no longer needed: the RetroArch hitkey/quit key functions are used.

Probably you need to set the controllers path in the paths Panel to “/opt/retropie/configs/all/retroarch/autoconfig” "

Hmmm what ? do you mean you have heavily linked amiberry to retropie or retroarch ? :(

Darknior commented 6 years ago

Hmmm what ? do you mean you have heavily linked amiberry to retropie or retroarch ? :(

I think he only speak about controller keys, nothing more. It use the gamepad CFG from Retroarch. It is perfect because if he can detect like Retroarch witch pad you use ? You will always have the same keys assigned :) I think it's really a good idea, i only search now to understand how to use these CFG files.

Voljega commented 6 years ago

Yeah I just think this is too soon and weird at that point, would have been much simpler to just advance to sdl2, clean the controller conf and everything and then transform amiberry into a libreto core.

So if I understand this right, controller configuration will not be in an uae conf anymore but we will have to generate alongside it or somewhere else another conf file akin to the retroarch one ?

HoraceAndTheSpider commented 6 years ago

@Voljega Yes and no.

Amiberry will Read RetroArch controller Config files to perform mapping of controllers to the internal input triggers.

This is provided by a plain text file.

FS UAE does exactly the same thing but has its own controller file layout. Maybe I will also add support to read these files.

For 90% of all use cases, (RetroPie) the above path should be used. For everyone else you can place a retroarch Config file into an Amiberry “controllers” folder (currently the default) which enables the “benefit” of RetroArch layout mapping, but without actually being tied to RetroArch/RetroPie.

Ther is , of course, a fall back where a “default” controller layout will be used. However it is very unlikely this will match up with most controllers.

Hope this helps to explain

HoraceAndTheSpider commented 6 years ago

No , please do not confuse a host controller layout setting (which does not normally exist in UAE) with the actual emulator settings which are held in the .uae Config file.

All this does is tell the emulator where your “x” or “a” or “up” button is ... since this changes between controllers. This will be needed on the SDL branch too.

I do not understand why it is too soon or too weird. This satisfies the needs of 99% of Amiberry users, and can be replicated across the addition systems we will be adding support for.

Voljega commented 6 years ago

ok I'm mostly worried because I'm working into the integration of amiberry into Recalbox and it is not the same as retropie, but it uses Retroarch too ;) So amiberry will use a retroarch mapping conf file and you will decide which button in that mapping are used for which functionnality is this correct ? We won't configure that by ourself anymore ?

I assume you will try to have a setup working for both standard Amiga and CD32 ?

HoraceAndTheSpider commented 6 years ago

Yes standard settings for cd32 and and normal 2 button joystick are already available. There is also a full custom mapping option (pictured above) for games that need extra keyboard controls.

Voljega commented 6 years ago

No , please do not confuse a host controller layout setting (which does not normally exist in UAE) with the actual emulator settings which are held in the .uae Config file.

All this does is tell the emulator where your “x” or “a” or “up” button is ... since this changes between controllers. This will be needed on the SDL branch too.

So the settings in the uae files won't correspond to "sdl button id" anymore but to "retroarch button ids" ?

Actually I was already generating automatically my uae file with the right buttons independently of the controller connected using its configuration

HoraceAndTheSpider commented 6 years ago

If you have recall box using retroarch all you need to do is point the path to your desired controller folder and you will be able to share the same .uae settings for custom layouts etc with everyone

HoraceAndTheSpider commented 6 years ago

Yes, there are no SDL buttons in the use files

I use a referencing such as north_button = Again, the same as fs uae :)

Voljega commented 6 years ago

ok nice ! thank you for your explanation

so i assume exit = hk +start and entering gui will be on select ? (as the cd32 doesn't seem to have a select button)

HoraceAndTheSpider commented 6 years ago

If your RetrOArch cfg has “select” as the HotKey and “start” as your quitkey then yes.

Entering /existing GUI is the “menu button” in retroarch. The common use is HotKey+Triangle (in PlayStation terms, AKA “north button”) - I have it so that here is no need to press the HotKey to “exit” the gui with this button however.

It is actually possible to use an “extra” button (eg PS logo button) as the “hotkey” and free up an extra button (start) for in game remapping.

Darknior commented 6 years ago

I think i have all understand but i always have my only question : Whare to put the joystick file ? I take my : Xbox 360 Wireless Receiver (XBOX).cfg There : /opt/retropie/configs/all/retroarch/autoconfig to there : /opt/retropie/configs/amiga/amiberry/conf And i must rename it ? If some one use an other controller he must change this file ? Because for the moment Amiberry detect fine the different controlers...

HoraceAndTheSpider commented 6 years ago

Amiberry does not do any controller detection. You are “lucky” that your controller(s) happen to match the default layout (button 0=fire etc)

Leave the file where it is , enter the “paths” panel on the Amiberry GUi and point it to the retroarch controllers file.

Someone using another controller will have already set up their on cfg file.

HoraceAndTheSpider commented 6 years ago

http://www.djcresswell.com/amigaonline/paths_panel.JPG

This picture should show what you need. You may need to reload Amiberry after setting though.