Skip to content

Re order save slot and next slot button so we can make a custom button to save to next slot #20251

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

Open
2 tasks done
JZ6 opened this issue Apr 13, 2025 · 8 comments
Open
2 tasks done
Milestone

Comments

@JZ6
Copy link

JZ6 commented Apr 13, 2025

What should happen

Hi,
Should be a simple change, can the positions of the save slot and next slot buttons be swapped so that we can make a custom button that saves to next slot?

Right now the behavious is save to current slot and then go to next slot, which isn't ideal.

If someone can give me a starting point on the location of these button orders i can work on this pr as well.

Who would this benefit

All users of ppsspp

Image

Platform (if relevant)

Android

Games this would be useful in

All games

Other emulators or software with a similar feature

No response

Checklist

@JZ6 JZ6 closed this as completed Apr 14, 2025
@hrydgard
Copy link
Owner

Hm why close?

@JZ6
Copy link
Author

JZ6 commented Apr 14, 2025

I looked at the code, seems like we shouldn't change the key maps lol

https://github.com/hrydgard/ppsspp/blob/master/Core%2FKeyMap.h#L33

@hrydgard
Copy link
Owner

Oh you can add stuff at the end, but you shouldn't change the values.

And we can actually change the order they're processed in, if needed.

@hrydgard hrydgard reopened this Apr 14, 2025
@iota97
Copy link
Contributor

iota97 commented Apr 14, 2025

The order they are processed is tied to how they are saved in the bitmask right now. We could/should decouple it, still don't make this change lightly :)

@JZ6
Copy link
Author

JZ6 commented Apr 14, 2025

I find a work around by making 2 custom buttons and over laying them on top of each other.

When i press the buttons, it first goes to the next slot, then saves, works great for my use case

@JZ6
Copy link
Author

JZ6 commented Apr 14, 2025

The order they are processed is tied to how they are saved in the bitmask right now. We could/should decouple it, still don't make this change lightly :)

Can you link me to where this bit mask code is?

And yeah ideally a way to set key combo order for custom buttons would be great

@iota97
Copy link
Contributor

iota97 commented Apr 14, 2025

And yeah ideally a way to set key combo order for custom buttons would be great

This would require a proper UI for it, also might be confusing as PSP key are probably not handled sequentially by games when using custom buttons (not 100% sure about it, just a guess from how I remember the PSP data structure). A long term goal is to support custom touch controls with Lua, this use case might be better suited for a scripting language like that imho.

Can you link me to where this bit mask code is?

The bitmask is kinda all over the place as is a setting in the global struct, to keep in short:

The bit mask in passed to the CustomButton class from cfg.key here:

ppsspp/UI/GamepadEmu.cpp

Lines 908 to 910 in e9ac447

auto aux = root->Add(new CustomButton(cfg.key, key, cfg.toggle, cfg.repeat, controllMapper,
g_Config.iTouchButtonStyle == 0 ? customKeyShapes[cfg.shape].i : customKeyShapes[cfg.shape].l, customKeyShapes[cfg.shape].i,
customKeyImages[cfg.image].i, touch.scale, customKeyShapes[cfg.shape].d, buttonLayoutParams(touch)));

Inside the class is stored in the field pspButtonBit_ . The touch event is handled here:

ppsspp/UI/GamepadEmu.cpp

Lines 230 to 234 in e9ac447

for (int i = 0; i < ARRAY_SIZE(customKeyList); i++) {
if (pspButtonBit_ & (1ULL << i)) {
controlMapper_->PSPKey(DEVICE_ID_TOUCH, customKeyList[i].c, (on_ && toggle_) ? KEY_UP : KEY_DOWN);
}
}

Where the list of custom keys is here:

ppsspp/UI/GamepadEmu.h

Lines 286 to 331 in e9ac447

static const keyList customKeyList[] = {
{ ImageID("I_SQUARE"), CTRL_SQUARE },
{ ImageID("I_TRIANGLE"), CTRL_TRIANGLE },
{ ImageID("I_CIRCLE"), CTRL_CIRCLE },
{ ImageID("I_CROSS"), CTRL_CROSS },
{ ImageID::invalid(), CTRL_UP },
{ ImageID::invalid(), CTRL_DOWN },
{ ImageID::invalid(), CTRL_LEFT },
{ ImageID::invalid(), CTRL_RIGHT },
{ ImageID("I_START"), CTRL_START },
{ ImageID("I_SELECT"), CTRL_SELECT },
{ ImageID("I_L"), CTRL_LTRIGGER },
{ ImageID("I_R"), CTRL_RTRIGGER },
{ ImageID::invalid(), VIRTKEY_RAPID_FIRE },
{ ImageID::invalid(), VIRTKEY_FASTFORWARD },
{ ImageID::invalid(), VIRTKEY_SPEED_TOGGLE },
{ ImageID::invalid(), VIRTKEY_REWIND },
{ ImageID::invalid(), VIRTKEY_SAVE_STATE },
{ ImageID::invalid(), VIRTKEY_LOAD_STATE },
{ ImageID::invalid(), VIRTKEY_NEXT_SLOT },
#if !defined(MOBILE_DEVICE)
{ ImageID::invalid(), VIRTKEY_TOGGLE_FULLSCREEN },
#endif
{ ImageID::invalid(), VIRTKEY_SPEED_CUSTOM1 },
{ ImageID::invalid(), VIRTKEY_SPEED_CUSTOM2 },
{ ImageID::invalid(), VIRTKEY_TEXTURE_DUMP },
{ ImageID::invalid(), VIRTKEY_TEXTURE_REPLACE },
{ ImageID::invalid(), VIRTKEY_SCREENSHOT },
{ ImageID::invalid(), VIRTKEY_MUTE_TOGGLE },
{ ImageID::invalid(), VIRTKEY_OPENCHAT },
{ ImageID::invalid(), VIRTKEY_ANALOG_ROTATE_CW },
{ ImageID::invalid(), VIRTKEY_ANALOG_ROTATE_CCW },
{ ImageID::invalid(), VIRTKEY_PAUSE },
{ ImageID::invalid(), VIRTKEY_RESET_EMULATION },
{ ImageID::invalid(), VIRTKEY_DEVMENU },
#ifndef MOBILE_DEVICE
{ ImageID::invalid(), VIRTKEY_RECORD },
#endif
{ ImageID::invalid(), VIRTKEY_AXIS_X_MIN },
{ ImageID::invalid(), VIRTKEY_AXIS_Y_MIN },
{ ImageID::invalid(), VIRTKEY_AXIS_X_MAX },
{ ImageID::invalid(), VIRTKEY_AXIS_Y_MAX },
{ ImageID::invalid(), VIRTKEY_PREVIOUS_SLOT },
{ ImageID::invalid(), VIRTKEY_TOGGLE_TOUCH_CONTROLS },
{ ImageID::invalid(), VIRTKEY_TOGGLE_DEBUGGER },
};

The bitmask is set to the config struct here:

void CustomButtonMappingScreen::saveArray() {
if (id_ >= 0 && id_ < Config::CUSTOM_BUTTON_COUNT) {
g_Config.CustomButton[id_].key = arrayToInt(array);
}
}

@JZ6
Copy link
Author

JZ6 commented Apr 15, 2025

And yeah ideally a way to set key combo order for custom buttons would be great

Awesome thanks!

@hrydgard hrydgard added this to the v1.20 milestone Apr 15, 2025
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