[HowTo] Moonlight-Embedded (former Limelight) using Luna Launcher

exxe,
You were right… there is a conf file and it had the following item which was the obvious culprit:

address = 192.168.1.2

I deleted the conf file and now the streaming portion stars fine.

What is your recommendation on how to setup a wireless controller? I have a PC wireless XB360 controller and PS3/PS4 controllers (blutooth). I followed the setup instructions on how to the XB360 controller running using xboxdrv but it never ran properly. If the controller is not on when the RPi is booted it doesn’t work, and even then right now I can only add it to the LUNA config, but it doesn’t do anything in game or on Steam. The “add mapping” option cannot be selected in LUNA which I was hoping would solve the mapping issues i experienced when messing with it in the past. I tried selecting the “custom input” option on one of the other screens but it did not have an effect as far as I was able to tell.

Here’s what cat /proc/bus/input/devices looks like:

    I: Bus=0003 Vendor=1915 Product=0145 Version=0110
    N: Name="MemsArt MA144 RF Controller"
    P: Phys=usb-3f980000.usb-1.5/input0
    S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.0/0003:1915:0145.0001/input/input0
    U: Uniq=
    H: Handlers=sysrq kbd leds event0
    B: PROP=0
    B: EV=120013
    B: KEY=7 ff800000 7ff e0b2ffdf 1cfffff ffffffff fffffffe
    B: MSC=10
    B: LED=1f

    I: Bus=0003 Vendor=1915 Product=0145 Version=0110
    N: Name="MemsArt MA144 RF Controller"
    P: Phys=usb-3f980000.usb-1.5/input1
    S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.1/0003:1915:0145.0002/input/input1
    U: Uniq=
    H: Handlers=mouse0 event1
    B: PROP=0
    B: EV=17
    B: KEY=70000 0 0 0 0 0 0 0 0
    B: REL=103
    B: MSC=10

    I: Bus=0003 Vendor=1915 Product=0145 Version=0110
    N: Name="MemsArt MA144 RF Controller"
    P: Phys=usb-3f980000.usb-1.5/input2
    S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.5/1-1.5:1.2/0003:1915:0145.0003/input/input2
    U: Uniq=
    H: Handlers=kbd event2
    B: PROP=0
    B: EV=1f
    B: KEY=3007f 0 0 0 0 4c3ffff 17aff32d bf544446 0 0 1 130f93 8b17c000 677bfa d951dfed 9ed680 4400 0 10000002
    B: REL=40
    B: ABS=1 0
    B: MSC=10

    I: Bus=0003 Vendor=20a0 Product=0001 Version=0101
    N: Name="flirc.tv flirc"
    P: Phys=usb-3f980000.usb-1.4/input0
    S: Sysfs=/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/0003:20A0:0001.0005/input/input3
    U: Uniq=
    H: Handlers=sysrq kbd event3
    B: PROP=0
    B: EV=10001f
    B: KEY=3007f 0 0 0 0 483ffff 17aff32d bf544446 0 0 1 130c13 b17c000 267bfa d941dfed e09effdf 1cfffff ffffffff fffffffe
    B: REL=40
    B: ABS=1 0
    B: MSC=10

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="lircd"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input4
    U: Uniq=
    H: Handlers=sysrq kbd rfkill event4
    B: PROP=0
    B: EV=100003
    B: KEY=1fff 7fe001f ffff000f 3ffffff ffffffff ffffffff 0 0 0 7fffff ffffff07 ffffffff ffffffff ffffffff ffefffff ffffffff fffffffe

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name="Microsoft Xbox 360 Wireless Controller (PC)"
    P: Phys=
    S: Sysfs=/devices/virtual/input/input6
    U: Uniq=
    H: Handlers=kbd mouse1 event5
    B: PROP=0
    B: EV=f
    B: KEY=10000000 30000 0 0 0 0 1680 0 2006040 10807002
    B: REL=3
    B: ABS=3003c

Thanks so much for your help. If you have a paypal/donation box let me know cause I owe you a beer.

The ‘Add Mapping’ is only available if the device isn’t a KB / mouse. Unfortunately, the check is based on the assumption that all gamepads will have a ‘jsX’ handler, which is obviously wrong when looking at your devices.
Originally this behaviour was designed to prevent users from adding mapping files to their keyboards by accident. On the other hand it has caused so many problems by now that I might just remove the KB / mouse check, I guess no one will actually attempt to add a map to their keyboard (or at least I hope … ).

On the matter of the ‘custom input’ option: yes, that does something and needs to be enabled if you’re using the controller configuration - otherwise the configuration is discarded (i.e. not passed to moonlight).

If you should have issues with creating a mapping (especially for cases such as a ‘rotated’ D-pad) this comment is a pretty good starting point (plus the way he’s starting xboxdrv you don’t need to remove the xpad kernel module manually, which can often be a culprit).

My own ‘old’ way (before I used multiple controllers) of starting xboxdrv was:
xboxdrv --trigger-as-button --wid 0 --led 2 --deadzone 4000 --dpad-rotation 90 --axismap -DPAD_X=DPAD_X --silent &
If xpad is loaded on your system (you can check that with the lsmod command which lists all loaded kernel modules), either use the --detach-kernel-driver flag for xboxdrv as in the comment linked above or disable it using rmmod xpad.
Note: unloading xpad (if it’s even loaded) might also solve the issue with the ‘add mapping’ button being greyed out, as my controllers show up as Xbox Gamepad (userspace driver) with eventX and jsX being the only handlers using xboxdrv and not as Microsoft Xbox 360 Wireless Controller (PC) … when using xpad, they show up as Xbox 360 Wireless Receiver.

Hi exxe,
I used the lsmod command to check and xpad is not loaded.

I SSH’ed into my rPi and ran xboxdrv and the response was perfect when I moved the joysticks and clicked the buttons (aside from the deadzone being really bad). I assume that since everything works properly, I do not have to use a map file?

I added the xboxdrv command to the /etc/rc.local file and rebooted the rPi.

I know that the command started because the LED on the controller lit up properly. I also selected "Xbox Gamepad (userspace driver) in the Controller Configuration in LUNA however the gamepad does not work when I stream any of the titles that I tried, including just Steam. Do I have to have a map file loaded? Here’s the relevant info from the /proc/bus/input/devices since it changed because I unplugged the xbox keypad from it (I didn’t want that interfering with trying to get this setup):

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="Xbox Gamepad (userspace driver)"
P: Phys=
S: Sysfs=/devices/virtual/input/input6
U: Uniq=
H: Handlers=js0 event5
B: PROP=0
B: EV=b
B: KEY=7cdb0000 0 0 0 0 0 0 0 0 0
B: ABS=3061b

Sorry to keep asking you for help but I’m puzzled why the controller is not responding in moonlight while working from the command line.

ps: The “Create Mapping” option under LUNA Controller Configuration just allows me to enter a filename, but doesn’t seem to do anything after that point (just goes back to the “Add Controller” screen.

I’m sorry for my late answer, have been pretty busy during the last week.

Yeah, that’s pretty broken right now and will most likely be removed / replaced sooner or later. See this issue for details and the discussion on where this might be going in the future - feel free to chime in.

To be honest I’ve never tried this without a map file (btw, if you can’t create one I can send you my own via PN, it’s a fairly standard one), but I’ll try to test this tonight.
Your controller should be listed in Luna’s config file though, so that’s something you might want to check on your end.

That’s so not an issue :slight_smile: I’m always glad to help and it shows that some parts need to change to be more user friendly (and that I might need a proper user guide at some point). So it’s not only you asking for help but also providing feedback, which in the end is great!

Hi exxe,
So it turns out that the major reason why I’ve been having issues setting up the Xbox controller was hardware related. I ended up using the procedure here to setup the controller for use with OSMC:

The reason for going this route was because:

a) I thought it would be nice to be able to use the xbox controller in OSMC (and it is!)
b) It would remove the additional LUNA/moonlight complexities until I got the controller business sorted out.

The controller would work in some instances but often it would not and I was seeing USB communication errors. I noticed another person toward the end of that thread had something similar happen due to power issues. So I went to work and tried a number of different power supplies without success (the one I’m using is rated at 2A but who knows). I then tried 2 different powered USB hubs (also no effect). FINALLY the last one that I had was a 4-port hub with double male USB connections. It takes up 2 of the rPi’s ports BUT IT WORKS!

Anyway I’m really liking that I can control OSMC with the Xbox controller but it’s creating an issue with trying to set the controller up with LUNA/moonlight, this being, that the controller does not show up as a joystick:

osmc@osmc:~$ cat /proc/bus/input/devices
.....
I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="Microsoft Xbox 360 Wireless Controller (PC)"
P: Phys=
S: Sysfs=/devices/virtual/input/input3
U: Uniq=
H: Handlers=kbd mouse0 event2
B: PROP=0
B: EV=f
B: KEY=10000000 30000 0 0 0 0 1680 0 2006040 10807002
B: REL=3
B: ABS=3003c

This is why I think I’m not getting any output when I try to create a map file with:

osmc@osmc:~$ sudo moonlight map -input /dev/input/event2 xbox.map
Moonlight Embedded 2.2.2 (EMBEDDED;PI)
Move Left Stick Right
^X^CMove Left Stick Up

Is there a (hopefully relatively simple) solution for this? Preferably where I could still keep the xbox controller functionality in OSMC - or do I need to give that up if I want to use the controller with LUNA/moonlight?

In short: I can remove the restriction in Luna so you’re able to select your controller and select a map file (which is then passed to moonlight). Moonlight obviously doesn’t use the map file you created for Kodi.

Creating a map file from moonlight has the same restriction as Luna itself - Kodi locks all input devices, making both programs unable to catch any input events. You’ll have to completly shut down Kodi and then use moonlight’s map command.

I’ll see to it that you’ll have access to a patched version of Luna so you’re able to select a map file from within the add-on.

exxe,
Thank you once again. If I have to shut down Kodi every time I want to use the xbox controller in LUNA/moonlight then I’d rather give up the controller’s functionality in OSMC. If I understood you correctly that is.

I think I can already select the controller in LUNA, just no map file (since I wasn’t able to create one yet as per my last post)… you may have already lifted that restriction? Regardless, it sounds like I need to go back and modify the configuration file with what Toast posted way at the top of this thread. At least I’m making progress! :wink:

First of all, I’m sorry - really couldn’t make it last night, way too tired :slight_smile: But here it is!

Just to clear up some misunderstandings (it may have been poorly worded in my last post):

  • Kodi is shut down every time you launch a game from Luna anyway and restarted after the stream is exited (that’s the only way this works, apart from rendering through Kodi, as we can’t “hide” or minimise Kodi on the rPi for technical reasons)
  • You can’t map a controller if Kodi has been started after xboxdrv (as outlined here; be aware that this post is purely educational, no need to follow any steps). Sadly, as Kodi is restarted after streaming a game, any other possible solution (such as making xboxdrv a service which depends on Kodi to force a launch after it) won’t work reliably.
  • The above basically means: shut down Kodi from command line, create your map file for Luna / moonlight using moonlight’s CLI, restart Kodi manually. That’s a minor inconvenience, but one doesn’t create that file over and over again, right? Or just use one you found on the web / mine, copy it to your device and select it in Luna.
  • I believe you can have both working (using the controller in Kodi and have it working properly when streaming games), it’s just a) a configuration issue and b) I was blocking you from doing so before.

Nope, it’s only been lifted in the release linked above. It’s the combination of being able to select a controller (has always worked with every device) and assigning a map file (hasn’t been working for any device recognised as either a keyboard or a mouse). You can now assign map files to any input device (including keyboards / mice) … this is just a preliminary fix for now, as the entire UI needs some rework and I still want to include a service (as proposed by hazardlabs here to load matching map files (if there are any) and allow users to upload their own files for either unknown controllers or different mappings for known controllers.

Thanks for the clarification exxe,
I will try as you suggested though I have a feeling the controller won’t work in both OSMC and moonlight due to the difference in the configuration files (not maps) that are used when xboxdrv is started, that is the start.sh for OSMC and the xbox.ini/xbox.sh for moonlight. I’ll give it a shot anyway next chance I get.

Regards

I’ll try to find some time to mess with this myself. I wasn’t (fully) aware of all the scripts involved, as I never bothered to use a controller for OSMC.
Either way, I’ll let you know how it goes.

can someone link me an up to date tutorial how i can get my ps3 dualshock 3 sixaxis controller running wirless with an bluetooth dongle.
my head is smoking at recalbox the only step i needed to do was plug in a cable for 10sec and press the ps3 to recognize.
but here with luna it seems to be a very big deal.
i found this guide maybe someone with more experience can look over if i can folllow this blind or maybe someone have an easier way.

I’ve had massive issues using bluez when I tried to pair my PS3 controller (iirc it was the same tutorial I followed). Ended up reinstalling OSMC and doing something similar to this to get it somewhat working.
To be honest, when the sixaxis functionality started to interfere with my mappings, I gave up and bought another X360 controller …

That has nothing to do with Luna… it’s simply that recalbox (probably?) has controller support built in (as in: it’s shipped with the necessary drivers), while OSMC doesn’t as gaming clearly isn’t its focus.

exxe,
Actually the xbmc.ini located at the top of this thread kept the xbox controller working in OSMC, but I had to delete it because with the mapping in there, moonlight only saw it as a mouse and keyboard (like you see in the /input/devices/ output I posted a few replies back) and didn’t respond to the left stick and some button inputs during the mapping process. It did actually work in moonlight that way but the left stick was working as a mouse and it wasn’t registering as a proper xbox controller in a couple of games that I tried. Once I got rid of the configuration file the xbox controller changed to this in /input/devices/:

I: Bus=0000 Vendor=0000 Product=0000 Version=0000
N: Name="Xbox Gamepad (userspace driver)"
P: Phys=
S: Sysfs=/devices/virtual/input/input3
U: Uniq=
H: Handlers=js0 event2
B: PROP=0
B: EV=b
B: KEY=7cdb0000 0 0 0 0 0 0 0 0 0
B: ABS=3061b

and I was able to create a map file with moonlight using the CLI. All keys responded and a map file was created. Unfortunately next LUNA refused to allow me to enter the “Controller Configuration” option when I select it for some reason, so I again deleted the script.luna directory. This allowed allowed me back in to the “controller configuration” option and I selected the controller and map file. Next the games were re-scrubbed which as always, took a good amount of time so I went to bed.

Today though I did test the controller and it works in moonlight! Would be awesome if it would work in both OSMC and moonlight but anything above this I’ll take (or not take) as a bonus.

Couple of things:
How do I force LUNA to update the games cache?

Also, titles that are added manually to GFE show up twice in LUNA; but that must be a moonlight issue though because they also come up twice when I do

moonlight list

Thank you so much exxe, I think I would have given up without your help before I would have gotten this darn xbox controller working.

The exact same thing happened to me as well today, though I’m not sure why that is. There seems to be some issue with deleting input devices which aren’t present anymore (which might be induced by changing between a driver instance using the above xbmc.ini and one which doesn’t?) … need to debug this properly sometime. If you run into this more often, simply delete the input_storage file inside Luna’s .storage dir - it will suffice and you won’t have to re-pair and download the information for all games again (which yes, takes ages, but most of this is because the APIs of the providers - especially TGDB - are slow).
Edit: This has been fixed and will be part of the next RC. Just waiting a bit for other things to go wrong :wink:

Just finished!
If you find any errors or something isn’t entirely clear when you read it, please let me know so I can update the document accordingly. Thanks!

If you mean “How to update the game list?” - there’s a context menu item on each game that updates the list in the background.
I’m thinking about doing this automatically when changes are detected (pulling the list from the host PC is extremely fast) - would such a system be in your interest?

Does this happen with all manually added items or only specific ones? I’ve heard this before but never was able to reproduce this so far … I’m not even sure how that can happen, because games should be added by their application ID (which is assigned by GFE) and they would overwrite each other. Need to check up on that though, not entirely sure how that’s working off the top of my head.
Regardless, if you got any more information to share it’d be great, so we can open a GitHub issue to gather more information / track the progress :slight_smile:
Edit: The issue can be found here. As said above, I do need some more input on this.

Never mind :slight_smile: Sorry for saying poorly worded stuff at times and / or not fully understanding what you were going on about.

Wow exxe, you are a busy man. I was expecting to leave this alone for a while and maybe work on getting the chatpad to work next but since you went through all this trouble I will definitely make getting the controller working in both OSMC and moonlight a priority. I’m sure I’ll screw something up but at least I think I know how to get back to the configuration that I have now where it works in moonlight.

Yes, that is what I meant, I worded that badly. I didn’t realize that there was that option because I didn’t have that key properly bound on my universal remote. That’s one place where having the xbox working in OSMC will help… the other with being able to properly FF and REV in movies. This is a pain with the old Monster universal remote that I have.

I think putting a refresh button somewhere in the menu would be good; where it is at does not seem intuitive to me.

Yes. I had to add Styx:Master of Shadows and Firewatch manually and there are two icons for both. I’m running GFE 3.2.2.49. One instance in the host game view has clipart and looks like the rest of the titles and the second appears like the icon in windows explorer on the host machine. Like I mentioned previously, this is a moonlight issue since they both show up twice when I use the list command. It also lists my GFX cards incorrectly. I have a GTX 1070 and a GTX 670 installed but it lists them as GFX1070 x 2. I think that’s probably also a moonlight or GFE issue. If you need any dumps or photos of this let me know and I’ll shoot them to you via email.

…off to try your procedure.

.
yeh u was right spend two days at setting up the ps3 controller and only got the left stick working, and i dont get the sixad service to start alone :joy:
under libreelec it worked great but GFE update to fast and no one update moonlight there.
thats why i change to osmc luna and moonlight pretty great here but yeh no controller support is pain in ass too.
but my main question is … as hardcore 360 player in my old days i have enough xbox controller here and i saw i can buy in local store a xbox one stick for the controller signal. would this work to get my controller wirless on my raspberry? or do i need a 360 dongle from ebay?

I got one of those: X360 Receiver for Windows
Mainly bought a bundle (containing both the receiver and the controller) because a) I need at least one spare controller for my Xbox and b) the price difference was so small back then that it was just a great deal :wink:

IIRC the Xbox One Stick generally works, but ONLY for Xbox One controllers as they use a different wireless technology as far was I’m aware - so get a X360 Dongle if you got X360 controllers, and a Xbox One stick if you got Xbox One controllers (kinda obvious, right?).

The dongle linked above works with both xpad and xboxdrv drivers …

i spend the whole evening on setting up the xbox 360 controller and follow this guide from Toast
when i needed to type this 2 commands
sudo echo "uinput" | tee -a /etc/modules-load.d/modules.conf
sudo echo "joydev | tee -a /etc/modules-load.d/modules.conf
i got an access denied
so i log in with root account and wrote the command again this time it doesnt say something so i dont know if it works or not.
so when i enter sudo xboxdrv it shows my controller and it react when i press a button

Controller: Microsoft Xbox 360 Wireless Controller Vendor/Product: 045e:0291 USB Path: 001:004 Wireless Port: 0 Controller Type: Xbox360 (wireless) Your Xbox/Xbox360 controller should now be available as: /dev/input/js0 /dev/input/event0 Press Ctrl-c to quit, use '--silent' to suppress the event output X1: 1880 Y1: -2268 X2: -453 Y2: 2978 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:1 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0 X1: 1880 Y1: -2268 X2: -453 Y2: 2978 du:0 dd:0 dl:0 dr:0 back:0 guide:0 start:0 TL:0 TR:0 A:0 B:0 X:0 Y:0 LB:0 RB:0 LT: 0 RT: 0

so i tried to create a map file with moonlight map GamePad.map it ask me to move my stick but nothing happend when i do it.
i dont know how often i reinstall osmc today and how many tutorials ive read i hope someone can help me.

@Linus
Those commands are wrong, it’s
echo "uinput" | sudo tee -a /etc/modules-load.d/modules.conf
and
echo "joydev | sudo tee -a /etc/modules-load.d/modules.conf
respectively.
Besides, from my experience, both aren’t needed for general controller functionality.

The only things you need to make sure are
a) if you use xboxdrv, the xpad kernel module needs to be disabled (see my discussions with @Waynosan above)
b) xboxdrv needs to run in the background … best way to ensure this is to either create a script and call it from /etc/rc.local or just place the calls inside that file.
(I’m not sure which way you took and what exactly you did, so you might have done both already)

Other than that, you might also want to try to specify the event device when using the map command, e.g.: moonlight map -input /dev/input/event2 xbox360.map

In general, the entire discussion I had with @Waynosan should be a good starting point for debugging controller issues.

ok i was reading a lot today. i found your guide for setting up the xboxdrv as daemon .
i added this to my rc.local
modprobe xpad sleep 1 rmmod xpad modprobe uinput modprobe joydev /home/osmc/xbox.sh &

after i closed kodi over ssh i could use the map command it every button works but not the left stick, the right stick work just fine.
in osmc the controller just work fine.
dont know where the problem is