Skip to main content

Windows-only controller to keyboard mapper for browser games

Project description

PipKeyMon

PipKeyMon is a small Windows-only Python package that reads a game controller with pygame and injects real keyboard input with Win32 SendInput. It is aimed at browser-based games that only understand keyboard input.

Features

  • Controller buttons to keyboard keys

  • Controller buttons to arrow keys

  • D-pad or hat input to arrow keys

  • Joystick axes to digital keys using thresholds

  • Press and release handling

  • Clean release of held keys on shutdown

  • CLI entry point and python -m support

  • Human-editable JSON config that is auto-created on first run

Windows Only

This package only supports Windows because it injects keyboard input through Win32 SendInput with scan-code-based events.

Quick Start

Open a terminal and run exactly:

cd C:\ControlerKeysMapper
py -3.12 -m venv .venv
.venv\Scripts\activate
python -m pip install --upgrade pip
pip install -e .
pipkeymon --help
pipkeymon run

If you need to inspect controller input while setting up mappings, use debug mode after the normal run path is working:

pipkeymon run --debug

The same commands also work with python -m:

cd C:\ControlerKeysMapper
.venv\Scripts\activate
python -m pipkeymon --help
python -m pipkeymon run

Editable Install

For normal development:

cd C:\ControlerKeysMapper
py -3.12 -m venv .venv
.venv\Scripts\activate
python -m pip install --upgrade pip
pip install -e .

If you want to build the Sphinx docs too:

pip install -e .[docs]

How To Run

Normal mode:

pipkeymon run

Debug mode:

pipkeymon run --debug

Or:

python -m pipkeymon run --debug

Config Location

The config file is created automatically on first run at:

%LOCALAPPDATA%\PipKeyMon\config.json

You can print the path:

pipkeymon config-path

You can open it in your default editor:

pipkeymon edit-config

Default Mapping

The default JSON config maps:

  • Button 0 to SPACE

  • Button 1 to ESCAPE

  • Hat 0 to arrow keys

  • Axis 0 to A and D

  • Axis 1 to W and S

Some controllers expose the d-pad as a hat, and some expose it as ordinary buttons. During validation on a DualSense in this environment, pygame reported zero hats, so d-pad directions may need to be mapped through button_map after a short debug run.

Example config:

{
  "selected_controller_index": 0,
  "poll_interval_ms": 8,
    "axis_deadzone": 0.12,
  "button_map": {
    "0": "SPACE",
    "1": "ESCAPE"
  },
  "hat_map": {
    "0": {
      "up": "UP",
      "down": "DOWN",
      "left": "LEFT",
      "right": "RIGHT"
    }
  },
  "axis_map": {
    "0": {
      "negative": "A",
      "positive": "D",
      "threshold": 0.5
    },
    "1": {
      "negative": "W",
      "positive": "S",
      "threshold": 0.5
    }
  }
}

axis_deadzone clamps small stick jitter back to zero before threshold handling. You can also set deadzone inside an individual axis mapping to override the global default for that axis.

Typical After-Work Flow

cd C:\ControlerKeysMapper
py -3.12 -m venv .venv
.venv\Scripts\activate
python -m pip install --upgrade pip
pip install -e .
pipkeymon --help
pipkeymon run --debug
pipkeymon edit-config
pipkeymon run

Then open your browser, navigate to the game, and play.

Known Limitations

  • Windows only

  • No GUI

  • No profile manager

  • No rumble or controller feedback

  • Default controller button numbering depends on how pygame reports the device

  • Some controllers report the d-pad as buttons instead of a hat, so the config may need a quick debug-driven adjustment

  • Only one selected controller is read at a time

  • Axis mapping is digital threshold-based rather than analog

Documentation

Sphinx docs live under docs/.

Build them with:

pip install -e .[docs]
sphinx-build -b html docs docs/_build/html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pipkeymon-0.1.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pipkeymon-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file pipkeymon-0.1.0.tar.gz.

File metadata

  • Download URL: pipkeymon-0.1.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for pipkeymon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6e6e774f3849423da27f21861cb087e0acda61f7a0338f759777170ec9112d5a
MD5 799dabb6f07c9953a8abf2c1c4a6dac2
BLAKE2b-256 f19622fd8c210f667d4ea33e2ba418d88c6ba795939f5b8301553801c613800e

See more details on using hashes here.

File details

Details for the file pipkeymon-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pipkeymon-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for pipkeymon-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc782acc4f7b7c5f680f0dc7203fceff553a8fa3c10e93fcaa9b82d177f4c21b
MD5 3b0e47183b230cc1e0744ea0cf0c37cf
BLAKE2b-256 c64ba28a088668885170b8b8e054903809e679636585c975c62a9fe7f1af2a7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page