Giter Site home page Giter Site logo

keyboard-to-joystick's Introduction

Keyboard to Joystick

This program translates keyboard events to joystick events! It was made with the main purpose of emulating joystick movement with the mouse.

Usage:

Clone the repository and execute the program using cargo. The user needs to be in the "input" group; otherwise, it will be necessary to run the program as root. It is also necessary for the uinput module to be activated.

sudo modprobe uinput
cargo run --release

Configuration:

The program uses an environment variable called "GAMEPAD_PROFILES". Its configuration file must be called "virtualconf.json". Below is an example of configuration:

virtualconf.json

{
    "mouse" : "/dev/input/event7",
    "keyboard" : "/dev/input/event6",
    "events" : {
        "REL_X": "10000|+|ABS_X",
        "REL_Y": "10000|+|ABS_Y",
        "BTN_LEFT": "1|+|BTN_WEST",
        "BTN_RIGHT": "1|+|BTN_TR",
        "KEY_W": "100000|-|ABS_RY",
        "KEY_A": "100000|-|ABS_RX",
        "KEY_S": "100000|+|ABS_RY",
        "KEY_D": "100000|+|ABS_RX",
        "KEY_F": "1|+|BTN_SOUTH",
        "KEY_Q": "1|+|BTN_MODE",
        "KEY_SPACE": "1|+|BTN_NORTH",
        "KEY_E": "1|+|BTN_TL",
        "KEY_X": "1|+|BTN_THUMBL",
        "KEY_LEFTCTRL": "1|+|BTN_THUMBR",
        "KEY_LEFTSHIFT": "1|+|BTN_EAST",
        "KEY_3": "1|+|BTN_THUMB",
        "KEY_R": "1|+|BTN_SELECT",
        "KEY_1": "1|+|BTN_START",
        "KEY_LEFT": "1|+|BTN_DPAD_LEFT",
        "KEY_RIGHT": "1|+|BTN_DPAD_RIGHT",
        "KEY_UP": "1|+|BTN_DPAD_UP",
        "KEY_DOWN": "1|+|BTN_DPAD_DOWN"
    }
}

The file needs to declare mouse, which is the path to your mouse in /dev/input. The same goes for the keyboard. In events, the first value corresponds to the trigger, that is, the mouse/keyboard event. The value associated with the trigger is the Virtual Joystick event, in the following format:

{Value multiplier}|{Multiplication sign}|{Event}

To find out the valid events, visit the documentation of the evdev library for Rust.

keyboard-to-joystick's People

Contributors

zillaz avatar

Watchers

 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.