From 7a52f1eab8cabd68d2d3ce3832f234020f782771 Mon Sep 17 00:00:00 2001 From: Mathias Malmqvist Date: Wed, 1 Oct 2025 00:28:59 +0200 Subject: [PATCH] Stop auto-repeat circularity adjustment when passing below 1.00 --- js/modals/finetune-modal.js | 41 +++++++++++++++++++++++++++++++++++++ js/stick-renderer.js | 7 ++----- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/js/modals/finetune-modal.js b/js/modals/finetune-modal.js index 7ddec4e..688a33f 100644 --- a/js/modals/finetune-modal.js +++ b/js/modals/finetune-modal.js @@ -89,6 +89,12 @@ export class Finetune { left: false, right: false }; + + // Track previous axis values for stopping continuous adjustment + this._previousAxisValues = { + left: { x: 0, y: 0 }, + right: { x: 0, y: 0 } + }; } get mode() { @@ -882,6 +888,13 @@ export class Finetune { const element = $(`#finetune${inputSuffix}`); if (!element.length) return; + // Initialize previous axis values for the active stick + if (this.active_stick && this.controller.button_states.sticks) { + const currentStick = this.controller.button_states.sticks[this.active_stick]; + this._previousAxisValues[this.active_stick].x = currentStick.x; + this._previousAxisValues[this.active_stick].y = currentStick.y; + } + // Perform initial adjustment immediately... this._performDpadAdjustment(element, adjustment); this.clearCircularity(); @@ -916,6 +929,34 @@ export class Finetune { // Trigger the change event to update the finetune data await this._onFinetuneChange(); + + // Check if axis values have dropped from 1.00 to below 1.00 and stop adjustment if so + this._checkAxisValuesForStopCondition(); + } + + /** + * Check if axis values have dropped from 1.00 to below 1.00 and stop adjustment + */ + _checkAxisValuesForStopCondition() { + if (!this.active_stick || !this.continuous_adjustment.repeat_delay) { + return; // No continuous adjustment active + } + + const currentStick = this.controller.button_states.sticks[this.active_stick]; + const previousStick = this._previousAxisValues[this.active_stick]; + + // Check if X axis dropped from 1.00+ to below 1.00 + const xDropped = Math.abs(previousStick.x) >= 1.00 && Math.abs(currentStick.x) < 1.00; + // Check if Y axis dropped from 1.00+ to below 1.00 + const yDropped = Math.abs(previousStick.y) >= 1.00 && Math.abs(currentStick.y) < 1.00; + + if (xDropped || yDropped) { + console.log(`Stopping continuous adjustment: ${this.active_stick} axis dropped below 1.00`); + this.stopContinuousDpadAdjustment(); + } + + // Update previous values for next check + this._previousAxisValues[this.active_stick] = currentStick; } /** diff --git a/js/stick-renderer.js b/js/stick-renderer.js index 3c12f2d..21f98d6 100644 --- a/js/stick-renderer.js +++ b/js/stick-renderer.js @@ -158,11 +158,8 @@ export function draw_stick_position(ctx, center_x, center_y, sz, stick_x, stick_ // Draw filled circle at stick position ctx.beginPath(); - ctx.arc(center_x+display_x*sz, center_y+display_y*sz, 3, 0, 2*Math.PI); - - if (typeof highlight === 'boolean') { - ctx.fillStyle = highlight ? '#2989f7ff' : '#030b84ff'; - } + ctx.arc(center_x+display_x*sz, center_y+display_y*sz, highlight ? 4 : 3, 0, 2*Math.PI); + ctx.fillStyle = highlight ? '#2989f7ff' : '#030b84ff'; ctx.fill(); }