mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp.git
synced 2026-04-27 20:51:40 +00:00
Mods can now force right-stick aiming.
This commit is contained in:
parent
46b502b2f4
commit
8d538d25fc
3 changed files with 39 additions and 22 deletions
|
|
@ -6,24 +6,35 @@
|
||||||
#include "z64voice.h"
|
#include "z64voice.h"
|
||||||
#include "audiothread_cmd.h"
|
#include "audiothread_cmd.h"
|
||||||
|
|
||||||
RECOMP_DECLARE_EVENT(recomp_before_first_person_aiming_update(PlayState* play, Player* this, bool in_free_look, bool* disable_left_stick_aiming));
|
RECOMP_DECLARE_EVENT(recomp_before_first_person_aiming_update_event(PlayState* play, Player* this, bool in_free_look, RecompAimingOverideMode* recomp_aiming_override_mode));
|
||||||
RECOMP_DECLARE_EVENT(recomp_after_first_person_aiming_update(PlayState* play, Player* this, bool in_free_look));
|
RECOMP_DECLARE_EVENT(recomp_after_first_person_aiming_update_event(PlayState* play, Player* this, bool in_free_look));
|
||||||
|
|
||||||
s32 func_80847190(PlayState* play, Player* this, s32 arg2);
|
s32 func_80847190(PlayState* play, Player* this, s32 arg2);
|
||||||
s16 func_80832754(Player* this, s32 arg1);
|
s16 func_80832754(Player* this, s32 arg1);
|
||||||
s32 func_8082EF20(Player* this);
|
s32 func_8082EF20(Player* this);
|
||||||
|
|
||||||
|
// This flag is reset every frame by 'poll_inputs()'.
|
||||||
|
RecompAimingOverideMode recomp_aiming_override_mode = RECOMP_AIMINIG_OVERRIDE_OFF;
|
||||||
|
|
||||||
// @recomp Patched to add gyro and mouse aiming.
|
// @recomp Patched to add gyro and mouse aiming.
|
||||||
RECOMP_PATCH s32 func_80847190(PlayState* play, Player* this, s32 arg2) {
|
RECOMP_PATCH s32 func_80847190(PlayState* play, Player* this, s32 arg2) {
|
||||||
s32 pad;
|
s32 pad;
|
||||||
s16 var_s0;
|
s16 var_s0;
|
||||||
|
|
||||||
|
// Checks if we're in free look (C-Up look around mode).
|
||||||
|
bool in_free_look = (!func_800B7128(this) && !func_8082EF20(this) && !arg2);
|
||||||
|
|
||||||
|
// Checking if any mods have disabled aiming with the left stick.
|
||||||
|
recomp_before_first_person_aiming_update_event(play, this, in_free_look, &recomp_aiming_override_mode);
|
||||||
|
|
||||||
// @recomp Get the aiming camera inversion state.
|
// @recomp Get the aiming camera inversion state.
|
||||||
s32 inverted_x, inverted_y;
|
s32 inverted_x, inverted_y;
|
||||||
recomp_get_inverted_axes(&inverted_x, &inverted_y);
|
recomp_get_inverted_axes(&inverted_x, &inverted_y);
|
||||||
// @recomp Get the analog camera input values if analog cam is enabled.
|
|
||||||
|
// @recomp Get the analog camera input values if analog cam is enabled, or right-stick aiming is being forced.
|
||||||
s32 analog_x = 0;
|
s32 analog_x = 0;
|
||||||
s32 analog_y = 0;
|
s32 analog_y = 0;
|
||||||
if (recomp_analog_cam_enabled()) {
|
if (recomp_analog_cam_enabled() || recomp_aiming_override_mode == RECOMP_AIMINIG_OVERRIDE_FORCE_RIGHT_STICK) {
|
||||||
float analog_x_float = 0.0f;
|
float analog_x_float = 0.0f;
|
||||||
float analog_y_float = 0.0f;
|
float analog_y_float = 0.0f;
|
||||||
recomp_get_camera_inputs(&analog_x_float, &analog_y_float);
|
recomp_get_camera_inputs(&analog_x_float, &analog_y_float);
|
||||||
|
|
@ -38,13 +49,9 @@ RECOMP_PATCH s32 func_80847190(PlayState* play, Player* this, s32 arg2) {
|
||||||
// play->state.input[0].rel.stick_x, play->state.input[0].rel.stick_y,
|
// play->state.input[0].rel.stick_x, play->state.input[0].rel.stick_y,
|
||||||
// analog_x, analog_y);
|
// analog_x, analog_y);
|
||||||
|
|
||||||
if (!func_800B7128(this) && !func_8082EF20(this) && !arg2) {
|
if (in_free_look) {
|
||||||
// Checking if any mods have disabled aiming with the left stick.
|
|
||||||
int disable_left_stick_aiming = 0;
|
|
||||||
recomp_before_first_person_aiming_update(play, this, true, &disable_left_stick_aiming);
|
|
||||||
|
|
||||||
// @recomp Add in the analog camera Y input. Clamp to prevent moving the camera twice as fast if both sticks are held.
|
// @recomp Add in the analog camera Y input. Clamp to prevent moving the camera twice as fast if both sticks are held.
|
||||||
if (disable_left_stick_aiming) {
|
if (recomp_aiming_override_mode != RECOMP_AIMINIG_OVERRIDE_OFF) {
|
||||||
var_s0 = CLAMP(analog_y, -61, 61) * 0xF0;
|
var_s0 = CLAMP(analog_y, -61, 61) * 0xF0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -58,7 +65,7 @@ RECOMP_PATCH s32 func_80847190(PlayState* play, Player* this, s32 arg2) {
|
||||||
Math_SmoothStepToS(&this->actor.focus.rot.x, var_s0, 0xE, 0xFA0, 0x1E);
|
Math_SmoothStepToS(&this->actor.focus.rot.x, var_s0, 0xE, 0xFA0, 0x1E);
|
||||||
|
|
||||||
// @recomp Add in the analog camera X input. Clamp to prevent moving the camera twice as fast if both sticks are held.
|
// @recomp Add in the analog camera X input. Clamp to prevent moving the camera twice as fast if both sticks are held.
|
||||||
if (disable_left_stick_aiming) {
|
if (recomp_aiming_override_mode != RECOMP_AIMINIG_OVERRIDE_OFF) {
|
||||||
var_s0 = CLAMP(analog_x, -61, 61) * -0x10;
|
var_s0 = CLAMP(analog_x, -61, 61) * -0x10;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -71,14 +78,8 @@ RECOMP_PATCH s32 func_80847190(PlayState* play, Player* this, s32 arg2) {
|
||||||
}
|
}
|
||||||
var_s0 = CLAMP(var_s0, -0xBB8, 0xBB8);
|
var_s0 = CLAMP(var_s0, -0xBB8, 0xBB8);
|
||||||
this->actor.focus.rot.y += var_s0;
|
this->actor.focus.rot.y += var_s0;
|
||||||
|
|
||||||
recomp_after_first_person_aiming_update(play, this, true);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Checking if any mods have disabled aiming with the left stick.
|
|
||||||
int disable_left_stick_aiming = 0;
|
|
||||||
recomp_before_first_person_aiming_update(play, this, false, &disable_left_stick_aiming);
|
|
||||||
|
|
||||||
static float total_gyro_x, total_gyro_y;
|
static float total_gyro_x, total_gyro_y;
|
||||||
static float total_mouse_x, total_mouse_y;
|
static float total_mouse_x, total_mouse_y;
|
||||||
static float filtered_gyro_x, filtered_gyro_y;
|
static float filtered_gyro_x, filtered_gyro_y;
|
||||||
|
|
@ -121,7 +122,7 @@ RECOMP_PATCH s32 func_80847190(PlayState* play, Player* this, s32 arg2) {
|
||||||
// @recomp Invert the Y axis accordingly (default is inverted, so negate if not inverted).
|
// @recomp Invert the Y axis accordingly (default is inverted, so negate if not inverted).
|
||||||
// Also add in the analog camera Y input. Clamp to prevent moving the camera twice as fast if both sticks are held.
|
// Also add in the analog camera Y input. Clamp to prevent moving the camera twice as fast if both sticks are held.
|
||||||
s32 stick_y;
|
s32 stick_y;
|
||||||
if (disable_left_stick_aiming) {
|
if (recomp_aiming_override_mode != RECOMP_AIMINIG_OVERRIDE_OFF) {
|
||||||
stick_y = CLAMP(analog_y, -61, 61);
|
stick_y = CLAMP(analog_y, -61, 61);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -149,7 +150,7 @@ RECOMP_PATCH s32 func_80847190(PlayState* play, Player* this, s32 arg2) {
|
||||||
// @recomp Invert the X axis accordingly. Also add in the analog camera Y input.
|
// @recomp Invert the X axis accordingly. Also add in the analog camera Y input.
|
||||||
// Clamp to prevent moving the camera twice as fast if both sticks are held.
|
// Clamp to prevent moving the camera twice as fast if both sticks are held.
|
||||||
s32 stick_x;
|
s32 stick_x;
|
||||||
if (disable_left_stick_aiming) {
|
if (recomp_aiming_override_mode != RECOMP_AIMINIG_OVERRIDE_OFF) {
|
||||||
stick_x = CLAMP(analog_x, -61, 61);
|
stick_x = CLAMP(analog_x, -61, 61);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -165,10 +166,10 @@ RECOMP_PATCH s32 func_80847190(PlayState* play, Player* this, s32 arg2) {
|
||||||
applied_aim_y = target_aim_y;
|
applied_aim_y = target_aim_y;
|
||||||
|
|
||||||
this->actor.focus.rot.y = CLAMP(var_s0, -0x4AAA, 0x4AAA) + this->actor.shape.rot.y;
|
this->actor.focus.rot.y = CLAMP(var_s0, -0x4AAA, 0x4AAA) + this->actor.shape.rot.y;
|
||||||
|
|
||||||
recomp_after_first_person_aiming_update(play, this, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recomp_after_first_person_aiming_update_event(play, this, in_free_look);
|
||||||
|
|
||||||
this->unk_AA6 |= 2;
|
this->unk_AA6 |= 2;
|
||||||
|
|
||||||
return func_80832754(this, (play->unk_1887C != 0) || func_800B7128(this) || func_8082EF20(this));
|
return func_80832754(this, (play->unk_1887C != 0) || func_800B7128(this) || func_8082EF20(this));
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,14 @@ typedef enum {
|
||||||
RECOMP_CAMERA_DUALANALOG,
|
RECOMP_CAMERA_DUALANALOG,
|
||||||
} RecompCameraMode;
|
} RecompCameraMode;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
RECOMP_AIMINIG_OVERRIDE_OFF = 0,
|
||||||
|
RECOMP_AIMINIG_OVERRIDE_DISABLE_LEFT_STICK = 1,
|
||||||
|
RECOMP_AIMINIG_OVERRIDE_FORCE_RIGHT_STICK = 2
|
||||||
|
} RecompAimingOverideMode;
|
||||||
|
|
||||||
extern RecompCameraMode recomp_camera_mode;
|
extern RecompCameraMode recomp_camera_mode;
|
||||||
|
extern RecompAimingOverideMode recomp_aiming_override_mode;
|
||||||
|
|
||||||
DECLARE_FUNC(void, recomp_get_gyro_deltas, float* x, float* y);
|
DECLARE_FUNC(void, recomp_get_gyro_deltas, float* x, float* y);
|
||||||
DECLARE_FUNC(void, recomp_get_mouse_deltas, float* x, float* y);
|
DECLARE_FUNC(void, recomp_get_mouse_deltas, float* x, float* y);
|
||||||
|
|
|
||||||
|
|
@ -70,8 +70,17 @@ void poll_inputs(void) {
|
||||||
// Begin reading controller data
|
// Begin reading controller data
|
||||||
osContStartReadData(serialEventQueue);
|
osContStartReadData(serialEventQueue);
|
||||||
|
|
||||||
|
|
||||||
// Suppress the right analog stick if analog camera is active unless the ocarina is in use.
|
// Suppress the right analog stick if analog camera is active unless the ocarina is in use.
|
||||||
recomp_set_right_analog_suppressed(recomp_analog_cam_enabled() && sOcarinaInstrumentId == OCARINA_INSTRUMENT_OFF);
|
recomp_set_right_analog_suppressed(
|
||||||
|
(
|
||||||
|
recomp_analog_cam_enabled()
|
||||||
|
|| recomp_aiming_override_mode == RECOMP_AIMINIG_OVERRIDE_FORCE_RIGHT_STICK
|
||||||
|
)
|
||||||
|
&& sOcarinaInstrumentId == OCARINA_INSTRUMENT_OFF
|
||||||
|
);
|
||||||
|
// Resets this flag for the next frame;
|
||||||
|
recomp_aiming_override_mode == RECOMP_AIMINIG_OVERRIDE_OFF;
|
||||||
|
|
||||||
// Wait for controller data
|
// Wait for controller data
|
||||||
osRecvMesg(serialEventQueue, NULL, OS_MESG_BLOCK);
|
osRecvMesg(serialEventQueue, NULL, OS_MESG_BLOCK);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue