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

GamePad Mapping #83

Open
hazardlabs opened this issue Oct 23, 2016 · 13 comments
Open

GamePad Mapping #83

hazardlabs opened this issue Oct 23, 2016 · 13 comments

Comments

@hazardlabs
Copy link

Hi there,

I'm attempting to create a custom mapping for a generic game pad (Looks like a PS2 controller, available from Game UK).

In the 'Select Input Devices' window, the game pad is report as 'DragonRise Inc. Generic USB Joystick'.

I then select 'Add Mapping', followed by 'Create Mapping'.

I give the name as a single letter (after the first three times I thought I would speed up the process...).

The next dialog box, titled 'Luna' asks me to 'left stick left'. There is no response from the software and I am unable to progress.

To get past this, I remove the existing controller from the 'Select Input Devices Window' and try again.

The left stick left dialog window now responds to input.

My particular controller does not have a 'special button' so I reuse the select button. After going through the motions, I get a 'Something went wrong' message after all input combinations have been completed. Is this because I am reusing a button for two commands?

The other note is that the delay between each instruction isn't long enough, often I will move 'right stick right' for example, and the system will cycle through a few instructions whilst I have still the right stick right.

If there is anything I can do to help, logs etc, please don't hesitate to ask.

Best Wishes

HL

@hazardlabs
Copy link
Author

As a work around, I am using the 'moonlight -map GamePad.map' command to generate the map file, then using LUNAs interface to select it. Just got some odd behavior to work out (not sure if the map is wrong or something else at present)

@wackerl91 wackerl91 added the bug label Oct 24, 2016
@richiesgr
Copy link

Hi
I'm trying to do it for a PS3 controller
I need to use the map file for the controller you tell using LUNAs interface to select it
How do you make this ?
Thanks

@hazardlabs
Copy link
Author

richiesgr, I used the command:

moonlight map GamePad.map

to create the map file, then pointed luna to it using lunas interface. I did this all whilst in the home directory: cd ~ which made finding the file easy.

You can also use the same map file with two or more controllers.

HL

@richiesgr
Copy link

Hi
Sorry but I can't see how to configure luna with a map file. That's my question
I'm in osmc Luna is working but setting doesn't show any option for entering a map file
Thanks for all

@wackerl91
Copy link
Owner

@richiesgr
In Luna's settings there should be an option called "Select Input Device(s)" under "Input". Selecting this option should bring up another window. In there:

  • add a controller field
  • it comes up as Controller [No] - None (Disabled)
  • selecting None (Disabled) brings up the Select Input Device window
  • selecting any of the available input devices will pass it back to the previous screen and thus enabling this controller
  • you should be able to select the "Add Mapping" button now
  • doing so appends a line beneath the input device where you can either select a previously created mapping file or create one (the latter is pretty bugged right now as pointed out by @hazardlabs, so you might want to stick with his workaround)

@hazardlabs: in the currently released version every controller type (except X360 controllers) calls moonlight as a subprocess. This is more or less unreliable because it sometimes just doesn't do anything at all (as you experienced), which is why the readme points out that this feature is 'sometimes not working' (and why the interface isn't really refined - originally I wanted to prompt using button images, but there's no point in doing so until the feature itself is working reliable).

Either way, thanks a lot for giving a detailed description of both your issue and your workaround and thus helping others. Really appreciate it!

@hazardlabs
Copy link
Author

Always happy to help, if you need any testing further down the line just give me a prod.

HL

@wackerl91
Copy link
Owner

Let's leave this open for reference until it's resolved :)
If there's a test version I'll let you know! Thanks!

@wackerl91 wackerl91 reopened this Nov 4, 2016
@wackerl91
Copy link
Owner

It appears that Kodi is blocking any reads from attached input devices (at least when xboxdrv is used, but I guess this will be the same for any driver).

I've tested this using both the /dev/input/jsX and the /dev/input/eventX devices. Here's the script I've used for eventX (requires python-evdev, installable via sudo pip install evdev):

>>> import evdev
>>> device = evdev.InputDevice('/dev/input/event1')
>>> for event in device.read_loop():
...     print event

xboxdrv is auto-started via rc.local:

xboxdrv --daemon \
	--led 2 --deadzone 4000 --dpad-rotation 90 --axismap -DPAD_X=DPAD_X --trigger-as-button \
	--next-controller \
	--led 3 --deadzone 4000 --dpad-rotation 90 --axismap -DPAD_X=DPAD_X --trigger-as-button &

The behaviour is exactly the same each and every time:

  • after a complete reboot (xboxdrv and Kodi running), the above script shows no output
  • shutting down Kodi (sudo systemctl stop mediacenter) immediately restores functionality in the script (as soon as the process is gone, it starts working - without 're-opening' the device)
  • starting Kodi again (sudo systemctl start mediacenter) causes the script to stop receiving any events
  • funny enough, Kodi only seems to block devices which are known when it starts up: if I kill xboxdrv, restart Kodi and start xboxdrv again after Kodi is fully available, the above script works as long as Kodi isn't restarted

I've found a mention of this behaviour on the OSMC forum:

Kodi indeed blocks input for joypads if it doesn't run on x11.

Question is: how to get around this behaviour? Any time one starts a game, Kodi will restart and thus block the input devices again ...
Just throw away the entire mapping module and provide default mappings for PS3 / XBOX controllers and tell people to make their own if they feel uncomfortable using the provided ones?

@hazardlabs I'd love to hear what you think...

@hazardlabs
Copy link
Author

I'm thinking that proving default mappings would be a good way to go. Most games provide a mechanism to allow the remapping of game controls which would be away around it.

I've only used a PS2 like controller from GAME uk, and previously used x360ce on windows to do my mappings. When you run the x360 mapping application, it tries to search for a user submitted mapping online and apply it.

Could a similar system work for us? Scan the github repo for a matching mapping file, if not found ask the user to create one, and submit the map for others to use? Means less effort for lucky users.

@wackerl91
Copy link
Owner

In general that's a really good idea. Providing default mappings as part of the repo isn't so much of an issue (other than that I only got ones for X360 controllers myself). I wouldn't automate a "push" to the repo from inside Luna though, but rather write a small web service that's automatically checked and where users can upload their own mapping files (possibly including a small vote system to have multiple mappings for the same controller ranked according to their usefulness, similar to how mappings for the Steam controller are distributed).
Hosting could be done on RH cloud (free and slow-ish, but certainly enough) with storage on mLab. Small weekend project :)

In addition to the web service this would also include some changes to Luna's UI, but that's certainly doable.

That being said, I'd like to include some metadata gathering (OS version, Luna's version, ...) while doing this to get a feel for the install base. Explicitly NO personal information (so no IP address, no game lists) other than a generated UID per single installation. This would be transmitted only once after installation or after updating the add-on. That is if there's no objection on your end.

Of course, if an additional web service is the way to go, it'd be open source and publicly available as well.

@mchrbn
Copy link

mchrbn commented Jan 4, 2017

Hey @wackerl91, awesome project you did!

I also had an issue with my Xbox360 controller (not wireless) not being mapped correctly. The workarounds above didn't work for me so I ended up doing the following thing and it works. Just posting it here in case someone is in the same case as me.

  1. Installed xboxdrv via sudo apt-get install xboxdrv

  2. sudo xboxdrv --detach-kernel-driver --buttonmap du=dl,dl=du,dd=dr,dr=dd,x=y,y=x --silent

Where the arguments after --buttonmap are the correct mapping (for my controller). More info about these names on http://manpages.ubuntu.com/manpages/precise/man1/xboxdrv.1.html

  1. Add this command to /etc/rc.local to start this instance on boot

@wackerl91
Copy link
Owner

@mchrbn
Well, that's another way to handle mapping issues ;) The D-pad mappings should have pretty much the same effect as --dpad-rotation 90 if I'm not confused? Might make this snippet a bit less easier to read / adapt.

That being said, you don't need to include sudo when adding the command to rc.local (that's always executed as root) and --detach-kernel-driver is obviously only needed if the xpad kernel module is still loaded - just in case anyone's wondering.

Thanks for providing others with an alternative and working solution, greatly appreciate that!

@wackerl91
Copy link
Owner

Looks like custom mapping files aren't needed anymore since moonlight-embedded 2.4, see #152 for more details.

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

4 participants