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

filter the sdl joystick number via command line #17503

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nadenislamarre
Copy link
Contributor

the aim is to be able to play with the pad i want (by sdl id). not always the first found. In case i've many pads plugged on my computer, i've to unplug the others.

it is not perfect.
maybe the SDL_CONTROLLERDEVICEADDED should clean controllers.

however, the current way it not good too. it initialise all pads, but apply events only on pad 0 (the code make think it is possible to have multiple players in psp, but i don't think it is possible) (key.deviceId = DEVICE_ID_PAD_0 + getDeviceIndex(event.cbutton.which);)

Comment on lines 52 to 55
if(_njoy < numjoys) {
setUpController(_njoy);
if (controllers.size() > 0) {
cout << "pad 1 has been assigned to control pad: " << SDL_JoystickNameForIndex(_njoy) << endl;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is all over the place here. Please use an editor that respects editorconfig, or just manually switch to tabs, 4-width, when editing PPSSPP.

@@ -30,4 +30,5 @@ class SDLJoystick{
bool registeredAsEventHandler;
std::vector<SDL_GameController *> controllers;
std::map<int, int> controllerDeviceMap;
int _njoy;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention we use (but not followed everywhere yet, as seen here) is to have a _ suffix, not prefix, for member variables.

Signed-off-by: Nicolas Adenis-Lamarre <nicolas.adenis.lamarre@gmail.com>
@nadenislamarre
Copy link
Contributor Author

fixed.

@unknownbrackets
Copy link
Collaborator

(the code make think it is possible to have multiple players in psp, but i don't think it is possible)

While the PSP of course was a handheld console that could not have multiple inputs, the controller mapping works like this:

device input -> control mapper -> psp game inputs

So when you see device pad numbers, that's for the device input. At least on Windows, it's perfectly possible to plug in four controllers, and map things such that all buttons on controller 1 press X for the emulated PSP, and the second one could have all buttons mapped to O, etc. Maybe you'd even want to do this for some crazy dance controller.

-[Unknown]

Copy link
Collaborator

@unknownbrackets unknownbrackets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried this might even break the steam deck, I think it had specific behavior when you put the device to sleep that was supported by these change events? Or was that only audio?

-[Unknown]

@@ -41,16 +41,19 @@ SDLJoystick::SDLJoystick(bool init_SDL ) : registeredAsEventHandler(false) {
cout << "gamecontrollerdb.txt missing" << endl;
}
cout << "SUCCESS!" << endl;
setUpControllers();
//setUpControllers();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this comments out all calls to setUpControllers(), but also modifies it. That's confusing.

Git remembers code forever, so if we don't need this anymore the line should be removed and so should the entire method.

-[Unknown]

@@ -186,7 +189,7 @@ void SDLJoystick::ProcessInput(SDL_Event &event){
axis.value = event.caxis.value / 32767.0f;
if (axis.value > 1.0f) axis.value = 1.0f;
if (axis.value < -1.0f) axis.value = -1.0f;
axis.deviceId = DEVICE_ID_PAD_0 + getDeviceIndex(event.caxis.which);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for anyone who is not using your new parameter, and who has multiple controller devices, such as probably the author of #8993, this will break their use of PPSSPP.

Wouldn't it be better if your use case was only activated when your parameter was passed?

-[Unknown]

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.

3 participants