Skip to content
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

[Basic feature request] Render presses for a longer time #425

Open
jkidd1 opened this issue Oct 28, 2024 · 3 comments
Open

[Basic feature request] Render presses for a longer time #425

jkidd1 opened this issue Oct 28, 2024 · 3 comments

Comments

@jkidd1
Copy link

jkidd1 commented Oct 28, 2024

Thank you very much for creating and maintaining this very useful plugin. In my case, I am using it to visualize hits on a drum controller (each hit maps to a keyboard press). The issue is that the keys/hits only stay pressed for a very short amount of time, so the visuals ultimately do not look very smooth. I am wondering whether it would be easy/trivial to add an option for extending the render of the "pressed" icon. For example, the key could display the "pressed" state for an additional second after it is released.

If this is too much effort to implement, I totally understand. And if it's not done through the plugin, does anyone have tips for how it could be accomplished in OBS? Is there perhaps another plugin I could use in tandem with this one?

@univrsal
Copy link
Owner

You could use the browser source. https://github.com/univrsal/input-overlay/tree/master/data/overlay_render contains an example for rendering the gamepad preset in the browser source. It cold be adapted to load any other gamepad preset and to extend button presses.

@jkidd1
Copy link
Author

jkidd1 commented Oct 30, 2024

Thank you so much for the suggestion. I have coding experience but am not familiar with javascript, so my apologies if I am a bit slow. I found a draw function in here in elements.js. If I understand correctly, this is where you perform the trick of shifting the render window downwards in the texture file so that the "pressed" image is shown. The shift only happens if this.pressed is true. I also see that you have some wrappers, e.g., on_keyboard_input, that presumably keep track of the state of each key code on each tick. What approach should I be taking to the modification? Should I be trying to keep this.pressed true for additional ticks after the initial change of the state? Any advice would be highly appreciated.

@univrsal
Copy link
Owner

univrsal commented Nov 4, 2024

Yeah basically just keep track of whether the button was pressed before and if it isn't any more delay the switch from true to false by however long you wan the presses to last.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants