Gamepad focus model (Re: Input and games.)
Rick Yorgason
rick at firefang.com
Fri May 10 03:34:32 PDT 2013
Pekka Paalanen <ppaalanen at ...> writes:
> Also, allowing multiple gamepads in one seat does not exclude the seat
> approach. A server could still assign every gamepad to a different
> seat, provided it had some way to solve the focus assignment.
Unfortunately, that comes at the expense of requiring clients to support two
code paths. For better or worse, a lot of game developers prefer to write
close to the metal, so if their compositor of choice prefers one method,
there's a very real chance that the game developer will forget to support
the other method.
> > is the player ID not better represented through a wl_seat? - if you're
> > playing a full-screen game, both seats can safely have the same focus,
> > otherwise, players can play games independently.
> > plus, if both players have a separate seat, they can use their keyboard
> > independently for data entry.
>
> Those were exactly my thoughts in the beginning, however during the way
> long email thread, I got convinced otherwise for now. There are a few
> issues that come mind:
> - how to know, when one seat should follow the keyboard(?) focus of
> another seat?
> - a client still needs to map seats into players; how? does it need an
> UI to fix it in case a user is not happy with the result?
You would definitely need a UI for corner cases and advanced users, but I
think you could design a heuristic that's good enough for games most of the
time. Here's an example heuristic:
A) Whenever a keyboard or mouse is plugged into the system, it gets added to
the first seat.
B) Whenever a gamepad is plugged into the system, it gets added to the first
seat without a gamepad. If all the seats already have a gamepad assigned, a
new seat is automatically created.
C) If a user explicitly creates a seat, that seat gets full access to the
desktop by default, including their own desktop-level cursor. (I call this
"collaboration" below.)
D) If the compositor has to automatically create a new seat to deal with a
new gamepad, that seat has collaboration turned off, and follows the first
seat's focus.
E) If a keyboard, mouse, or touch screen is attached or plugged into the
gamepad, it goes in the same seat as the gamepad. This does not override rule D.
F) There must always be at least one seat.
G) At least one seat must be in collaborative mode.
I've put together an example scenario below. Excuse the ASCII art :)
-Rick-
1) The users plug two keyboards and two mice into the computer. They all get
assigned to seat 1.
2) The users open a seat configuration dialogue. They see this:
Seat 1 [Configure] [Renumber]
[Add a new seat]
3) They click "Configure". They see this:
Seat 1
------
Choose the devices you want in this seat:
[X] Keyboard 1
[X] Keyboard 2
[X] Mouse 1
[X] Mouse 2
[X] This seat can collaboratively share the desktop (disabled)
Derive focus from [N/A] (disabled)
4) They go back and click "Add a new seat". They see this:
Seat 2
------
Choose the devices you want in this seat:
[ ] Keyboard 1
[ ] Keyboard 2
[ ] Mouse 1
[ ] Mouse 2
[X] This seat can collaboratively share the desktop
(disabled) Derive focus from [Seat 1]
5) They reconfigure it like so:
Seat 2
------
Choose the devices you want in this seat:
[ ] Keyboard 1
[X] Keyboard 2
[ ] Mouse 1
[X] Mouse 2
[X] This seat can collaboratively share the desktop
Derive focus from [N/A] (disabled)
6) This automatically removes Keyboard 2 and Mouse 2 from Seat 1. It also
un-disables the "collaborative" line. If they go back to Seat 1's
configuration screen, they'll see this:
Seat 1
------
Choose the devices you want in this seat:
[X] Keyboard 1
[ ] Keyboard 2
[X] Mouse 1
[ ] Mouse 2
[X] This seat can collaboratively share the desktop
Derive focus from [N/A] (disabled)
7) They plug a gamepad into the computer. It automatically gets assigned to
seat 1:
Seat 1
------
Choose the devices you want in this seat:
[X] Keyboard 1
[ ] Keyboard 2
[X] Mouse 1
[ ] Mouse 2
[X] Gamepad 1
[X] This seat can collaboratively share the desktop
Derive focus from [N/A] (disabled)
8) They plug another gamepad into the computer. It automatically gets
assigned to seat 2:
Seat 2
------
Choose the devices you want in this seat:
[ ] Keyboard 1
[X] Keyboard 2
[ ] Mouse 1
[X] Mouse 2
[ ] Gamepad 1
[X] Gamepad 2
[X] This seat can collaboratively share the desktop
Derive focus from [N/A] (disabled)
9) They plug a third gamepad into the computer. The compositor automatically
creates a seat with collaboration turned off. The seat list now looks like this:
Seat 1 [Configure] [Renumber] [Delete]
Seat 2 [Configure] [Renumber] [Delete]
Seat 3 [Configure] [Renumber] [Delete]
[Add a new seat]
10) They configure seat 3, and see this:
Seat 3
------
Choose the devices you want in this seat:
[ ] Keyboard 1
[ ] Keyboard 2
[ ] Mouse 1
[ ] Mouse 2
[ ] Gamepad 1
[ ] Gamepad 2
[X] Gamepad 3
[ ] This seat can collaboratively share the desktop
Derive focus from [Seat 1]
11) The users decide that player 3 should follow player 2's focus, so they
reconfigure it:
Seat 3
------
Choose the devices you want in this seat:
[ ] Keyboard 1
[ ] Keyboard 2
[ ] Mouse 1
[ ] Mouse 2
[ ] Gamepad 1
[ ] Gamepad 2
[X] Gamepad 3
[ ] This seat can collaboratively share the desktop
Derive focus from [Seat 2]
12) They go back and delete seat 1. Seat 2 can no longer be deleted, since
it's the only collaborative seat:
Seat 2 [Configure] [Renumber]
Seat 3 [Configure] [Renumber] [Delete]
[Add a new seat]
13) They renumber seat 2 to be seat 1. Player 2 is now player 1:
Seat 1 [Configure] [Renumber]
Seat 3 [Configure] [Renumber] [Delete]
[Add a new seat]
14) Looking at seat 1, we see it's still connected to the same devices as
when it was seat 2:
Seat 1
------
Choose the devices you want in this seat:
[ ] Keyboard 1
[X] Keyboard 2
[ ] Mouse 1
[X] Mouse 2
[ ] Gamepad 1
[X] Gamepad 2
[X] This seat can collaboratively share the desktop (disabled)
Derive focus from [N/A] (disabled)
15) They add a new seat. It automatically gets put in slot 2:
Seat 1 [Configure] [Renumber] [Delete]
Seat 2 [Configure] [Renumber] [Delete]
Seat 3 [Configure] [Renumber] [Delete]
[Add a new seat]
More information about the wayland-devel
mailing list