Vita: L2/R2 and L3/R3 can now be mapped on PSTV (fixes #1292)

This commit is contained in:
Vicki Pfau 2019-06-06 15:54:35 -07:00
parent 9b9aeb0c2b
commit 7b12516df4
3 changed files with 23 additions and 10 deletions

View File

@ -51,6 +51,7 @@ Misc:
- Qt: Improve sync code - Qt: Improve sync code
- Switch: Dynamic display resizing - Switch: Dynamic display resizing
- Qt: Make mute menu option also toggle fast-forward mute (fixes mgba.io/i/1424) - Qt: Make mute menu option also toggle fast-forward mute (fixes mgba.io/i/1424)
- Vita: L2/R2 and L3/R3 can now be mapped on PSTV (fixes mgba.io/i/1292)
0.7.2: (2019-05-25) 0.7.2: (2019-05-25)
Emulation fixes: Emulation fixes:

View File

@ -41,7 +41,7 @@ static void _drawEnd(void) {
static uint32_t _pollInput(const struct mInputMap* map) { static uint32_t _pollInput(const struct mInputMap* map) {
SceCtrlData pad; SceCtrlData pad;
sceCtrlPeekBufferPositive(0, &pad, 1); sceCtrlPeekBufferPositiveExt2(0, &pad, 1);
int input = mInputMapKeyBits(map, PSP2_INPUT, pad.buttons, 0); int input = mInputMapKeyBits(map, PSP2_INPUT, pad.buttons, 0);
if (pad.buttons & SCE_CTRL_UP || pad.ly < 64) { if (pad.buttons & SCE_CTRL_UP || pad.ly < 64) {
@ -127,17 +127,17 @@ int main() {
.id = PSP2_INPUT, .id = PSP2_INPUT,
.keyNames = (const char*[]) { .keyNames = (const char*[]) {
"Select", "Select",
0, "L3",
0, "R3",
"Start", "Start",
"Up", "Up",
"Right", "Right",
"Down", "Down",
"Left", "Left",
"L", "L2",
"R", "R2",
0, // L2? "L1",
0, // R2? "R1",
"\1\xC", "\1\xC",
"\1\xA", "\1\xA",
"\1\xB", "\1\xB",

View File

@ -267,7 +267,7 @@ static void _postAudioBuffer(struct mAVStream* stream, blip_t* left, blip_t* rig
uint16_t mPSP2PollInput(struct mGUIRunner* runner) { uint16_t mPSP2PollInput(struct mGUIRunner* runner) {
SceCtrlData pad; SceCtrlData pad;
sceCtrlPeekBufferPositive(0, &pad, 1); sceCtrlPeekBufferPositiveExt2(0, &pad, 1);
int activeKeys = mInputMapKeyBits(&runner->core->inputMap, PSP2_INPUT, pad.buttons, 0); int activeKeys = mInputMapKeyBits(&runner->core->inputMap, PSP2_INPUT, pad.buttons, 0);
int angles = mInputMapAxis(&runner->core->inputMap, PSP2_INPUT, 0, pad.ly); int angles = mInputMapAxis(&runner->core->inputMap, PSP2_INPUT, 0, pad.ly);
@ -313,8 +313,8 @@ void mPSP2Setup(struct mGUIRunner* runner) {
mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_DOWN, GBA_KEY_DOWN); mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_DOWN, GBA_KEY_DOWN);
mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_LEFT, GBA_KEY_LEFT); mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_LEFT, GBA_KEY_LEFT);
mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_RIGHT, GBA_KEY_RIGHT); mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_RIGHT, GBA_KEY_RIGHT);
mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_LTRIGGER, GBA_KEY_L); mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_L1, GBA_KEY_L);
mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_RTRIGGER, GBA_KEY_R); mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_R1, GBA_KEY_R);
struct mInputAxis desc = { GBA_KEY_DOWN, GBA_KEY_UP, 192, 64 }; struct mInputAxis desc = { GBA_KEY_DOWN, GBA_KEY_UP, 192, 64 };
mInputBindAxis(&runner->core->inputMap, PSP2_INPUT, 0, &desc); mInputBindAxis(&runner->core->inputMap, PSP2_INPUT, 0, &desc);
@ -398,6 +398,18 @@ void mPSP2LoadROM(struct mGUIRunner* runner) {
interframeBlending = fakeBool; interframeBlending = fakeBool;
} }
// Backcompat: Old versions of mGBA use an older binding system that has different mappings for L/R
if (!sceKernelIsPSVitaTV()) {
int key = mInputMapKey(&runner->core->inputMap, PSP2_INPUT, __builtin_ctz(SCE_CTRL_L2));
if (key >= 0) {
mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_L1, key);
}
key = mInputMapKey(&runner->core->inputMap, PSP2_INPUT, __builtin_ctz(SCE_CTRL_R2));
if (key >= 0) {
mPSP2MapKey(&runner->core->inputMap, SCE_CTRL_R1, key);
}
}
MutexInit(&audioContext.mutex); MutexInit(&audioContext.mutex);
ConditionInit(&audioContext.cond); ConditionInit(&audioContext.cond);
memset(audioContext.buffer, 0, sizeof(audioContext.buffer)); memset(audioContext.buffer, 0, sizeof(audioContext.buffer));