Giter VIP home page Giter VIP logo

pycontroller's Introduction

PyController


License: GPL v3 GitHub release (latest by date including pre-releases)

A Game Pad key mapping utility for Linux. It works well with any modern USB device including Game Controllers (XBox One), Game Pads (Razer Tartarus), Keyboards and mice.

  • NOTE: It does not do macros IE: map one key press to multiple pre-programmed presses. This may be included in a future release.
  • NOTE: This app should run before any games run as it generates a new input device and some games cannot handle a new USB device being plugged in.

Install


This utility requires Python 3.7+

# Install requirements (pip should point to a Python 3.7+ environment.
# cd to path
pip install -r requirements.txt
# Once this is has an official non-beta release this will be published on PyPI and this command can change
pip install .

This tool was originally made for The Razor Nostromo but can work on any other game pad that can be manipulated by evdev. (Which should be all USB keyboard devices)

The main config file is called main.yaml. It references files for devices in devices.d/.

Finding and connecting devices


To add your own device simply add the file in device.d following the exampleDevice.yaml config file. Then reference that config file in main.yaml.

A note about VendorID and ProductID. To find your device simply use the command:

python3 PyController.py --list-devices

You can also use the 'lsusb' command. The VendorID and ProductID will follow the word 'ID' and be followed by the name of the device. They are separated by a colon IE: ':'.

Example:

lsusb | grep Razer
~> Bus 001 Device 006: ID 1532:0111 Razer USA, Ltd

If you do not see your listed device using the '--list-devices' flag for PyController but do see it under 'lsusb' then it is possible there is a permissions issue. Checks perms like so:

ls -l /dev/input
crw-rw---- 1 root input 13,  64 Feb 26 12:47 event0

Most distros will automatically create the device with root:input permissions. You can add the user to the 'input' group like so: (you will need to be root to do this) You may also need to reboot after making this change.

sudo usermod -G input <username>

Editing configuration


Upon running PyController for the first time this application should generate a PyController config file. This should be located in "~/.config/PyController/". Run '--show-config-path' to verify:

python3 PyController.py --show-config-path

/home/rye/.config/PyController/main.yaml

Under the 'PyController/' config directory there will be a 'main.yaml' and two directories 'devices.d' and 'profiles.d'.

Edit the main.yaml to enable and disable logging. As well as to specify which device and profile config files should be active. Example devices.yaml below:

--- !Device # This has to be here it tells yaml to make the below information into a PyController Device object.
name: ExampleDevice # This has to be here to and with no spaces.
fullname: "Example Full Name of Device" # This is an optional key and used if there are multiple entries for the device
                                        # and there is a need to specify which device to capture. The full name can be 
                                        # seen using the flag '--list-devices'.
vendorid: '1111' # Also required and can be found via the lsusb command
productid: '2222' # Also required and can be found via the lsusb command
type: 'EV_KEY' # This should default to EV_KEY as it currently the only supported type. Others include EV_LED and so on.
keys: # This and all below it is not required. This is where you can remap keys.
  KEY_A: KEY_B # If you do want to remap a key it has to be the lines following the 'keys:' and it has spaced like this
    # example
  KEY_LEFTALT: KEY_SPACE

Too determine what KEYS to use you can use the following flags:

# Lists a printout of keys on a standard QWERTY keyboard
python3 PyController.py --print-classic-keys
# Provides the specified device's aviable key presses.
python3 PyController.py --print-capabilities XXXX:XXXX
# If you are still having trouble using this flag will listen to the device. 
# You can try different keys to see what there symbol is.
python3 PyController.py --print-key-presses XXXX:XXXX

Game Profiles


PyController supports making key mapping specific to a game. It will run a monitor in another process which will watch for any configured game and then load the configured keymaps and unload those keymaps once the game is no longer running. This also supports keymaps for specific devices per game.

The example Yaml config file:

# The 'executable' value should be the name or part of the full path of the application. Launch the game and use
#  'ps -wweo comm,args' to find what the game binary is called as it may not be what you expect.
RTS: # This will be the name of the profile
  executable: CompanyOfHeroes2 # This should be the name of the executable that runs your game. IE CompanyOfHeroes
  defualts-keys: # Below is a list of keys that should be remapped across all enabled devices
    KEY_LEFTALT: KEY_U # This must be spaced just like this. Invalid yaml entries will cause an error. Invalid KEY_* 
                       # entries will be ignored.
  devices:
    - Name: "Nostromo" # The name of the device as per the 'name' field in the device.yaml config file.
      keys:
        KEY_S: KEY_T
    - Name: "Tartarus_V2" # Can have more than one specified device.
      keys:
        KEY_S: KEY_T
RPGs: # There can be multiple profiles in the same config file.
  executable: [pillarsofeternity, kingmaker.exe] # You can link multiple games to one profile. This is not case-sensitive
  keys:
    KEY_A: KEY_B

More information will follow.

pycontroller's People

Contributors

orcephrye avatar

Watchers

 avatar

Forkers

derekmoyes

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.