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, rudimentary mouse movement to joystick logic and more #1356

Open
wants to merge 74 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

kalaposfos13 commented Nov 15, 2024

At this point, I think the rewrite is in a good enough state for people to start using. More 1000 lines of code translates to about 6 changes for the end user, so here they are:

  • Input combinations have changed from a key and modifier key to 3 keys of any kind.
  • modkey_toggle got renamed to key_toggle, as you can now set any key to toggle any other key's virtual state.
  • The W-S-S issue (where you press W, then S, then release S, and the character stops instead of continuing forward) is now fixed.
  • A lot of pressed input at once are now less likely to 'jam' the system
  • Wheel inputs are hopefully fixed once and for all
  • Mouse input toggle is moved from f9 to f7, as f9 is 'pause emulator' if the ctrl f10 debug menu is active

@GHU7924 GHU7924 mentioned this pull request Nov 15, 2024
4 tasks
@GHU7924
Copy link

GHU7924 commented Nov 15, 2024

Build abc1fa2

KBM

And there is also such a moment:

2024-11-15.17-44-06.mp4

I tested it for literally 10 minutes and only Bloodborne, I did not check other functions.

@kalaposfos13
Copy link
Contributor Author

kalaposfos13 commented Nov 15, 2024

Thanks for the feedback! As for impossible-to-guess keybind names, they can be found on the qt-config-gui branch in the Help section, so it's not completely hidden. For your video, I was able to replicate it myself: it seems that if you hold both a and d or w and s, the joystick input is also activated.

@GHU7924
Copy link

GHU7924 commented Nov 15, 2024

Build f760bab The problem from the video has been fixed.

It might be worth adding such a feature, but the problem is that kbmconfig is not created with the user folder.

1

Perhaps this should be done by default, so that the kbmConfig folder is created when creating a User folder, and it would have only one default.ini, and the rest of the ".ini" files are added directly when launching games.

@GHU7924
Copy link

GHU7924 commented Nov 15, 2024

The build is the same f760bab.

"ini" files are created in the kbmConfig folder.

grrr

Editing and applying configurations is also going well.

grr

But in the CUSA01113, I ran into such a problem that if I just press the direction button (W or A or S or D), the following happens:

2024-11-16.00-16-56.mp4

Halfmode (The character stops):

2024-11-16.00-42-31.mp4

The character's movements work correctly on the gamepad, but not from the keyboard.

Gamepad:

2024-11-16.00-47-08.mp4

Did I do something wrong or is it something else?

@kalaposfos13
Copy link
Contributor Author

I added my GUI to this branch, too, as there has been no response from @VasylBaran for way too long. Perhaps he will get around to creating a better GUI in the future, but for now, here's mine as a placeholder. Feedback on it is welcome, but don't expect me to add a lot of features.

@GHU7924
Copy link

GHU7924 commented Nov 16, 2024

Build 3466de0

Gravity Rush is fixed.

2024-11-16.14-30-41.mp4

Next, you GUI

The first thing I want to say is that I definitely like the new interface more than the previous one.

Config1

The new layout of the elements, as well as the corrected second help window.
The text is no longer embedded, and it is possible to copy it and translate it using an online translator for those who do not know English or are not so good at it.

Config2

The text is highlighted in yellow... I don't understand why it is needed in default.ini, if it is in the FAQ.
Therefore, I do not just suggest making changes (since there is a lot of excess in default.ini at the moment), I really ask you to make it this way:

default

Further, I understand that there is a typo here

Config3

You've done a wonderful job.

@GHU7924
Copy link

GHU7924 commented Nov 16, 2024

Build 3261674 I looked at the fixes, I think it's okay.

There have already been a lot of changes in this PR and a lot of messages have been written, so I don't know if it will be appropriate and makes sense, but maybe it's worth closing this PR and opening a new "Mouse, Keyboard, QT Editor" (so to speak, a new beginning).
And it can be noted that the new PR is a continuation of PR 1356.
You can copy and add the information that was provided in your comments.
#1356 (comment)
#1356 (comment)

Perhaps then it will be possible to close problem 298 and focus on a new PR, if the main development team approves it.

P.S. This is in my subjective opinion.

@georgemoralis
Copy link
Collaborator

The pr seems mergable.

@polybiusproxy
Copy link
Collaborator

I believe Turtle wanted to review it

@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

@georgemoralis What do you think the controller window should be?

I know for sure that there were such requirements (from 308):

we gonna have common configuration for keyboard and game pad in future.
We gonna add 4 available ports on future.

In 308 there is a vision of the interface from VasylBaran

I wrote this earlier.
My vision is based on a screenshot from RPCS3, processed with "Paint" in a hurry.
4y6w

Or is it possible to do with a minimalistic look?
This is how I understand the branching of ports and controllers to save ini files with a modified configuration and the settings window from PCSX2 (1.6.0).
789

Kalaposfos13 did a great job, but we also have controllers besides the keyboard and mouse.
It is also not clear yet with the reassignment of the controller keys. Is there an implementation or not yet?

@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.

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