Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input-remapper disables joystick pass through #437

Closed
tfulmer1 opened this issue Jul 22, 2022 · 15 comments
Closed

input-remapper disables joystick pass through #437

tfulmer1 opened this issue Jul 22, 2022 · 15 comments

Comments

@tfulmer1
Copy link

Possibly related to Issue 324

While attempting to use Input-remapper to remap a gaming control pad ( https://store.azeron.eu/index.php?route=extension/azeron_store_design_product/getAllKeypads#keypad=cyborg ) I encountered an issue with joystick pass through.

I built from source using documented steps in the readme:
sudo apt install git python3-setuptools gettext
git clone https://github.com/sezanzeb/input-remapper.git
cd input-remapper && ./scripts/build.sh
sudo apt install ./dist/input-remapper-1.5.0.deb

Steps post install:
--Loaded the game (before applying input-remapper)
--Started input-remapper, selected the game keypad
--set bindings for the action keys
--Swapped to game, confirmed I could move around with the thumb joystick
--swapped to input-remapper and hit Apply
--Swapped back to game, all keymappings set in remapper worked, but joystick no longer functioned
--Hit "stop injection" joystick works again, key remappings are disabled

Possibly relevant:
The setup for the game pad has options for "left joystick" and "Right joystick" which are not available if I select my keyboard from the devices list. Both of these default to "joystick" trying to swap them to mouse/keyboard/wheel have unfortunate consequences like locking my mouse position in the top left corner, constantly zooming in with the mouse wheel, etc.. But the fact it's looking for two joysticks may mean it's detect my device like a two joystick game controller, but I don't see a way to set it to anything else manually. That may not be related anyway.

@jonasBoss
Copy link
Collaborator

This has to do with the way we apply the remapping and the forwarding of input events.

When no injection is running for a input-device inputremapper does nothing and the device works as if inputremapper is not running at all.

If a injection is running we clone the original device and forward all input-events to the clone except the ones used by a mapping. All events generated by a mapping are sent to predefined virtual devices (gamepad, keyboard or mouse).

This means if you configure a game without the injection running you are configuring a different device than the one used if a injection is running. On some games this works fine, on others not.
It is best to start the injection before you start the game, and then configure the input with the injection running. Unfortunately this might still not work because there are now up to three controllers connected: the original which does not send events and should not be accessible by the game, the clone which sends all the event from the original device and possibly a third controller predefined by inputremapper (if you have a mapping which targets the "gamepad").
It is up to the game if it is able to handle different input devices at once.

I am currently working on the beta branch which aims to address those issues by allowing to remap not only keys but also every other input-event. This will allow us to only use the predefined "gamepad" for all the functions the original gamepad provides while also applying any mapping.

@tfulmer1
Copy link
Author

tfulmer1 commented Jul 23, 2022

I think we're talking about separate issues, I see how the above would mess with keybindings in a game, but the joystick is not changed in input-remapper. But all I'm doing with input-remapper is configuring the device to use the keyboard events that are already bound, so I'm not configuring gamepad thumb --> event in game. I'm configuring gamepad thumb --> Spacebar (already bound from keyboard in game).

Based on the above though, I did the following diagnostic to confirm it was not an issue with the input remapper starting after the game was running:
-- Started input-remapper with my keymappings for the gamepad
-- Started the game
-- My the gamepad input keys work correctly and trigger proper game events, but the joystick still does not cause any movement of the character
-- My keyboard, mouse and a second gamepad (With directional pad instead of joystick) plugged in for testing can all maneuver the character
-- I stopped injecting with input-mapper
-- The keys on the gamepad are now sending to the game with incorrect inputs (expected) and do nothing/wrong thing, but the joystick now works and the character will move.

So I still think something about the joystick input/pass through with input-remapper is the issue and not something with how input remapper is outputting to the game. It seems to work as expected for all other keys on the pad, just not the omni-joystick.

Do you consider the beta branch stable? And will it install over the current or as a separate installation? Happy to try it if you think it might work. Can send feedback afterwards

@jonasBoss
Copy link
Collaborator

I think I need to clarify: even if you map only one button of your gamepad to something else the whole gamepad is cloned into a different device.
This can cause the issues where all the buttons you remapped work fine because they are usually mapped to the virtual keyboard while all the inputs you did not change are broken (for the game) because they are now sent to the clone which is not properly configured ingame.

On which game do you observe the issue? Maybe I can try and reproduce the issue.

You can try the beta branch it will install over the current installation and create a copy of all your existing mappings. so you will not lose anything and can always roll back. In your case I would suggest you use this branch it is essentially beta with one added feature that allows you to map all the axis of your gamepad to the virtual inputremapper-gamepad.
I am happy to get feedback for the beta branch, feel free to open issues for that.

@tfulmer1
Copy link
Author

That makes more sense, thanks -- still no change in behavior though when starting before the game or making changes and re-applying while game is running.

If I try to capture a new key and "change" key and manipulate the joystick, it doesn't register anything. I have both left/right joystick set to "joystick" in the configurable space on the left. So I don't know where else to configure a joystick in the interface to make sure it's passed through successfully.

I'll install the version you linked above hopefully later today and see what happens. This is happening while playing Final Fantasy XIV via Lutris

@tfulmer1
Copy link
Author

Ok, this beta + 1 commit seems to be working much better.

The joystick now registers as an input when trying to assign keys. It shows as Joystick-Y Up, Joystick-X Right, etc as input register values. There was no equivalent output so I mapped to KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT.

Using those configs I was able to move the character around via joystick control on the gamepad. It had a few quirks:

  1. Sometimes even if Joystick-Y UP (--> KEY_UP) was released on the game pad, character kept running forward. I had the "release" set in the advanced settings and also tried with that setting off, but no dice. I eventually just deleted the key mapping, created a new one and turned the sensitivity way down

  2. The default sensitivity (1) was way too sensitive. It's nearly impossible to get an analog stick perfectly right, left, forward, back so almost everything registered as forward + right, Forward + left, etc. I fixed this by turning the trigger thresholds way up

  3. Even with a lot of tinkering on what % of axis is considered active, etc. It's still kind of quirky. It's hard to exactly capture this, but when I'm not passing the joystick through inputer-mapper, when I move the joystick I go where I mean to go. Despite lots of tinkering on %s, I still tend to go forward +right/left a lot instead of forward when passing through input-mapper.

Honestly though, the amount of configuring I have to do to just push a joystick input through seems high. Most people are going to want the direction of the joystick to just pass through. Is there a way to just pass unassigned signals through the emulated device like a transparent proxy layer in networking? Or does everything have to be caught and processed for the emulation to work?

Overall though, this beta +1 branch allows the joystick to work. So I can at least use my gamepad now! Thanks for the support. I think I can deal with the little bit of quirkyness to get all the extra buttons

@jonasBoss
Copy link
Collaborator

jonasBoss commented Jul 23, 2022

first of all thank you for the feedback.

There was no equivalent output so I mapped to KEY_UP, KEY_DOWN, KEY_LEFT, KEY_RIGHT.

Those are the arrow keys on your keyboard, so you use the joystick to push the keyboard buttons.
But there should be a better way to do this:
image
image
This maps the input joystick-X axis to the x-axis on the virtual joystick. It should work much better than mapping the joystick to arrow keys.

edit: see also beta usage

@tfulmer1
Copy link
Author

That worked MUCH better, much better match out of the box to the joystick functionality pre-input-remapper.

I had tried that before, but I guess when in "keyboard" target output that didn't work. I just had "no axis" or something like that as an option. Switching to gamepad mode enabled the analog input.

Thanks for your time

@tfulmer1
Copy link
Author

Ok, so not sure if I should open a new issue or if this is related --

After adding the joystick on analog, everything was working fine. All bindings were good, joystick control was good. I decided to remap one of the keys originally pointing to ALT_L to SHIFT_L. I made no other changes to the config.

I then tried to restart injection and input-mapper reported "Staring injection" bottom left, but the "stop injection" never lit up. The injections weren't happening. I swapped the key binding back, but same problem. Restarted input-mapper, same problem. I did a system halt and brought everything up from scratch, same problem. I rebuilt the beta and did an apt remove and re-installed. Same problem

If I wait long enough, bottom left eventually goes to "injection failed" state.

I'm pretty confused as everything was working and the change I made was minor - and the fact this bad state persisted through a re-install and a system halt is even more impressive. Not sure what happened.

Only other thing I'm thinking of doing is deleting the whole key binding list and rebuilding from scratch. If that works I'll report back

@jonasBoss
Copy link
Collaborator

I created a new issue for this: #441

@ebakosci
Copy link

ebakosci commented Oct 3, 2024

hello,
I can't solve the problem, even by remaping the joysticks.
please help me.
Have a good day

@jonasBoss
Copy link
Collaborator

Can you please explain what you are trying to do and what your issues are?

@ebakosci
Copy link

ebakosci commented Oct 4, 2024

I want to play a game with my PS4 controller.
By default, the game supports both joysticks but not the rest of the keys. So I have to put keyboard keys on the controller to do certain actions like attack for example.
The problem is that when I put the keyboard keys on the controller, the game does not detect when I move the joysticks.
so I mapped the input joystick axis to the virtual joystick axis.
But that doesn't solve the problem.

@ebakosci
Copy link

ebakosci commented Oct 4, 2024

I don't know if this has a connection but when the mapping was done I did:
jstest /dev/input/js0
I touch the controller, nothing happens

jstest /dev/input/js1
only the joystics react

jstest /dev/input/js2
everything reacts except the joysticks

@ebakosci
Copy link

ebakosci commented Oct 5, 2024

I realized that the game doesn't support joysticks well.
So I would have to put zqsd (the movement keys) on the joystick and the mouse movements on the other. But it's complicated.
Does anyone know how to do this?

@jonasBoss
Copy link
Collaborator

jonasBoss commented Oct 10, 2024

Interesting. InputRemapper does not create those /dev/input/jsX devices directly, so in order to check that InputRemapper works correctly you need to use evtest. Run sudo evtest there you should see 3 joystick devices:

  1. your pyhsical joystick
  2. a device called input-remapper <your joystick> forward
  3. and input-remapper gamepad

when your mapping is correct all your mapped buttons and axes should only show up at the third device.

If that does not work, please open a new issue and provide your affected presets (~/.config/input-remapper-2/presets)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants