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

Add per-Viewport InputEvent device masking #1249

Open
rjkilpatrick opened this issue Jul 24, 2020 · 3 comments
Open

Add per-Viewport InputEvent device masking #1249

rjkilpatrick opened this issue Jul 24, 2020 · 3 comments

Comments

@rjkilpatrick
Copy link

Describe the project you are working on:
Split-screen FPS with support for 8 concurrent players split-screen, with up to 8 game controllers at once.

Describe the problem or limitation you are having in your project:
Currently, I have actions in the Input Map corresponding to each game controller incredibly verbosely, e.g. forward_1.
This is hard to maintain and leads to duplicated input map for each player character.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
I propose, one action that triggers across all devices which can be masked per Device, as in the current Input Map.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
Under the current Viewport/Gui settings, there could be added something equivalent to the current rendering targets bit-masking for each physical device.
Bitmasking for collision layers

If this enhancement will not be used often, can it be worked around with a few lines of script?:
It could ben an autoload with a script similar to https://kidscancode.org/blog/2018/07/godot3_splitscreen/ with an export var for the id and string interpolation on the Input.is_action_pressed("forward_%s") in combination with populating the Input Map with code, but in editor would be preferable for consistency with other projects and helping contributors understand where code is located.

Is there a reason why this should be core and not an add-on in the asset library?:
Viewport in editor settings are core.

@Calinou Calinou changed the title Add inputEvent device masking per Viewport Add per-Viewport InputEvent device masking Jul 24, 2020
@cgbeutler
Copy link

cgbeutler commented Oct 8, 2021

Yeah, I think they built actions to be emitted to the input callbacks of the tree, not really for polling.

There may be a more general proposal hiding in this one somewhere?

The InputEventAction object passed to the tree's input methods does have a Device field that gets set. The one gotcha that I know of there is that the device id reported is not unique across all devices. If you have Device of 0, that could be a Keyboard, Mouse, or Joypad, so you may have to make those action names unique or something...

Maybe each device could be given a truly unique id, then you could maybe have a call like Input.get_devices_with_pressed_action("forward") that returns a list? or maybe Input.is_action_pressed("forward", uniqueDeviceId)

Anyway, food for thought.

@Sauermann
Copy link

Sauermann commented Jun 30, 2023

The Physical device-Bitmask seems too narrow a solution for the problem, that users want to filter events to be sent to SubViewports on other criteria.

In godotengine/godot#78762 I propose a more general solution to this problem.
That PR introduces a SubViewportContainer-function, that users can overwrite and specify, which events should be sent to the SubViewport.
So for example, you could filter for a Viewport A only those InputEvents, that have a device id 5 and for a Viewport B only those, that have a device id 6.

@djpeach
Copy link

djpeach commented Aug 3, 2023

To confirm, Sauermann's implementation (split into #78762 and #79480) allows nested input layers/screens without losing focus, local splitscreen menu's, and really whatever the dev wants to do.

Demo

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

No branches or pull requests

5 participants