jak-project/goal_src/jak1/pc/pckernel-h.gc

610 lines
20 KiB
Common Lisp
Raw Normal View History

;;-*-Lisp-*-
(in-package goal)
Dependency graph work - Part 1 - Preliminary work (#3505) Relates to #1353 This adds no new functionality or overhead to the compiler, yet. This is the preliminary work that has: - added code to the compiler in several spots to flag when something is used without being properly required/imported/whatever (disabled by default) - that was used to generate project wide file dependencies (some circulars were manually fixed) - then that graph underwent a transitive reduction and the result was written to all `jak1` source files. The next step will be making this actually produce and use a dependency graph. Some of the reasons why I'm working on this: - eliminates more `game.gp` boilerplate. This includes the `.gd` files to some extent (`*-ag` files and `tpage` files will still need to be handled) this is the point of the new `bundles` form. This should make it even easier to add a new file into the source tree. - a build order that is actually informed from something real and compiler warnings that tell you when you are using something that won't be available at build time. - narrows the search space for doing LSP actions -- like searching for references. Since it would be way too much work to store in the compiler every location where every symbol/function/etc is used, I have to do ad-hoc searches. By having a dependency graph i can significantly reduce that search space. - opens the doors for common shared code with a legitimate pattern. Right now jak 2 shares code from the jak 1 folder. This is basically a hack -- but by having an explicit require syntax, it would be possible to reference arbitrary file paths, such as a `common` folder. Some stats: - Jak 1 has about 2500 edges between files, including transitives - With transitives reduced at the source code level, each file seems to have a modest amount of explicit requirements. Known issues: - Tracking the location for where `defmacro`s and virtual state definitions were defined (and therefore the file) is still problematic. Because those forms are in a macro environment, the reader does not track them. I'm wondering if a workaround could be to search the reader's text_db by not just the `goos::Object` but by the text position. But for the purposes of finishing this work, I just statically analyzed and searched the code with throwaway python code.
2024-05-12 12:37:59 -04:00
(require "engine/ps2/pad.gc")
#|
This file contains code that we need for the PC port of the game specifically.
It should be included as part of the game engine package (engine.cgo).
This file contains various types and functions to store PC-specific information
and also to communicate between the game (GOAL) and the operating system.
This way we can poll, change and display information about the system the game
is running on, such as:
- display devices and their settings, such as fullscreen, DPI, refresh rate, etc.
- audio devices and their settings, such as audio latency, channel number, etc.
- graphics devices and their settings, such as resolution, FPS, anisotropy, shaders, etc.
- input devices and their settings, such as controllers, keyboards, mice, etc.
- information about the game window (position, size)
- PC-specific goodies, enhancements, fixes and settings.
- whatever else.
If you do not want to include these PC things, you should exclude it from the build system.
|#
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(deftype pckernel-version (int64)
((build int16 :offset 0)
(revision int16 :offset 16)
(minor int16 :offset 32)
(major int16 :offset 48)
)
)
(defmacro static-pckernel-version (major minor rev build)
`(new 'static 'pckernel-version :major ,major :minor ,minor :revision ,rev :build ,build))
(defconstant PC_KERNEL_INVALID_VERSION (static-pckernel-version #xffff #xffff #xffff #xffff))
;; version: invalid
(defconstant PC_KERNEL_VERSION PC_KERNEL_INVALID_VERSION)
(defconstant PC_KERNEL_VER_MAJOR (-> PC_KERNEL_VERSION major))
(defconstant PC_KERNEL_VER_MINOR (-> PC_KERNEL_VERSION minor))
(defconstant PC_KERNEL_VER_REVISION (-> PC_KERNEL_VERSION revision))
(defconstant PC_KERNEL_VER_BUILD (-> PC_KERNEL_VERSION build))
(defun-extern get-pckernel-version pckernel-version)
(defconstant PS2_VOICE_AMOUNT 48)
(defconstant PC_VOICE_AMOUNT 256)
(defconstant ASPECT_4X3 (/ 4.0 3.0))
(defconstant ASPECT_16X9 (/ 16.0 9.0))
(defconstant ASPECT_16X9_SCALE (/ ASPECT_16X9 ASPECT_4X3))
(defconstant PC_BASE_WIDTH 640)
(defconstant PC_BASE_HEIGHT 480)
(defconstant PC_MIN_WIDTH 320)
(defconstant PC_MIN_HEIGHT 240)
(defconstant PC_DEFAULT_MSAA 2)
;; how many entries the music log has. the game only has 21 tracks but let's have more space for no reason.
(defconstant PC_MUSIC_LOG_LENGTH 30)
;; how many entries the spool anim log has. only 164 are used in-game.
(defconstant PC_SPOOL_LOG_LENGTH 170)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; types and enums
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; graphics renderers
(defenum pc-gfx-renderer
:type uint8
(software)
(opengl)
(vulkan)
(direct3d)
)
;; music log info
(deftype pc-music-log-entry (structure)
((name symbol)
(flava-mask int32)
)
:pack-me
)
;; bingo integration. placeholder for now.
(deftype pc-bingo-info (structure)
()
:pack-me
)
;; All of the configuration for the PC port in GOAL. Access things from here!
;; Includes some methods to change parameters.
(deftype pc-settings (basic)
((version pckernel-version) ;; version of this settings
;; "generic" graphics settings
(target-fps int16) ;; the target framerate of the game
;; game resolution?
(width int64)
(height int64)
;; window size. resolution = window size in windowed mode.
(window-width int64)
(window-height int64)
;; reported window framebuffer size from OS
(framebuffer-width int64)
(framebuffer-height int64)
;; the region to draw in that framebuffer. rest is cleared to black.
(framebuffer-scissor-width int64)
(framebuffer-scissor-height int64)
(dpi-x float) ;; DPI width scale
(dpi-y float) ;; DPI height scale
[game] pc port progress menu (#1281) * fix typo * more typo * shorten discord rpc text * allow expanding enums after the fact (untested) * make `game_text` work similar to subtitles * update progress decomp * update some types + `do-not-decompile` in bitfield * fixes and fall back to original progress code * update `progress` decomp with new enums * update config files * fix enums and debug menu * always allocate (but not use) a lot of particles * small rework to display mode options * revert resolution/aspect-ratio symbol mess * begin the override stuff * make `progress-draw` more readable * more fixes * codacy good boy points * first step overriding code * finish progress overrides, game options menu fully functional! * minor fixes * Update game.gp * Update sparticle-launcher.gc * clang * change camera controls text * oops * some cleanup * derp * nice job * implement menu scrolling lol * make scrollable menus less cramped, fix arrows * make some carousell things i guess * add msaa carousell to test * oops * Update progress-pc.gc * make `pc-get-screen-size` (untested) * resolution menu * input fixes * return when selecting resolution * scroll fixes * Update progress-pc.gc * add "fit to screen" button * bug * complete resolutions menu * aspect ratio menu * subtitles language * subtitle speaker * final adjustments * ref test * fix tests * fix ref! * reduce redundancy a bit * fix mem leaks? * save settings on progress exit * fix init reorder * remove unused code * rename goal project-like files to the project extension * sha display toggle * aspect ratio settings fixes * dont store text db's in compiler * properly save+load native aspect stuff
2022-04-11 18:38:54 -04:00
(aspect-ratio-auto? symbol) ;; if on, aspect ratio is calculated automatically based on game display size.
(aspect-ratio float) ;; the desired aspect ratio. set auto to off and then this to 4/3 to force 4x3 aspect.
(aspect-ratio-scale float) ;; aspect ratio compared to 4x3
[game] pc port progress menu (#1281) * fix typo * more typo * shorten discord rpc text * allow expanding enums after the fact (untested) * make `game_text` work similar to subtitles * update progress decomp * update some types + `do-not-decompile` in bitfield * fixes and fall back to original progress code * update `progress` decomp with new enums * update config files * fix enums and debug menu * always allocate (but not use) a lot of particles * small rework to display mode options * revert resolution/aspect-ratio symbol mess * begin the override stuff * make `progress-draw` more readable * more fixes * codacy good boy points * first step overriding code * finish progress overrides, game options menu fully functional! * minor fixes * Update game.gp * Update sparticle-launcher.gc * clang * change camera controls text * oops * some cleanup * derp * nice job * implement menu scrolling lol * make scrollable menus less cramped, fix arrows * make some carousell things i guess * add msaa carousell to test * oops * Update progress-pc.gc * make `pc-get-screen-size` (untested) * resolution menu * input fixes * return when selecting resolution * scroll fixes * Update progress-pc.gc * add "fit to screen" button * bug * complete resolutions menu * aspect ratio menu * subtitles language * subtitle speaker * final adjustments * ref test * fix tests * fix ref! * reduce redundancy a bit * fix mem leaks? * save settings on progress exit * fix init reorder * remove unused code * rename goal project-like files to the project extension * sha display toggle * aspect ratio settings fixes * dont store text db's in compiler * properly save+load native aspect stuff
2022-04-11 18:38:54 -04:00
(aspect-ratio-reciprocal float) ;; reciprocal of that
(aspect-custom-x int)
(aspect-custom-y int)
(display-mode symbol) ;; display mode. can be windowed, fullscreen or borderless
(letterbox? symbol) ;; letterbox. #f = stretched
(vsync? symbol) ;; vsync.
(font-scale float) ;; font scaling.
(monitor int32) ;; index of which monitor to use when fullscreen or borderless
;; debug settings
(os symbol) ;; windows, linux, macos
(user symbol) ;; username. not system username, just debug thing.
(debug? symbol) ;; more debug stuff just in case.
(debug-font-scale float) ;; debug font scaling factor.
(debug-font-scale-auto? symbol) ;; auto-scale debug font by screen height.
;; device settings
(ignore-controller-win-unfocused? symbol)
(controller-led-hp? symbol)
(controller-led-eco? symbol)
(controller-led-heat? symbol)
(controller-led-brightness float)
(controller-led-min-brightness float)
(controller-led-max-brightness float)
(controller-led-color rgbaf :inline)
(stick-deadzone float) ;; analog stick deadzone. 0-1
game: disable keyboard input by default, give users a way to enable it via the imgui menu (#3295) It was narrowed down recently that a lot of people have issues with the controller input because of Steam Input working as intended. Steam Input can be configured to replicate controller inputs as keyboard inputs (for example, pressing X on your controller presses Enter on the keyboard). This results in the problem of "jumping pauses the game" and similar issues. This is a consequence of the intended behaviour of the game listening to all input sources at the same time. Since the vast majority of players are using controllers over keyboards, it makes sense to disable the keyboard input by default to solve this problem. However that makes things awkward for users that want to use the keyboard (how do they enable the setting). The solution is a new imgui option in the settings menu: ![Screenshot 2024-01-07 141224](https://github.com/open-goal/jak-project/assets/13153231/6f9ffa2d-be7a-433d-b698-15b70210e97e) **Known issue that I don't care about** -- in Jak 1's menu code, since the flags are controlled by pointers to values instead of a lambda like in jak 2, the menu won't update live with the imgui option. This has no functional impact and I don't care enough to fix it. I also made the pc-settings.gc file persist on first load if the file wasn't found. Hopefully this helps diagnose the support issues related to the black screen. # Why not just ignore the keyboard inputs for a period of time? This won't work, the keyboard is polled every frame. Therefore if you hold down the X button on your controller, steam is continuously signaling that `Enter` is held down on the keyboard. Yes it would be possible to completely disable the keyboard while the controller is being used, but this defeats the purpose of creating an input system that allows multiple input sources at the same time. With an explicit option, not only can the user decide the behaviour they want (do they want the keyboard ignored or simultaneously listened to) but we avoid breaking strange edge-cases in usage leading to never ending complexity: - ie. imagine steam input sends events to the mouse, well you can't disable the mouse while using the keyboard because most times people are using mouse and keyboard - ie. a user that wants to hold a direction with the keyboard and press buttons on the controller in tandem (something i frequently do while TAS'ing, to move in a perfect straight line)
2024-02-23 18:19:07 -05:00
(keyboard-enabled? symbol) ;; NOTE - this is here solely to satisfy jak 1's menu design, the setting has been moved into `input-settings.json`
(mouse-enabled? symbol)
(mouse-camera? symbol)
(mouse-xsens float)
(mouse-ysens float)
(mouse-movement? symbol)
(auto-hide-cursor? symbol)
;; audio settings
(audio-latency-ms int16) ;; audio latency in milliseconds
(audio-pan-override float) ;; audio pan modifier
(audio-volume-override float) ;; audio volume modifier
(audio-channel-nb int16) ;; audio channel amount. will be 48 on PS2 mode.
;; graphics settings
(gfx-renderer pc-gfx-renderer) ;; the renderer to use
(gfx-resolution float) ;; for supersampling
(gfx-anisotropy float) ;; for anisotropy
(gfx-msaa int32) ;; for MSAA
;; ps2 settings
(ps2-read-speed? symbol) ;; emulate DVD loads
(ps2-parts? symbol) ;; if off, increase particle cap
(ps2-music? symbol) ;; if off, use .wav files stored somewhere
(ps2-se? symbol) ;; if off, use adjusted sound effects
(ps2-hints? symbol) ;; if off, enables extra game hints
;; lod settings
(ps2-shadow? symbol) ;; if off, enables extended object shadows
(ps2-lod-dist? symbol) ;; use original lod distances
(force-envmap? symbol) ;; dont use envmap fading (force max).
(shrub-dist-mod float) ;; shrub render distance modifier
(lod-dist-mod float) ;; non-shrub lod distance modifier
(lod-force-tfrag int8) ;; tfrag lod tier override. 0 = highest detail
(lod-force-tie int8) ;; tie lod tier override
(lod-force-ocean int8) ;; ocean lod tier override
(lod-force-actor int8) ;; merc lod tier override
;; misc settings
(ps2-actor-vis? symbol) ;; skips vis check for actor entity if disabled
(use-vis? symbol) ;; if off, don't use vis trees. this MUST be off for custom (non-cropping) aspect ratios.
(hinttitles? symbol) ;; if on, non-cutscene subtitles will show up
(subtitle-speaker? symbol) ;; #f (force off), #t (force on), auto (on for offscreen)
(first-camera-h-inverted? symbol) ;; first-person horizontal camera inverted
(first-camera-v-inverted? symbol) ;; first-person vertical camera inverted
(third-camera-h-inverted? symbol) ;; third-person horizontal camera inverted
(third-camera-v-inverted? symbol) ;; third-person vertical camera inverted
(music-fadeout? symbol) ;; music fadeout toggle.
(music-fadein? symbol) ;; music fadein toggle.
(territory int16)
(bingo pc-bingo-info :inline) ;; bingo integration. does nothing for now.
(discord-rpc? symbol) ;; enable discord rich presence integration
(speedrunner-mode? symbol) ;; enable speedrunner mode
(flava-hack int64)
;; TODO - save/restore original settings (language/sound/etc)
)
(:methods
(new (symbol type) _type_)
2023-08-16 12:53:38 -04:00
(initialize (_type_) _type_)
(update (_type_) none)
(update-from-os (_type_) none)
(update-to-os (_type_) none)
(update-discord-rpc (_type_) none)
(update-speedrun (_type_) none)
(update-video-hacks (_type_) object)
(reset (_type_ symbol) int)
(reset-audio (_type_ symbol) int)
(reset-input (_type_ symbol symbol) int)
(reset-gfx (_type_ symbol) int)
(reset-ps2 (_type_ symbol) int)
(reset-misc (_type_ symbol) int)
(reset-camera (_type_ symbol) int)
(reset-extra (_type_ symbol) int)
(print-debug-misc (_type_) object)
(draw (_type_ dma-buffer) object)
(draw-memory (_type_ dma-buffer) symbol)
(set-display-mode! (_type_ symbol symbol) int)
(set-size! (_type_ int int symbol) none)
(set-aspect! (_type_ int int) none)
(set-aspect-ratio! (_type_ float) none)
(set-frame-rate! (_type_ int symbol) int)
(set-monitor! (_type_ int) none)
(set-game-setting! (_type_ symbol symbol) object)
(get-game-setting (_type_ symbol) symbol)
(set-game-language! (_type_ language-enum) language-enum)
(get-game-language (_type_) language-enum)
(get-current-game-width (_type_) int)
(get-current-game-height (_type_) int)
(read-from-file (_type_ string) symbol)
(write-to-file (_type_ string) symbol)
(handle-input-settings (_type_ file-stream) object)
(handle-output-settings (_type_ file-stream) object)
(led-enabled? (_type_) symbol)
(update-led (_type_) symbol)
(update-cheats (_type_) int)
(update-music-log (_type_) int)
(add-to-music-log (_type_ symbol int) int)
(commit-to-file (_type_) none)
[game] pc port progress menu (#1281) * fix typo * more typo * shorten discord rpc text * allow expanding enums after the fact (untested) * make `game_text` work similar to subtitles * update progress decomp * update some types + `do-not-decompile` in bitfield * fixes and fall back to original progress code * update `progress` decomp with new enums * update config files * fix enums and debug menu * always allocate (but not use) a lot of particles * small rework to display mode options * revert resolution/aspect-ratio symbol mess * begin the override stuff * make `progress-draw` more readable * more fixes * codacy good boy points * first step overriding code * finish progress overrides, game options menu fully functional! * minor fixes * Update game.gp * Update sparticle-launcher.gc * clang * change camera controls text * oops * some cleanup * derp * nice job * implement menu scrolling lol * make scrollable menus less cramped, fix arrows * make some carousell things i guess * add msaa carousell to test * oops * Update progress-pc.gc * make `pc-get-screen-size` (untested) * resolution menu * input fixes * return when selecting resolution * scroll fixes * Update progress-pc.gc * add "fit to screen" button * bug * complete resolutions menu * aspect ratio menu * subtitles language * subtitle speaker * final adjustments * ref test * fix tests * fix ref! * reduce redundancy a bit * fix mem leaks? * save settings on progress exit * fix init reorder * remove unused code * rename goal project-like files to the project extension * sha display toggle * aspect ratio settings fixes * dont store text db's in compiler * properly save+load native aspect stuff
2022-04-11 18:38:54 -04:00
(load-settings (_type_) int)
(set-ignore-controller-in-bg! (_type_ symbol) none)
(update-mouse-controls! (_type_) none)
(debug-font-scale-factor (_type_) float)
)
)
(defconstant PC_TEMP_STRING_LEN 1024)
(define *pc-temp-string* (new 'global 'string PC_TEMP_STRING_LEN (the string #f)))
(define *pc-temp-string-1* (new 'global 'string 2048 (the string #f)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; debug settings
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define *display-actor-bank* #f)
(define *display-pad-debug* #f)
(define *display-led* #f)
(define *display-led-rgba* (new 'static 'rgba))
(define *display-heap-status* #f)
(define *display-actor-counts* #f)
(define *display-text-box* #f)
(define *display-sha* *debug-segment*)
;; collision renderer things. debug only.
(define *collision-renderer* #f)
(define *collision-wireframe* #f)
(define *collision-mode* (pc-collision-mode mode))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; resets
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmethod reset pc-settings ((obj pc-settings) (call-handlers symbol))
"Reset everything back to default settings
If call-handlers = #t then events will be sent to the runtime kernel to update OS settings
such as window size, etc.
If you just want to set the settings and handle the fields yourself later, set call-handlers to #f
such as if you're setting the initial values right before reading the settings file that changes them."
(format 0 "pc settings reset~%")
(set! (-> obj version) (get-pckernel-version))
(set! (-> obj os) (pc-get-os))
(set! (-> obj user) #f)
(set! (-> obj debug?) #f)
(set! (-> obj font-scale) 1.0)
(set! (-> obj aspect-custom-x) 4)
(set! (-> obj aspect-custom-y) 3)
(set! (-> obj discord-rpc?) #t)
(set! (-> obj speedrunner-mode?) #f)
(set! (-> obj debug-font-scale) 1.0)
(set! (-> obj debug-font-scale-auto?) #t)
(reset-gfx obj call-handlers)
(reset-audio obj call-handlers)
(reset-input obj 'all call-handlers)
(reset-ps2 obj call-handlers)
(reset-misc obj call-handlers)
(reset-extra obj call-handlers)
0)
(defmethod reset-gfx pc-settings ((obj pc-settings) (call-handlers symbol))
"Set the default graphics settings"
;; temporarily "set" to windowed so we can change window size
;; we set our actual target display mode later.
(set! (-> obj display-mode) 'windowed)
(set-size! obj PC_BASE_WIDTH PC_BASE_HEIGHT #f)
(set-aspect! obj 4 3)
(set-frame-rate! obj 60 call-handlers)
(set! (-> obj use-vis?) #f)
(set! (-> obj aspect-ratio-auto?) #t)
(set! (-> obj vsync?) #t)
(set! (-> obj letterbox?) #t)
;; get screen size and set to borderless at screen res (if retail)
(cond
((> (pc-get-num-resolutions) 0)
;; pick first available resolution by default
(pc-get-resolution 0 (&-> obj width) (&-> obj height))
)
(else
;; somehow didn't get a single resolution. this is pretty bad.
(pc-get-active-display-size (&-> obj width) (&-> obj height))
(max! (-> obj width) PC_MIN_WIDTH)
(max! (-> obj height) PC_MIN_HEIGHT)
(format 0 "!!!! failed to get any screen resolutions !!!!")
)
)
(format 0 "fullscreen resolution defaulted to ~D x ~D~%" (-> obj width) (-> obj height))
(if (not *debug-segment*)
(set-display-mode! obj 'borderless call-handlers)
(set-display-mode! obj 'windowed call-handlers))
(set! (-> obj gfx-msaa) PC_DEFAULT_MSAA) ;; default msaa
0)
(defmethod reset-audio pc-settings ((obj pc-settings) (call-handlers symbol))
"Set the default audio settings"
(set! (-> obj audio-latency-ms) 80)
(set! (-> obj audio-pan-override) 0.0)
(set! (-> obj audio-volume-override) 1.0)
(set! (-> obj audio-channel-nb) PS2_VOICE_AMOUNT)
(set! (-> obj music-fadeout?) #t)
(set! (-> obj music-fadein?) #t)
0)
(defmethod reset-input pc-settings ((obj pc-settings) (device symbol) (call-handlers symbol))
"Set the default input settings"
(when (or (= device 'all) (= device 'controller))
(set! (-> obj ignore-controller-win-unfocused?) #f)
(set! (-> obj controller-led-hp?) #t)
(set! (-> obj controller-led-eco?) #t)
(set! (-> obj controller-led-heat?) #t)
(set! (-> obj stick-deadzone) 0.3)
(set! (-> obj controller-led-brightness) 1.0)
(set! (-> obj controller-led-min-brightness) 0.25)
(set! (-> obj controller-led-max-brightness) 1.0)
)
game: disable keyboard input by default, give users a way to enable it via the imgui menu (#3295) It was narrowed down recently that a lot of people have issues with the controller input because of Steam Input working as intended. Steam Input can be configured to replicate controller inputs as keyboard inputs (for example, pressing X on your controller presses Enter on the keyboard). This results in the problem of "jumping pauses the game" and similar issues. This is a consequence of the intended behaviour of the game listening to all input sources at the same time. Since the vast majority of players are using controllers over keyboards, it makes sense to disable the keyboard input by default to solve this problem. However that makes things awkward for users that want to use the keyboard (how do they enable the setting). The solution is a new imgui option in the settings menu: ![Screenshot 2024-01-07 141224](https://github.com/open-goal/jak-project/assets/13153231/6f9ffa2d-be7a-433d-b698-15b70210e97e) **Known issue that I don't care about** -- in Jak 1's menu code, since the flags are controlled by pointers to values instead of a lambda like in jak 2, the menu won't update live with the imgui option. This has no functional impact and I don't care enough to fix it. I also made the pc-settings.gc file persist on first load if the file wasn't found. Hopefully this helps diagnose the support issues related to the black screen. # Why not just ignore the keyboard inputs for a period of time? This won't work, the keyboard is polled every frame. Therefore if you hold down the X button on your controller, steam is continuously signaling that `Enter` is held down on the keyboard. Yes it would be possible to completely disable the keyboard while the controller is being used, but this defeats the purpose of creating an input system that allows multiple input sources at the same time. With an explicit option, not only can the user decide the behaviour they want (do they want the keyboard ignored or simultaneously listened to) but we avoid breaking strange edge-cases in usage leading to never ending complexity: - ie. imagine steam input sends events to the mouse, well you can't disable the mouse while using the keyboard because most times people are using mouse and keyboard - ie. a user that wants to hold a direction with the keyboard and press buttons on the controller in tandem (something i frequently do while TAS'ing, to move in a perfect straight line)
2024-02-23 18:19:07 -05:00
(when (or (= device 'all) (= device 'input))
game: disable keyboard input by default, give users a way to enable it via the imgui menu (#3295) It was narrowed down recently that a lot of people have issues with the controller input because of Steam Input working as intended. Steam Input can be configured to replicate controller inputs as keyboard inputs (for example, pressing X on your controller presses Enter on the keyboard). This results in the problem of "jumping pauses the game" and similar issues. This is a consequence of the intended behaviour of the game listening to all input sources at the same time. Since the vast majority of players are using controllers over keyboards, it makes sense to disable the keyboard input by default to solve this problem. However that makes things awkward for users that want to use the keyboard (how do they enable the setting). The solution is a new imgui option in the settings menu: ![Screenshot 2024-01-07 141224](https://github.com/open-goal/jak-project/assets/13153231/6f9ffa2d-be7a-433d-b698-15b70210e97e) **Known issue that I don't care about** -- in Jak 1's menu code, since the flags are controlled by pointers to values instead of a lambda like in jak 2, the menu won't update live with the imgui option. This has no functional impact and I don't care enough to fix it. I also made the pc-settings.gc file persist on first load if the file wasn't found. Hopefully this helps diagnose the support issues related to the black screen. # Why not just ignore the keyboard inputs for a period of time? This won't work, the keyboard is polled every frame. Therefore if you hold down the X button on your controller, steam is continuously signaling that `Enter` is held down on the keyboard. Yes it would be possible to completely disable the keyboard while the controller is being used, but this defeats the purpose of creating an input system that allows multiple input sources at the same time. With an explicit option, not only can the user decide the behaviour they want (do they want the keyboard ignored or simultaneously listened to) but we avoid breaking strange edge-cases in usage leading to never ending complexity: - ie. imagine steam input sends events to the mouse, well you can't disable the mouse while using the keyboard because most times people are using mouse and keyboard - ie. a user that wants to hold a direction with the keyboard and press buttons on the controller in tandem (something i frequently do while TAS'ing, to move in a perfect straight line)
2024-02-23 18:19:07 -05:00
(set! (-> obj keyboard-enabled?) #f)
(set! (-> obj mouse-enabled?) #f)
(set! (-> obj auto-hide-cursor?) #t)
)
(when (or (= device 'all) (= device 'mouse))
(set! (-> obj mouse-camera?) #f)
(set! (-> obj mouse-xsens) -15.0)
(set! (-> obj mouse-ysens) 10.0)
(set! (-> obj mouse-movement?) #f)
)
0)
(defmethod reset-ps2 pc-settings ((obj pc-settings) (call-handlers symbol))
"Set the default ps2 settings"
(set! (-> obj ps2-read-speed?) #f)
(set! (-> obj ps2-parts?) #f)
(set! (-> obj ps2-music?) #t)
(set! (-> obj ps2-se?) #t)
(set! (-> obj ps2-hints?) #t)
(set! (-> obj ps2-shadow?) #f)
(set! (-> obj ps2-lod-dist?) #f)
(set! (-> obj force-envmap?) #t)
(set! (-> obj shrub-dist-mod) 1.0)
(set! (-> obj lod-dist-mod) 1.0)
(set! (-> obj lod-force-tfrag) 0)
(set! (-> obj lod-force-tie) 0)
(set! (-> obj lod-force-ocean) 0)
(set! (-> obj lod-force-actor) 0)
0)
(defmethod reset-misc pc-settings ((obj pc-settings) (call-handlers symbol))
"Set the default misc settings"
(set! (-> obj ps2-actor-vis?) #t)
(set! (-> obj hinttitles?) #t)
(set! (-> obj subtitle-speaker?) 'auto)
(reset-camera obj call-handlers)
(set! (-> obj territory) -1) ;; auto
0)
(defmethod reset-camera pc-settings ((obj pc-settings) (call-handlers symbol))
"Set the original game's camera controls"
(set! (-> obj first-camera-h-inverted?) #f) ;; first-person horizontal is NOT inverted in original game
(set! (-> obj first-camera-v-inverted?) #t) ;; first-person vertical IS inverted in original game
(set! (-> obj third-camera-h-inverted?) #t) ;; third person horizontal IS inverted in original game
(set! (-> obj third-camera-v-inverted?) #t) ;; third-person vertical IS inverted in original game
0)
(defmethod reset-extra pc-settings ((obj pc-settings) (call-handlers symbol))
"Set the default goodies settings"
0)
(defmacro with-pc (&rest body)
"encapsulates the code around PC-specific checks"
`(#when PC_PORT (when (and *pc-settings*)
,@body
))
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; quick helpers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defmacro get-debug-font-scale-factor ()
"return the debug font scale factor to be used."
`(debug-font-scale-factor *pc-settings*))
2023-12-03 03:11:18 -05:00
(defmacro fullscreen? ()
`(symbol-member? (-> *pc-settings* display-mode) '(fullscreen borderless)))
(defun bcd->dec ((bcd uint))
"Convert a number encoded in BCD to its decimal equivalent"
(+ (* (shr (logand bcd #xf0) 4) 10) (logand bcd #x0f)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; cheats
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(seval (define *pc-cheat-map*
'((#\a (circle triangle))
(#\b (square x))
(#\c (circle))
(#\d (down))
(#\e (right right))
;; #\f
;; #\g
;; #\h
(#\i (up))
;; #\j
(#\k (circle))
(#\l (left))
(#\m (triangle))
(#\n (up up))
(#\o (square))
(#\p (square circle))
;; #\q
(#\r (right))
(#\s (down down))
(#\t (triangle))
(#\u (up))
(#\v (down))
(#\w (left left))
(#\x (x))
(#\y (triangle))
(#\z (x x))
))
)
(desfun pc-cheat-encode (word extra)
"turn a cheat word into input names."
(let ((out '())
(word-str (symbol->string word)))
(dotimes (i (string-length word-str))
(let ((char-to-inputs (assoc (string-ref word-str i) *pc-cheat-map*)))
(if (not char-to-inputs)
(ferror "bad input for pc cheat name: {}" (string-ref word-str i))
(dolist (button (cadr char-to-inputs))
(set! out (cons (car button) out))
))
))
(dolist (ex extra)
(set! out (cons (car ex) out)))
out)
)
(defmacro pc-check-cheat-code (cheat-var pad-idx input &key (extra ()) &rest body)
"execute body when a cheat code made up of sequential inputs has been inputted"
(let ((buttons (pc-cheat-encode input extra)))
`(when (nonzero? (cpad-pressed ,pad-idx)) ;; only check when some button has been pressed
(case ,cheat-var
,@(apply-i
(lambda (x i)
`((,i)
(if (cpad-pressed? ,pad-idx ,x)
,(if (< i (- (length buttons) 1))
`(1+! ,cheat-var)
`(begin
(cond
((-> *pc-settings* speedrunner-mode?)
(sound-play "cursor-options"))
(else
,@body)
)
(set! ,cheat-var 0)
)
)
(set! ,cheat-var 0)
)
)
)
buttons)
)
)
))
(defun-extern real-movie? symbol)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; entity debugging
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(when *debug-segment*
(deftype entity-debug-inspect (basic)
(
(scroll-y int16)
(scroll-y-max int16)
(entity entity)
(show-actor-info symbol)
(show-long-info symbol)
)
(:methods
(new (symbol type) _type_)
(set-entity! (_type_ entity) entity)
(update-pad (_type_ int) none)
)
)
(defmethod new entity-debug-inspect ((allocation symbol) (type-to-make type))
"make a new entity-debug-inspect object"
(let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
(set! (-> obj scroll-y) 0)
(set! (-> obj scroll-y-max) 0)
(set! (-> obj entity) (the entity #f))
(set! (-> obj show-actor-info) #f)
(set! (-> obj show-long-info) #f)
obj
)
)
(define *entity-debug-inspect* (new 'debug 'entity-debug-inspect))
) ;; when debug_segment