mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-23 15:52:41 +02:00
port: cleanup; camspy and slayer respect invert pitch option
note: dual analog mode now only works if you set StickCButtons=0 in pd.ini
This commit is contained in:
1 parent
e2b1cdce86
commit
d1817aaea6
5 files changed
+73
-90
No files matched your search
+37
-28
@@ -37,7 +37,7 @@ static f32 mouseSensY = 1.5f;
|
||||
|
||||
static f32 rumbleScale = 0.5f;
|
||||
|
||||
// NOTE: by default this gets inverted for 1.2
|
||||
// NOTE: by default this gets inverted for 1.2: "right stick" here means left stick on your controller
|
||||
static u32 axisMap[2][2] = {
|
||||
{ SDL_CONTROLLER_AXIS_LEFTX, SDL_CONTROLLER_AXIS_LEFTY },
|
||||
{ SDL_CONTROLLER_AXIS_RIGHTX, SDL_CONTROLLER_AXIS_RIGHTY },
|
||||
@@ -73,22 +73,22 @@ static const char *ckNames[CK_TOTAL_COUNT] = {
|
||||
"Z_TRIG",
|
||||
"B_BUTTON",
|
||||
"A_BUTTON",
|
||||
"CK_0001",
|
||||
"CK_0002",
|
||||
"CK_0004",
|
||||
"CK_0008",
|
||||
"CK_0010",
|
||||
"CK_0020",
|
||||
"CK_0040",
|
||||
"CK_0080",
|
||||
"CK_0100",
|
||||
"CK_0200",
|
||||
"CK_0400",
|
||||
"CK_0800",
|
||||
"CK_1000",
|
||||
"CK_2000",
|
||||
"CK_4000",
|
||||
"CK_8000"
|
||||
"CK_0001",
|
||||
"CK_0002",
|
||||
"CK_0004",
|
||||
"CK_0008",
|
||||
"CK_0010",
|
||||
"CK_0020",
|
||||
"CK_0040",
|
||||
"CK_0080",
|
||||
"CK_0100",
|
||||
"CK_0200",
|
||||
"CK_0400",
|
||||
"CK_0800",
|
||||
"CK_1000",
|
||||
"CK_2000",
|
||||
"CK_4000",
|
||||
"CK_8000"
|
||||
"STICK_XNEG",
|
||||
"STICK_XPOS",
|
||||
"STICK_YNEG",
|
||||
@@ -169,8 +169,8 @@ void inputSetDefaultKeyBinds(void)
|
||||
{ CK_STICK_XPOS, SDL_SCANCODE_RIGHT, 0 },
|
||||
{ CK_STICK_YNEG, SDL_SCANCODE_DOWN, 0 },
|
||||
{ CK_STICK_YPOS, SDL_SCANCODE_UP, 0 },
|
||||
{CK_4000, SDL_SCANCODE_LSHIFT, 0 },
|
||||
{CK_2000, SDL_SCANCODE_LCTRL, 0 }
|
||||
{ CK_4000, SDL_SCANCODE_LSHIFT, 0 },
|
||||
{ CK_2000, SDL_SCANCODE_LCTRL, 0 }
|
||||
};
|
||||
|
||||
static const u32 joybinds[][2] = {
|
||||
@@ -461,7 +461,7 @@ s32 inputInit(void)
|
||||
stickSens[2] = configGetFloat("Input.RStickScaleX", 1.f);
|
||||
stickSens[3] = configGetFloat("Input.RStickScaleY", 1.f);
|
||||
|
||||
stickCButtons = configGetInt("Input.StickCButtons", 1);
|
||||
stickCButtons = configGetInt("Input.StickCButtons", 0);
|
||||
|
||||
if (configGetInt("Input.SwapSticks", 1)) {
|
||||
// invert axis map
|
||||
@@ -544,7 +544,6 @@ s32 inputReadController(s32 idx, OSContPad *npad)
|
||||
rightX = inputAxisScale(rightX, deadzone[axisMap[1][0]], stickSens[axisMap[1][0]]);
|
||||
rightY = inputAxisScale(rightY, deadzone[axisMap[1][1]], stickSens[axisMap[1][1]]);
|
||||
|
||||
|
||||
if (!npad->stick_x && leftX) {
|
||||
npad->stick_x = leftX / 0x100;
|
||||
}
|
||||
@@ -554,13 +553,23 @@ s32 inputReadController(s32 idx, OSContPad *npad)
|
||||
npad->stick_y = (stickY == 128) ? 127 : stickY;
|
||||
}
|
||||
|
||||
if (!npad->rstick_x && rightX) {
|
||||
npad->rstick_x = rightX / 0x100;
|
||||
}
|
||||
|
||||
s32 rStickY = -rightY / 0x100;
|
||||
if (!npad->rstick_y && rStickY) {
|
||||
npad->rstick_y = (rStickY == 128) ? 127 : rStickY;
|
||||
if (stickCButtons) {
|
||||
// rstick emulates C buttons
|
||||
if (rightX < -0x4000) npad->button |= L_CBUTTONS;
|
||||
if (rightX > +0x4000) npad->button |= R_CBUTTONS;
|
||||
if (rightY < -0x4000) npad->button |= U_CBUTTONS;
|
||||
if (rightY > +0x4000) npad->button |= D_CBUTTONS;
|
||||
npad->rstick_x = 0;
|
||||
npad->rstick_y = 0;
|
||||
} else {
|
||||
// rstick is an analog input
|
||||
if (rightX) {
|
||||
npad->rstick_x = rightX / 0x100;
|
||||
}
|
||||
s32 rStickY = -rightY / 0x100;
|
||||
if (rStickY) {
|
||||
npad->rstick_y = (rStickY == 128) ? 127 : rStickY;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -728,13 +728,13 @@ void eyespyProcessInput(bool allowbuttons)
|
||||
|
||||
c2buttons = allowbuttons ? joyGetButtons(contpad2, 0xffffffff) : 0;
|
||||
} else {
|
||||
#ifndef PLATFORM_N64
|
||||
#ifndef PLATFORM_N64
|
||||
c2stickx = joyGetRStickX(contpad1);
|
||||
c2sticky = joyGetRStickY(contpad1);
|
||||
#else
|
||||
#else
|
||||
c2stickx = c1stickx;
|
||||
c2sticky = c1sticky;
|
||||
#endif
|
||||
#endif
|
||||
c2buttons = c1buttons;
|
||||
}
|
||||
|
||||
@@ -953,6 +953,12 @@ void eyespyProcessInput(bool allowbuttons)
|
||||
g_Vars.currentplayer->eyespy->sintheta = sinf(g_Vars.currentplayer->eyespy->theta * 0.017453292384744f);
|
||||
|
||||
// Update verta
|
||||
#ifndef PLATFORM_N64
|
||||
// respect the invert pitch setting
|
||||
if (optionsGetForwardPitch(g_Vars.currentplayerstats->mpindex)) {
|
||||
pitchspeed = -pitchspeed;
|
||||
}
|
||||
#endif
|
||||
g_Vars.currentplayer->eyespy->verta -= pitchspeed * 0.0625f * g_Vars.lvupdate60freal;
|
||||
|
||||
if (prevverta != g_Vars.currentplayer->eyespy->verta) {
|
||||
|
||||
+20
-57
@@ -39,11 +39,12 @@
|
||||
#include "data.h"
|
||||
#include "types.h"
|
||||
#ifndef PLATFORM_N64
|
||||
#include <math.h>
|
||||
#include "input.h"
|
||||
#include "video.h"
|
||||
#endif
|
||||
|
||||
void handleProcessInputAltButton(struct movedata *data, s8 contpad, s32 i){
|
||||
static void bgunProcessInputAltButton(struct movedata *data, s8 contpad, s32 i)
|
||||
{
|
||||
s32 buttons = joyGetButtonsOnSample(i, contpad, 0xffffffff);
|
||||
if (buttons & (BUTTON_ALTMODE)) {
|
||||
if (g_Vars.currentplayer->altdowntime >= -1) {
|
||||
@@ -52,7 +53,6 @@ void handleProcessInputAltButton(struct movedata *data, s8 contpad, s32 i){
|
||||
&& bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, true, false, true) != USETIMER_CONTINUE) {
|
||||
g_Vars.currentplayer->altdowntime = -3;
|
||||
}
|
||||
|
||||
if (g_Vars.currentplayer->altdowntime != -4) {
|
||||
if (g_Vars.currentplayer->altdowntime <= 0) {
|
||||
g_Vars.currentplayer->altdowntime++;
|
||||
@@ -64,22 +64,19 @@ void handleProcessInputAltButton(struct movedata *data, s8 contpad, s32 i){
|
||||
g_Vars.currentplayer->altdowntime = -4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (buttons & (BUTTON_CANCEL_USE | BUTTON_ACCEPT_USE)) {
|
||||
} else if (buttons & (BUTTON_CANCEL_USE | BUTTON_ACCEPT_USE)) {
|
||||
if (g_Vars.currentplayer->altdowntime >= -1) {
|
||||
if (buttons & (Z_TRIG)
|
||||
&& g_Vars.currentplayer->altdowntime >= 0
|
||||
&& bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, true, false, true) != USETIMER_CONTINUE) {
|
||||
g_Vars.currentplayer->altdowntime = -3;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
} else {
|
||||
// Released L
|
||||
if (g_Vars.currentplayer->altdowntime != 0) {
|
||||
s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, (g_Vars.currentplayer->altdowntime == -3 ? true: false), false, true);
|
||||
|
||||
const bool trigpressed = (g_Vars.currentplayer->altdowntime == -3);
|
||||
s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, trigpressed, false, true);
|
||||
if (result == USETIMER_STOP) {
|
||||
g_Vars.currentplayer->altdowntime = -1;
|
||||
} else if (result == USETIMER_REPEAT) {
|
||||
@@ -91,6 +88,8 @@ void handleProcessInputAltButton(struct movedata *data, s8 contpad, s32 i){
|
||||
}
|
||||
}
|
||||
|
||||
#endif // PLATFORM_N64
|
||||
|
||||
void bmoveSetControlDef(u32 controldef)
|
||||
{
|
||||
g_Vars.currentplayer->controldef = controldef;
|
||||
@@ -808,14 +807,15 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
|
||||
|
||||
c2allowedbuttons = 0xffffffff;
|
||||
|
||||
// NOTE: I'm not 100% sure of correctness here
|
||||
if (g_Vars.currentplayer->joybutinhibit << 0 >> 32) {
|
||||
inhibitedbuttons = g_Vars.currentplayer->joybutinhibit >> 32;
|
||||
// NOTE: joybutinhibit used to store two copies of the 16-bit inhibited mask for some reason
|
||||
// now it only stores one mask because it is 32 bits in size
|
||||
if (g_Vars.currentplayer->joybutinhibit) {
|
||||
inhibitedbuttons = g_Vars.currentplayer->joybutinhibit;
|
||||
c2allowedbuttons = ~inhibitedbuttons;
|
||||
inhibitedbuttons = joyGetButtons(contpad2, 0xffffffff) & inhibitedbuttons;
|
||||
c2buttons &= ~inhibitedbuttons;
|
||||
c2buttonsthisframe &= ~inhibitedbuttons;
|
||||
g_Vars.currentplayer->joybutinhibit = (g_Vars.currentplayer->joybutinhibit & 0xffffffff) | (inhibitedbuttons << 32);
|
||||
g_Vars.currentplayer->joybutinhibit |= inhibitedbuttons;
|
||||
}
|
||||
|
||||
if (ignorec2) {
|
||||
@@ -1501,45 +1501,10 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
if (allowc1buttons) {
|
||||
for (i = 0; i < numsamples; i++) {
|
||||
handleProcessInputAltButton(&movedata, contpad1, i);
|
||||
}
|
||||
// handle L button : alt switching
|
||||
// for (i = 0; i< numsamples; i++) {
|
||||
// if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & BUTTON_ALTMODE)) {
|
||||
// if (g_Vars.currentplayer->altdowntime >= -1) {
|
||||
// if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons)
|
||||
// && g_Vars.currentplayer->altdowntime >= 0
|
||||
// && bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, true, false, true) != USETIMER_CONTINUE) {
|
||||
// g_Vars.currentplayer->altdowntime = -3;
|
||||
// }
|
||||
//
|
||||
// if (g_Vars.currentplayer->altdowntime != -4) {
|
||||
// if (g_Vars.currentplayer->altdowntime <= 0) {
|
||||
// g_Vars.currentplayer->altdowntime++;
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// if (g_Vars.currentplayer->altdowntime == -2) {
|
||||
// bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, false, false, true);
|
||||
// g_Vars.currentplayer->altdowntime = -4;
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// // Released L
|
||||
// if (g_Vars.currentplayer->altdowntime != 0) {
|
||||
// s32 result = bgunConsiderToggleGunFunction(g_Vars.currentplayer->altdowntime, (g_Vars.currentplayer->altdowntime == -3 ? true: false), false, true);
|
||||
//
|
||||
// if (result == USETIMER_STOP) {
|
||||
// g_Vars.currentplayer->altdowntime = -1;
|
||||
// } else if (result == USETIMER_REPEAT) {
|
||||
// g_Vars.currentplayer->altdowntime = -2;
|
||||
// }
|
||||
// }
|
||||
// g_Vars.currentplayer->altdowntime = 0;
|
||||
// bgun0f0a8c50();
|
||||
// }
|
||||
// }
|
||||
for (i = 0; i < numsamples; i++) {
|
||||
bgunProcessInputAltButton(&movedata, contpad1, i);
|
||||
}
|
||||
|
||||
// Handle ALT1 / MI Reload Hack
|
||||
for (i = 0; i < numsamples; i++) {
|
||||
@@ -1548,7 +1513,6 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle radial menu (D-Down)
|
||||
for (i = 0; i < numsamples; i++) {
|
||||
if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & BUTTON_RADIAL)) {
|
||||
@@ -1614,7 +1578,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
|
||||
}
|
||||
}
|
||||
|
||||
// // Handle xbla-style crouch cycling
|
||||
// Handle xbla-style crouch cycling
|
||||
for (i = 0; i < numsamples; i++) {
|
||||
s32 crouchsample = joyGetButtonsPressedOnSample(i, contpad1, 0xffffffff) & BUTTON_CROUCH_CYCLE;
|
||||
if (crouchsample) {
|
||||
@@ -1625,7 +1589,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
|
||||
}
|
||||
}
|
||||
|
||||
// handle 1964GEPD style crouch setting
|
||||
// handle 1964GEPD style crouch setting
|
||||
crouchsample = joyGetButtonsPressedOnSample(i, contpad1, c1allowedbuttons) & BUTTON_HALF_CROUCH;
|
||||
if (crouchsample) {
|
||||
if (g_Vars.currentplayer->crouchpos == CROUCHPOS_DUCK) {
|
||||
@@ -1713,7 +1677,6 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Handle shutting eyes in multiplayer
|
||||
if (bmoveGetCrouchPos() == CROUCHPOS_SQUAT
|
||||
&& g_Vars.currentplayer->crouchoffset == -90
|
||||
|
||||
+1
-1
@@ -2050,7 +2050,7 @@ void lvTick(void)
|
||||
g_Vars.lvupdate240 = 0;
|
||||
|
||||
for (j = 0; j < PLAYERCOUNT(); j++) {
|
||||
g_Vars.players[j]->joybutinhibit = 0xefffefff;
|
||||
g_Vars.players[j]->joybutinhibit = 0xefffffff;
|
||||
}
|
||||
} else {
|
||||
s32 slowmo = lvGetSlowMotionType();
|
||||
|
||||
+6
-1
@@ -3598,6 +3598,11 @@ void playerTick(bool arg0)
|
||||
sp174 = -stickx * LVUPDATE60FREAL() * 0.00025f;
|
||||
|
||||
#ifndef PLATFORM_N64
|
||||
// respect the invert pitch setting
|
||||
if (optionsGetForwardPitch(g_Vars.currentplayerstats->mpindex)) {
|
||||
sp178 = -sp178;
|
||||
}
|
||||
// mouse control
|
||||
if (g_Vars.currentplayernum == 0) {
|
||||
f32 mdx, mdy;
|
||||
inputMouseGetScaledDelta(&mdx, &mdy);
|
||||
@@ -3672,7 +3677,7 @@ void playerTick(bool arg0)
|
||||
targetspeed = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
newspeed = prevspeed;
|
||||
|
||||
if (prevspeed < targetspeed) {
|
||||
|
||||
Reference in new issue
Block a user