mistercar-input-devices


Namemistercar-input-devices JSON
Version 0.3.0 PyPI version JSON
download
home_pagehttps://github.com/PypayaTech/mistercar-input-devices
SummaryRead and emulate keyboard, mouse, gamepad, and steering wheel
upload_time2024-11-29 22:59:48
maintainerNone
docs_urlNone
authorPypayaTech
requires_python<4.0,>=3.10
licenseMIT
keywords input reading input emulation gui automation keyboard mouse gamepad
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🎮 mistercar-input-devices

A cross-platform Python package for capturing and emulating keyboard, mouse, and gamepad inputs.

## 🌟 Features

- ⌨ī¸ Keyboard input capture and emulation
- 🖱ī¸ Mouse input capture and emulation
- 🕹ī¸ Gamepad input capture and emulation
- 🏎ī¸ Racing wheel input capture
- đŸ–Ĩī¸ Cross-platform support (Windows, macOS, Linux)

## 🚀 Installation

You can install mistercar-input-devices using pip:

```bash
pip install mistercar-input-devices
```

### 📋 Prerequisites

- Python 3.10 or higher

#### Windows-specific setup

1. Disable driver signature enforcement. This is necessary for installing unsigned drivers. Follow the instructions in this guide: [How to disable driver signature enforcement on Windows 10](https://medium.com/@pypaya_tech/unlock-your-windows-a-guide-to-disabling-driver-signature-enforcement-342103d51997)

2. Open a command prompt as an administrator.

3. Navigate to the appropriate directory:
   - For 64-bit systems: `cd path\to\mistercar_input_devices\backend\windows\platform_specific\pyxinput\ScpVBus-x64`
   - For 32-bit systems: `cd path\to\mistercar_input_devices\backend\windows\platform_specific\pyxinput\ScpVBus-x86`

4. Run the following command:
   ```
   devcon.exe install ScpVBus.inf Root\ScpVBus
   ```

## đŸŽ¯ Usage

Here are some basic examples of how to use mistercar-input-devices:

### ⌨ī¸ Keyboard

```python
from mistercar_input_devices.input_readers.keyboard_reader import global_keyboard_reader
from mistercar_input_devices.input_emulators.keyboard_emulator import global_keyboard_emulator

# Check if a key is pressed
if global_keyboard_reader.get_key_state('A'):
    print("A key is pressed")

# Press a key
global_keyboard_emulator.emulate_key('B', 1)  # Press
global_keyboard_emulator.emulate_key('B', 0)  # Release
```

### 🖱ī¸ Mouse

```python
from mistercar_input_devices.input_readers.mouse_reader import global_mouse_reader
from mistercar_input_devices.input_emulators.mouse_emulator import global_mouse_emulator

# Read mouse position
x, y = global_mouse_reader.get_cursor_position()
print(f"Mouse position: {x}, {y}")

# Move mouse
global_mouse_emulator.move_cursor_to(100, 100)

# Click
global_mouse_emulator.left_click()
```

### 🕹ī¸ Gamepad

```python
from mistercar_input_devices.input_readers.gamepad_reader import global_gamepad_reader
from mistercar_input_devices.input_emulators.gamepad_emulator import global_gamepad_emulator

# Read gamepad state
gamepad_state = global_gamepad_reader.get_control_state('AxisLx')
print(f"Left stick X-axis: {gamepad_state}")

# Emulate gamepad input
global_gamepad_emulator.emulate_control('AxisLx', 0.5)  # Move left stick halfway to the right
```

### 🏎ī¸ Racing Wheel

```python
from mistercar_input_devices.input_readers.wheel_reader.manufacturers.thrustmaster.tmx import (
    global_tmx_wheel, WheelButton
)

# Get complete wheel state
state = global_tmx_wheel.get_state()
print(f"Steering: {state.steering:.2f}")  # -1.0 (full left) to 1.0 (full right)
print(f"Throttle: {state.throttle:.2f}")  # 0.0 to 1.0
print(f"Brake: {state.brake:.2f}")        # 0.0 to 1.0
print(f"Clutch: {state.clutch:.2f}")      # 0.0 to 1.0

# Check specific buttons
if state.buttons[WheelButton.XBOX_A]:
    print("A button is pressed")

if state.buttons[WheelButton.PADDLE_RIGHT]:
    print("Right paddle shifter is pressed")

# Switch pedal mode if needed (for wheels that support it)
global_tmx_wheel.set_pedal_mode("swapped")  # Changes throttle/clutch mapping
```

## 🚀 Examples

Check out the `examples` directory for comprehensive demonstrations of the library's capabilities. We provide three example scripts:

1. `keyboard_example.py`: Demonstrates keyboard input reading and emulation.
2. `mouse_example.py`: Shows mouse input reading and emulation.
3. `gamepad_example.py`: Illustrates gamepad input reading and emulation.
4. `read_thrustmaster_tmx_wheel.py`: Illustrates Thrustmaster TMX steering wheel input reading.

## 📊 Implementation status

The current implementation status of mistercar-input-devices across different platforms:

| Feature | Windows | Linux | macOS |
|---------|---------|-------|-------|
| Keyboard Reader | ✅ | ❌ | ❌ |
| Keyboard Emulator | ✅ | ✅ | ✅ |
| Mouse Reader | ✅ | ❌ | ❌ |
| Mouse Emulator | ✅ | ✅ | ✅ |
| Gamepad Reader | ✅ | ❌ | ❌ |
| Gamepad Emulator | ✅ | ❌ | ❌ |
| Racing Wheel Reader | ⚠ī¸ | ❌ | ❌ |

Legend:
- ✅ Fully implemented
- ⚠ī¸ Partially implemented or needs testing
- ❌ Not yet implemented

### Supported racing wheels

Currently supported racing wheel models:
- Thrustmaster TMX Racing Wheel (Windows only)

### Notes on implementation

- Windows: Custom low-level implementation for all features, ensuring reliability in various contexts, including video games.
- Linux and macOS: 
  - Keyboard and Mouse emulation use PyAutoGUI, which works well in most contexts but may have limitations in some video games.
  - Keyboard and Mouse reading functionality is not yet implemented.
  - Gamepad functionality is not yet implemented.
- Racing wheel support is currently limited to specific models on Windows, with plans to expand both device and platform support.

### Roadmap

- Implement keyboard and mouse reading functionality for Linux and macOS platforms.
- Implement gamepad support for Linux and macOS.
- Enhance cross-platform compatibility and consistency.
- Explore options for more reliable input methods in game contexts for Linux and macOS.
- Expand racing wheel support to more models and manufacturers
- Implement force feedback support for compatible wheels
- Add racing wheel support for Linux and macOS platforms

We welcome contributions to help improve and extend the library's functionality across all supported platforms!

## 🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgments

Special thanks to the creators of these libraries and projects that have been instrumental in the development of mistercar-input-devices:

- [PYXInput](https://github.com/bayangan1991/PYXInput): For gamepad reading and emulation implementation on Windows.
- [pygta5](https://github.com/Sentdex/pygta5): For inspiration from the self-driving car GTA V project and the `keys.py` file, which was particularly helpful for implementing keyboard emulation on Windows.
- [PyAutoGUI](https://pypi.org/project/PyAutoGUI/): For providing cross-platform keyboard and mouse emulation capabilities, especially utilized in our Linux and macOS implementations.
- [PyWinUSB](https://github.com/rene-aguirre/pywinusb): For USB device communication on Windows, enabling racing wheel support.

We are grateful for the open-source community and these projects that have made our work possible.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PypayaTech/mistercar-input-devices",
    "name": "mistercar-input-devices",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "input reading, input emulation, GUI automation, keyboard, mouse, gamepad",
    "author": "PypayaTech",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/a3/7a/4cfcb3791c8018210f7ee4ab32fc21904b9b187297097eb269f2d768d998/mistercar_input_devices-0.3.0.tar.gz",
    "platform": null,
    "description": "# \ud83c\udfae mistercar-input-devices\n\nA cross-platform Python package for capturing and emulating keyboard, mouse, and gamepad inputs.\n\n## \ud83c\udf1f Features\n\n- \u2328\ufe0f Keyboard input capture and emulation\n- \ud83d\uddb1\ufe0f Mouse input capture and emulation\n- \ud83d\udd79\ufe0f Gamepad input capture and emulation\n- \ud83c\udfce\ufe0f Racing wheel input capture\n- \ud83d\udda5\ufe0f Cross-platform support (Windows, macOS, Linux)\n\n## \ud83d\ude80 Installation\n\nYou can install mistercar-input-devices using pip:\n\n```bash\npip install mistercar-input-devices\n```\n\n### \ud83d\udccb Prerequisites\n\n- Python 3.10 or higher\n\n#### Windows-specific setup\n\n1. Disable driver signature enforcement. This is necessary for installing unsigned drivers. Follow the instructions in this guide: [How to disable driver signature enforcement on Windows 10](https://medium.com/@pypaya_tech/unlock-your-windows-a-guide-to-disabling-driver-signature-enforcement-342103d51997)\n\n2. Open a command prompt as an administrator.\n\n3. Navigate to the appropriate directory:\n   - For 64-bit systems: `cd path\\to\\mistercar_input_devices\\backend\\windows\\platform_specific\\pyxinput\\ScpVBus-x64`\n   - For 32-bit systems: `cd path\\to\\mistercar_input_devices\\backend\\windows\\platform_specific\\pyxinput\\ScpVBus-x86`\n\n4. Run the following command:\n   ```\n   devcon.exe install ScpVBus.inf Root\\ScpVBus\n   ```\n\n## \ud83c\udfaf Usage\n\nHere are some basic examples of how to use mistercar-input-devices:\n\n### \u2328\ufe0f Keyboard\n\n```python\nfrom mistercar_input_devices.input_readers.keyboard_reader import global_keyboard_reader\nfrom mistercar_input_devices.input_emulators.keyboard_emulator import global_keyboard_emulator\n\n# Check if a key is pressed\nif global_keyboard_reader.get_key_state('A'):\n    print(\"A key is pressed\")\n\n# Press a key\nglobal_keyboard_emulator.emulate_key('B', 1)  # Press\nglobal_keyboard_emulator.emulate_key('B', 0)  # Release\n```\n\n### \ud83d\uddb1\ufe0f Mouse\n\n```python\nfrom mistercar_input_devices.input_readers.mouse_reader import global_mouse_reader\nfrom mistercar_input_devices.input_emulators.mouse_emulator import global_mouse_emulator\n\n# Read mouse position\nx, y = global_mouse_reader.get_cursor_position()\nprint(f\"Mouse position: {x}, {y}\")\n\n# Move mouse\nglobal_mouse_emulator.move_cursor_to(100, 100)\n\n# Click\nglobal_mouse_emulator.left_click()\n```\n\n### \ud83d\udd79\ufe0f Gamepad\n\n```python\nfrom mistercar_input_devices.input_readers.gamepad_reader import global_gamepad_reader\nfrom mistercar_input_devices.input_emulators.gamepad_emulator import global_gamepad_emulator\n\n# Read gamepad state\ngamepad_state = global_gamepad_reader.get_control_state('AxisLx')\nprint(f\"Left stick X-axis: {gamepad_state}\")\n\n# Emulate gamepad input\nglobal_gamepad_emulator.emulate_control('AxisLx', 0.5)  # Move left stick halfway to the right\n```\n\n### \ud83c\udfce\ufe0f Racing Wheel\n\n```python\nfrom mistercar_input_devices.input_readers.wheel_reader.manufacturers.thrustmaster.tmx import (\n    global_tmx_wheel, WheelButton\n)\n\n# Get complete wheel state\nstate = global_tmx_wheel.get_state()\nprint(f\"Steering: {state.steering:.2f}\")  # -1.0 (full left) to 1.0 (full right)\nprint(f\"Throttle: {state.throttle:.2f}\")  # 0.0 to 1.0\nprint(f\"Brake: {state.brake:.2f}\")        # 0.0 to 1.0\nprint(f\"Clutch: {state.clutch:.2f}\")      # 0.0 to 1.0\n\n# Check specific buttons\nif state.buttons[WheelButton.XBOX_A]:\n    print(\"A button is pressed\")\n\nif state.buttons[WheelButton.PADDLE_RIGHT]:\n    print(\"Right paddle shifter is pressed\")\n\n# Switch pedal mode if needed (for wheels that support it)\nglobal_tmx_wheel.set_pedal_mode(\"swapped\")  # Changes throttle/clutch mapping\n```\n\n## \ud83d\ude80 Examples\n\nCheck out the `examples` directory for comprehensive demonstrations of the library's capabilities. We provide three example scripts:\n\n1. `keyboard_example.py`: Demonstrates keyboard input reading and emulation.\n2. `mouse_example.py`: Shows mouse input reading and emulation.\n3. `gamepad_example.py`: Illustrates gamepad input reading and emulation.\n4. `read_thrustmaster_tmx_wheel.py`: Illustrates Thrustmaster TMX steering wheel input reading.\n\n## \ud83d\udcca Implementation status\n\nThe current implementation status of mistercar-input-devices across different platforms:\n\n| Feature | Windows | Linux | macOS |\n|---------|---------|-------|-------|\n| Keyboard Reader | \u2705 | \u274c | \u274c |\n| Keyboard Emulator | \u2705 | \u2705 | \u2705 |\n| Mouse Reader | \u2705 | \u274c | \u274c |\n| Mouse Emulator | \u2705 | \u2705 | \u2705 |\n| Gamepad Reader | \u2705 | \u274c | \u274c |\n| Gamepad Emulator | \u2705 | \u274c | \u274c |\n| Racing Wheel Reader | \u26a0\ufe0f | \u274c | \u274c |\n\nLegend:\n- \u2705 Fully implemented\n- \u26a0\ufe0f Partially implemented or needs testing\n- \u274c Not yet implemented\n\n### Supported racing wheels\n\nCurrently supported racing wheel models:\n- Thrustmaster TMX Racing Wheel (Windows only)\n\n### Notes on implementation\n\n- Windows: Custom low-level implementation for all features, ensuring reliability in various contexts, including video games.\n- Linux and macOS: \n  - Keyboard and Mouse emulation use PyAutoGUI, which works well in most contexts but may have limitations in some video games.\n  - Keyboard and Mouse reading functionality is not yet implemented.\n  - Gamepad functionality is not yet implemented.\n- Racing wheel support is currently limited to specific models on Windows, with plans to expand both device and platform support.\n\n### Roadmap\n\n- Implement keyboard and mouse reading functionality for Linux and macOS platforms.\n- Implement gamepad support for Linux and macOS.\n- Enhance cross-platform compatibility and consistency.\n- Explore options for more reliable input methods in game contexts for Linux and macOS.\n- Expand racing wheel support to more models and manufacturers\n- Implement force feedback support for compatible wheels\n- Add racing wheel support for Linux and macOS platforms\n\nWe welcome contributions to help improve and extend the library's functionality across all supported platforms!\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Acknowledgments\n\nSpecial thanks to the creators of these libraries and projects that have been instrumental in the development of mistercar-input-devices:\n\n- [PYXInput](https://github.com/bayangan1991/PYXInput): For gamepad reading and emulation implementation on Windows.\n- [pygta5](https://github.com/Sentdex/pygta5): For inspiration from the self-driving car GTA V project and the `keys.py` file, which was particularly helpful for implementing keyboard emulation on Windows.\n- [PyAutoGUI](https://pypi.org/project/PyAutoGUI/): For providing cross-platform keyboard and mouse emulation capabilities, especially utilized in our Linux and macOS implementations.\n- [PyWinUSB](https://github.com/rene-aguirre/pywinusb): For USB device communication on Windows, enabling racing wheel support.\n\nWe are grateful for the open-source community and these projects that have made our work possible.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Read and emulate keyboard, mouse, gamepad, and steering wheel",
    "version": "0.3.0",
    "project_urls": {
        "Homepage": "https://github.com/PypayaTech/mistercar-input-devices",
        "Repository": "https://github.com/PypayaTech/mistercar-input-devices"
    },
    "split_keywords": [
        "input reading",
        " input emulation",
        " gui automation",
        " keyboard",
        " mouse",
        " gamepad"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0efa7cffd2b345d4f7ad47d1ea5727b8330d2e9fb0a7dd9de359af2ce065cbed",
                "md5": "36fb4a842623861da9a88dc87f2dfe83",
                "sha256": "811964e75602112f5bf3236eee792c757b626c2c60c25e7222c72c4eef22f933"
            },
            "downloads": -1,
            "filename": "mistercar_input_devices-0.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "36fb4a842623861da9a88dc87f2dfe83",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 5467298,
            "upload_time": "2024-11-29T22:59:43",
            "upload_time_iso_8601": "2024-11-29T22:59:43.639490Z",
            "url": "https://files.pythonhosted.org/packages/0e/fa/7cffd2b345d4f7ad47d1ea5727b8330d2e9fb0a7dd9de359af2ce065cbed/mistercar_input_devices-0.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a37a4cfcb3791c8018210f7ee4ab32fc21904b9b187297097eb269f2d768d998",
                "md5": "d7c5817d742d25facbb67259d979d6eb",
                "sha256": "dad3b0c1ef96ad59e358ed1a50284cb55ce8738f79470c475b55d2626f126a49"
            },
            "downloads": -1,
            "filename": "mistercar_input_devices-0.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d7c5817d742d25facbb67259d979d6eb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 5433999,
            "upload_time": "2024-11-29T22:59:48",
            "upload_time_iso_8601": "2024-11-29T22:59:48.457515Z",
            "url": "https://files.pythonhosted.org/packages/a3/7a/4cfcb3791c8018210f7ee4ab32fc21904b9b187297097eb269f2d768d998/mistercar_input_devices-0.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-29 22:59:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PypayaTech",
    "github_project": "mistercar-input-devices",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "mistercar-input-devices"
}
        
Elapsed time: 1.85960s