[jak2] Support STICK_DEADZONE (#3239)

fixes #3235
This commit is contained in:
Brent Hickey 2023-12-03 00:11:10 -08:00 committed by GitHub
parent 37069e2f8e
commit e119a66788
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -316,6 +316,11 @@ The cpad-set-buzz! function can be used for vibration.
;; weird leftover debug thing, enabling overrides the x position of both sticks on both controllers. ;; weird leftover debug thing, enabling overrides the x position of both sticks on both controllers.
(define *cpad-debug* #f) (define *cpad-debug* #f)
(#if PC_PORT
(defconstant STICK_DEADZONE (-> *pc-settings* stick-deadzone))
(defconstant STICK_DEADZONE 0.3)
)
(defun service-cpads () (defun service-cpads ()
"Read from cpads and update vibration" "Read from cpads and update vibration"
(let ((pads *cpad-list*)) (let ((pads *cpad-list*))
@ -526,7 +531,7 @@ The cpad-set-buzz! function can be used for vibration.
(set! (-> pad stick0-dir) (atan (- f30-0) f28-0)) (set! (-> pad stick0-dir) (atan (- f30-0) f28-0))
(set! (-> pad stick0-speed) (fmin 1.0 (sqrtf (+ (* f30-0 f30-0) (* f28-0 f28-0))))) (set! (-> pad stick0-speed) (fmin 1.0 (sqrtf (+ (* f30-0 f30-0) (* f28-0 f28-0)))))
) )
(if (< (-> pad stick0-speed) 0.3) (if (< (-> pad stick0-speed) STICK_DEADZONE)
(set! (-> pad stick0-speed) 0.0) (set! (-> pad stick0-speed) 0.0)
) )
) )
@ -540,7 +545,7 @@ The cpad-set-buzz! function can be used for vibration.
) )
) )
(if (or (!= (-> pad button0-abs 0) (-> pad button0-abs 1)) (if (or (!= (-> pad button0-abs 0) (-> pad button0-abs 1))
(or (< 0.3 (-> pad stick0-speed)) (zero? (-> pad change-time))) (or (< STICK_DEADZONE (-> pad stick0-speed)) (zero? (-> pad change-time)))
) )
(set! (-> pad change-time) (get-current-time)) (set! (-> pad change-time) (get-current-time))
) )