mirror of
https://github.com/dualshock-tools/dualshock-tools.github.io.git
synced 2026-07-16 05:34:11 +03:00
Switch active stick based on stick movement
This commit is contained in:
committed by
dualshock-tools
parent
71633d7718
commit
470bdaeeb4
47
core.js
47
core.js
@@ -23,7 +23,7 @@ let finetune_visible = false
|
||||
let on_finetune_updating = false
|
||||
|
||||
// Active stick tracking for finetune modal
|
||||
let active_stick = 'left' // 'left' or 'right'
|
||||
let active_stick = null // 'left', 'right', or null
|
||||
|
||||
// Continuous D-pad adjustment tracking
|
||||
let dpad_adjustment_interval = null
|
||||
@@ -1340,7 +1340,6 @@ function ds5_finetune_update_all() {
|
||||
|
||||
function highlight_active_finetune_input() {
|
||||
const sticks = ds_button_states.sticks;
|
||||
const currentStick = sticks[active_stick];
|
||||
const deadzone = 0.3;
|
||||
|
||||
// Clear highlights from all inputs first
|
||||
@@ -1355,7 +1354,10 @@ function highlight_active_finetune_input() {
|
||||
$(`#finetuneStickCanvas${suffix}`).removeClass("text-primary");
|
||||
});
|
||||
|
||||
if(!active_stick) return;
|
||||
|
||||
// Only highlight if stick is moved significantly from center
|
||||
const currentStick = sticks[active_stick];
|
||||
if (Math.abs(currentStick.x) >= deadzone || Math.abs(currentStick.y) >= deadzone) {
|
||||
const quadrant = get_stick_quadrant(currentStick.x, currentStick.y);
|
||||
const inputSuffix = get_finetune_input_suffix_for_quadrant(active_stick, quadrant);
|
||||
@@ -1402,6 +1404,10 @@ function finetune_close() {
|
||||
}
|
||||
|
||||
function set_stick_to_finetune(stick) {
|
||||
if(active_stick === stick) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Stop any continuous adjustments when switching sticks
|
||||
stop_continuous_dpad_adjustment();
|
||||
|
||||
@@ -1420,11 +1426,42 @@ function set_stick_to_finetune(stick) {
|
||||
}
|
||||
|
||||
function handle_finetune_stick_switching(changes) {
|
||||
if (changes.l1) {
|
||||
// Handle automatic stick switching based on movement
|
||||
if (changes.sticks) {
|
||||
update_active_stick_based_on_movement();
|
||||
}
|
||||
}
|
||||
|
||||
function is_stick_away_from_center(stick_pos, deadzone = 0.2) {
|
||||
return Math.abs(stick_pos.x) >= deadzone || Math.abs(stick_pos.y) >= deadzone;
|
||||
}
|
||||
|
||||
function update_active_stick_based_on_movement() {
|
||||
const sticks = ds_button_states.sticks;
|
||||
const deadzone = 0.2;
|
||||
|
||||
const left_is_away = is_stick_away_from_center(sticks.left, deadzone);
|
||||
const right_is_away = is_stick_away_from_center(sticks.right, deadzone);
|
||||
|
||||
if (left_is_away && right_is_away) {
|
||||
// Both sticks are away from center - clear highlighting
|
||||
clear_active_stick();
|
||||
} else if (left_is_away && !right_is_away) {
|
||||
// Only left stick is away from center
|
||||
set_stick_to_finetune('left');
|
||||
} else if (changes.r1) {
|
||||
} else if (right_is_away && !left_is_away) {
|
||||
// Only right stick is away from center
|
||||
set_stick_to_finetune('right');
|
||||
}
|
||||
// If both sticks are centered, keep current active stick (no change)
|
||||
}
|
||||
|
||||
function clear_active_stick() {
|
||||
// Remove active class from both cards
|
||||
$("#left-stick-card").removeClass("stick-card-active");
|
||||
$("#right-stick-card").removeClass("stick-card-active");
|
||||
|
||||
active_stick = null; // Clear active stick
|
||||
}
|
||||
|
||||
function get_stick_quadrant(x, y) {
|
||||
@@ -1457,6 +1494,8 @@ function get_finetune_input_suffix_for_quadrant(stick, quadrant) {
|
||||
}
|
||||
|
||||
function handle_finetune_dpad_adjustment(changes) {
|
||||
if(!active_stick) return;
|
||||
|
||||
const sticks = ds_button_states.sticks;
|
||||
const currentStick = sticks[active_stick];
|
||||
|
||||
|
||||
11
index.html
11
index.html
@@ -521,7 +521,7 @@ input[id^="finetune"].border-primary {
|
||||
|
||||
<!-- Finetune Modal -->
|
||||
<div class="modal fade" id="finetuneModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="finetuneModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-xl modal-fullscreen-lg-down">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg modal-fullscreen-lg-down">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5 ds-i18n" id="finetuneModalLabel">Finetune stick calibration</h1>
|
||||
@@ -530,9 +530,10 @@ input[id^="finetune"].border-primary {
|
||||
<div class="modal-body">
|
||||
<p class="ds-i18n">This screen allows to finetune raw calibration data on your controller</p>
|
||||
<div class="alert alert-info" role="alert">
|
||||
<i class="fas fa-info-circle"></i> <span class="ds-i18n">
|
||||
Press L1 to select Left stick, R1 to select Right stick</span><br/><br/>
|
||||
<span class="ds-i18n">While holding the stick to be adjusted straight up/down/left/right, observe the highlighted value at the bottom of then dialog, then use the D-pad buttons to adjust the finetune value:</span><br/>
|
||||
<i class="fas fa-info-circle"></i>
|
||||
<span class="ds-i18n">
|
||||
While holding the stick to be adjusted straight up/down/left/right, observe the highlighted value at the bottom of then dialog, then use the D-pad buttons to adjust the finetune value:
|
||||
</span><br/>
|
||||
<small class="ds-i18n">
|
||||
• Move the stick position towards the center until it is just smaller than 1.00 (or larger than -1.00) then move back to 1.00 (or -1.00)<br>
|
||||
• Repeat the adjustment for the left/right and up/down pairs several times until you can move away from 1.00 with only one button press.
|
||||
@@ -543,7 +544,7 @@ input[id^="finetune"].border-primary {
|
||||
<div class="row">
|
||||
<div class="col col-lg-6 col-12">
|
||||
|
||||
<div class="card text-bg-light stick-card-active" id="left-stick-card">
|
||||
<div class="card text-bg-light" id="left-stick-card">
|
||||
<div class="card-header"><span class="ds-i18n">Left stick</span></div>
|
||||
<div class="card-body">
|
||||
<div class="container-fluid">
|
||||
|
||||
Reference in New Issue
Block a user