|
|
@@ -22,7 +22,7 @@ class DawdlehornApp {
|
|
|
this.gamepadState = {
|
|
|
leftStick: { x: 0, y: 0 },
|
|
|
rightStick: { x: 0, y: 0 },
|
|
|
- triggers: { left: 0, right: 0 },
|
|
|
+ dpadAxis: 0,
|
|
|
buttons: new Set()
|
|
|
};
|
|
|
|
|
|
@@ -35,7 +35,7 @@ class DawdlehornApp {
|
|
|
filterDisplay: document.getElementById('filter-display'),
|
|
|
leftStickDisplay: document.getElementById('left-stick-display'),
|
|
|
rightStickDisplay: document.getElementById('right-stick-display'),
|
|
|
- triggersDisplay: document.getElementById('triggers-display'),
|
|
|
+ dpadDisplay: document.getElementById('dpad-display'),
|
|
|
buttonsDisplay: document.getElementById('buttons-display'),
|
|
|
visualizer: document.getElementById('visualizer')
|
|
|
};
|
|
|
@@ -151,18 +151,19 @@ class DawdlehornApp {
|
|
|
// Update debug displays with current gamepad state
|
|
|
this.elements.leftStickDisplay.textContent = `${this.gamepadState.leftStick.x.toFixed(2)}, ${this.gamepadState.leftStick.y.toFixed(2)}`;
|
|
|
this.elements.rightStickDisplay.textContent = `${this.gamepadState.rightStick.x.toFixed(2)}, ${this.gamepadState.rightStick.y.toFixed(2)}`;
|
|
|
- this.elements.triggersDisplay.textContent = `L: ${this.gamepadState.triggers.left.toFixed(2)} R: ${this.gamepadState.triggers.right.toFixed(2)}`;
|
|
|
-
|
|
|
- // Update button display
|
|
|
+ this.elements.dpadDisplay.textContent = `${this.gamepadState.dpadAxis.toFixed(2)}`;
|
|
|
+ // Update button display - show ALL pressed buttons dynamically
|
|
|
let buttonDisplay = '';
|
|
|
- buttonDisplay += this.gamepadState.buttons.has('A') ? '[A]' : 'A';
|
|
|
- buttonDisplay += ' ';
|
|
|
- buttonDisplay += this.gamepadState.buttons.has('B') ? '[B]' : 'B';
|
|
|
- buttonDisplay += ' ';
|
|
|
- buttonDisplay += this.gamepadState.buttons.has('X') ? '[X]' : 'X';
|
|
|
- buttonDisplay += ' ';
|
|
|
- buttonDisplay += this.gamepadState.buttons.has('Y') ? '[Y]' : 'Y';
|
|
|
- this.elements.buttonsDisplay.textContent = buttonDisplay;
|
|
|
+
|
|
|
+ // Convert Set to Array and sort for consistent display order
|
|
|
+ const pressedButtons = Array.from(this.gamepadState.buttons).sort();
|
|
|
+
|
|
|
+ pressedButtons.forEach((button, index) => {
|
|
|
+ if (buttonDisplay) buttonDisplay += ' ';
|
|
|
+ buttonDisplay += `[${button}]`;
|
|
|
+ });
|
|
|
+
|
|
|
+ this.elements.buttonsDisplay.textContent = buttonDisplay || 'None pressed';
|
|
|
}
|
|
|
requestAnimationFrame(updateLoop);
|
|
|
};
|
|
|
@@ -176,6 +177,7 @@ class DawdlehornApp {
|
|
|
|
|
|
if (!this.audioInitialized) return;
|
|
|
|
|
|
+
|
|
|
// Map face buttons to notes with proper debouncing
|
|
|
const noteMap = {
|
|
|
'A': 261.63, // C4
|
|
|
@@ -209,6 +211,7 @@ class DawdlehornApp {
|
|
|
|
|
|
if (!this.audioInitialized) return;
|
|
|
|
|
|
+
|
|
|
// Stop audio if no face buttons are pressed
|
|
|
const faceButtons = ['A', 'B', 'X', 'Y'];
|
|
|
const anyFaceButtonPressed = faceButtons.some(btn => this.gamepadState.buttons.has(btn));
|
|
|
@@ -225,6 +228,11 @@ class DawdlehornApp {
|
|
|
|
|
|
handleAxisChange(axis, value, rawValue) {
|
|
|
try {
|
|
|
+ // Debug logging for stick issues (can be removed in production)
|
|
|
+ // if (axis.includes('STICK')) {
|
|
|
+ // console.log(`🕹️ ${axis}: processed=${value.toFixed(3)}, raw=${rawValue.toFixed(3)}`);
|
|
|
+ // }
|
|
|
+
|
|
|
// Update gamepad state
|
|
|
switch (axis) {
|
|
|
case 'LEFT_STICK_X':
|
|
|
@@ -241,17 +249,11 @@ class DawdlehornApp {
|
|
|
this.gamepadState.rightStick.y = value;
|
|
|
this.updateFilter();
|
|
|
break;
|
|
|
+ case 'DPAD_AXIS':
|
|
|
+ this.gamepadState.dpadAxis = value;
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
- // Handle analog triggers (some controllers map triggers to axes)
|
|
|
- if (axis === 'LEFT_TRIGGER' || axis === 'RIGHT_TRIGGER') {
|
|
|
- if (axis === 'LEFT_TRIGGER') {
|
|
|
- this.gamepadState.triggers.left = value;
|
|
|
- } else {
|
|
|
- this.gamepadState.triggers.right = value;
|
|
|
- }
|
|
|
- this.updateVolume();
|
|
|
- }
|
|
|
|
|
|
} catch (error) {
|
|
|
console.error('❌ Axis change error:', error);
|
|
|
@@ -285,14 +287,11 @@ class DawdlehornApp {
|
|
|
updateVolume() {
|
|
|
if (!this.audioInitialized) return;
|
|
|
|
|
|
- // Triggers control volume
|
|
|
- const triggerVolume = (this.gamepadState.triggers.left + this.gamepadState.triggers.right) / 2;
|
|
|
- if (Math.abs(triggerVolume - this.currentVolume) > 0.05) {
|
|
|
- this.currentVolume = triggerVolume;
|
|
|
- const dbVolume = -40 + (this.currentVolume * 40); // -40dB to 0dB
|
|
|
- this.volume.volume.setValueAtTime(dbVolume, Tone.now());
|
|
|
- this.elements.volumeDisplay.textContent = `${Math.round(this.currentVolume * 100)}%`;
|
|
|
- }
|
|
|
+ // Simple volume control - could be enhanced later if needed
|
|
|
+ // For now, just keep the current volume logic without trigger dependency
|
|
|
+ const dbVolume = -40 + (this.currentVolume * 40); // -40dB to 0dB
|
|
|
+ this.volume.volume.setValueAtTime(dbVolume, Tone.now());
|
|
|
+ this.elements.volumeDisplay.textContent = `${Math.round(this.currentVolume * 100)}%`;
|
|
|
}
|
|
|
|
|
|
setupVisualizer() {
|