mirror of
https://github.com/Zelda64Recomp/Zelda64Recomp.git
synced 2025-10-30 08:03:03 +00:00
prototype: control of camera and Mirror shield with Mouse
This commit is contained in:
parent
54997438de
commit
4ec02642af
4 changed files with 56 additions and 11 deletions
|
|
@ -28,6 +28,8 @@ float analog_camera_y_sensitivity = 500.0f;
|
||||||
|
|
||||||
static const float analog_cam_threshold = 0.1f;
|
static const float analog_cam_threshold = 0.1f;
|
||||||
|
|
||||||
|
float mouse_camera_sensitivity = 0.1f;
|
||||||
|
|
||||||
RECOMP_EXPORT void recomp_set_camera_fixes(bool new_val) {
|
RECOMP_EXPORT void recomp_set_camera_fixes(bool new_val) {
|
||||||
camera_fixes = new_val;
|
camera_fixes = new_val;
|
||||||
}
|
}
|
||||||
|
|
@ -66,8 +68,12 @@ void update_analog_cam(Camera* c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable analog cam if the right stick is held.
|
// Enable analog cam if the right stick is held.
|
||||||
float input_x, input_y;
|
float analog_x, analog_y;
|
||||||
recomp_get_camera_inputs(&input_x, &input_y);
|
|
||||||
|
recomp_get_camera_inputs(&analog_x, &analog_y);
|
||||||
|
|
||||||
|
float input_x = analog_x + (mouse_input_handler.crouch_shielding ? 0.0f : mouse_input_handler.delta_x * MOUSE_CAMERA_SCALE_X);
|
||||||
|
float input_y = analog_y + (mouse_input_handler.crouch_shielding ? 0.0f : mouse_input_handler.delta_y * MOUSE_CAMERA_SCALE_Y);
|
||||||
|
|
||||||
if (fabsf(input_x) >= analog_cam_threshold || fabsf(input_y) >= analog_cam_threshold) {
|
if (fabsf(input_x) >= analog_cam_threshold || fabsf(input_y) >= analog_cam_threshold) {
|
||||||
analog_cam_active = true;
|
analog_cam_active = true;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#include "patches.h"
|
#include "patches.h"
|
||||||
|
#include "play_patches.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "z64snap.h"
|
#include "z64snap.h"
|
||||||
// Decomp rename, TODO update decomp and remove this
|
// Decomp rename, TODO update decomp and remove this
|
||||||
|
|
@ -6,6 +7,8 @@
|
||||||
#include "z64voice.h"
|
#include "z64voice.h"
|
||||||
#include "audiothread_cmd.h"
|
#include "audiothread_cmd.h"
|
||||||
|
|
||||||
|
MouseInputHandler mouse_input_handler;
|
||||||
|
|
||||||
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_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_event(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));
|
||||||
RECOMP_DECLARE_EVENT(recomp_set_extra_item_slot_statuses(PlayState* play, s32 enabled));
|
RECOMP_DECLARE_EVENT(recomp_set_extra_item_slot_statuses(PlayState* play, s32 enabled));
|
||||||
|
|
@ -102,12 +105,9 @@ RECOMP_PATCH s32 func_80847190(PlayState* play, Player* this, s32 arg2) {
|
||||||
|
|
||||||
filtered_gyro_x = filtered_gyro_x * gyro_filter_factor + total_gyro_x * (1.0f - gyro_filter_factor);
|
filtered_gyro_x = filtered_gyro_x * gyro_filter_factor + total_gyro_x * (1.0f - gyro_filter_factor);
|
||||||
filtered_gyro_y = filtered_gyro_y * gyro_filter_factor + total_gyro_y * (1.0f - gyro_filter_factor);
|
filtered_gyro_y = filtered_gyro_y * gyro_filter_factor + total_gyro_y * (1.0f - gyro_filter_factor);
|
||||||
|
|
||||||
float delta_mouse_x, delta_mouse_y;
|
|
||||||
recomp_get_mouse_deltas(&delta_mouse_x, &delta_mouse_y);
|
|
||||||
|
|
||||||
total_mouse_x += delta_mouse_x;
|
total_mouse_x += mouse_input_handler.delta_x;
|
||||||
total_mouse_y += delta_mouse_y;
|
total_mouse_y += mouse_input_handler.delta_y;
|
||||||
|
|
||||||
// The gyro X-axis (tilt) corresponds to the camera X-axis (tilt).
|
// The gyro X-axis (tilt) corresponds to the camera X-axis (tilt).
|
||||||
// The gyro Y-axis (left/right rotation) corresponds to the camera Y-axis (left/right rotation).
|
// The gyro Y-axis (left/right rotation) corresponds to the camera Y-axis (left/right rotation).
|
||||||
|
|
@ -1473,10 +1473,13 @@ RECOMP_PATCH void Player_Action_18(Player* this, PlayState* play) {
|
||||||
func_8082F164(this, BTN_R | BTN_B);
|
func_8082F164(this, BTN_R | BTN_B);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->av2.actionVar2 != 0) {
|
if (this->av2.actionVar2 != 0) {
|
||||||
f32 yStick = sPlayerControlInput->rel.stick_y * 180;
|
f32 yStick = sPlayerControlInput->rel.stick_y * 180 + mouse_input_handler.shield_pos_y;
|
||||||
f32 xStick = sPlayerControlInput->rel.stick_x * -120;
|
f32 xStick = sPlayerControlInput->rel.stick_x * -120 + mouse_input_handler.shield_pos_x;
|
||||||
|
// Needed so analog input and mouse input don't double up.
|
||||||
|
xStick = CLAMP(xStick, -MOUSE_SHIELD_CLAMP_X, MOUSE_SHIELD_CLAMP_X);
|
||||||
|
yStick = CLAMP(yStick, -MOUSE_SHIELD_CLAMP_Y, MOUSE_SHIELD_CLAMP_Y);
|
||||||
|
|
||||||
s16 temp_a0 = this->actor.shape.rot.y - Camera_GetInputDirYaw(GET_ACTIVE_CAM(play));
|
s16 temp_a0 = this->actor.shape.rot.y - Camera_GetInputDirYaw(GET_ACTIVE_CAM(play));
|
||||||
s16 var_a1;
|
s16 var_a1;
|
||||||
s16 temp_ft5;
|
s16 temp_ft5;
|
||||||
|
|
@ -1493,7 +1496,7 @@ RECOMP_PATCH void Player_Action_18(Player* this, PlayState* play) {
|
||||||
if (inverted_x) {
|
if (inverted_x) {
|
||||||
xStick = -xStick;
|
xStick = -xStick;
|
||||||
}
|
}
|
||||||
|
recomp_printf("Shielding X=%f, Y=%f\n", xStick, yStick);
|
||||||
var_a1 = (yStick * Math_CosS(temp_a0)) + (Math_SinS(temp_a0) * xStick);
|
var_a1 = (yStick * Math_CosS(temp_a0)) + (Math_SinS(temp_a0) * xStick);
|
||||||
temp_ft5 = (xStick * Math_CosS(temp_a0)) - (Math_SinS(temp_a0) * yStick);
|
temp_ft5 = (xStick * Math_CosS(temp_a0)) - (Math_SinS(temp_a0) * yStick);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,21 @@ RECOMP_DECLARE_EVENT(recomp_after_play_update(PlayState* play));
|
||||||
|
|
||||||
void controls_play_update(PlayState* play) {
|
void controls_play_update(PlayState* play) {
|
||||||
gSaveContext.options.zTargetSetting = recomp_get_targeting_mode();
|
gSaveContext.options.zTargetSetting = recomp_get_targeting_mode();
|
||||||
|
|
||||||
|
Player* player = GET_PLAYER(play);
|
||||||
|
recomp_get_mouse_deltas(&mouse_input_handler.delta_x, &mouse_input_handler.delta_y);
|
||||||
|
mouse_input_handler.crouch_shielding = player->stateFlags1 & PLAYER_STATE1_400000;
|
||||||
|
|
||||||
|
if (mouse_input_handler.crouch_shielding) {
|
||||||
|
mouse_input_handler.shield_pos_x -= mouse_input_handler.delta_x * 10.0f;
|
||||||
|
mouse_input_handler.shield_pos_y -= mouse_input_handler.delta_y * 10.0f;
|
||||||
|
mouse_input_handler.shield_pos_x = CLAMP(mouse_input_handler.shield_pos_x, -MOUSE_SHIELD_CLAMP_X, MOUSE_SHIELD_CLAMP_X);
|
||||||
|
mouse_input_handler.shield_pos_y = CLAMP(mouse_input_handler.shield_pos_y, -MOUSE_SHIELD_CLAMP_Y, MOUSE_SHIELD_CLAMP_Y);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mouse_input_handler.shield_pos_x = 0.0f;
|
||||||
|
mouse_input_handler.shield_pos_y = 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @recomp Patched to add hooks for various added functionality.
|
// @recomp Patched to add hooks for various added functionality.
|
||||||
|
|
@ -174,6 +189,11 @@ RECOMP_PATCH void Play_Init(GameState* thisx) {
|
||||||
|
|
||||||
// @recomp_event recomp_on_play_init(PlayState* this): A new PlayState is being initialized.
|
// @recomp_event recomp_on_play_init(PlayState* this): A new PlayState is being initialized.
|
||||||
recomp_on_play_init(this);
|
recomp_on_play_init(this);
|
||||||
|
mouse_input_handler.crouch_shielding = false;
|
||||||
|
mouse_input_handler.delta_x = 0.0f;
|
||||||
|
mouse_input_handler.delta_y = 0.0f;
|
||||||
|
mouse_input_handler.shield_pos_x = 0.0f;
|
||||||
|
mouse_input_handler.shield_pos_y = 0.0f;
|
||||||
|
|
||||||
if ((gSaveContext.respawnFlag == -4) || (gSaveContext.respawnFlag == -0x63)) {
|
if ((gSaveContext.respawnFlag == -4) || (gSaveContext.respawnFlag == -0x63)) {
|
||||||
if (CHECK_EVENTINF(EVENTINF_TRIGGER_DAYTELOP)) {
|
if (CHECK_EVENTINF(EVENTINF_TRIGGER_DAYTELOP)) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,22 @@
|
||||||
|
|
||||||
#include "patches.h"
|
#include "patches.h"
|
||||||
|
|
||||||
|
#define MOUSE_SHIELD_CLAMP_X 7200.0f
|
||||||
|
#define MOUSE_SHIELD_CLAMP_Y 10800.0f
|
||||||
|
#define MOUSE_CAMERA_SCALE_X 0.04f
|
||||||
|
#define MOUSE_CAMERA_SCALE_Y 0.04f
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float delta_x;
|
||||||
|
float delta_y;
|
||||||
|
|
||||||
|
bool crouch_shielding;
|
||||||
|
float shield_pos_x;
|
||||||
|
float shield_pos_y;
|
||||||
|
} MouseInputHandler;
|
||||||
|
|
||||||
|
extern MouseInputHandler mouse_input_handler;
|
||||||
|
|
||||||
void debug_play_update(PlayState* play);
|
void debug_play_update(PlayState* play);
|
||||||
void camera_pre_play_update(PlayState* play);
|
void camera_pre_play_update(PlayState* play);
|
||||||
void camera_post_play_update(PlayState* play);
|
void camera_post_play_update(PlayState* play);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue