mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-23 15:52:41 +02:00
port: add an option to make opposite c-buttons cancel each other
for #581
This commit is contained in:
1 parent
daade36e19
commit
9cff3591dd
2 files changed
+30
-3
No files matched your search
@@ -142,6 +142,10 @@ void inputControllerSetSticksSwapped(s32 cidx, s32 swapped);
|
|||||||
s32 inputControllerGetDualAnalog(s32 cidx);
|
s32 inputControllerGetDualAnalog(s32 cidx);
|
||||||
void inputControllerSetDualAnalog(s32 cidx, s32 enable);
|
void inputControllerSetDualAnalog(s32 cidx, s32 enable);
|
||||||
|
|
||||||
|
// get/set Input.Player%d.CancelCButtons
|
||||||
|
s32 inputControllerGetCancelCButtons(s32 cidx);
|
||||||
|
void inputControllerSetCancelCButtons(s32 cidx, s32 cancel);
|
||||||
|
|
||||||
// get/set sensitivity for a given player
|
// get/set sensitivity for a given player
|
||||||
f32 inputControllerGetAxisScale(s32 cidx, s32 stick, s32 axis);
|
f32 inputControllerGetAxisScale(s32 cidx, s32 stick, s32 axis);
|
||||||
void inputControllerSetAxisScale(s32 cidx, s32 stick, s32 axis, f32 value);
|
void inputControllerSetAxisScale(s32 cidx, s32 stick, s32 axis, f32 value);
|
||||||
|
|||||||
+26
-3
@@ -44,7 +44,8 @@ static SDL_GameController *pads[INPUT_MAX_CONTROLLERS];
|
|||||||
.deadzone = { DEFAULT_DEADZONE, DEFAULT_DEADZONE, DEFAULT_DEADZONE, DEFAULT_DEADZONE_RY }, \
|
.deadzone = { DEFAULT_DEADZONE, DEFAULT_DEADZONE, DEFAULT_DEADZONE, DEFAULT_DEADZONE_RY }, \
|
||||||
.stickCButtons = 0, \
|
.stickCButtons = 0, \
|
||||||
.swapSticks = 1, \
|
.swapSticks = 1, \
|
||||||
.deviceIndex = -1 \
|
.deviceIndex = -1, \
|
||||||
|
.cancelCButtons = 0, \
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct controllercfg {
|
static struct controllercfg {
|
||||||
@@ -56,6 +57,7 @@ static struct controllercfg {
|
|||||||
s32 stickCButtons;
|
s32 stickCButtons;
|
||||||
s32 swapSticks;
|
s32 swapSticks;
|
||||||
s32 deviceIndex;
|
s32 deviceIndex;
|
||||||
|
s32 cancelCButtons;
|
||||||
} padsCfg[INPUT_MAX_CONTROLLERS] = {
|
} padsCfg[INPUT_MAX_CONTROLLERS] = {
|
||||||
CONTROLLERCFG_DEFAULT,
|
CONTROLLERCFG_DEFAULT,
|
||||||
CONTROLLERCFG_DEFAULT,
|
CONTROLLERCFG_DEFAULT,
|
||||||
@@ -768,12 +770,22 @@ s32 inputReadController(s32 idx, OSContPad *npad)
|
|||||||
npad->stick_x = xdiff < 0 ? -0x80 : (xdiff > 0 ? 0x7F : 0);
|
npad->stick_x = xdiff < 0 ? -0x80 : (xdiff > 0 ? 0x7F : 0);
|
||||||
npad->stick_y = ydiff < 0 ? -0x80 : (ydiff > 0 ? 0x7F : 0);
|
npad->stick_y = ydiff < 0 ? -0x80 : (ydiff > 0 ? 0x7F : 0);
|
||||||
|
|
||||||
|
const struct controllercfg *cfg = &padsCfg[idx];
|
||||||
|
|
||||||
|
if (cfg->cancelCButtons) {
|
||||||
|
// opposite C buttons cancel each other out
|
||||||
|
if ((npad->button & (L_CBUTTONS | R_CBUTTONS)) == (L_CBUTTONS | R_CBUTTONS)) {
|
||||||
|
npad->button &= ~(L_CBUTTONS | R_CBUTTONS);
|
||||||
|
}
|
||||||
|
if ((npad->button & (U_CBUTTONS | D_CBUTTONS)) == (U_CBUTTONS | D_CBUTTONS)) {
|
||||||
|
npad->button &= ~(U_CBUTTONS | D_CBUTTONS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!pads[idx]) {
|
if (!pads[idx]) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct controllercfg *cfg = &padsCfg[idx];
|
|
||||||
|
|
||||||
s32 leftX = SDL_GameControllerGetAxis(pads[idx], cfg->axisMap[0][0]);
|
s32 leftX = SDL_GameControllerGetAxis(pads[idx], cfg->axisMap[0][0]);
|
||||||
s32 leftY = SDL_GameControllerGetAxis(pads[idx], cfg->axisMap[0][1]);
|
s32 leftY = SDL_GameControllerGetAxis(pads[idx], cfg->axisMap[0][1]);
|
||||||
s32 rightX = SDL_GameControllerGetAxis(pads[idx], cfg->axisMap[1][0]);
|
s32 rightX = SDL_GameControllerGetAxis(pads[idx], cfg->axisMap[1][0]);
|
||||||
@@ -951,6 +963,16 @@ void inputControllerSetDualAnalog(s32 cidx, s32 enable)
|
|||||||
padsCfg[cidx].stickCButtons = !enable;
|
padsCfg[cidx].stickCButtons = !enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s32 inputControllerGetCancelCButtons(s32 cidx)
|
||||||
|
{
|
||||||
|
return padsCfg[cidx].cancelCButtons;
|
||||||
|
}
|
||||||
|
|
||||||
|
void inputControllerSetCancelCButtons(s32 cidx, s32 cancel)
|
||||||
|
{
|
||||||
|
padsCfg[cidx].cancelCButtons = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
f32 inputControllerGetAxisScale(s32 cidx, s32 stick, s32 axis)
|
f32 inputControllerGetAxisScale(s32 cidx, s32 stick, s32 axis)
|
||||||
{
|
{
|
||||||
return padsCfg[cidx].sens[stick * 2 + axis];
|
return padsCfg[cidx].sens[stick * 2 + axis];
|
||||||
@@ -1476,6 +1498,7 @@ PD_CONSTRUCTOR static void inputConfigInit(void)
|
|||||||
configRegisterFloat(strFmt("%s.RStickScaleX", secname), &padsCfg[c].sens[2], -10.f, 10.f);
|
configRegisterFloat(strFmt("%s.RStickScaleX", secname), &padsCfg[c].sens[2], -10.f, 10.f);
|
||||||
configRegisterFloat(strFmt("%s.RStickScaleY", secname), &padsCfg[c].sens[3], -10.f, 10.f);
|
configRegisterFloat(strFmt("%s.RStickScaleY", secname), &padsCfg[c].sens[3], -10.f, 10.f);
|
||||||
configRegisterInt(strFmt("%s.StickCButtons", secname), &padsCfg[c].stickCButtons, 0, 1);
|
configRegisterInt(strFmt("%s.StickCButtons", secname), &padsCfg[c].stickCButtons, 0, 1);
|
||||||
|
configRegisterInt(strFmt("%s.CancelCButtons", secname), &padsCfg[c].cancelCButtons, 0, 1);
|
||||||
configRegisterInt(strFmt("%s.SwapSticks", secname), &padsCfg[c].swapSticks, 0, 1);
|
configRegisterInt(strFmt("%s.SwapSticks", secname), &padsCfg[c].swapSticks, 0, 1);
|
||||||
configRegisterInt(strFmt("%s.ControllerIndex", secname), &padsCfg[c].deviceIndex, -1, 0x7FFFFFFF);
|
configRegisterInt(strFmt("%s.ControllerIndex", secname), &padsCfg[c].deviceIndex, -1, 0x7FFFFFFF);
|
||||||
secname[13] = '.';
|
secname[13] = '.';
|
||||||
|
|||||||
Reference in new issue
Block a user