Metadata-Version: 2.4
Name: gpio-pedal
Version: 0.1.1
Summary: Map Raspberry Pi GPIO pins to keyboard shortcuts — turn any foot pedal or button into a keystroke
Author-email: Whitney Smith <whitnaaays@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Whitney Smith
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/whitneyjsmith/gpio-pedal
Project-URL: Bug Tracker, https://github.com/whitneyjsmith/gpio-pedal/issues
Project-URL: Repository, https://github.com/whitneyjsmith/gpio-pedal
Keywords: raspberry-pi,gpio,pedal,footswitch,keyboard,automation,accessibility
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Home Automation
Classifier: Topic :: System :: Hardware
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: RPi.GPIO>=0.7.1; sys_platform == "linux"
Requires-Dist: pynput>=1.7.0
Provides-Extra: yaml
Requires-Dist: PyYAML>=6.0; extra == "yaml"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: build>=1.0; extra == "dev"
Requires-Dist: twine>=4.0; extra == "dev"
Dynamic: license-file

# gpio-pedal

[![PyPI Version](https://img.shields.io/pypi/v/gpio-pedal.svg)](https://pypi.org/project/gpio-pedal/)
[![Python Versions](https://img.shields.io/pypi/pyversions/gpio-pedal.svg)](https://pypi.org/project/gpio-pedal/)
[![License](https://img.shields.io/pypi/l/gpio-pedal.svg)](LICENSE)

**Turn any Raspberry Pi GPIO pin into a keyboard shortcut.**

Wire a foot pedal, footswitch, or momentary button to a GPIO pin and `gpio-pedal` will simulate whatever key press you configure — space bar, Ctrl+C, a media key, anything. Works great for hands-free control, live performance, transcription, accessibility setups, or any situation where your hands are busy.

---

## Features

- Map any number of GPIO pins to individual keys or key combinations (`ctrl+c`, `shift+f1`, etc.)
- Configurable debounce time to eliminate phantom presses
- Load config from a JSON or YAML file, or pass a plain Python dict
- CLI command (`gpio-pedal config.json`) for running without writing any code
- Clean shutdown on Ctrl+C with automatic GPIO cleanup

---

## Requirements

- Raspberry Pi (any model with GPIO)
- Python 3.9 or higher
- A normally-open momentary switch wired between a GPIO pin and GND

---

## Installation

```bash
pip install gpio-pedal
```

For YAML config file support:

```bash
pip install gpio-pedal[yaml]
```

---

## Hardware Setup

Wire your switch between the GPIO pin and GND. `gpio-pedal` enables the internal pull-up resistor automatically, so no external resistor is needed.

```
GPIO pin ──── [switch] ──── GND
```

For example, to use GPIO 17:

```
Pin 11 (GPIO 17) ──── [foot pedal] ──── Pin 9 (GND)
```

Use BCM pin numbering (the number after "GPIO", not the physical pin number).

---

## Quick Start

```python
from gpio_pedal import PedalController

config = {
    17: "space",    # GPIO 17 → Spacebar
    22: "ctrl+c",   # GPIO 22 → Ctrl+C
    27: "m",        # GPIO 27 → M key
}

pedal = PedalController(config)
pedal.run()
```

---

## CLI Usage

Create a JSON config file:

```json
{
    "17": "space",
    "22": "ctrl+c",
    "27": "m"
}
```

Then run:

```bash
gpio-pedal config.json
```

Options:

```
gpio-pedal config.json --bouncetime 200   # faster debounce (ms)
gpio-pedal config.json --verbose          # debug logging
gpio-pedal --version
gpio-pedal --help
```

---

## Config File Format

| Format | Extension | Install |
|--------|-----------|---------|
| JSON   | `.json`   | built-in |
| YAML   | `.yaml` / `.yml` | `pip install gpio-pedal[yaml]` |

**JSON example:**
```json
{
    "17": "space",
    "22": "ctrl+z",
    "27": "shift+f5"
}
```

**YAML example:**
```yaml
17: space
22: ctrl+z
27: shift+f5
```

Keys can be single characters (`a`, `1`, `!`) or any key name from
[pynput's Key enum](https://pynput.readthedocs.io/en/latest/keyboard.html),
such as `space`, `enter`, `tab`, `ctrl`, `shift`, `alt`, `f1`–`f20`, etc.
Combine them with `+` for shortcuts.

---

## Python API

```python
from gpio_pedal import PedalController, load_config
from gpio_pedal.utils import list_special_keys, describe_config

# Load from a file
config = load_config("config.json")

# Or define inline
config = {17: "space", 22: "ctrl+c"}

# See all supported special key names
print(list_special_keys())

# Preview your config before running
print(describe_config(config))

# Start listening (blocks until Ctrl+C)
controller = PedalController(config, bouncetime=300)
controller.run()
```

---

## Development

```bash
git clone https://github.com/whitneyjsmith/gpio-pedal.git
cd gpio-pedal
pip install -e ".[dev]"
pytest
```

---

## License

Distributed under the MIT License. See [LICENSE](LICENSE) for details.
