From 512696b625d6a88f9eb0b570be7c79f1dbd6de0d Mon Sep 17 00:00:00 2001 From: Matt Dallmeyer Date: Mon, 8 Dec 2025 14:43:04 -0800 Subject: [PATCH] [jak3] Support dpad pacman controls (#4083) Not sure if we really want this change in vanilla openGOAL, but I had it working on a branch so figured I'd PR it. --- decompiler/config/jak3/all-types.gc | 1 + .../jak3/text/game_custom_text_en-US.json | 3 +- goal_src/jak3/engine/ui/text-h.gc | 1 + .../jak3/levels/city/vinroom/power-game.gc | 75 +++++++++++++++---- goal_src/jak3/pc/pckernel-impl.gc | 1 + .../jak3/pc/progress/progress-static-pc.gc | 8 ++ 6 files changed, 75 insertions(+), 14 deletions(-) diff --git a/decompiler/config/jak3/all-types.gc b/decompiler/config/jak3/all-types.gc index aeb780513a..916b82ba0b 100644 --- a/decompiler/config/jak3/all-types.gc +++ b/decompiler/config/jak3/all-types.gc @@ -10294,6 +10294,7 @@ (progress-controller-options-swap-r1-r2 #x134b) (progress-controller-options-enable-trigger-effects #x134c) (progress-misc-fix-projectile-focus #x134d) + (progress-controller-options-pacman-dpad #x134e) ) ;; ---text-h:text-id diff --git a/game/assets/jak3/text/game_custom_text_en-US.json b/game/assets/jak3/text/game_custom_text_en-US.json index a56c5a60a6..95bd86199a 100644 --- a/game/assets/jak3/text/game_custom_text_en-US.json +++ b/game/assets/jak3/text/game_custom_text_en-US.json @@ -245,5 +245,6 @@ "134a": "Pressure Sensitivity", "134b": "Swap R1 and R2", "134c": "Trigger Effects", - "134d": "Fix Projectile Focus" + "134d": "Fix Projectile Focus", + "134e": "Eco Grid (Pac-Man) D-Pad Controls" } diff --git a/goal_src/jak3/engine/ui/text-h.gc b/goal_src/jak3/engine/ui/text-h.gc index 9bb48b6f10..51613e887d 100644 --- a/goal_src/jak3/engine/ui/text-h.gc +++ b/goal_src/jak3/engine/ui/text-h.gc @@ -1599,6 +1599,7 @@ (progress-controller-options-swap-r1-r2 #x134b) (progress-controller-options-enable-trigger-effects #x134c) (progress-misc-fix-projectile-focus #x134d) + (progress-controller-options-pacman-dpad #x134e) ) ;; ---text-id diff --git a/goal_src/jak3/levels/city/vinroom/power-game.gc b/goal_src/jak3/levels/city/vinroom/power-game.gc index 84bceee37a..73d23ee5f9 100644 --- a/goal_src/jak3/levels/city/vinroom/power-game.gc +++ b/goal_src/jak3/levels/city/vinroom/power-game.gc @@ -1485,21 +1485,70 @@ ) (defmethod power-game-method-40 ((this power-game) (arg0 int)) - (let ((s3-0 (new 'stack-no-clear 'vector)) - (gp-0 (new 'stack-no-clear 'vector)) + ;; og:preserve-this support dpad inputs for pacman + ;; when enabled, dpad input will supercede stick input + (#cond + (PC_PORT + (cond + ((and (-> *pc-settings* pacman-dpad?) + (or (and (= arg0 0) (or (cpad-pressed? 0 up) (cpad-hold? 0 up))) + (and (= arg0 1) (or (cpad-pressed? 0 right) (cpad-hold? 0 right))) + (and (= arg0 2) (or (cpad-pressed? 0 down) (cpad-hold? 0 down))) + (and (= arg0 3) (or (cpad-pressed? 0 left) (cpad-hold? 0 left))) + )) + ;; clear dpad inputs when we have a match + ;; gives better control moving across 1 lane vs 2 lanes + (logclear! + (-> *cpad-list* cpads 0 button0-abs 0) + (pad-buttons up right down left) + ) + (logclear! + (-> *cpad-list* cpads 0 button0-rel 0) + (pad-buttons up right down left) + ) + ;; allow moving with dpad (added in pc port) + #t + ) + (else + ;; allow moving with stick (original) + (let ((s3-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + (let ((s2-0 (new 'stack-no-clear 'matrix))) + (set! (-> s3-0 x) (sin (-> *cpad-list* cpads 0 stick0-dir))) + (set! (-> s3-0 y) 0.0) + (set! (-> s3-0 z) (cos (-> *cpad-list* cpads 0 stick0-dir))) + (set! (-> s3-0 w) 0.0) + (matrix-copy! s2-0 (matrix-local->world #t #f)) + (vector-matrix*! s3-0 s3-0 s2-0) + (warp-vector-into-surface! gp-0 s3-0 *up-vector* s2-0) + ) + (vector-float*! gp-0 gp-0 (-> *cpad-list* cpads 0 stick0-speed)) + (let ((v1-8 (power-game-method-38 this (new 'stack-no-clear 'vector) arg0))) + (< 0.5 (vector-dot gp-0 v1-8)) + ) + ) + ) ) - (let ((s2-0 (new 'stack-no-clear 'matrix))) - (set! (-> s3-0 x) (sin (-> *cpad-list* cpads 0 stick0-dir))) - (set! (-> s3-0 y) 0.0) - (set! (-> s3-0 z) (cos (-> *cpad-list* cpads 0 stick0-dir))) - (set! (-> s3-0 w) 0.0) - (matrix-copy! s2-0 (matrix-local->world #t #f)) - (vector-matrix*! s3-0 s3-0 s2-0) - (warp-vector-into-surface! gp-0 s3-0 *up-vector* s2-0) ) - (vector-float*! gp-0 gp-0 (-> *cpad-list* cpads 0 stick0-speed)) - (let ((v1-8 (power-game-method-38 this (new 'stack-no-clear 'vector) arg0))) - (< 0.5 (vector-dot gp-0 v1-8)) + (#t + (let ((s3-0 (new 'stack-no-clear 'vector)) + (gp-0 (new 'stack-no-clear 'vector)) + ) + (let ((s2-0 (new 'stack-no-clear 'matrix))) + (set! (-> s3-0 x) (sin (-> *cpad-list* cpads 0 stick0-dir))) + (set! (-> s3-0 y) 0.0) + (set! (-> s3-0 z) (cos (-> *cpad-list* cpads 0 stick0-dir))) + (set! (-> s3-0 w) 0.0) + (matrix-copy! s2-0 (matrix-local->world #t #f)) + (vector-matrix*! s3-0 s3-0 s2-0) + (warp-vector-into-surface! gp-0 s3-0 *up-vector* s2-0) + ) + (vector-float*! gp-0 gp-0 (-> *cpad-list* cpads 0 stick0-speed)) + (let ((v1-8 (power-game-method-38 this (new 'stack-no-clear 'vector) arg0))) + (< 0.5 (vector-dot gp-0 v1-8)) + ) + ) ) ) ) diff --git a/goal_src/jak3/pc/pckernel-impl.gc b/goal_src/jak3/pc/pckernel-impl.gc index 68c79763fc..95e2a71951 100644 --- a/goal_src/jak3/pc/pckernel-impl.gc +++ b/goal_src/jak3/pc/pckernel-impl.gc @@ -106,6 +106,7 @@ ;; other (controller-led-status? symbol) (controller-swap-r1-r2? symbol) + (pacman-dpad? symbol) (speedrunner-mode-custom-bind uint32) (memcard-subtitles? symbol) diff --git a/goal_src/jak3/pc/progress/progress-static-pc.gc b/goal_src/jak3/pc/progress/progress-static-pc.gc index ece21f9774..2826a72e9a 100644 --- a/goal_src/jak3/pc/progress/progress-static-pc.gc +++ b/goal_src/jak3/pc/progress/progress-static-pc.gc @@ -318,6 +318,14 @@ This gives us more freedom to write code how we want. :falsey-text (text-id progress-off) :get-value-fn (lambda () (pc-get-trigger-effects-enabled?)) :on-confirm (lambda ((val symbol)) (pc-set-trigger-effects-enabled! val))) + (new 'static 'menu-generic-boolean-option + :name (text-id progress-controller-options-pacman-dpad) + :truthy-text (text-id progress-on) + :falsey-text (text-id progress-off) + :get-value-fn (lambda () (-> *pc-settings* pacman-dpad?)) + :on-confirm (lambda ((val symbol)) + (set! (-> *pc-settings* pacman-dpad?) val) + (pc-settings-save))) (new 'static 'menu-generic-confirm-option :name (text-id progress-restore-defaults) :on-confirm (lambda ((val symbol))