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

Added keyboard and mouse input remapping, mouse movement to joystick logic, GUI and more #1356

Open
wants to merge 87 commits into
base: main
Choose a base branch
from

Conversation

kalaposfos13
Copy link
Contributor

I changed the original hard-coded switch case keyboard inputs to handling keyboard key - controller button pairs with std::map-s, to which the input pairs get loaded to from a file in the user/ directory (currently hard-coded to keyboardInputConfig.ini).
Mouse movement is baked to the right joystick at the moment, and is handled by polling the mouse delta position.
I didn't touch the other input modes only the keyboard, to which i also put mouse input too.
The provided ini file currently has a souls inspired bloodborne layout.
I also added a robust multi-key input system that is able to accept a key-modifier key pair as input.
F8 reparses the config file and you can even change inputs while ingame
F9 toggles mouse capture

@kalaposfos13
Copy link
Contributor Author

kalaposfos13 commented Oct 13, 2024

Update:
Mouse movement input is now not hard-coded, and can be set to either joystick, and it can be toggled ingame with f7, as it currently overwrites all other inputs to the bound joystick.

@georgemoralis
Copy link
Collaborator

i have some doubt for mouse . Most games calls sceMouse lib library to do it natively . check draft #633

@kalaposfos13
Copy link
Contributor Author

Well for the games that support it just disable this? I wrote this specifically for Bloodborne that doesn't have support, and there, this works fine. I know that this isn't the cleanest option, but for some games you use either this or nothing

@georgemoralis
Copy link
Collaborator

well sure bb what else :D . Need to check how to have both working . Maybe have an config option to enable/disable this

@kalaposfos13
Copy link
Contributor Author

I checked the libMouse branch, and it looks like it can coexist with this, even without manual config other than not adding mouse bindings to my keyboardInputConfig.ini file like this:
This is my waitEvent:

case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP:
case SDL_EVENT_MOUSE_BUTTON_UP:
case SDL_EVENT_MOUSE_BUTTON_DOWN:
    SDL_AddTimer(33, keyRepeatCallback, (void*)payload_to_timer);
    onKeyPress(&event);
    break;

and this is yours:

case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP:
  onKeyPress(&event);
  break;
case SDL_EVENT_MOUSE_BUTTON_DOWN:
case SDL_EVENT_MOUSE_BUTTON_UP:
  onMouseAction(&event);
  break;

These can be merged into one, and while I haven't tested this, this will probably work fine, since they use different things, and the overhead of checking mouse input both ways is probably negligible.
Here's an example of merging the two:

case SDL_EVENT_MOUSE_BUTTON_UP:
case SDL_EVENT_MOUSE_BUTTON_DOWN:
    onMouseAction(&event);
    // no break here
case SDL_EVENT_KEY_DOWN:
case SDL_EVENT_KEY_UP:
    SDL_AddTimer(33, keyRepeatCallback, (void*)payload_to_timer);
    onKeyPress(&event);
    break;

@stinkyolddude
Copy link

Update: Mouse movement input is now not hard-coded, and can be set to either joystick, and it can be toggled ingame with f7, as it currently overwrites all other inputs to the bound joystick.

What are the new controls and how do I change them? I really wanna take the X O Square and Triangle buttons off the Numpad. That would help a lot!

@kalaposfos13
Copy link
Contributor Author

What are the new controls and how do I change them? I really wanna take the X O Square and Triangle buttons off the Numpad. That would help a lot!

You can find the new bindings in the user/keyboardInputConfig.ini file, and they are already changed. To use it, just copy it to your user/ directory and you are good to go, and the syntax is fairly straightforward

@kalaposfos13
Copy link
Contributor Author

kalaposfos13 commented Oct 14, 2024

Quick notice, as it stands now mouse wheel support is incompatible with Logitech mouse software due to an unknown bug (the wheel inputs don't get registered correctly, the rest work fine)

@kalaposfos13
Copy link
Contributor Author

https://github.com/kalaposfos13/shadPS4/tree/main?tab=readme-ov-file#keyboard-and-mouse-mappings
Link for easy reviewing of changes to README
If this were to be merged, someone will have to make the translations for the new GUI, as I didn't do anything on that front, since this is my first time using Qt.

@GHU7924
Copy link

GHU7924 commented Nov 17, 2024

Do you need to retest?

@kalaposfos13
Copy link
Contributor Author

Seeing as the previous version had two major bugs in it, yes, a test of the new one is appreciated.

@GHU7924
Copy link

GHU7924 commented Nov 17, 2024

It looks like there's a problem right now. Last time I put the save files in your build in advance and checked the movement and so on, but now I started the game from the very beginning, and the controls fall off on this screen, I do not know how to describe it correctly…
grr1

At first, the apple moved, then it stopped responding to the keys of the keyboard and gamepad and now, because of this, it is impossible to continue the game.

Honestly, I don't know if it's the fault of this build or if something strange really started happening to the game on the latest versions of the emulator.

Although... I tried the game on the Main e1fecda build, but there's only the controller, and it looks like everything is fine there, the apple fell and the game continued.

Edit:
Here I am attaching a log from your build.
shad_log.txt (new)

Here I am attaching a log from Main build.
shad_log.txt

After I replaced the saves with my own again (where there is little progress in passing), I checked and made sure that everything was fine with the character's movements.

@GHU7924
Copy link

GHU7924 commented Nov 20, 2024

I've set aside more time to test your build and found some problem.
I can't tell if it happened before or if something changed after rewriting the code.

Build 45cc82e

I started Bloodborne, decided to change the configuration to this:
CUSA03173 Config

I saved it, pressed the F8 key, the configuration was applied, but when I clicked on the controller again, I saw that the configuration was reset (the default one is displayed), although the one I set still works in the game.
CUSA03173 Config2

After closing the emulator and restarting it, the default configuration will be used.

Next

At first I didn't notice it, but I didn't like the mouse control, as if the original problem had returned (the one that was in the first implementation), the mouse was too sensitive, and the camera was slow, but then I saw:

mouse_movement_params = 1, 0.5, 0.125

I have doubts and a couple of questions about whether the values are set correctly? and is the sequence spelled out correctly here? so I went to study the "Special bindings" section in the help.

mouse_movement_params = 1, 0.5, 0.125 (mouse_deadzone_offset, mouse_speed, mouse_speed_offset)
Is it so?

I saw and realized that the information did not correspond to what was written.
CUSA03173 Config3

If you want to check it personally, here I am attaching a text file with my file configuration:
Bloodborne config.txt

mouse_speed_offset - I still haven't decided which value to set.

Note: All this happens during gameplay (and maybe not only).
Note 2: It seems that Default.ini affects other configurations (if you change its contents, it will be copied to other configuration files).

@GHU7924
Copy link

GHU7924 commented Nov 21, 2024

Build 216a5dc - The previous issue has been fixed.

Next
Help
It would be necessary to make sure that if both windows are open (as in the picture), then clicking on the cross highlighted in a red circle closes both windows.

Next
There is some kind of bug that causes the emulator to close.
If you resize the window, then click on the area a couple of times, then click Help, sometimes it closes the emulator, although it may not happen the first time (or if you make several clicks on the area again after opening the help).

2024-11-21.17-26-03.mp4

And a new proposal, if it can be implemented. I'm not saying to do it, but it would be great if there was such a thing. This way it will be easier for users to figure out than to prescribe parameters by configuring the configuration. This should also save you from questions about mouse settings (maybe yes, maybe no).
Mouse Settings

This is an example, so I did not try to draw carefully, especially since this implementation may not exist.

If it's closed with the top right close button instead of clicking the Help button again, a required flag wasn't reset, making the next click on Help try to close a nonexistent window and segfault
@kalaposfos13
Copy link
Contributor Author

And a new proposal, if it can be implemented. I'm not saying to do it, but it would be great if there was such a thing. This way it will be easier for users to figure out than to prescribe parameters by configuring the configuration. This should also save you from questions about mouse settings (maybe yes, maybe no).

This I will not do, because while I would love to have a better GUI, I also stated that this is only a temporary one, and since this will probably be implemented by whoever will write the next GUI, it doesn't make sense to add it to here, especially since this is just a quality of life feature, not something important, so as I said earlier, I won't do much more with it other than fixing bugs.

@kalaposfos13 kalaposfos13 changed the title Added keyboard and mouse input remapping, rudimentary mouse movement to joystick logic and more Added keyboard and mouse input remapping, mouse movement to joystick logic, GUI and more Nov 21, 2024
@GHU7924
Copy link

GHU7924 commented Nov 21, 2024

Build ca37d03 - The previous issue has been fixed.

Next

@kalaposfos13 If you click the Help button, then close the help window, repeat this several times, then a window flashes for a second in the upper-left corner of the screen (presumably, this is a help window that is configured according to the standard, and then immediately moves to the specified coordinates, if I understood correctly). It's not a problem, but it's noticeable.

Also, unfortunately, I cannot test the behavior of your build on Linux, I have problems with the game there.
The latest Main builds also don't work well. Even Beach Buggy Racing works in 3 fps.

@kalaposfos13
Copy link
Contributor Author

I finished the first version of my controller remapping support, but not everything is done yet, here's the current status:

  • Button-to-button mapping: works
  • Axis-to-axis mapping: works if you don't mix the types (joystick axis to trigger or vice versa). If you do, it still activates outputs, but for example, binding r2 to rightjoystick_x only pushes it in the positive direction, and you have no way of making it go the other way.
  • Button-to-axis mapping: works
  • Axis-to-button mapping: works with the triggers, but with the joystick, the current implementation doesn't differentiate between positive or negative directions, so you an only bind one output to it, and it will activate both ways
  • Button+axis-to-axis: works (e.g. the joystick only 'activates' if a button is held)
  • Touchpad remapping: you can bind buttons to it, but not the other way.

For axis-to-axis mapping, there's a new syntax: axis_left_x = axis_left_x
I also changed the folder name from kbmConfig to inputConfig.

@GHU7924
Copy link

GHU7924 commented Nov 26, 2024

The sequence of launching the emulator.
Step 1. When we first launch the emulator, the "User" folder is created.
Step 2. When we select the directory with games, a list is created, and if we ignore this step, there will be no list.
Step 3. When we click the "Controller" button, the "input Config" folder is created with the default.ini file.

It turns out that there are no games, but the control can be configured... I do not know if it is right to do this?

Perhaps it should be done so that the "input Config" folder is created at the time of confirming the paths to the games.
At this stage, there is only default.ini, and the new configuration files for games are created only when you select them in the Edit Config File. (Configuration files weigh very little, so even if there are 1000 of them, they will have almost no weight.)

In addition, each game has the option to delete it,

88

so we need to add the option so that when choosing to delete a game, the question is asked whether it is also worth deleting the configuration file. (But here it is necessary to take into account that a person could play on the controller and not create a configuration file, because, I remind you, new game configuration files are created only when you select them in the Edit Config File).

I also think that although there is a default.ini file, it should remain hidden when choosing a configuration, because you will be configuring the specific configuration file needed for the game, not default.ini.
For example: CUSA03173, CUSA02366, CUSA26789, CUSA01113, CUSA04943, etc.

Instead of this:
000

It must be this:
99

You also need to add the ability to reset any configuration file to the default.ini content. (It is very desirable to use one button - Restore to Default)
For example, you configured the CUSA03173 configuration file, then decided to reset it to the default values, clicked the button and everything is ready,
it is important that the specific selected file is reset, not everything!!!

An insignificant moment:

2024-11-26.17-47-52.mp4

If you scroll the mouse wheel slightly inside the field.

@GHU7924
Copy link

GHU7924 commented Nov 27, 2024

src/qt_gui/kbm_config_dialog.cpp

? "Do you want to reset your custom default config to the original default config?"

I do not know why this is necessary...
You just need to reset the user settings to the default values, and default.ini itself should not be affected at all, content is simply taken from it to reset custom configurations.

(The default .ini file should remain unchanged and its changes should be prohibited. In any case, you will only change the necessary CUSA*****.ini, as there are many games of different genres, so you will not be able to configure default.ini for all.)

Perhaps you should separate the configurations, here's an example.

gg

This way you can make default.ini hidden, as I wrote in the previous comment.

And if we talk about the list of configurations, is it somehow limited or not?

gameslistconfig

I don't have any more ideas for improvement or correction yet, in general, everything has been done quite well at this stage, but I don't rule out that something could have been missed or implemented better, then see for yourself what is needed there. If anything, people will point out errors after merging with Main.

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

Successfully merging this pull request may close these issues.

8 participants