diff --git a/README.MD b/README.MD index 420e108..c3622d9 100644 --- a/README.MD +++ b/README.MD @@ -4,6 +4,7 @@ Changes in this Version - stop hotkeys from affecting game controls in some cases - always allow left stick to control on screen keyboard +- allow mapping of stick and dpad independently Description ===== @@ -289,6 +290,7 @@ CHANGELOG - stop hotkeys from affecting game controls in some cases - always allow left stick to control on screen keyboard +- allow mapping of stick and dpad independently 1.82 diff --git a/src/gp2x/menu/menu_config.cpp b/src/gp2x/menu/menu_config.cpp index b3da4de..6f8a635 100755 --- a/src/gp2x/menu/menu_config.cpp +++ b/src/gp2x/menu/menu_config.cpp @@ -83,6 +83,10 @@ int mainMenu_custom_up[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom_down[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom_left[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom_right[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom_stickup[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom_stickdown[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom_stickleft[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom_stickright[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom_A[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom_B[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom_X[MAX_NUM_CONTROLLERS] = { }; @@ -101,6 +105,10 @@ int mainMenu_custom1_up[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom1_down[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom1_left[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom1_right[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom1_stickup[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom1_stickdown[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom1_stickleft[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom1_stickright[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom1_A[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom1_B[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom1_X[MAX_NUM_CONTROLLERS] = { }; @@ -117,6 +125,10 @@ int mainMenu_custom2_up[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom2_down[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom2_left[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom2_right[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom2_stickup[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom2_stickdown[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom2_stickleft[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom2_stickright[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom2_A[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom2_B[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom2_X[MAX_NUM_CONTROLLERS] = { }; @@ -133,6 +145,10 @@ int mainMenu_custom3_up[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom3_down[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom3_left[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom3_right[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom3_stickup[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom3_stickdown[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom3_stickleft[MAX_NUM_CONTROLLERS] = { }; +int mainMenu_custom3_stickright[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom3_A[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom3_B[MAX_NUM_CONTROLLERS] = { }; int mainMenu_custom3_X[MAX_NUM_CONTROLLERS] = { }; @@ -279,7 +295,7 @@ void SetDefaultMenuSettings(int general) mainMenu_stylusOffset = 0; mainMenu_tapDelay = 10; mainMenu_customControls = 0; - mainMenu_custom_currentlyEditingControllerNr = 0; + mainMenu_custom_currentlyEditingControllerNr = 0; mainMenu_custom_dpad = 0; for (int i=0; iMIN_CUSTOM_ID) - mainMenu_custom_up[ctrlNr]--; - else - mainMenu_custom_up[ctrlNr]=MAX_CUSTOM_ID; + if (editingStick) { + if (mainMenu_custom_stickup[ctrlNr]>MIN_CUSTOM_ID) + mainMenu_custom_stickup[ctrlNr]--; + else + mainMenu_custom_stickup[ctrlNr]=MAX_CUSTOM_ID; + } else { + if (mainMenu_custom_up[ctrlNr]>MIN_CUSTOM_ID) + mainMenu_custom_up[ctrlNr]--; + else + mainMenu_custom_up[ctrlNr]=MAX_CUSTOM_ID; + } #if defined(__PSP2__) || defined(__SWITCH__) mapback_custom_controls(); //record this change in custom control set #endif } else if (right) { - if (mainMenu_custom_up[ctrlNr]MIN_CUSTOM_ID) - mainMenu_custom_down[ctrlNr]--; - else - mainMenu_custom_down[ctrlNr]=MAX_CUSTOM_ID; + if (editingStick) { + if (mainMenu_custom_stickdown[ctrlNr]>MIN_CUSTOM_ID) + mainMenu_custom_stickdown[ctrlNr]--; + else + mainMenu_custom_stickdown[ctrlNr]=MAX_CUSTOM_ID; + } else { + if (mainMenu_custom_down[ctrlNr]>MIN_CUSTOM_ID) + mainMenu_custom_down[ctrlNr]--; + else + mainMenu_custom_down[ctrlNr]=MAX_CUSTOM_ID; + } #if defined(__PSP2__) || defined(__SWITCH__) mapback_custom_controls(); //record this change in custom control set #endif } else if (right) { - if (mainMenu_custom_down[ctrlNr]MIN_CUSTOM_ID) - mainMenu_custom_left[ctrlNr]--; - else - mainMenu_custom_left[ctrlNr]=MAX_CUSTOM_ID; + if (editingStick) { + if (mainMenu_custom_stickleft[ctrlNr]>MIN_CUSTOM_ID) + mainMenu_custom_stickleft[ctrlNr]--; + else + mainMenu_custom_stickleft[ctrlNr]=MAX_CUSTOM_ID; + } else { + if (mainMenu_custom_left[ctrlNr]>MIN_CUSTOM_ID) + mainMenu_custom_left[ctrlNr]--; + else + mainMenu_custom_left[ctrlNr]=MAX_CUSTOM_ID; + } #if defined(__PSP2__) || defined(__SWITCH__) mapback_custom_controls(); //record this change in custom control set #endif } else if (right) { - if (mainMenu_custom_left[ctrlNr]MIN_CUSTOM_ID) - mainMenu_custom_right[ctrlNr]--; - else - mainMenu_custom_right[ctrlNr]=MAX_CUSTOM_ID; + if (editingStick) { + if (mainMenu_custom_stickright[ctrlNr]>MIN_CUSTOM_ID) + mainMenu_custom_stickright[ctrlNr]--; + else + mainMenu_custom_stickright[ctrlNr]=MAX_CUSTOM_ID; + } else { + if (mainMenu_custom_right[ctrlNr]>MIN_CUSTOM_ID) + mainMenu_custom_right[ctrlNr]--; + else + mainMenu_custom_right[ctrlNr]=MAX_CUSTOM_ID; + } #if defined(__PSP2__) || defined(__SWITCH__) mapback_custom_controls(); //record this change in custom control set #endif } else if (right) { - if (mainMenu_custom_right[ctrlNr] joyDeadZoneSquared) { + int *up = 0; + int *down = 0; + int *left = 0; + int *right = 0; +#ifdef __SWITCH__ + if (mainMenu_customControls && !vkbd_mode && !(buttonStart[0] && triggerR[0]) && !singleJoycons) +#else + if (mainMenu_customControls && !vkbd_mode && !(buttonStart[0] && triggerR[0])) +#endif + { + up = &stickUp[i]; + down = &stickDown[i]; + left = &stickLeft[i]; + right = &stickRight[i]; + } else + { + up = &dpadUp[i]; + down = &dpadDown[i]; + left = &dpadLeft[i]; + right = &dpadRight[i]; + } // upper right quadrant if (joyY>0 && joyX>0) { if (joyY>slope*joyX) - dpadUp[i] = 1; + *up = 1; if (joyX>slope*joyY) - dpadRight[i] = 1; + *right = 1; } // upper left quadrant else if (joyY>0 && joyX<=0) { if (joyY>slope*(-joyX)) - dpadUp[i] = 1; + *up = 1; if ((-joyX)>slope*joyY) - dpadLeft[i] = 1; + *left = 1; } // lower right quadrant else if (joyY<=0 && joyX>0) { if ((-joyY)>slope*joyX) - dpadDown[i] = 1; + *down = 1; if (joyX>slope*(-joyY)) - dpadRight[i] = 1; + *right = 1; } // lower left quadrant else if (joyY<=0 && joyX<=0) { if ((-joyY)>slope*(-joyX)) - dpadDown[i] = 1; + *down = 1; if ((-joyX)>slope*(-joyY)) - dpadLeft[i] = 1; + *left = 1; } } } @@ -1383,9 +1433,9 @@ if(!vkbd_mode) if(mainMenu_custom_dpad == 0) // always true on Vita { #ifdef __SWITCH__ - for (int j = 0; j < 14; j++) + for (int j = 0; j < 18; j++) #else - for (int j = 0; j < 10; j++) + for (int j = 0; j < 14; j++) #endif { switch (j) @@ -1415,61 +1465,85 @@ if(!vkbd_mode) mainMenu_custom = &(mainMenu_custom_right[i]); break; case 4: + //STICK UP + button = &(stickUp[i]); + justPressed = &(justMovedStickUp[i]); + mainMenu_custom = &(mainMenu_custom_stickup[i]); + break; + case 5: + //STICK DOWN + button = &(stickDown[i]); + justPressed = &(justMovedStickDown[i]); + mainMenu_custom = &(mainMenu_custom_stickdown[i]); + break; + case 6: + //STICK LEFT + button = &(stickLeft[i]); + justPressed = &(justMovedStickLeft[i]); + mainMenu_custom = &(mainMenu_custom_stickleft[i]); + break; + case 7: + //STICK RIGHT + button = &(stickRight[i]); + justPressed = &(justMovedStickRight[i]); + mainMenu_custom = &(mainMenu_custom_stickright[i]); + break; + case 8: //(A) button = &(buttonA[i]); justPressed = &(justPressedA[i]); mainMenu_custom = &(mainMenu_custom_A[i]); break; - case 5: + case 9: //(B) button = &(buttonB[i]); justPressed = &(justPressedB[i]); mainMenu_custom = &(mainMenu_custom_B[i]); break; - case 6: + case 10: //(X) button = &(buttonX[i]); justPressed = &(justPressedX[i]); mainMenu_custom = &(mainMenu_custom_X[i]); break; - case 7: + case 11: //(Y) button = &(buttonY[i]); justPressed = &(justPressedY[i]); mainMenu_custom = &(mainMenu_custom_Y[i]); break; - case 8: + case 12: //(L) button = &(triggerL[i]); justPressed = &(justPressedL[i]); mainMenu_custom = &(mainMenu_custom_L[i]); break; - case 9: + case 13: //(R) button = &(triggerR[i]); justPressed = &(justPressedR[i]); mainMenu_custom = &(mainMenu_custom_R[i]); break; #ifdef __SWITCH__ - case 10: + case 14: //(L2) button = &(triggerL2[i]); justPressed = &(justPressedL2[i]); mainMenu_custom = &(mainMenu_custom_L2[i]); break; - case 11: + case 15: //(R2) button = &(triggerR2[i]); justPressed = &(justPressedR2[i]); mainMenu_custom = &(mainMenu_custom_R2[i]); break; - case 12: + case 16: //(L3) button = &(triggerL3[i]); justPressed = &(justPressedL3[i]); mainMenu_custom = &(mainMenu_custom_L3[i]); break; - case 13: + case 17: //(R3) button = &(triggerR3[i]); justPressed = &(justPressedR3[i]); diff --git a/src/od-joy.cpp b/src/od-joy.cpp index d280dba..84a94f4 100755 --- a/src/od-joy.cpp +++ b/src/od-joy.cpp @@ -41,6 +41,10 @@ extern int dpadUp[MAX_NUM_CONTROLLERS]; extern int dpadDown[MAX_NUM_CONTROLLERS]; extern int dpadLeft[MAX_NUM_CONTROLLERS]; extern int dpadRight[MAX_NUM_CONTROLLERS]; +extern int stickUp[MAX_NUM_CONTROLLERS]; +extern int stickDown[MAX_NUM_CONTROLLERS]; +extern int stickLeft[MAX_NUM_CONTROLLERS]; +extern int stickRight[MAX_NUM_CONTROLLERS]; extern int buttonA[MAX_NUM_CONTROLLERS]; extern int buttonB[MAX_NUM_CONTROLLERS]; extern int buttonX[MAX_NUM_CONTROLLERS]; @@ -529,7 +533,8 @@ void read_joystick(int nr, unsigned int *dir, int *button) top = 1; else if(mainMenu_custom_dpad == 0) { - if((mainMenu_custom_up[i]==u && dpadUp[i]) || (mainMenu_custom_down[i]==u && dpadDown[i]) || (mainMenu_custom_left[i]==u && dpadLeft[i]) || (mainMenu_custom_right[i]==u && dpadRight[i])) + if((mainMenu_custom_up[i]==u && dpadUp[i]) || (mainMenu_custom_down[i]==u && dpadDown[i]) || (mainMenu_custom_left[i]==u && dpadLeft[i]) || (mainMenu_custom_right[i]==u && dpadRight[i]) + || (mainMenu_custom_stickup[i]==u && stickUp[i]) || (mainMenu_custom_stickdown[i]==u && stickDown[i]) || (mainMenu_custom_stickleft[i]==u && stickLeft[i]) || (mainMenu_custom_stickright[i]==u && stickRight[i])) top = 1; } @@ -542,7 +547,8 @@ void read_joystick(int nr, unsigned int *dir, int *button) bot = 1; else if(mainMenu_custom_dpad == 0) { - if((mainMenu_custom_up[i]==d && dpadUp[i]) || (mainMenu_custom_down[i]==d && dpadDown[i]) || (mainMenu_custom_left[i]==d && dpadLeft[i]) || (mainMenu_custom_right[i]==d && dpadRight[i])) + if((mainMenu_custom_up[i]==d && dpadUp[i]) || (mainMenu_custom_down[i]==d && dpadDown[i]) || (mainMenu_custom_left[i]==d && dpadLeft[i]) || (mainMenu_custom_right[i]==d && dpadRight[i]) + || (mainMenu_custom_stickup[i]==d && stickUp[i]) || (mainMenu_custom_stickdown[i]==d && stickDown[i]) || (mainMenu_custom_stickleft[i]==d && stickLeft[i]) || (mainMenu_custom_stickright[i]==d && stickRight[i])) bot = 1; } @@ -555,7 +561,8 @@ void read_joystick(int nr, unsigned int *dir, int *button) left = 1; else if(mainMenu_custom_dpad == 0) { - if((mainMenu_custom_up[i]==l && dpadUp[i]) || (mainMenu_custom_down[i]==l && dpadDown[i]) || (mainMenu_custom_left[i]==l && dpadLeft[i]) || (mainMenu_custom_right[i]==l && dpadRight[i])) + if((mainMenu_custom_up[i]==l && dpadUp[i]) || (mainMenu_custom_down[i]==l && dpadDown[i]) || (mainMenu_custom_left[i]==l && dpadLeft[i]) || (mainMenu_custom_right[i]==l && dpadRight[i]) + || (mainMenu_custom_stickup[i]==l && stickUp[i]) || (mainMenu_custom_stickdown[i]==l && stickDown[i]) || (mainMenu_custom_stickleft[i]==l && stickLeft[i]) || (mainMenu_custom_stickright[i]==l && stickRight[i])) left = 1; } @@ -568,7 +575,8 @@ void read_joystick(int nr, unsigned int *dir, int *button) right = 1; else if(mainMenu_custom_dpad == 0) { - if((mainMenu_custom_up[i]==r && dpadUp[i]) || (mainMenu_custom_down[i]==r && dpadDown[i]) || (mainMenu_custom_left[i]==r && dpadLeft[i]) || (mainMenu_custom_right[i]==r && dpadRight[i])) + if((mainMenu_custom_up[i]==r && dpadUp[i]) || (mainMenu_custom_down[i]==r && dpadDown[i]) || (mainMenu_custom_left[i]==r && dpadLeft[i]) || (mainMenu_custom_right[i]==r && dpadRight[i]) + || (mainMenu_custom_stickup[i]==r && stickUp[i]) || (mainMenu_custom_stickdown[i]==r && stickDown[i]) || (mainMenu_custom_stickleft[i]==r && stickLeft[i]) || (mainMenu_custom_stickright[i]==r && stickRight[i])) right = 1; } } @@ -621,7 +629,8 @@ void read_joystick(int nr, unsigned int *dir, int *button) *button = 1; else if(mainMenu_custom_dpad == 0) { - if((mainMenu_custom_up[i]==b1 && dpadUp[i]) || (mainMenu_custom_down[i]==b1 && dpadDown[i]) || (mainMenu_custom_left[i]==b1 && dpadLeft[i]) || (mainMenu_custom_right[i]==b1 && dpadRight[i])) + if((mainMenu_custom_up[i]==b1 && dpadUp[i]) || (mainMenu_custom_down[i]==b1 && dpadDown[i]) || (mainMenu_custom_left[i]==b1 && dpadLeft[i]) || (mainMenu_custom_right[i]==b1 && dpadRight[i]) + || (mainMenu_custom_stickup[i]==b1 && stickUp[i]) || (mainMenu_custom_stickdown[i]==b1 && stickDown[i]) || (mainMenu_custom_stickleft[i]==b1 && stickLeft[i]) || (mainMenu_custom_stickright[i]==b1 && stickRight[i])) *button = 1; } if((mainMenu_custom_A[i]==b2 && buttonA[i]) || (mainMenu_custom_B[i]==b2 && buttonB[i]) || (mainMenu_custom_X[i]==b2 && buttonX[i]) || (mainMenu_custom_Y[i]==b2 && buttonY[i]) || (mainMenu_custom_L[i]==b2 && triggerL[i]) || (mainMenu_custom_R[i]==b2 && triggerR[i]) @@ -633,7 +642,8 @@ void read_joystick(int nr, unsigned int *dir, int *button) *button |= 1 << 1; else if(mainMenu_custom_dpad == 0) { - if((mainMenu_custom_up[i]==b2 && dpadUp[i]) || (mainMenu_custom_down[i]==b2 && dpadDown[i]) || (mainMenu_custom_left[i]==b2 && dpadLeft[i]) || (mainMenu_custom_right[i]==b2 && dpadRight[i])) + if((mainMenu_custom_up[i]==b2 && dpadUp[i]) || (mainMenu_custom_down[i]==b2 && dpadDown[i]) || (mainMenu_custom_left[i]==b2 && dpadLeft[i]) || (mainMenu_custom_right[i]==b2 && dpadRight[i]) + || (mainMenu_custom_stickup[i]==b2 && stickUp[i]) || (mainMenu_custom_stickdown[i]==b2 && stickDown[i]) || (mainMenu_custom_stickleft[i]==b2 && stickLeft[i]) || (mainMenu_custom_stickright[i]==b2 && stickRight[i])) *button |= 1 << 1; } }