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
Avoid multiple detect from single12way rotate #16389
base: master
Are you sure you want to change the base?
Avoid multiple detect from single12way rotate #16389
Conversation
…est for saved poll data). This functionality can be compiled out with a NO_FILTERED_POLL option.
I see one check so far was not successful (some tests still running). The changes I made to the main Makefile probably would need to be done with the Makefiles for these builds as well. Worse case, this feature would be compiled out with NO_FILTERED_POLL set to equal 1. |
Ah, look at the details tab. Okay, these issues seem easy enough to fix. Can you give me feedback on anything else (hopefully nothing) so I can fix everything together? |
There seems to be a C89 build failure that has to be fixed. |
Just move the declarations to the beginning of the scope of each function or code block, that should cover most of what I see. C89 is strict on this. |
…style // with /*** and */ at end.
Almost got it. I just need to fix some text in a comment to now pass the PS4 build. I should get that fixed within the hour I assume or less. |
@zorro2055 @LibretroAdmin |
Thanks all. I moved the declarations to the top and fixed the comment errors. As you can see, everything compiles now. I'll do the same shortly for mame2003-plus. |
OK so looking at this I have some concerns:
|
Hi @LibretroAdmin , thanks for looking this over. Below are the answers to your questions.
I just double checked this by running retroarch with this patch with mame2003-plus without the proposed patch essentially (uncommented NO_FILTERED_POLL=1 in mame2003-plus Makefile and recompiled) and it runs fine. In this case, a core that does not call these filtered_poll.c functions does not lose performance in anyway since these functions are never run. Good question on the overhead. I can say the game Ikari Warriors that I tested on the PS Vita at 60 fps fine. The performance seems the same as without the patch. The patch is written to minimize intercepting. If there is an easy way to benchmark performance, let me know. If a core is not using this feature, there is no performance impact. No code was introduced into the existing retroarch code files. Thus not complicating backporting the latest MAME features back to retroarch.
More detail: the rotary joystick twists and "snaps" every 30 degrees. This rotates a character on the screen by 30 or 45 degrees depending on the game. The 12 way rotary joystick that I have: For reference on games with this discrete rotary joystick, here is a picture of Ikari Warriors: And video of Ikari Warriors gameplay: These are all the games (on MAME) that I know of offhand that use this type of 8 or 12 way rotary joystick: Hopefully that answers your questions. Let me know what you think! |
There is also the option to compile this filtered poll functionality out of RetroArch by uncommenting the "NO_FILTERED_POLL=1" line in the RetroArch Makefile for whatever reason might come up. |
And actually, here is a basic over view of how it works both without and with patch (retroarch and mame2003-plus). This should help with what it affects. Currently without patch (or NO_FILTERED_POLL=1 uncommented in proposed mame2003-plus in Makefile):During initialization:
During game loop:
With proposed retroarch (and mame2003-plus ) PR. Other cores could use this optionally.During initialization:
During game loop:
So, any core out there right now is set to the default (or maybe some other input callback). This retroarch PR does not be default, change the behavior of any core. A core would specifically have to be modified (and code other logic) to set the custom input callback function in filtered_poll.c in order to have its behavior modified. Hopefully, that makes sense. |
Just checking in on this. I obviously posted a bunch of info before, but here are more direct answers to your questions. Let me know from these answers if it makes sense to merge this. Or if I should just go back and only implement this in Mame2003-Plus. Thanks!
No, no core would be affected by this unless it explicitly changed the retro_set_input_state function defined in the core (and declared and called in RA). This function sets the input callback function. The custom input callback function defined in the new proposed file filtered_poll.c would have to be explicitly referenced in the retro_set_input_state function definition in the core. That retro_set_input_state function (declared in RA) shown defined in the unpatched Mame2003-Plus for reference: Here is that same area in my patched Mame2003-Plus PR: Yeah, it is slower by about 3.2 microseconds on an AMD Ryzen 9 7940HS with a clockspeed of 4 - 5.2 GHz.
The advantage is it provides a generic system for other cores to use this filtering as well which they can opt into if desired as explained above. It seemed handy to have that, but I have no idea how often other cores would have use for it. Ie, would they have a similar problem that I am trying to solve for Mame2003-Plus? |
Hi @mahoneyt944 , I'm copying and pasting the comments I just put in the mame2003-plus pull request that are used for this for the most part.
its been a while as it definitely took longer than expected and other things came up, but I believe it is done (it appears to work as intended with my 12-way rotary joystick) and ready to merge! It definitely uses more code than I expected.
See the corresponding RetroArch pull request that is needed for this to work that I request shortly.
First, some key points about implementation on the mame2003-plus and RetroArch side) after how this ended up (hopefully, it all looks good to you):
https://github.com/zorro2055/mame2003-plus-libretro/blob/8c57fd7d81f48d7e6a1f9a53ad1aa6c2b01ce529/Makefile#L5-L7
Note I just had to sync in 2 merges from other on RetroArch just now, so technically, that is not tested.
I successfully tested this with this option enabled on the above mentioned platforms as well.
4. This adds the new files filtered_poll.c and filtered_poll.h. Only filtered_poll.h is used in mame2003-plus, but I have filtered_poll.c in mame2003-plus as it seems to be done with other libretro files as well. Both of these files are used in RetroArch. I threw in a copyright header from another file for both of these, but let me know if that should change in any way.
5. The intercept requested saved poll data is implemented in filtered_poll.c and filtered_poll.h. Filtered_poll.c is compiled in RetroArch where this functionality resides. This also keeps to the original intent of not modifying any existing RetroArch source code files. I have one timeout filter currently which is used for my use case. I have basic comments showing where 3 more other filters could be defined in the future if there is ever a use for that.
https://github.com/zorro2055/RetroArch/blob/8d25800544f356ea261546320739803d48aa84fa/libretro-common/filtered_poll/filtered_poll.c#L151C1-L164C15
https://github.com/zorro2055/RetroArch/blob/8d25800544f356ea261546320739803d48aa84fa/libretro-common/include/filtered_poll.h#L39-L43
6. Any other core could use the RETRO_API functions defined in filtered_poll.h for their own purposes.
That is all I can think of at the moment. Let me know if you have any questions of course. Hopefully, it is ready to merge off the bat.
Thanks!
Link to mame2003-plus pull request that uses these changes:
libretro/mame2003-plus-libretro#1652
Guidelines
Description
[Description of the pull request, detail any issues you are fixing or any features you are implementing]
Related Issues
[Any issues this pull request may be addressing]
Related Pull Requests
[Any other PRs from related repositories that might be needed for this pull request to work]
Reviewers
[If possible @mention all the people that should review your pull request]