Dolphin, the GameCube and Wii emulator - Forums

Full Version: [PATCH] X11 XInput 2.0 support on Linux (including Multi-Pointer X!)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Max-E

Hello all, first time poster, and first time patch submitter. Smile

First, I should clarify that this has NOTHING to do with the XInput API on Windows, and is only of interest to Linux (and possibly BSD) users. This is about adding support for the X11 XInput extension, version 2.0. A little backstory: X11's original input system wasn't good enough, so the X.Org developers added an extension, XInput. Version 2.0 of that extension added a lot of really cool stuff, including Multi-Pointer X (MPX). MPX is awesome because you can have multiple mouse pointers at once, and configure which hardware keyboards and mice are associated with each. That way, multiple people can use the same computer for different tasks without interfering with each other. This video shows what I mean:
https://www.youtube.com/watch?v=GhzXsEYqXig

Since most Linux distros have had XInput2 for about three years now, it's mature and ubiquitous to really start using. And since I don't have any gamepads but may still wish to play with friends, I figured adding it to Dolphin would be a good candidate for using it.

Here's how you set it up:
  • Before you launch Dolphin, you have to set up all the pointers and associate the desired keyboards and mice with each one. This may be done from the command line as described here, or using the xinput-ui GUI utility I wrote, which has its own GitHub page. Unfortunately, there is no way to save your setup permanently (X.org does not have that feature,) so you have to create it again if you reboot your computer.
  • Then, in Dolphin you use the Xinput2 input devices that show up. They will be called Xinput2//<name> where <name> is the name you gave the pointer in step 1. For example, the default pointer, which is created automatically by X11 and has all your hardware devices by default, is called "Virtual core pointer". So to refer to that one, you would select "Xinput2//Virtual core pointer" as the input device in Dolphin.

This screenshot shows it in action. Two people can play the same game using only keyboards and mice:
[Image: 1vm.th.png]
Pardon the huge screenshot, I've got a big dual-monitor setup. As you can see, all the laptop's built-in input devices are available to player 1, while I've created a pointer for player 2 with the external keyboard and Razer DeathAdder mouse. The screenshot doesn't show it, but player 2 has exactly the same bindings, except that the selected input device is "Xinput2//Player 2 pointer". This does not cause any conflict because the keyboards are truly separate.

(Another cool feature is that it's now possible to have axis controls on Linux, which previously were only available on Windows. Not sure if they behave identically to the Windows ones, though.)

What I'm looking for is:
  • Relatively tech-savvy Linux users willing to test this code.
  • Developers to look over the code and make sure it complies to any coding style requirements for the Dolphin codebase. Also, I don't really know CMake, so my changes to the CMake files would be a good thing for someone more experienced to double-check.
  • Any constructive criticism.

If you're interested in trying my code out, you have two options:
  • Recommended: pull the xorg_xinput2 branch from my GitHub fork (https://github.com/Max-E/dolphin-emu/tree/xorg_xinput2)
    Code:
    git pull https://github.com/Max-E/dolphin-emu.git xorg_xinput2
    git checkout xorg_xinput2
  • Not recommended: Download the patch series I've attached to this thread and apply them one by one with "git am."

Then, make sure you've got the correct branch checked out:
Code:
maxtothemax@maxtothemax-mint ~/src/dolphin-emu $ git branch
  master
  tev_fixes
* xorg_xinput2
maxtothemax@maxtothemax-mint ~/src/dolphin-emu $
Then, re-run CMake and compile Dolphin as normal. Select "Xinput2//Virtual core pointer" instead of "Xlib/0/Keyboard Mouse" in GCPad Configuration, and test. Dolphin should work identically. Then, you can create a new pointer and move some devices over to it, and test a splitscreen game.

Cheers,
-Max Eliaser
Cool! I'll try to take some time to review that patch today or tomorrow.