Homepage Forums RetroPie Project Peoples Projects No more gamepad ? Why not use the phone ?

Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
  • #92188

    Hi guys !

    I’m writing this post to introduce my little project called node-virtual-gamepads available on github here.

    The goal of this project is to provide the possibility to use up to 4 smartphones or tablets as virtual gamepads simply by reaching a local address.

    I made two little video demonstrations here and here.

    From now there are no more excuses for not playing because, even if there are not enough gamepads, everybody has a smartphone :)



    Hi miroof,

    what a great idea! I just tried it but can’t get it to work:
    after typing npm install
    I get two warnings:

    npm install
    npm WARN package.json virtual-gamepads@0.0.1 No repository field.
    npm WARN package.json struct@0.0.8 'repositories' (plural) Not supported. Please pick one as the 'repository' field

    And sudo node main.js throws an error:

    sudo node main.js
        throw err;
    Error: Cannot find module 'connect'
        at Function.Module._resolveFilename (module.js:336:15)
        at Function.Module._load (module.js:278:25)
        at Module.require (module.js:365:17)
        at require (module.js:384:17)
        at Object.<anonymous> (/home/pi/node-virtual-gamepads/node_modules/express/lib/express.js:5:15)
        at Module._compile (module.js:460:26)
        at Object.Module._extensions..js (module.js:478:10)
        at Module.load (module.js:355:32)
        at Function.Module._load (module.js:310:12)
        at Module.require (module.js:365:17)

    Do you know what I did wrong?



    Hi Zombiebraut,

    What is your node and npm version ?

    You can check it with:

    node --version
    npm --version

    Here are the steps I followed to install Node and npm:

    # Download and unpack Node.js
    wget http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-arm-pi.tar.gz
    tar -xvzf node-v0.10.28-linux-arm-pi.tar.gz
    rm -r node-v0.10.28-linux-arm-pi.tar.gz
    # Move sources and create sym links
    sudo mv node-v0.10.28-linux-arm-pi /opt/node
sudo mkdir /opt/bin

    sudo ln -s /opt/node/bin/* /opt/bin/
    # Add binaries to the PATH, add this line at the end of '/etc/profile' file
    # test
    npm --version
    # Install node-gyp
    npm install -g node-gyp

    I remember that I encountered some issues by installing nodeJS and npm directly with aptitude.



    That is a very fascinating concept! generally speaking I think it might be more viable for games with more simple controls but a genius idea nonetheless. great work!

    Also- I think this would be a really useful thing to add to the wiki under advanced configurations.


    Once I get time I’ll try and test it out for myself and try and add it to the wiki if you don’t beat me to it.


    Hi Miroof,

    thank you for your quick reply :)

    I removed my packages and used your sources instead, I now run npm version 1.4.9 and node version v0.10.28

    I was now able to do the npm install without warnings. But when I type sudo node main.js I get sudo: node: command not found
    and without sudo again the error:

    node main.js
            throw er; // Unhandled 'error' event
    Error: listen EACCES
        at errnoException (net.js:904:11)
        at Server._listen2 (net.js:1023:19)
        at listen (net.js:1064:10)
        at Server.listen (net.js:1138:5)
        at Object.<anonymous> (/home/pi/node-virtual-gamepads/main.js:54:8)
        at Object.<anonymous> (/home/pi/node-virtual-gamepads/main.js:58:4)
        at Module._compile (module.js:456:26)
        at Object.Module._extensions..js (module.js:474:10)
        at Module.load (module.js:356:32)
        at Function.Module._load (module.js:312:12)


    When trying to execute npm install -g node-gyp I get the following error messages:

    npm http GET http://registry.npmjs.org/node-gyp
    npm http 304 http://registry.npmjs.org/node-gyp
    npm ERR! error rolling back Error: EACCES, unlink '/opt/lib/node_modules/node-gyp'
    npm ERR! error rolling back  node-gyp@1.0.3 { [Error: EACCES, unlink '/opt/lib/node_modules/node-gyp']
    npm ERR! error rolling back   errno: 3,
    npm ERR! error rolling back   code: 'EACCES',
    npm ERR! error rolling back   path: '/opt/lib/node_modules/node-gyp' }
    npm ERR! Error: EACCES, unlink '/opt/lib/node_modules/node-gyp'
    npm ERR!  { [Error: EACCES, unlink '/opt/lib/node_modules/node-gyp']
    npm ERR!   errno: 3,
    npm ERR!   code: 'EACCES',
    npm ERR!   path: '/opt/lib/node_modules/node-gyp' }
    npm ERR!
    npm ERR! Please try running this command again as root/Administrator.
    npm ERR! System Linux 3.18.7-v7+
    npm ERR! command "/opt/bin/node" "/opt/bin/npm" "install" "-g" "node-gyp"
    npm ERR! cwd /home/pi/node-virtual-gamepads
    npm ERR! node -v v0.10.28
    npm ERR! npm -v 1.4.9
    npm ERR! path /opt/lib/node_modules/node-gyp
    npm ERR! code EACCES
    npm ERR! errno 3
    npm ERR! stack Error: EACCES, unlink '/opt/lib/node_modules/node-gyp'
    npm ERR!
    npm ERR! Additional logging details can be found in:
    npm ERR!     /home/pi/node-virtual-gamepads/npm-debug.log
    npm ERR! not ok code 0



    You got an EACCESS error because by default the application listens on port 80 and without root privileges you can’t listen on ports below 1024.

    So you have two solutions :

    The first one is to launch the application with sudo (sudo node main.js) and this page can help you : http://stackoverflow.com/questions/4976658/on-ec2-sudo-node-command-not-found-but-node-without-sudo-is-ok

    The second solution is to edit the file config.json by changing the port 80 for a port above 1024 (like 3000). In this case the application will be reachable at http://localhost:3000.

    I never tried the application without root privileges so I hope you will not have other issues … The first solution is the best one for me.

    And about installing node-gyp it’s the same, you can’t do that without root privileges.



    Hi Miroof,

    Thank you for your help. I got it :)

    One last question: I now can open the virtual controller on my mobile but it doesn’t connect to pi and the “LEDs” just blink. What do I have to do to connect it to emulationstation?

    best regards


    For anyone who was having an issue with this, this is what I did to get it working from a fresh install (it’s a little easier than the above methods):

    #Install Node.js first:
    sudo apt-get update && sudo apt-get upgrade
    wget http://node-arm.herokuapp.com/node_latest_armhf.deb
    sudo dpkg -i node_latest_armhf.deb
    # must be run as root
    git clone https://github.com/miroof/node-virtual-gamepads
    cd node-virtual-gamepads
    npm install
    # The following steps are to get it to run everytime when the pi boots up
    # Install globally pm2
    sudo npm install pm2 -g
    # Launch virtual gamepads application with pm2
    sudo pm2 start main.js
    # Configure pm2 to launch at startup
    sudo pm2 startup
    # Save the current state of pm2 
    # to reload all current applications at startup
    sudo pm2 save
    #Then switch back to user pi to start up emulationstation and configure controller
    su pi
    #Once in emulationstation configure it like you would any other controller.

    type your IP address into your web browser: e.g.

    then configure your controller like you would any other controller in emulationstation and with retroarch configs and voila away you go.

    see source code at https://github.com/miroof/node-virtual-gamepads

    You’re a genius Miroof!

    btw Miroof- is there any way to get this to load automatically on boot or will I have to do this every time I want to play games with my android?


    Hi Herbfargus,

    Thanks a lot for the explanations :)

    To launch a node.js application at startup, I use the amazing project pm2:


    Simply run these commands:

    # Install globally pm2
    sudo npm install pm2 -g
    # Launch virtual gamepads application with pm2
    sudo pm2 start main.js
    # Configure pm2 to launch at startup
    sudo pm2 startup
    # Save the current state of pm2 
    # to reload all current applications at startup
    sudo pm2 save

    Normally it should launch the application again at startup. PM2 will also relaunch automatically the application in case of crash.

    I highly recommand it for all node.js projects !

    I hope it’s OK for you now ?



    @Miroof: everything works fine :) Thank you for your help. Great project!


    Thanks for the input Miroof, I’ll give it a go when I get the chance.

    I’ve submitted a request on github to have your script added as a retropie setup module

    ** Edit

    I followed your steps and it now runs on boot. Brilliant!

    I made a video of the steps I took to get it to work:


    Question: Is it possible for the configurations to be saved? I have to reconfigure it every time that I reboot (at least for emulationstation, I haven’t yet tested retroarch configs)


    Hi Herbfargus,

    Thanks a lot for your video, I will update the Github page to add it. I’m very happy to see that this project interests you :)

    About emulationStation I was sure that the config was saved … So I will take a look very soon.



    It is possible it has something to do with the latest SD image- I’ll do more testing when I’ve got some time- its not a super huge deal as it only takes a couple seconds to do.

    **EDIT upon further review the issue with saved configurations is a completely separate issue. It has nothing to do with the virtual game pad so disregard the previous post- your project works fine.

    Petrockblog is working on a thing called inputstation that is basically an all in one controller configuration- it looks and works like the controller configuration for emulation station except it has more options and configures controls for retroarch as well. I’ve tested it with your virtual gamepad and it doesn’t quite work with it yet, but once input station is more stable I want to make sure your project works with it.



    BTW, I added it to the Wiki: https://github.com/retropie/RetroPie-Setup/wiki/Virtual-Gamepad


    This is great! I had a similar idea a while back but didn’t have the savvy to implement it.

    One idea I did have was to set up the raspberry pi as an independent wifi hotspot. That way the phone wouldn’t have to be connected to the local wifi network at all, it could connect to the raspberry pi directly, which would route all requests to the controller page.

    Of course the drawbacks to this are pretty clear – I don’t think you’d be able to access the internet on your pi anymore. But it might be useful for someone who wanted their retroPie system to be a bit more portable. You also wouldn’t need to know the IP address of the raspberry pi, you’d just have to connect to the hotspot.

    Just a thought :)


    I am having issues with this. I am able to follow the steps up until entering su and password. When I enter su it prompts for a password. I try raspberry but it fails to Authenticate. A little research shows a command to set root password. I can access root but get an error when trying to install npm. Any Suggestions. I have tried this with several various builds including the latest RetroPie3.2.1. Below is what I get. Any help would be greatly appreciated.

    pi@retropie ~ $ su
    su: Authentication failure
    pi@retropie ~ $ sudo passwd root
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully
    pi@retropie ~ $ su
    root@retropie:/home/pi# git clone https://github.com/miroof/node-virtual-gamepads
    Cloning into ‘node-virtual-gamepads’…
    remote: Counting objects: 191, done.
    remote: Total 191 (delta 0), reused 0 (delta 0), pack-reused 191
    Receiving objects: 100% (191/191), 3.05 MiB | 1.68 MiB/s, done.
    Resolving deltas: 100% (81/81), done.
    root@retropie:/home/pi# cd node-virtual-gamepads
    root@retropie:/home/pi/node-virtual-gamepads# npm install
    /usr/local/bin/node: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.20′ not found (required by /usr/local/bin/node)
    /usr/local/bin/node: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.16’ not found (required by /usr/local/bin/node)


    Just install it from the experimental menu of the retropie setup script


Viewing 17 posts - 1 through 17 (of 17 total)
  • The forum ‘Peoples Projects’ is closed to new topics and replies.