Moonlight Pi

Moonlight on a Raspberry Pi

Contents
1 Howto: 50$ Steambox with Moonlight on a Raspberry Pi
1.1 Ingredients
1.2 Preparations on the PC
1.3 Preparations on the Raspberry PI
1.4 Connect a game controller (optional)
1.5 Automatic Bootup
1.6 Power on the PC automatically
1.7 Power off the Raspberry Pi gracefully and the PC automatically

Howto: 50$ Steambox with Moonlight on a Raspberry Pi

I connected my TV in the ground floor to my computer in the second floor by a Raspberry Pi for realtime game streaming. This cost me about 50$ and now I can play high quality computer games in my living room – without sitting in an office (again …), without the computer’s noise and on a big TV screen.

I configured everything to start up automatically. That is when I power on the Raspberry Pi, my PC is electrically powered up too, Steam (providing a dashboard for games) is started on the PC and Moonlight (formerly known as Limelight) – which provides the game streaming facilities – is started on the Raspberry Pi. So all I have to do is to power on the Pi, wait a few moments and then the Steam dashboard appears on my Tv and I can select and play my favored PC game with my XBox game controller. It behaves like I had built a high performance steambox for only 50$ 😉

Here’s how you can repeat this on your own.

Ingredients

A Windows PC with an NVidia Gfx-Card capable of running Shield. (Install the ‘GForce Experience’ software from NVidia to find out wether you card supports Shield. I’m very happy with my very quiet and inexpensive ‘ASUS GeForce® GTX 750 TI’. The PC should have contemporary performance, I used a quad core i5 with >3 GHz clock, but less would do also because the video compression takes place on the Gfx-Card.)
USB-Mouse, USB-Keyboard (If you intend to use a game controller lateron the USB-Mouse/Keyboard of your PC are sufficient and will only have to be connected to the device during the installation.)
Any recent PC-Game
A Raspberry Pi. I used a starter kit consisting of the device, case, power adapter, heatsink, a NOOBS-preinstalled SD-Card, HDMI-Cable (and a USB-WLan adapter which I don’t need). http://www.amazon.de/Raspberry-Complete-Starter-Wesentlich-Zubehör/dp/B00P9FGSHU/ref=sr_1_3
An Ethernet connection between the PC and the Pi. (As far as I know wlan is not recommended, but might be working either).
Optional: A game controller, I used an XBox USB for PC controller. http://www.amazon.de/PC-Xbox-Controller-Windows-schwarz/dp/B004JU0JSK/ref=sr_1_1
Optional: A power on/off controller (On http://www.msldigital.com are several of this devices. LED-Pushbuttons, Rocker-Switch, optionally with additional IR remote control receivers …)

If you didn’t buy a NOOBS-preinstalled SD-Card you will need a card writer for micro SD (I used a very cheap adapter between micro SD and the bigger SD slot of my laptop).
Preparations on the PC

Install Steam, make the Game startable from Steam (by buying it in Stream or by referencing to an existing game in the steam settings)
Install GeForce Experienve from Nvidia (or update it if you allready have it), there in Preferences / GameStream: Select ‘On my network’). Leave the PC on and this window opened.
Find out the hostname (or IP) of the PC. E.g. by pressing the Windows-Key and the Pause-Key at the same time (or by ipconfig).

Preparations on the Raspberry PI

Connect the PI device to an internet router (by Ethernet or a WiFi-USB-Stick – Ethernet is recommended for Moonlight anyway), HDMI, Mouse, Keyboard, Power
If you bought a NOOBS preinstalled SD-Card:
In NOOBS install Raspbian (I used from Ethernet, Ethernet-Jack-Icon)
Continue below at ‘In the setup menu configure …’
If you have no NOOBS preinstalled, but an empty SD-Card, download the operating system on your PC and copy the image to the SD-Card
On http://www.raspberrypi.org/downloads/
Download Raspbian (‘download torrent’ was for me way faster than ‘download zip’: 8 MByte/s instead of 400 KByte/s)
Unzip the downloaded file
Flash to the Pi’s SD-Card as written in http://www.raspberrypi.org/documentation/installation/installing-images/README.md
Execute ‘sync’, remove the SD-Card and insert it into the Pi and in the NOOBS installer choose (only) raspbian and press the ‘install’ button (or the key ‘i’ on the keyboard).

The system reboots automatically into the raspbian-config menu (which can lateron be entered again, e.g. for adjusting the overclocking, by the command ‘rapi-config’). In this menu configure the following:
At 1) Expand the filesystem (possibly obsolete when NOOBS was used to setup the SD-Card)
At 2) Choose a password
At 3) Note: Leave the default to console login !
At 4) Optional: Set localization and timezone if wished
At 8) A3 GPU memoty to 256 MB
Optional: If you’re familiar with SSH is you can enable it in 8) and A4 and later connect by the user ‘pi’. SSH lets you connect the Pi console from another PC which eliminates the need to directly connect a keyboard to it. For simplicity, however, I will continue without mentioning SSH and assume that you have a keyboard directly connected to the Pi.

Finish the settings dialog, which automatically triggers a reboot of the Pi, and Login with user ‘pi’ and the password you set before.

sudo apt-get update
sudo apt-get dist-upgrade

sudo sh -c “echo ‘deb http://archive.itimmer.nl/raspbian/moonlight wheezy main’ >> /etc/apt/sources.list”
(This is one single, long command line)

sudo apt-get update
sudo apt-get install moonlight-embedded
(Press ‘y’ in case of any questions)

Then start the pairing process on Moonlight

mkdir ~/Moonlight
cd ~/Moonlight
moonlight pair <PC’s Hostname or IP>

You will have to enter the code given on the console to the PC. It is not possible to use the windows remote desktop, this gave for me and others the error 530, you’ll have to walk between the rooms … (or you might try VNC instead of the Windows Remote Desktop)

On the Pi execute for testing the connection:

moonlight stream <PC’s Hostname or IP>

After a short while the remote content should be displayed (if the display remains black this might be the raspbian screen saver, press any key)

Connect a game controller (optional)

The following section shows how to connect a controller – in this particular example an XBox 360 USB controller for PCs. An alternative approach using a wireless PS3 dual shock controller and a bluetooth-usb-dongle can be found here: PS3 controller for Moonlight. You can, however, also skip this section and play your games with USB connected mouse and keyboard instead (then don’t use ‘-mapping xbox.map’ when starting ‘moonlight stream’).

The XBox 360 controller will be recognized by default. I made, however, the experience that the following procedure gives better results (and also eliminates the annoying blinking led of the default driver). Instructions taken from https://github.com/irtimmer/moonlight-embedded/wiki/Controllers-set-up

sudo modprobe -r xpad

sudo sh -c “echo ‘blacklist xpad’ >> /etc/modprobe.d/gamepad.conf”
(This is one single, long command line)

sudo nano /etc/rc.local

Enter the following line BEFORE the line ‘exit 0’
xboxdrv –trigger-as-button –wid 0 –led 2 –deadzone 4000 –dpad-as-button –silent &
Save and exit (Press Ctrl+X and Y)

Note: The setting –trigger-as-button is not apropriate for games that need a linear input from this button, like racing games. Maybe just removing the option ‘–trigger-as-button’ is sufficient for this type of games, maybe also a different mapfile is needed (see below), I haven’t tried this yet.

A map file is needed, that tells Moonlight which button-code does which action. We store this mapping file (.map) in the Moonlight folder, we created above.

cd ~/Moonlight

You can simply download the one I provided online

wget https://raw.githubusercontent.com/RoelofBerg/moonlightpisteambox/master/xbox.map
(Enter this as one single command line)

(I created the file with the command ‘moonlight map xbox.map’.)

To enable/use the controller, the .map file we just created has to be added to the command ‘moonlight stream’, which was used above to establish our very first connection successfully – you remember that one ? Here’s how the command to start streaming will look like now:

moonlight stream -mapping xbox.map <PC’s Hostname or IP>

Automatic Bootup

Now after every boot you can login and ‘cd Moonlight’ and repeat the command above to start Moonlight (the PS3-controller has to be paired before by pressing the PS-button. If you skipped the controller installation above, use the command without the ‘-mapping xbox.map’ option).

moonlight stream -mapping xbox.map <PC’s Hostname or IP>

To do this automatically at every boot, do the following:

Autostart (taken from http://www.opentechguides.com/how-to/article/raspberry-pi/5/raspberry-pi-auto-start.html)

Create a script that starts Moonlight

cd /home/pi/Moonlight
wget https://raw.githubusercontent.com/RoelofBerg/moonlightpisteambox/master/autostart.sh
(Enter wget … start.sh as one single command line)
nano autostart.sh

Modify the script:

#!/bin/sh
cd /home/pi/Moonlight
moonlight -mapping xbox.map -60fps stream <PC’s Hostname or IP>

Give the script execution permissions

chmod +x autostart.sh

You may want to test the script. Enter

./autostart.sh

The PC’s steam console should become visible on the TV. Press ctrl+c to abort/finish the test.

sudo nano /etc/inittab

Outcomment the line that starts getty and add a startup of /bin/login. On my system the position of this lines was at the very end of the file. If you have something different from T0:23, use what you have in the /sbin/getty line also in the /bin/login line.

#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
T0:23:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1

sudo nano /etc/profile

At the bottom of the file add the following line to start the autostart script created above (with a trailing dot and space character)

. /home/pi/Moonlight/autostart.sh

Test by executing

sudo reboot

After a reboot the steam display should appear automatically on your TV and you can use the xbox controller to control it.

Power on the PC automatically

The above procedure needs you to power on the PC and also to login to the PC before powering on the Raspberry PI. This, however, can also be automated by the wakeonlan feature of recent PCs. (This section is optional and can be skipped – but then, off course, you’ll have to power on your PC manually and log on to Windows.)

For remotely powering up your PC you will have to enable wakeonlan in the PC’s UEFI/BIOS configuration and in Windows. When powering on your PC interrupt the boot sequence, enter UEFI and enable wakeonlan – for example I had to enable booting for my whole PCIe-bus. Save, exit and continue in Windows (remember, as mentioned above, that once you used a remote-desktop connection you’ll have to reboot before being able to connect Moonlight again.)

ToDo: How to enable WakeOnLan in Windows (there was something I did)

Enable automatic login at boot (note: this reduces the system’s security, see http://technet.microsoft.com/en-us/magazine/ee872306.aspx)

1. Click Start, type netplwiz, and then press Enter. 2. In the User Accounts dialog box, click the account you want to automatically log on to.If it is available, clear the Users Must Enter A User Name And Password To Use This Computer check box. 3. Click OK. 4. In the Automatically Log On dialog box, enter the user’s password twice and click OK.

Open a Windows terminal (press Windows-Key and R, type ‘cmd’ and enter) and enter the command ‘ipconfig’. Read out the PC’s MAC address. It should be something like 12:34:56:67:90:12. Power off the Windows PC.

Back on the Raspberry PI console install the wakeonlan tool.

sudo apt-get install wakeonlan

Test the wakeonlan feature by calling it using the MAC address obtained above (replace 12:34 … by your MAC address):

wakeonlan 12:34:56:67:90:12

The PC should power on automatically. If this is the case you can add the wakeonlan command to the boot-sequence of your raspberry PI, so that everytime you power on the PI also the PC will be powered on remotely. (Exit Moonlight by pressing ctrl+c)

cd ~/Moonlight

We will now extend the script autostart.sh we used above allready. You may want to download my example again to save you some typing by calling wget again (careful, your changes in the file like the hostname/ip of your PC will be lost).

wget https://raw.githubusercontent.com/RoelofBerg/moonlightpisteambox/master/autostart.sh
(Enter this as one single command line)

Then

nano autostart.sh

and enter your PC’s Hostname/IP and Ethernet MAC adress, safe and exit.

Power off the Raspberry Pi gracefully and the PC automatically

A standard debian based Linux system shouldn’t be powered off without issuing the ‘poweroff’ command on the console. Otherwise the file system might be corrupted. On http://www.msldigital.com (my distributor was www.insaneware.de) I found poweroff-switches that come along with shutdown-scripts for the Pi. Theese provide a convenient power-on-off by just pressing a button. I chose a model that additionally adds IR remote control capabilities to my Pi, the ‘RemotePi Board Plus 2015’. I had to drill two additional holes into my Pi casing, which was quite easy with a standard drilling machine.

I don’t know if this was necessary but I upgraded to Firmware of the RemotePi board to V1.5 as shown in http://www.msldigital.com/pages/upgrade-firmware (and I restored /etc/inittab afterwards – which is not mentioned in the upgrade guide.)

Then I installed the poweroff-scripts by following the guide on http://www.msldigital.com/pages/support-for-remotepi-board-plus-2015 – there the secion with the caption ‘XBian’.

Work in progress: I have to find a straightforward way to poweroff the PC from within the RemotePi’s shutdown script.

65 thoughts on “Moonlight Pi”

  1. Hi there, excellent article!

    I followed this almost verbatum and was happily playing in no time flat. A couple of errors I encountered and resolved during my setup:

    1) I initially had an error when running limelight stating something like “steam app not found in GFE app list” And it turned out that I had configured steam to point from the default C:\Program Files… directory to c:\Games\Steam. All I had to do to resolve the issue was go into gforce experience on my PC and add my c:\Games\Steam folder to the search path, this resolved the issue immediately.

    2) After mapping the controls for the xbox 360 controller I started playing ‘Assassins Creed: Black Flag’ and noticed that the Left Trigger / Left bumper buttons were back-to-front, as was the Right Trigger/ Right Bumper. So I just re-created the map file as per your instructions with the correct mappings (including the switch for ‘B’ and ‘X’ buttons) and it works a treat.

    My final question is regarding the poweroff solution. At this stage I don’t really want to have to fork out for a separate relay board just to power down the pi gracefully. I would love for the system to somehow call a shutdown script when I exit the Steam interface. Yes I realise that this would require a manual power on of the pi, but I am happy to buy a cheap remote controlled mains power switch to achieve this funcationality. Can you think of how I might configure a script to get called after exiting limelight?

    Cheers, and thanks for the excellent article!

    Jason.

  2. Thanks for the feedback. I corrected the xbox.map file, so it should work out of the box now. I will have a look at the shutdown topic in the next days. The autostart.sh script has allready a detection for whether steam is running.

    I will check out the following aproach:

    Create a script shutdown.sh near autostart.sh like follows:
    #!/bin/bash
    while nc -z -w5 47989 &>/dev/null; do :; done
    halt

    (Or ‘poweroff’ instead of ‘halt’ if the Pi supports this command).
    Give execute permissions:

    chmod +x shutdown.sh

    Then call shutdown.sh to be run in parallel from autostart in line 9 of startup.sh before “#Start limelight” (the &-sign makes it being run in parallel):

    ./shutdown.sh &
    #Start limelight

    This will shutdown the Pi when steam is shut down. I hope that steam can be shut down (entirely, without lingering around and having a tray-icon near the windows clock).

    To shutdown windows the starting of steam can be replaced by a batchfile (that is then registrered to the windows autostart-folder instead of the steam executable). This batchfile should start steam and upon return (when steam ended) can halt the windows system, example file (haven’t checked the path to steam, but it’s obvious what I mean, I guess):

    “C:\Program Files\Stream\Steam.exe”
    shutdown -s

    This, however, works only if Steam can be shut down entirely from the steam menu in some way. Otherwise one has to find another solution.

  3. Hello,
    Awesome article ! Howerver, I strictly followed your guide to setup with my Pi2 and everything works but my Xbox360 usb controller. The controller is working under raspbian since the jtest actually passed but it just don’t works with limelight… I have no ideas why…
    Any suggestion ?
    Thanks !

      1. By the way I just tried retropie distribution on my PI2 to check if my Xbox 360 controller is working and, yes, it works. So, it’s still a mystery to me why it just don’t works with limelight. Maybe it is something related to my host PC ?

      2. Ok, i’ve made it to work. Apparently I must keep the original gamepad driver without installing xboxdrv at all. When i install xboxdrv, the gamepad is not listed anymore in /dev/input/by-path. No idea why but now it works. By the way, there might be an issue with your map file because with Grid2 game, for example, pressing RT make like LT is also pressed at the same time (meaning you accelerate and brake a t the same time ^^).

        1. Great 🙂 I wasn’t aware that the driver is allready included in raspbian, maybe this is new. I will update the guide, thanks for notifying.

          I assume, you saw the instructions for generating a .map file on your own, this can help with the RT/LT assignment. If you have a mapfile that is working better, I’d be grateful, if you’d email it to me: rberg@berg-solutions.de (or commiting it to github would also be an option), then I can publish it here.

          1. I have to check how to generate the mapping file but, yes, sure, I will send it to you !

  4. I’m using 1.2.1 embedded with a fresh install of raspbian on my PI2. I tried with the old map file but still with no luck 🙁 There is something wrong in my config but I really don’t know what since jtest confirm that my controller works. I’m using this command :
    java -jar limelight.jar stream -mapping xbox.map -720

  5. Thanks for the info. Updated guide:
    – Use V1.2.2
    – Use default xbox controller driver (removed paragraph to install another driver)
    – Checked mapfile, on Wolfenstein all keys are working as expected now (also no confusion between RT and LT using the default xbox controller driver)

  6. Hi Roelof,
    Thanks for very very good article, you know if possible use two pad with limelight for game with two player?
    I have try with two xbox 360 pad wired and the two pad on steam work but after start the game only one are recognized.
    Sorry for my bad english!

    1. Interesting question. By using xboxdrv this could be possible as shown in https://github.com/petrockblog/RetroPie-Setup/wiki/Setting-up-the-XBox360-controller. If you’re new to Linux: With ‘sudo nano somefile’ you can create the configuration file mentioned in the article. Some of the files can possibly easier be obtained from my github space at: https://github.com/RoelofBerg/limelightpisteambox . Click on the file, then on raw, copy the URL from the browser and then use ‘wget …URL…’ .

  7. Hi,

    First of all, thanks a lot for the great guide! I didn’t get Limelight to work on my Pi 2, but using this guide, it instantly worked like a charm. My Xbox 360 controller is also working, although while both my thumbsticks are working, the D-pad isn’t.

    Familiar with this issue? Any ideas on how to fix it?

    1. Hoy Daan, good to hear that the guide is compatible also to the Pi2. Is the D-pad not working at all or is it only misassigned (e.g. down swapped with right) ? When executing ‘java -jar limelight.jar map -input /dev/input/event1 xbox-daan.map’ you can record your own map-file. You can compare this to mine, esp. the entries for btn_west, btn_east, btn_north, btn_south and maybe use your recorded numbers in my file. Command ‘nano xbox-daan.map’ for looking into the file. Please give me a note when you found some misassignment, so I can update the reference file. Good luck 🙂

      1. Hey,

        I used your xbox.map from the link you provided when the issue occurred, so I’ll have to check again what might have went wrong. It seemed like everything worked except the D-pad, up-down-left-right, neither of them did a thing. Tonight I won’t be able to try what you replied though. But thanks for the quick response, I’ll try it out tomorrow and get back to you!

      2. Thanks for you awesome post and help!

        I also have this problem you mention, where the D-pad axis seem to be swapped on limelight (and its working fine on raspbian).

        I’ve tried mapping my own file to compare with yours but it doesn’t move past the first command (Left stick Right).

        Any idea on how to fix this Dpad issue?

        Thanks again!

        1. Yes, creating the mapfile is difficult. I tried moving the stick to left/right/top/down several times. I tried to move as clean as possible only to (e.g.) left without any (e.g.) partial top/down movement. I moved it quickly and slowly. After a lot of tries it succeeded. I remember that I had to start over several times.

  8. Hi o everyone, first of all, thanks for the work done on this blog, mi question is how i can manage two different (at hardware level) controllers with files maps different.

    1. Interesting question, I have no answer. At first both devices should be available in /dev/input, like /dev/input/event0 and /dev/input/event1, off course, which can be tested with ‘jtest’. Whether different map-files are possible would be a good question to the limelight developers at https://github.com/irtimmer/limelight-embedded/issues. Maybe it has to be requested as a new feature. I also wonder if there could be an intermediate layer that translates codes, making one controller look like another one.

  9. One way to make raspi shutdown your pc is by installing cygwin and sshd service on it. Then set up login from pi without password by keys.
    (Here a short guide from google
    http://www.linuxproblem.org/art_9.html ).
    Then you need to run
    ssh windowsip "shutdown /s /t 0"
    from within your script.
    But beware anyone with access to your pi can now access your windows pc.

  10. While trying to fix the Dpad axis, I noticed that it doesn’t really matter if I use a map file or not, I get the same result. Also, I’ve messed with the map file to test it out, and no changes in the result which leads me into believing that for some reason limelight is ignoring the -mapping command?

    Anyone else had trouble with this?

  11. Hi,

    first of all, excellent guide!

    But can you update it with how to run the newest version 2.0 of Moonlight Embedded that’s written in C instead of Java? I have no knowledge about compiling code from git & a tutorial would help me a lot!

    1. Hi Julian, thanks for reminding me, I will update the guide. I’m quite busy theese days, our baby won’t fall asleep before 10 pm everyday and after she sleeps I have to do the left over household (dishes, washing and so forth) before I get up at 7 am again and do the next diper before rushing to work … Having little children is quite some effort, and worth every minute, however I’ll also be glad when our youngest one will be three years old, then life will become easier 🙂 So please forgive me, if it might take a while until I find some time, at some point I will take care of it.

      If anyone wants to contribute to the guide, just send me an e-mail.

      By the way, I haven’t had a look at the package, but usually one types (after ‘wget http://…tgz’ and ‘tar -xzf …tgz’) something like:
      sudo apt-get install build-essential
      ./configure
      make
      sudo make install
      (Maybe it helps, don’t know if Moonlight follows to this standard pattern.)

  12. Hey, I installed this and tried to stream. I used the commend to stream and I received a message of “Can’t find app Steam”.

    I have removed/purged moonlight-embedded and installed it again and I have received the same errors.

    Has anyone else had this issue? I would greatly appreciate your help. Will send emails of me smiling to anyone who is able to help.

    1. Hey.
      Just add the Steam App to the NVidia Experience list. Change the name to “Steam”.
      Now on raspberry type:

      moonlight stream your-PC -app steam

      You can also start a game directly by putting the game name behind -app

      Should work 😉

  13. btw: I’m using the RasPi Check App on my Android. Here you can execute saved commands via SSH. Just add the autostart.sh to the commands (e.g. “sh /home/pi/moonlight/autostart.sh”). Now you can start your PC and get the Raspberry into Steam mode by tapping your Android only 😉

  14. Hi,

    This is the second time I ‘ve used your guide and it’s so far the best DIY moonlight I could find. Hope you can appreciate some remarks / suggestions. I’m a windows techie so technical is no problem but linux is not my thing. So following your guide I came across the follow issues (after a noobs raspian install):

    1) I found that sudo sh -c “echo ‘deb http://archive.itimmer.nl/raspbian/moonlight wheezy main’ >> /etc/apt/sources.list” returned an error. I had to sudo nano the sources.list then copy + paste the line.

    2) The mkdir moonlight had no extra value for me as the package is now accessable from anywhere.

    3) T0:23:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1 caused my Pi to be bricked after login. So I used 1:2345:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1 instead and kept the original TO23

    4) for me . /home/pi/Moonlight/autostart.sh was not working I had to remove/home/pi to acces the file.

    5) the linux nc command can’t reach windows pc’s. So I’m using ping to check if the pc is available.

    6) I’m using the pi for moonlight and kodi so I made a “start menu”. Whichs offers the change to start moonlight otherwise by default it starts Kodi (watch more movies then I play games. It’s a sin I know). sh goes in /etc/profile so it starts after boot.

    #!/bin/bash

    timelimit=5
    # Time limit to enter input
    clear
    echo -e “Start Kodi or Moonlight?”
    choice=””
    stty -icanon min 0 time ${timelimit}0

    read choice
    if [ ! -z “$choice” ]
    then
    clear
    date
    echo -e “Booting Kodi.”

    #Check if your video share is available
    echo -e “Connecting to …”
    while ! ping -c1 &>/dev/null; do :; done

    #Start Kodi
    echo -e ” available, starting Kodi.”
    kodi-standalone

    else
    clear
    date
    echo -e “Booting Moonlight.”

    #Check if PC is available.
    echo -e “Connecting to Gamestream …”
    while ! ping -c1 &>/dev/null; do :; done

    #Start Moonlight
    echo -e “Gamestream available, starting moonlight.”
    moonlight -mapping xbox.map -60fps -1080 -fs stream

    fi

    7) I placed the above sh file in the root together with the xbox.map file.

    And Finally a question, does sudo apt-get update work if there are new moonlight versions available? Or how dow you get a specific moonlight version? for instance when a future release appears to be broken and you want to rollback to another release.

    Thank for all the time and effort you put in the diy, hope the menu repays your work.

    Grtz.

    1. Hi Richard, thanks for contributing so much excellent information. I will walk through this and edit the guide, presumably in September.

      I used nc because I wanted to wait until steam is running, which might be a bit later than the time when the PC responds to ping. Maybe I have to look at my Windows firewall configuration and add this to the guide.

      Thanks a lot !
      Roelof

  15. Hello,
    First, I want to say that this is amazing guide and was very helpful.

    But I have a problem. My keyboard is not mapped correctly so when i press the space key it’s make number 2 key instead.
    In the Raspberry Pi console and in the PC everything is working with no problem and the space key mapped correctly.
    What can be the problem?

    Many thanks to you for this guide.
    Amir

    1. Hi Amir, good to hear that the guide is still compatible. Unfortunately I didn’t use a keyboard, I allways used SSH. When I will be using it next time, I will connect a keyboard and have a look. (Might take some time, I’m quite busy these days, and nights)

    1. Hi,

      the best way to update moonlight is to use apt-get:
      sudo apt-get update
      sudo apt-get upgrade moonlight-embedded

      If that does the trick, very good, that was easy 🙂

      If, however, you need a more recent version, than apt-get gives you, you can install moonlight manually as follows. (Not testet, sorry, our two babies take all spare time away from me, I’m happy when they’ll be grown a bit older. I welcome you to ask questions, if it doesn’t work.)

      So, if you need a more recent version, you have to download the sourcecode from the moonlight software developers and compile the application yourself to an executable binary. If this is new to you: This mostly works but not allways. Compiling is a complex task that is not so easy to understand, esp. it might be hard to get a connection between any error messages and how to cure it.

      The following instructions are about how to download the latest release-version on https://github.com/irtimmer/moonlight-embedded/releases . This is a very recent version. If you, however, want the very latest beta version that is used by the software developers, that might be just one hour old, use git instead, as stated at the very bottom of this post. I recommend to use the last official release, so you can just read on and ignore the bottom of this post.

      Instructions for firefox: When you hover with the mouse over “moonlight-embedded-2.1.1.tar.xz” you see the download location in the browser below. You can alternatively klick on it and select “copy link location” to get the link location into the clipboard.

      It should be something like:
      https://github.com/irtimmer/moonlight-embedded/releases/download/v2.1.1/moonlight-embedded-2.1.1.tar.xz

      Then on the raspberry you can issue the wget command on the location you found out above:

      wget https://github.com/irtimmer/moonlight-embedded/releases/download/v2.1.1/moonlight-embedded-2.1.1.tar.xz

      Extract the downloaded file:
      tar -xf
      e.g. “tar -xf moonlight-embedded-2.1.1.tar.xz”

      Go into the new directory (use “ls” to find out its name)
      cd
      e.g. “cd moonlight-embedded-2.1.1/”

      Then (steps taken from https://github.com/irtimmer/moonlight-embedded/wiki/Compilation) install the prerequisites:

      sudo apt-get install libopus0 libexpat1 libasound2 libudev0 libavahi-client3 libcurl3 libevdev2 libraspberrypi0 libssl-dev libopus-dev libasound2-dev libudev-dev libavahi-client-dev libcurl4-openssl-dev libevdev-dev cmake rbp-userland-dev-osmc ibraspberrypi-dev build-essential

      This is one big command that automatically installs software from the internet. If you use osmc, also add rbp-userland-osmc. By the way, when you use ssh you can copy and paste the commands instead of re-typing it.

      In further versions you can check if this list is still correct by looking at the bottom of https://github.com/irtimmer/moonlight-embedded/wiki/Compilation in the section “Debian”. Just install everything that is listed there by adding it to above “sudo apt-get install …” command.

      Then execute the following commands. This will compile the program from scratch. If this is the first time you’re compiling a software: Congratulations, you transformed a sourcecode into a program, that is what programmers do. In the folder “src” you can use “nano ” to have a look into the sourcecode files of the moonlight programmes. Is that cool, ay 🙂
      mkdir build
      cd build/
      cmake ../
      make
      make install

      if cmake or make gives trouble, execute
      sudo apt-get install git
      git submodule update –init
      and retry
      cmake ../
      make
      sudo make install

      —————-

      Addendum, using alternatively the latest developer beta version instead of the latest release version:

      (And by the way, you can use git to fetch the very latest sourcecode, if the latest release is not fresh enough. By
      sudo apt-get install git
      git clone https://github.com/irtimmer/moonlight-embedded.git
      cd moonlight-embedded

      Then continue at “apt-get install …” above.
      )

      Hope it works from scratch.

  16. Thanks man! I appreciate your effort here!:)

    Just 2 questions though:

    1) I do not want to install beta versions (only “stable” ones found in here https://github.com/irtimmer/moonlight-embedded/releases). Right now 2.1.1 is the latest. So if a new one comes out and i use:

    sudo apt-get update
    sudo apt-get upgrade moonlight-embedded

    will this install new version on my current folder setup? Cause i see that that i have a “Moonlight” folder in my home/pi dir.

    2) Have you been able to map 2 different controllers at the same time? e.g logitech f310 and xbox gamepad? While i can do it with:

    moonlight stream -mapping xbox.map -mapping logitech.map XXX.XXX.X.XXX (assuming i have xbox and logitech map files)

    i canot make them to work (Actually dpads and analog sticks for both gamepads work, but if they are loaded together only xbox’s buttons work!)

    Thanks!

    1. Hi,

      the command “sudo apt-get upgrade moonlight-embedded” (or initially “sudp apt-get install moonlight-embedded”) installs the binaries into the system folders, not into your home folder. Don’t worry, that’s a proper way to do it.

      By the way. If there’s a new major version of raspbian, you can also try (after “sudo apt-get update”) to enter “sudo apt-get dist-upgrade”. This does something like upgrading from Windows 7 to Windows 10, and then you might get more recent packages.

      Another option is to find if there are more recent binary packages from an inofficial source. “sudo apt-get” does something like when Windows looks only at a microsoft server for an update. It only looks into the official Raspbian servers. But it is possible to add alternative servers that contain more recent binary packages. And having a binary package means, you don’t have to compile yourself.

      I found something here, haven’t looked deeper into it. Seems to be a bundle with OSMC.
      https://launchpad.net/~dodslaser/+archive/ubuntu/moonlight-osmc
      Read at the “Read about installing” link on that site. Launchpad itself is very popular and trustworthy. However as everyone can add content to Launchpad this software packages might be less reliable than official Raspbian packages. So you have to trust Mr. Erik Lundgren in this case, that he didn’t add any backdoors. Well, it’s a decent name at least, I personally would trust him 🙂

      Another way could be to move to a beta-branch of Raspbian like here: http://forums.debian.net/viewtopic.php?f=3&t=110687 . Unfortunately I found no package overview (like Debian or Ubuntu has it), where I could have looked into and right now I have no access to the RaspPi.

      Regarding the two controllers: I’m very happy that I finally made at least one controller working 🙂 A good place for such topics is https://github.com/irtimmer/moonlight-embedded/issues

      Hope it helps more than it confuses,
      Roelof

  17. Hi!

    First of all i want to thank you for your perfect work! Very nice tutorial that explains everything that i wanted! Everything works fine but nevertheless i have two questions. What can I do about the controller not reacting straight after booting. I have to click on the screen to get it reacting. Second thing is: is there a command to set the pc to sleep again? If so, I would like to connect a ir receiver and write a program that sets the pc to sleep and shuts down the raspberry. Greetings!

    1. Hi, glad to hear. I wonder why you have to click anywhere, I don’t have to. You connect the controller directly to the Pi and not to a (possibly nearby) PC, right ? The command to shutdown a PC is “shutdown -s”. The best way would be that the Raspberry Pi instructs the PC during its own shutdown to power off too. Check out my post from March 23d 2015 (Haven’t tried that aproach yet, sorry, far too busy at the moment): http://embedded-software-architecture.com/?page_id=140#comment-380

      1. Hey. Thanks for your reply. I found out that I can press the a button on my controller and everything is fine. Now I’m facing some performance problems while streaming 1080p. I have a slight delay on controller inputs. It’s not that harmful but a tiny bit annoying.
        I’llI’ll test the thing with shutdown -S. Thanks a lot

        1. Fine, you can fine-tune moonlight by some parameters (resolution, fps), maybe this could lower the controller’s or video output’s latency – both sum up to the percepted latency. Also Ethernet is better than WLAN. And a last fallback would be to connect the controller without moonlight, but that should really by a final option when everything else fails. Good to hear that this is working for you now, happy gaming then 🙂

  18. I’m thinking I could make my own Nvidia Shield-type thing, with just a controller, a battery pack, a small LCD, a Pi, and a wifi dongle thingy. I’ll see what I can do over the next few months.

  19. I don’t know if this is a directly moonlight/network/gamestream drivers related issue, but since I cannot localize the problem itself, I just wanna try to get some input here.

    My Setup:
    PC: Intel core 2 quad q6600 @2.4 Ghz, 4gb RAM, GTX 750 Ti, gfe 2.7.4.10, driver 359.00, 1920×1080, 60hz, WIN7 Pro 64bit
    Client: RPI 1, oc to high, Raspbian jessie, speedlink torid wireless gamepad
    Network: Router is connected through ethernet hub to rp1 (wired)

    While everything works fine (even managed to play with 2 controllers!) my games are not as “smooth” (in terms of fps experience) as i expected. E.g when i play **PES 2015** while in my pc the game runs smooth (with lower details of course), in my rpi there is a image micro-stuttering (like when you see a ntsc fps 29.97 movie which stutters every now and then). This problem may dissapear for a while (without any reason) and then it appears again. This is happening to almost – all my games like (nba2k14, pes15, toca 3, dirt 2). To understand what i mean see this video

    https://www.youtube.com/watch?v=jDLTqJDNq18

    in 480p mode from 01.00 to 01.10 min (this bizzarre movement “break” when the player moves from one side of the court to the other)

    It is like a sudden fps drop/stutter (like when your laptop is getting hot or there are too many graphics for the cpu/card to handle). I can see that to almost any game. (I dont see it -or- it is minimized in games like pes09, machinarium, mark of the ninja, mk komplete etc)

    I am using the -30fps command

    moonlight stream -30fps -mapping xbox.map 192.168.1.109

    The problem remains when:

    1) I lower bitrate from default to 3000
    2) I run moonlight to 720p/1080p 60 Hz

    Maybe my cpu is outdated or network related problem?

    Any thoughts appreciated

  20. Reading through this, I only got my first Raspberry today but this might work for shutdown.

    net rpc -I 192.168.0.5 -U john%password shutdown -t 1 -f

    Create a script and place it in /etc/rc0.d.
    /etc/rc0.d (shutdown)
    /etc/rc6.d (reboot)

    Will investigate and provide feedback.

  21. So I tried this method and and the method on How to Geek to install moonlight, and every time I get this error “The following packages have unmet dependencies: moonlight-embedded : Depends: libenetla but is not installable E: Unable to correct problems, you have held broken packages.”

    Can anyone help me out with this?

    1. Change “http://archive.itimmer.nl/raspbian/moonlight wheezy main” to “http://archive.itimmer.nl/raspbian/moonlight jessie main”

  22. Hi, thanks a ton for that very helpful post. It helped me (as a linux newbie) to set up everything for gaming in the livingroom… nearly everything.

    One thing that I don’t get suppressed is the annoying blinking led from my wired Xbox360 controller. I’m on a Pi3 running Moonlight 2.2.2 and xboxdrv 0.8.5.

    I set up the rc.local with the xboxdrv command with –led 2 (also tested a lot other options such as 0). Using xboxdrv I got the RT/RB buttons working but the led parameter still does not seem to work.

    Has anyone an idea what to do?
    Thanks!

    btw: In your tutorial you set the parameters for xboxdrv with a single ‘-‘, which needs to be a double ‘–‘. Maybe you want to add this to your tutorial.

    1. Thanks for reporting the script improvement. I also find this blinking LED annoying, fully agreed. Maybe a hardware-solution is faster than in software. E.g. by just coloring it with a paint marker (or by disconnecting it from the PCB carefully, if you’re familiar with electronics) would do the trick 🙂

  23. Agree, that would be the ultimate solution. I was just wondering because the man of xboxdrv describes about 15 different states that can be set with the led option.
    I’ll try with a sticker first. Maybe another idea is coming up.

  24. Hello.
    I followed the how to be geek tutorial to know how to stream my pc on my raspberry, and then, this one in french to find out how to setup my wired Xbox 360 controller on my raspberry: https://www.raspberrypi.org/forums/viewtopic.php?t=48681

    After that, i had a blinking controler that didn’t worked on my steam’s streaming.

    After some researchs, I found your tutorial. I downloaded your Xbox mapping file, and after that, it worked except the triggers and the directional cross (joysticks and other buttons worked perfectly).

    I’ve decided to do instructions before that:

    sudo modprobe -r xpad

    sudo sh -c “echo ‘blacklist xpad’ >> /etc/modprobe.d/gamepad.conf”
    (This is one single, long command line)

    sudo nano /etc/rc.local

    Enter the following line BEFORE the line ‘exit 0’
    xboxdrv –trigger-as-button –wid 0 –led 2 –deadzone 4000 –dpad-as-button –silent &
    Save and exit (Press Ctrl+X and Y)

    And, after that, anything worked anymore.

    Have you got an idea on what could have went wrong?

    I add that, weirdly, if I try to map my ps4 controller with the moonlight tool, it’s working (with some latency), but, when I try to use the moonlight tool to map my Xbox 360 controller, the raspberry doesn’t even detect i’m pressing buttons…

    Thank you for your help, and sorry for my english 😉

  25. thx. it seems that xboxdrv dont work with jessie. i use now xpad with my XBOX 360 wired Controller. But i need a new Map File:

    abs_x = 0
    abs_y = 1
    abs_z = 2
    reverse_x = false
    reverse_y = true
    abs_rx = 3
    abs_ry = 4
    abs_rz = 5
    reverse_rx = false
    reverse_ry = true
    abs_deadzone = 0
    abs_dpad_x = 16
    abs_dpad_y = 17
    reverse_dpad_x = false
    reverse_dpad_y = false
    btn_north = 308
    btn_east = 305
    btn_south = 304
    btn_west = 307
    btn_select = 314
    btn_start = 315
    btn_mode = 316
    btn_thumbl = 317
    btn_thumbr = 318
    btn_tl = 310
    btn_tr = 311
    btn_tl2 = -1
    btn_tr2 = -1
    btn_dpad_up = 546
    btn_dpad_down = 547
    btn_dpad_left = 544
    btn_dpad_right = 545

Leave a Reply

Your email address will not be published. Required fields are marked *