-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Input Recording/Playback Functionality #2412
Conversation
1d31bcb
to
8b65bf1
Compare
I should actually come back and get my own todos done before my opinion's worth anything but... do we really want such extensive changes in mainline? Input recording and replay's definitely something that would be nice to have (although very much preferably in a plugin independent way, which would mean changing the way the plugins and core work), but... lua scripting? Um. Some of this really seems like material that should stay in a fork to me. |
+1 for plugin independenecy |
I think it's a cool feature, often requested as well. Is there an effect on performance or stability? |
Pulling this out into a plugin is a great idea and something that I thought of after making this PR. But to be completely honest I don't have the time to dedicate to both doing that work and understanding how to intercept controller inputs without being invasive. But if thats a deal breaker and unless someone else wants to take on that work it will have to remain in it's fork. There aren't that many new hotkeys, there are 3 important ones and I guess I could remove the savestate ones on the numpad if that is deemed too much. From what I understood that wouldn't be a breaking change as a user's existing I've seen no issues myself on performance or stability but of course this is a huge testing surface so no guarantees. I don't think you could turn these features "off", as mentioned, they are invasive in some spots. However it requires a user action to begin recording / using the lua engine. So problems should only occur once that happens From what I understand, the only plugin that these changes touch is the snapshot features in GSdx, which from what I can tell is completely unrelated to the recording/lua components and could be reversed if thats an issue? I will try to maintain these changes time permitted, my main priority is the recording functionality and the tooling for it. It's a bit rough in some spots and I have a list of TODOs in mind to make it better. It seems like the Lua scripting is what got the attention for the merge, but it definitely needs much more work and testing than the recording features. I would hope that means that other people would be willing to pitch into that work but if not, I'd have no problems gutting the lua portion from this as the recording features are really all I use and would like to see in mainline pcsx2. |
I don't think plugin independent meant "making a specific plugin for it" (about what, even?) But having the thing inside core, and adjusting plugin interfaces if really required. "Turning off" the feature wouldn't be impossible then, with enough #ifdefs and a config setting (like gsdx sse4 or portaudio noasio). Said this anyway, imo all of these features would be appreciated by all the devs here, at least in theory. The only actual blocker is polishedness. ^^ |
In my opinion, it can be "a little" invasive, if it's useful. Let's see about GSDX: For the hotkeys: @sudonim1: |
I believe the screenshot changes were added just to add some additional convenience. A menu option was added to easily dump frames/audio instead of pressing I can explore adding some kind of toggle for TAS/Lua features but it will take some time as that is a significant amount of code to wrap in config setting checks, also I'd have to look into how this is even accomplished. Looking at the examples mirh mentioned should help but I have zero familiarity at the moment. I will wait and let this PR sit for a while before doing that work since it's only purpose would be to fit well into mainline pcsx2, but the possibility of these large changes being rejected is still there. As more people look at this PR, I imagine there will be a clearer direction towards getting this merged or a clear rejection (which I completely understand the hesitation to merge such large/unrelated changes), at which point I can move forward. |
Maybe it's just my c# background but for me these //tas comments in the code are smelly. It looks to me like a virtual call with inheritance is what you want to do. Just subclass all pcsx2 classes (sio/counter) and overwrite TAS-specific methods with your own implementations including the TAS-calls. Like that you basically need a single ifdef/if per pcsx2 class in each consumer to clearly separate TAS and non-TAS code. Not sure how performance critical the code is and how much it will suffer from virtual method calls though. |
I think it's a great feature to have on PCSX2. If people think its too intrusive on the GUI you can just add an option inside emulation settings to show or hide the TAS stuff. About code standards and being invasive in PCSX2 code, I too would also like it to be as contained as possible as long as it is doable and doesn't need huge amounts of work. Worst case scenario it could remain as a fork although personally I'd love the extra functionality in PCSX2 :) |
I am welcome for having TAS-capable abilities to PCSX2 mainline, since I am a TASer. But I also agree for the opinion that the code is too smelly and invasive. In my opinion, it needs code cleaning. (I tried to make the code cleaner and stable but I was busy and lost motivation at last.) I also planned to shrink the granularity of the pull request, in other words, to make some individual pull requests such as scripting core, input injection mechanism, movie support, etc. Isn't this change just too big and hard to review? I wish PCSX2 will have a stable and sophisticated functionality for TASing in future anyways. Thank you devs for trying to make the first step for that. P.S. I would be more happy if the movie format would be changed to text-based format, which is more extensible and readable. |
I will clean up the code at the same time as making the changes to make it acceptable for merging, but in regards to having a smaller PR, you can't really make it any smaller other than removing the Lua code or vise-versa. In my opinion it wouldn't make much sense to make a PR to upstream which adds TAS support that did not actually add TAS support, all of the underlying TAS code is required to make that happen. Maybe I'm flawed in that mentality but I see this as the initial spike that can be worked on in the future with reasonably sized PRs. Of course you could make an individual PR for just the input recording for example and stub everything else out...but that adds no value to PCSX2 on it's own There is already an included tool that can be used to view (and I believe edit) the movie files in a human readable format. I would prefer to see this be worked on instead of making another breaking change to the movie file format. I'm not sure what you mean by extensible as the movie format has to always be tightly coupled with the underlying TAS code. |
a4707ff
to
4d611d7
Compare
Went through and wrapped the invasive code that interfaces with the Recording/Lua tools in new In the next few days I will do a pass of the diff in this PR and see if there is anything I've missed, I'll update the PR description, and most of all I will split the Lua portion into it's own PR to make reviewing easier. While the +7K line diff looks intimidating for reviewing, keep in mind that 1/3rd of that is the addition of the standard lua C library and additional standard CMake scripts. Hopefully the improvements I've made makes these large changes more acceptable for merging, and if changes still need to be made it should just be simpler refactors from here on out 🤞 |
5caa455
to
0c87dfe
Compare
The crashes that @bositman brought to my attention appear to have gone away with the removal of the Lua code, which I will look into before PRing those changes, at one point I got a stacktrace and it seemed related to initializing This is ready for review |
You may want to squash/annihilate the commits where you add lua in the first place then. |
@mirh Maybe I'm just not confident enough with rebasing, but it looks like a terrible mess as this PR has merges with integration branches as well as pcsx2/master. The PR could just be squashed to a single commit upon merge. If removing the first few commits which just append files is really desired then I guess I could remake the PR with a new branch and cherry-pick the correct commits. If all lua code wants to be removed from the commit history then I might as well just squash it to a single commit myself since it's a part of basically every commit here....although I'd really like to preserve my commit history as I have to maintain this lol |
It could, but it really shouldn't. As is, it's already 46 files and 3300 LOC, which will be a nightmare to review. The best you can do is split it into meaningful and relatively independent and incremental commits to make it easier to chew - for whomever reviews it and later for anyone who looks at the code and wants to understand it and its evolution. If it gets in, it still has to be maintained and understood by others, and meaningful commits are essential, especially in such a big PR. |
@avih I completely agree with you but if the intent is to rely on individual commits to review it, then the entire PR has to be rebased anyway as old commits do not reflect the current diff. I also agree with you that having contextual commit messages is important (why I don't want to squash away my recent changes). Relying on individual commits for review purposes makes things very difficult from the contributor's standpoint....once reviewers suggest something and I change it, I then have to rebase the entire PR again to remove the original bad code to not confuse other reviewers (which also re-writes the entire commit history which will remove all comments and suggestions lol). |
You don't need a new PR for that. You should do that locally on your own system, in a branch, and once you're happy with the branch and its commits history, put it back at your It may or may not be simple to edit the current commits - it depends how far they are from your final history setup you want to create. Depending on your git knowledge, if editing the commits is hard, your safest bet would be to backup your current branch, start working from scratch on PCSX2 master, and apply/create the commits from scratch. This could be tedious, but it's important. I suggest though to leave it till you're happy with the overall commit. Actually, I think you have it in a |
1ece15c
to
e6bb1f2
Compare
@avih Done, I hope this is separated and isolated enough to make this acceptable for reviews. I edited my previous message, I am still concerned about the following:
I would hope that the individual commits make things easier to digest, but that comments are placed on the overall diff, so that I do not have to continually force-push away old code and automatically dismiss reviews. Simple example to illustrate my concern: reviewer suggests to change the name of a variable...all previous commits use the old variable name which causes confusion / other reviewers to make the same suggestion because they aren't cross-referencing the overall changeset. |
If rebasing gives you shivers (understandably), it's not like you couldn't just work in a new branch... And then make a new PR altogether. |
…er date This is a rather involved refactor and isn't critical to getting the main PR / spike merged.
… separate file alongside recording file Regressions were discovered after merging with master due to way the save state data was saved within the movie file. This change uses the same functions used in the GUI to create savestates to create a compressed save-state file. Eventually this could be re-incorporated back into the recording file and could be backwards compatible.
…eparate PR Along with changing the .bmp file naming scheme.
Squashed commits: [47be086] recording: Forgot to refactor the usage of std::size
Squashed commit: [7955b42] recording: Throw errors on fread/fwrite errors. [5a2160f] recording: Remove function implementation from header files [f2937ab] recording: Fixed UndoCount metadata bug and will gracefully fail if savestate is missing [d7f4d43] recording: Refactored code-style to be consistent [0f77fbb] recording: Refactor to use switch statements [28d7945] recording: Resolve CMake warnings and use tagged github links for cross-linking to LilyPad [7c01c6c] recording: corrected disparity between comment and code [17a8bd8] recording: Remove all usages of #define [3830f5a] recording: Refactor enums and general cleanup [569ef7d] recording: Completely disable new console log sources when recording is disabled
9e6059c
to
2f16e52
Compare
I'm ready for this to be merged unless anybody else has other comments/suggestions. We'll just have to bump the savestate version after merging. |
bin/PCSX2_keys.ini.default
Outdated
States_LoadSlot6 = KP_7 | ||
States_LoadSlot7 = KP_8 | ||
States_LoadSlot8 = KP_9 | ||
States_LoadSlot9 = KP_0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Num pad will probably be used for input bindings by people that don't use a controller so it's not a good idea to bind these, same goes for space.
Do we need to have hotkey bindings for saveslots ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the purposes of recording, yes they are definitely required as saving and loading save-states is done incredibly frequently (as is frame advance). These are just the default settings, if someone were to bind numpad/space wouldn't they already have duplicated and modified the PCSX2_keys.ini.default
file? I'm guessing the controller keybindings do not take precedence / detect conflicts and that is the bigger issue.
I can remove the defaults and add documentation somewhere on how to bind the recording keybindings, or leave them commented out in the same file?
As an aside, is the only way to modify non-controller keybindings in PCSX2 via the ini file? I actually never noticed but looking around the UI right now I see no other way. Would adding some sort of UI menu to change the keybindings be considered a valuable contribution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an aside, is the only way to modify non-controller keybindings in PCSX2 via the ini file? I actually never noticed but looking around the UI right now I see no other way. Would adding some sort of UI menu to change the keybindings be considered a valuable contribution?
That would be a great feature, it's just finding someone willing to add it :)
These are just the default settings, if someone were to bind numpad/space wouldn't they already have duplicated and modified the
PCSX2_keys.ini.default
file?
Lilypad has it's own ini config so hotkeys can actually become duplicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If somebody's doing a TAS, I would assume it's not really any more interested into normal gaming
So... How about "enable recording tool" making lilypad use a separate .ini?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A separate .ini file is a good idea, although I believe you meant make pcsx2 use a separate file? We aren't overwriting any controller keybindings, just emulator ones (savestates and new custom ones).
In the meantime and to keep things moving, the latest commit will enable / revert the recording keybindings while preserving whatever custom overrides a user has setup in the .ini file (tested and everything appears to work as expected).
Setting the bindings conditionally is pretty easy, the tricky part I found was reverting and restoring the original bindings if they disabled recording. Right now everything is centralized in the PCSX2_Keys.ini file or in code so to pull a portion of the bindings out into their own config file, might be a larger change (case in point, Lilypad's ini will overwrite). So I'm sure there's a more elegant solution than mine, but I think I'd be best to sit on it and think about it, currently low on ideas.
Is there anything else we're waiting for on this PR? I'd like to see it get merged soon :) @lightningterror @xTVaser |
@MrCK1 From my perspective there's nothing blocking it from being merged. The sooner it gets merged the sooner I can start to make things better with much more reasonably sized PRs. I imagine that it will need to be tested again before merging, and if anything comes out from that testing I'll try my best to address it as soon as possible. |
Can you add a commented out define for DISABLE_RECORDING just so we know where to change it if we want to disable the functionality. Bonus for adding a comment next or above the define explaining what it does. Anyway was linux behavior tested? Linux has gsdx options for recording and may need to be updated according to this pr. pcsx2/plugins/GSdx/Window/GSLinuxDialog.cpp Line 548 in 5c23a9f
|
After that change has been made, can we merge this please, I want this over and done with. It has been tested quite extensively and it's fine, these changes being asked are pretty petty |
Ok let's merge the initial pr, it's been delayed enough as it is :P |
Wee! :) |
First off, the vast majority of the credit for this work goes out to @pocokhc https://github.com/pocokhc/pcsx2-1.4.0-rr and @DocSkellington https://github.com/DocSkellington/pcsx2-1.4.0-rr I've just simply merged with upstream pcsx2 and made a few small bug fixes and improvements to the recording features, not pcsx2 itself.
These changes are not without issues but the core recording functionality is better than anything I've previously seen or worked with on pcsx2 and in my experience is quite reliable (I've never lost a recording yet, desyncs are comparable to Dolphin's recording, etc).
I will continue to work on polishing up these new features but I would only want to address major-blocking issues before getting this merged (otherwise, it never will lol). In addition, we also have Lua scripting tools and features to contribute, but as this PR is already getting fairly large, I will PR those separately after getting this through. Said code is currently in this branch https://github.com/xTVaser/pcsx2-rr/tree/add-lua-scripting
Changes
PCSX2 Unimplemented / "Hidden" Features
Save/LoadStateOther_Click
which lets you arbitrarily pick a file to save or load to. These have been refactored from usingOther
-> To/FromFile
pcsx2/pcsx2/gui/MainMenuClicks.cpp
Lines 531 to 539 in f6e4a30
F12
video/audio recording capabilities of GSdx through a menu optionsnaps/
folderPreprocessor Defintions
Recording/
directory) -DISABLE_RECORDING
GUI Modifications
Capture
Recording
System
submenu calledEnable Recording Tools
. This toggle is also preceded by a prompt warning the user about the potential performance / instability / work-in-progress nature.50ms
New Keybindings
Shift-R
is used to switch between replay or recording modeShift-P
to pause the emulator while still maintaining the game windowSpace
bar used to individually frame advance1-9
on the numberpad to load,Shift+1-9
on the number pad to saveConsole Logging Additions
Recording Console
All feedback from recording goes through hereController Info
disabled by default, outputs the raw byte data per frame for the controller in port 1.Recording Features
Frame 0
- This means that it is not necessary to backup and save the starting save-state like many emulator recording features require.- Recording editor to modify / view the inputs on a per frame basis- Conversions from old movie file formats:Demo
Outstanding Questions