Giter Site home page Giter Site logo

teldra / hid-retrobit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from msteinbeck/hid-retrobit

0.0 0.0 0.0 69 KB

Linux driver for the retro-bit controller adapter USB cable

License: GNU General Public License v3.0

Shell 5.46% Makefile 1.79% Python 81.87% C 10.88%

hid-retrobit's Introduction

hid-retrobit is a Linux driver for the Retro-Bit (also known as Retro-Link) Atari, Nintendo NES, SNES, and Sega Genesis USB adapters. This driver enables you to use supported joysticks and gamepads in emulators.

http://www.amazon.com/gp/product/B007ZS35CU/
http://www.amazon.com/gp/product/B0080RAT42/

This driver is based on https://github.com/robmcmullen/hid-atari-retrobit. Unfortunately, it looks like RobMcMulle doesn't maintain it anymore. However, hid-retrobit is an improved version as it is much easier to install and use. Have a look at Details for more information.

Installation

Raspberry Pi (RetroPie/Raspbian)
  1. Download the latest deb package from: https://github.com/retuxx/hid-retrobit/releases.
  2. Install linux headers and dkms:
    sudo apt-get install raspberrypi-kernel-headers dkms
    
  3. Install the driver:
    sudo dpkg -i hid-retrobit.deb
    
  4. Plugin your device.
Debian, Ubuntu, SteamOS, ...
  1. Download the latest deb package from: https://github.com/retuxx/hid-retrobit/releases.
  2. Install dkms:
    sudo apt-get install dkms
    
  3. Install the driver:
    sudo dpkg -i hid-retrobit.deb
    
  4. Plugin your device.
Fedora, CentOS, ...
  1. Download the latest rpm package from: https://github.com/retuxx/hid-retrobit/releases.
  2. Make sure you have installed the latest kernel. Otherwise, dkms is unable to build the module because the linux headers are missing:
    sudo yum update
    
  3. Reboot your system.
  4. Install linux headers:
    sudo yum install kernel-devel
    
  5. Install the driver:
    sudo yum localinstall hid-retrobit-1.0.0-1.noarch.rpm
    
  6. Plugin your device.
Manual

Install the driver with the following commands:

make              # build the driver
sudo make install # install the driver
sudo depmod -a    # update the module dependency graph

Now you should be able to load the driver with:
(the dirver was successfully loaded if there is no terminal output)

sudo modprobe hid-retrobit

Unfortunately, the driver hid-generic prevents hid-retrobit from binding your device. The file 99-hid-retrobit.rules contains some udev rules which unbinds all supported devices from hid-generic and rebinds them to hid-retrobit on the fly. Copy this file to /etc/udev/rules.d. To ensure the udev rules are able to rebind your devices, you finally need to copy the file hid-retrobit.conf to /etc/modules-load.d.

Now your devices are ready to use. Restart your system and have fun playing games retro style :).

Alternate solution

If the following driver does not work, the desperate solution is to recompile your kernel. It could be a lengthy and tedious task and should be repeated on every incoming security patch or on your Linux distro updates.

Here is the fix. The Retrolink adapter does not follow the USB HIB specification (section 5.10 and 6.2.25) and returns out-of-bound values. Contrary to the former, the HID driver strictly follows the specification and ignores such values. The fix consists in clamping the values instead of discarding them.

In your linux kernel source directory, edit the file /drivers/hid/hid-input.c

Search for:

if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
    (value < field->logical_minimum ||
    value > field->logical_maximum)) {
        dbg_hid("Ignoring out-of-range value %x\n", value);
        return;
}

and replace by:

if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
    (value < field->logical_minimum ||
    value > field->logical_maximum)) {
        if(value < field->logical_minimum)
            value = field->logical_minimum;
        else
            value = field->logical_maximum;
}

This fix could be improved by a new USB quirk assigned to Retrolink devices.

hid-retrobit's People

Contributors

msteinbeck avatar robmcmullen avatar vvivanloc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.