mirror of
https://github.com/BanjoRecomp/BanjoRecomp
synced 2026-05-28 16:00:49 -04:00
Analog camera sensitivity (#94)
* WIP analog camera sensitivity * Fix implementation errors. --------- Co-authored-by: Dario <dariosamo@gmail.com>
This commit is contained in:
@@ -19,6 +19,7 @@ namespace banjo {
|
||||
inline const std::string third_person_camera_invert_mode = "third_person_camera_invert_mode";
|
||||
inline const std::string flying_and_swimming_invert_mode = "flying_and_swimming_invert_mode";
|
||||
inline const std::string first_person_invert_mode = "first_person_invert_mode";
|
||||
inline const std::string analog_camera_sensitivity = "analog_camera_sensitivity";
|
||||
}
|
||||
|
||||
namespace sound {
|
||||
@@ -61,6 +62,8 @@ namespace banjo {
|
||||
|
||||
AnalogCamMode get_analog_cam_mode();
|
||||
|
||||
uint32_t get_analog_cam_sensitivity();
|
||||
|
||||
enum class NoteSavingMode {
|
||||
On,
|
||||
Off,
|
||||
|
||||
@@ -240,7 +240,7 @@ bool recomp_analog_camera_held(bool read_x, bool read_y) {
|
||||
// @recomp If movement is allowed, update the current camera mode's yaw with the input.
|
||||
void recomp_analog_camera_update() {
|
||||
if (recomp_analog_camera_enabled() && recomp_analog_camera_allowed(FALSE)) {
|
||||
f32 analog_yaw = recomp_analog_camera_get_x() * 120.0f * time_getDelta();
|
||||
f32 analog_yaw = recomp_analog_camera_get_x() * recomp_get_analog_cam_sensitivity() * 40.0f * time_getDelta();
|
||||
if (mlAbsF(analog_yaw) > 1e-6f) {
|
||||
if (ncDynamicCamera_getState() != DYNAMIC_CAMERA_STATE_R_LOOK) {
|
||||
ncDynamicCamera_setState(DYNAMIC_CAMERA_STATE_R_LOOK);
|
||||
@@ -503,7 +503,7 @@ RECOMP_PATCH void func_80290F14(void) {
|
||||
// If they are, use the vertical movement to update the zoom level.
|
||||
if (recomp_analog_camera_enabled()) {
|
||||
if (!func_80298850() && player_movementGroup() != BSGROUP_4_LOOK && batimer_get(7) == 0.0f && recomp_analog_camera_allowed(FALSE)) {
|
||||
analog_zoom = ml_clamp_f(analog_zoom + recomp_analog_camera_get_y() * 4.5f * time_getDelta(), 0.5f, 3.0f);
|
||||
analog_zoom = ml_clamp_f(analog_zoom + recomp_analog_camera_get_y() * recomp_get_analog_cam_sensitivity() * 1.5f * time_getDelta(), 0.5f, 3.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ extern RecompAimingOverideMode recomp_aiming_override_mode;
|
||||
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_inverted_axes, s32* x, s32* y);
|
||||
DECLARE_FUNC(u32, recomp_get_analog_cam_sensitivity);
|
||||
DECLARE_FUNC(s32, recomp_get_analog_cam_enabled);
|
||||
DECLARE_FUNC(void, recomp_get_analog_inverted_axes, s32* x, s32* y);
|
||||
DECLARE_FUNC(void, recomp_get_flying_and_swimming_inverted_axes, s32* x, s32* y);
|
||||
|
||||
@@ -50,3 +50,4 @@ recomp_get_note_saving_enabled = 0x8F0000B4;
|
||||
recomp_get_cutscene_aspect_ratio = 0x8F0000B8;
|
||||
recomp_get_flying_and_swimming_inverted_axes = 0x8F0000BC;
|
||||
recomp_get_first_person_inverted_axes = 0x8F0000C0;
|
||||
recomp_get_analog_cam_sensitivity = 0x8F0000C4;
|
||||
@@ -46,6 +46,17 @@ static void add_general_options(recomp::config::Config &config) {
|
||||
analog_cam_mode_options,
|
||||
banjo::AnalogCamMode::Off
|
||||
);
|
||||
config.add_number_option(
|
||||
banjo::configkeys::general::analog_camera_sensitivity,
|
||||
"Analog Camera Sensitivity",
|
||||
"Sets the sensitivity of the right stick analog camera, if enabled.",
|
||||
1, 10, 1, 0, false, 3
|
||||
);
|
||||
config.add_option_hidden_dependency(
|
||||
banjo::configkeys::general::analog_camera_sensitivity,
|
||||
banjo::configkeys::general::analog_cam_mode,
|
||||
banjo::AnalogCamMode::Off
|
||||
);
|
||||
static EnumOptionVector camera_invert_mode_options = {
|
||||
{banjo::CameraInvertMode::InvertNone, "InvertNone", "None"},
|
||||
{banjo::CameraInvertMode::InvertX, "InvertX", "Invert X"},
|
||||
@@ -92,6 +103,11 @@ T get_general_config_enum_value(const std::string& option_id) {
|
||||
return static_cast<T>(std::get<uint32_t>(recompui::config::get_general_config().get_option_value(option_id)));
|
||||
}
|
||||
|
||||
template <typename T = uint32_t>
|
||||
T get_general_config_number_value(const std::string& option_id) {
|
||||
return static_cast<T>(std::get<double>(recompui::config::get_general_config().get_option_value(option_id)));
|
||||
}
|
||||
|
||||
banjo::NoteSavingMode banjo::get_note_saving_mode() {
|
||||
return get_general_config_enum_value<banjo::NoteSavingMode>(banjo::configkeys::general::note_saving_mode);
|
||||
}
|
||||
@@ -116,6 +132,10 @@ banjo::AnalogCamMode banjo::get_analog_cam_mode() {
|
||||
return get_general_config_enum_value<banjo::AnalogCamMode>(banjo::configkeys::general::analog_cam_mode);
|
||||
}
|
||||
|
||||
uint32_t banjo::get_analog_cam_sensitivity() {
|
||||
return get_general_config_number_value(banjo::configkeys::general::analog_camera_sensitivity);
|
||||
}
|
||||
|
||||
template <typename T = uint32_t>
|
||||
T get_graphics_config_enum_value(const std::string& option_id) {
|
||||
return static_cast<T>(std::get<uint32_t>(recompui::config::get_graphics_config().get_option_value(option_id)));
|
||||
|
||||
@@ -125,6 +125,11 @@ extern "C" void recomp_get_bgm_volume(uint8_t* rdram, recomp_context* ctx) {
|
||||
_return(ctx, banjo::get_bgm_volume() / 100.0f);
|
||||
}
|
||||
|
||||
extern "C" void recomp_get_analog_cam_sensitivity(uint8_t* rdram, recomp_context* ctx) {
|
||||
_return<uint32_t>(ctx, banjo::get_analog_cam_sensitivity());
|
||||
}
|
||||
|
||||
|
||||
extern "C" void recomp_time_us(uint8_t* rdram, recomp_context* ctx) {
|
||||
_return(ctx, static_cast<u32>(std::chrono::duration_cast<std::chrono::microseconds>(ultramodern::time_since_start()).count()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user