<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Apr 24, 2013 at 9:41 AM, Todd Showalter <span dir="ltr"><<a href="mailto:todd@electronjump.com" target="_blank">todd@electronjump.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Wed, Apr 24, 2013 at 2:26 AM, David Herrmann <<a href="mailto:dh.herrmann@gmail.com">dh.herrmann@gmail.com</a>> wrote:<br>
<br>
> That's a known problem that isn't easy to fix. Of course, we can<br>
> adjust the kernel driver, but this breaks applications that expect the<br>
> current behavior. The problem I see is that we never paid enough<br>
> attention how keys are mapped when adding kernel drivers and now we<br>
> have a mess of different mappings that cannot be fixed. You can try to<br>
> send patches to <a href="mailto:linux-input@vger.kernel.org">linux-input@vger.kernel.org</a>, but chances are low that<br>
> they will get merged.<br>
<br>
</div> In the particular case of the ps3 controller, I have trouble<br>
believing anything is depending on the current behaviour, at least as<br>
I see it. I haven't tried to use the data, but the button and axis<br>
mappings just look wrong. The right stick is coming in as (ABS_Z,<br>
ABS_RZ), which is how the left and right shoulder triggers are mapped<br>
on the xbox controller. The buttons have names like DEAD and "(?)",<br>
the latter of which looks to be evtest's name lookup failure string.<br>
<br>
The more general problem, though, is that it means we have to<br>
treat every gamepad as unique, when they should be as ubiquitous and<br>
generic as mice.<br>
<br>
Sitting next to me here is a Kensington Slimblade trackball. It's<br>
my "mouse". It has two axis control like a mouse, four buttons,<br>
pretends to have a scroll wheel (rotating the ball around the z axis<br>
clockwise or counterclockwise sends mouse wheel clicks), and generally<br>
works.<br>
<br>
The top two buttons on it are mapped totally wrong on the wire<br>
when it talks over USB. Rather than coming in as buttons 2 and 3, the<br>
stupid thing sets flags in an option field in the USB data packets.<br>
There's a quirk in the kernel driver to remap them to BTN_MIDDLE and<br>
BTN_SIDE, so as far as anything reading the evdev stream is concerned,<br>
it's just a mouse like any other, with four buttons and a wheel.<br>
<br>
I can't do that with gamepads. I should be able to. The core<br>
idea of a gamepad (two sticks, two analog shoulder triggers, a dpad, a<br>
"home" button, a "start" button, two shoulder buttons, four face<br>
buttons opposite the dpad, and click on the two sticks) is universal<br>
enough at this point that it ought to be considered a basic system<br>
abstraction, like the core idea of a mouse.<br>
<div class="im"><br>
> Nevertheless, the problem is actually easy to fix in userspace. You<br>
> just need to create buttons mappings for the different devices. There<br>
> is no complex logic involved. It would be enough to have a bunch of<br>
> static tables indexed by input-device names which map the input<br>
> keycode to the correct/expected output keycode.<br>
<br>
</div> "easy to fix in userspace" rather ignores the deployment problem,<br>
and it also ignores the disconnect between the people adding hardware<br>
support and the people mapping it to something useful.<br>
<br>
If they can't just be fixed in place, what I'd much rather see is<br>
one of two fixes:<br>
<br>
a) an ioctl() or some similar knob I can frob to say "deliver events<br>
in canonical form, please"<br>
<br>
b) have gampads produce *two* /dev/input/eventX entries, one for<br>
"Microsoft X-Box 360 pad" or whatever, and the other for "system<br>
gamepad"; deliver events in the current form over the named device,<br>
and in canonical form over the "system gamepad" device<br>
<br>
Of the two solutions, I prefer the latter; it means I can walk<br>
down the list looking for "system gamepad" and only open those, but<br>
know that I'll get data I don't have to massage. It also means that<br>
as soon as the kernel supports a new bit of hardware, it will Just<br>
Work. We won't have to deal with keeping an external library in sync.<br>
We won't have to try to examine the output of EVIOCGNAME() and try to<br>
figure out if this is one of the devices we support. We won't fail to<br>
use an XBox 360 controller just because the device string said<br>
"MadCatz" instead of "Microsoft" and we'd never seen one of those in<br>
the wild and hadn't added it to our list of acceptable device name<br>
strings. Or because we were using vendor IDs and didn't have that<br>
vendor ID on our list.<br>
<br>
I think Linux actually has a decent shot in the next five years of<br>
becoming the OS for living room game and streaming media PCs (heck,<br>
we've got Valve sort-of onside, Microsoft's sitting unloved in the<br>
win8 pit, and Apple has been heading in the direction of more<br>
iOS/portable, not sit-down computing), but if it's going to happen<br>
then things like gamepads need to Just Work. If we're at a place<br>
where the FAQ is telling people that in order to support their new<br>
Logitech MustThraster JoyBanger they need to pull version 0.19.7-r3 or<br>
later of libGamepadTrans.so from github, it all goes pear-shaped for<br>
most people fast.<br>
<div class="im"><br>
> But I cannot see a reason why a compositor should do this, though.<br>
> This can be easily put into a library and every game that needs it<br>
> performs the mappings. Table-mappings add a single memory-read which<br>
> shouldn't affect performance and clients can share the library.<br>
> The compositor isn't interested in joystick/gamepad events so my first<br>
> approach would be to let clients handle them.<br>
<br>
</div> I don't think the clients should be dealing with this, and neither<br>
should the compositor. The data should be in useful format at its<br>
source. If the source is producing hardware-specific data then it<br>
needs to be fixed as close to the source as is practically possible.<br>
Every layer the data travels through in the wrong format multiplies<br>
the amount of work that ultimately needs to be done to fix it. Rather<br>
than having it remapped at its source, we're talking about every<br>
client that wants to work with the data having to load and use<br>
translation libraries to unfuck the events, and those translation<br>
libraries need to have a complete mirror of the kernel code so they<br>
know what they need to do in order to do the unfucking on a<br>
per-hardware-device basis. That's clearly the most complex and<br>
error-prone way we could possibly tackle the problem.<br>
<br>
If we can't get good data from the kernel, the we should massage<br>
it before it gets handed to clients. Amongst other things, that<br>
prevents the input translation layer from being embedded in the<br>
clients and becoming yet another bit of legacy that can't be broken<br>
even though it's making everything more complex. When we start<br>
getting sane input from the kernel, the translation layer can come out<br>
of Wayland/Weston, and the clients won't need to know. Nothing will<br>
break.<br>
<div class="im"><br>
> Input device detection is a mess. The kernel provides EV_* flags for<br>
> each device, but doesn't tell us what kind of device that is. It makes<br>
> it really hard to distinguish device classes. udev tries to do that,<br>
> but it never worked as well as we hoped. A solution would be to add<br>
> input PROP_* flags for device classes to the kernel and read these<br>
> from user-space.<br>
><br>
> So what I am trying to say is: you cannot rely on ABS_X to mean the<br>
> same for every device. It might be an accelerometer or a touchpad or a<br>
> touchscreen, ... A PROP_KEYBOARD, PROP_ACCELEROMETER, PROP_GAMEPAD,<br>
> ... property would help to distinguish the different device classes.<br>
> In each class, the different flags should mean the same.<br>
<br>
</div> This is what brought me here in the first place. Linux is mostly<br>
actually a pretty good environment for game development, but there are<br>
a couple of really grim areas, and this is one of them (the other is<br>
sound, with opengl support as a quickly improving third). Right now,<br>
to use gamepads on Linux, you either need to use libjsw and have a<br>
priori knowledge of what hardware is plugged in, or use evdev with<br>
root permissions and have a priori knowledge about how different<br>
gamepads map their controls.<br>
<br>
A translation library just cans a snapshot of that a priori<br>
knowledge, adds one more system dependency the user and developer have<br>
to care about, and one more thing that might go wrong.<br>
<div class="im"><br>
> I'm currently looking into an interface that provides file-descriptors<br>
> for wl_keyboard/wl_mouse for clients. The FDs are muted (EVIOCMUTE<br>
> proposed on linux-input by krh) while clients are inactive and unmuted<br>
> when they get input focus. This is basically a performance boost<br>
> because input events no longer pass through the compositor.<br>
> However, this mechanism could be easily used to forward any other<br>
> input fd to clients. A wl_gamepad interface could be just empty except<br>
> for this FD-passing logic.<br>
<br>
</div> Being able to talk to the gamepads through evdev without elevated<br>
permissions would definitely be a step forward.<br></blockquote><div><br></div><div>Hi all,<br></div><div>I hope you'll allow me to chip in just a bit here. As a disclaimer, I haven't read the entire thread but I think I have a decent idea of what's gone on.<br>
<br></div><div>Personally, I would like to see some sort of a wl_joypad interface that isn't just an FD passthrough. Sure, it will probably be optional and clients shouldn't assume it, but I think it would still be good to have it there. Part of the reason is that, as of now, the wayland protocol isn't terribly restricted to standard Linux and I would like to avoid things that require Linux underneath such a an FD that's expected to be a Linux evdev. There are a couple of reasons for this.<br>
<br></div><div>One reason is if we want to do network forwarding. Now, instead of simply providing a forwarded version of the wl_joypad we have to forward the evdev and possibly do some translation of the stream in order to make everthing happy (I'm not sure what all this would involve). If the client expects to be able to do any ioctls on said stream things would get particularly interesting.<br>
<br></div><div>Second is that events may not come directly from the kernel. Once my Android compositor app gets beyond just displaying the simple-shm client, I'm going to want to forward input events including mouse, touch, virtual keyboard, USB keyboard, and gamepad events. The problem is that NONE of those events come from evdev. They all come from the Android event system and need to be translated into something useful.<br>
<br></div><div>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?<br>
<br></div><div>Anyhow, there's my 2 cents worth.<br></div><div>--Jason Ekstrand<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im HOEnZb"><br>
Todd.<br>
<br>
--<br>
Todd Showalter, President,<br>
Electron Jump Games, Inc.<br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</div></div></blockquote></div><br></div></div>