Input and games.

Todd Showalter todd at electronjump.com
Wed Apr 24 08:28:34 PDT 2013


On Wed, Apr 24, 2013 at 11:03 AM, Jason Ekstrand <jason at jlekstrand.net> wrote:

> I realize that my little Android project shouldn't be the sole driver of
> protocol decisions, but I don't think that is the only case where game
> controller events would come from something that's not evdev.  As another
> example, people have talked about Wayland on FreeBSD; how does FreeBSD
> handle game controllers?  Can we assume that some sort of evdev fd passing
> will work there and on Linux in any sort of reasonable way?

    I haven't run FreeBSD for a while, but my memory of how game
controllers were handled is that it was not far removed from just
throwing the USB packets at the client and letting the client figure
it out.  Hopefully it has improved.

    The core of my argument here is that there should be a standard
gamepad coming through the event system, much like the standard mouse
does.  The standard gamepad would be:

- left analog stick
- right analog stick
- left analog trigger
- right analog trigger
- dpad
- home button (ps3 ps, xbox glowy x, wii home)
- start button
- left shoulder button
- right shoulder button
- face top button (ps3 triangle, xbox Y)
- face left button (ps3 square, xbox X)
- face right button (ps3 circle, xbox B)
- face bottom button (ps3 x, xbox A)

    An actual gamepad could generate more events than this (xbox has a
back button, ps3 has a select button, ps3 also has accelerometers...),
and some stripped down gamepads might not be able to produce all
events (no analog triggers, perhaps, or no home button), but what the
gamepad has that matches the spec should produce the standard events.

    As a game I want to be able to say: "oh, a gamepad, ABS_X and
ABS_Y are the stick, BTN_FACE_SOUTH is jump, BTN_FACE_EAST is shoot,
and BTN_START brings up the pause menu".  I don't want to have to
dlopen("libGameTrans.so", RTLD_NOW), then call a function to march the
event list looking for supported gamepads, then call functions to hook
up translation layers and so forth.  We don't make clients do this for
mice, they shouldn't have to for gamepads.

    We're into the weeds on evdev a bit because that's what happens to
be producing these events on Linux, but my ultimate concern is what a
client has to do in order to use a gamepad in the Wayland world.  I
would like that process to be as sane and trouble-free as possible,
regardless of what Wayland is sitting on top of.  So, I would prefer
things to Just Work on your project as well.

                                       Todd.

--
 Todd Showalter, President,
 Electron Jump Games, Inc.


More information about the wayland-devel mailing list