{"id":41688055,"url":"https://github.com/younes-alhyan/ps4-controller-simulator","last_synced_at":"2026-01-24T20:00:00.148Z","repository":{"id":286705908,"uuid":"962277637","full_name":"younes-alhyan/ps4-controller-simulator","owner":"younes-alhyan","description":"This script lets PCs without Bluetooth or USB use a PS4 controller via an Android phone. It forwards controller input through vJoy and x360ce, making games recognize it as an Xbox 360 controller. 🚀","archived":false,"fork":false,"pushed_at":"2025-09-04T03:19:02.000Z","size":199,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-04T04:38:00.676Z","etag":null,"topics":["android-app","diy-project","gamepad-api","gamepad-emulator","input-simulator","ps4-controller","virtual-controller","virtual-controllers"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/younes-alhyan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-07T23:17:56.000Z","updated_at":"2025-09-04T03:19:05.000Z","dependencies_parsed_at":"2025-08-13T21:38:04.669Z","dependency_job_id":"e4f9cb74-6447-4744-b891-13b9aa86c64a","html_url":"https://github.com/younes-alhyan/ps4-controller-simulator","commit_stats":null,"previous_names":["itachi-555/ps4controllersimulator","younes-alhyan/ps4controllersimulator","younes-alhyan/ps4-controller-simulator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/younes-alhyan/ps4-controller-simulator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younes-alhyan%2Fps4-controller-simulator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younes-alhyan%2Fps4-controller-simulator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younes-alhyan%2Fps4-controller-simulator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younes-alhyan%2Fps4-controller-simulator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/younes-alhyan","download_url":"https://codeload.github.com/younes-alhyan/ps4-controller-simulator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younes-alhyan%2Fps4-controller-simulator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28736103,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T19:23:36.361Z","status":"ssl_error","status_checked_at":"2026-01-24T19:23:28.966Z","response_time":89,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android-app","diy-project","gamepad-api","gamepad-emulator","input-simulator","ps4-controller","virtual-controller","virtual-controllers"],"created_at":"2026-01-24T19:59:59.459Z","updated_at":"2026-01-24T20:00:00.142Z","avatar_url":"https://github.com/younes-alhyan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎮 PS4 Controller Simulator\n\n[![Python](https://img.shields.io/badge/Python-3776AB?style=flat-square\u0026logo=python\u0026logoColor=white)](https://www.python.org/)\n[![PS4](https://img.shields.io/badge/PS4-003791?style=flat-square\u0026logo=playstation\u0026logoColor=white)](https://www.playstation.com/)\n[![ADB](https://img.shields.io/badge/ADB-3DDC84?style=flat-square\u0026logo=android\u0026logoColor=white)](https://developer.android.com/studio#downloads)\n[![vJoy](https://img.shields.io/badge/vJoy-000000?style=flat-square\u0026logo=youtubegaming\u0026logoColor=white)](https://vjoystick.sourceforge.io/)\n\n**This script bridges the gap for PCs without Bluetooth or a USB connection. It connects to an Android phone via ADB, reads input from a PS4 controller connected to the phone, and simulates a virtual controller on Windows using vJoy and x360ce. Essentially, the phone forwards the PS4 controller’s inputs to a vJoy device, and x360ce converts them into an Xbox 360 controller that PC games can recognize.** 🚀\n\n## 📑 Table of Contents\n\n- [🔍 Overview](#overview)\n- [⚙️ Requirements](#requirements)\n- [🛠️ Setup](#setup)\n- [🔗 Getting the `controller_device_path`](#getting-the-controller_device_path)\n- [🎛️ vJoy Configuration](#vjoy-configuration)\n- [🚀 Running the Script](#running-the-script)\n- [🕹️ Making It Work in Games Using x360ce](#making-it-work-in-games-using-x360ce)\n- [🎮 Controller Mapping Table](#controller-mapping-table)\n- [🗂️ File Descriptions](#file-descriptions)\n- [⚠️ Troubleshooting](#troubleshooting)\n\n\u003cspan id=\"overview\"\u003e\u003c/span\u003e\n\n## 🔍 Overview\n\n- **Main Components**:\n\n- `main.py`: The entry point of the application. It sets up signal handling for graceful shutdown and starts listening for controller input.\n\n- `controller.py`: Listens for input events from the Android phone using ADB, processes the events, and forwards them to `vJoy`.\n\n- `event_handler.py`: Handles specific events such as button presses, triggers, and stick movements, translating them into vJoy actions.\n\n- `utils.py`: Utility functions for scaling inputs and parsing D-pad values.\n\n- `config.py`: Configuration file with mappings for buttons, triggers, and axes.\n\n\u003cspan id=\"requirements\"\u003e\u003c/span\u003e\n\n## ⚙️ Requirements\n\n1.  **Python 3.x**\\\n    Ensure you have Python 3 installed on your system.\n\n2.  **Dependencies**:\n\n    - `pyvjoy`: Python bindings for the vJoy API, which simulates the controller.\n\n    - `subprocess`: Used to interact with ADB and read the input events from the Android device.\n\n    - `concurrent.futures`: Used for handling controller events asynchronously with a thread pool.\n\n    - `logging`: For logging and debugging purposes.\n\n    You can install the necessary dependencies using `pip`:\n\n    ```shell\n        pip install pyvjoy\n    ```\n\n3.  **ADB Setup**:\n\n    - Ensure [ADB](https://developer.android.com/studio#downloads) is installed and properly configured on your machine. You'll need to connect your Android device via USB and enable USB debugging on the device.\n\n4.  **vJoy Setup**:\n\n    - You need to install [vJoy](https://vjoystick.sourceforge.io/) on your Windows machine to simulate the virtual controller. Ensure that the vJoy device is properly set up.\n\n\u003cspan id=\"setup\"\u003e\u003c/span\u003e\n\n## 🛠️ Setup\n\n1.  **Clone the repository**:\n\n    ```shell\n        git clone https://github.com/itachi-555/ps4-controllers-imulator\n        cd ps4-controllers-imulator\n    ```\n\n2.  **Android Device Configuration**:\n\n    - Enable **USB Debugging** on your Android phone and connect it to your PC.\n\n    - Install `adb` on your machine and ensure that your Android device is recognized by running:\n\n      ```shell\n          adb devices\n      ```\n\n3.  **vJoy Configuration**:\n\n    - Install and configure vJoy on your Windows PC, ensuring that a virtual joystick is created and ready to be used by the script.\n\n\u003cspan id=\"getting-the-controller_device_path\"\u003e\u003c/span\u003e\n\n## 🔗 Getting the `controller_device_path`\n\nTo identify the correct device path for your Android controller, follow these steps:\n\n1.  **Connect your Android device** via USB and ensure that **USB debugging** is enabled.\n\n2.  **Run the following command in your terminal**:\n\n    ```shell\n        adb shell getevent -i\n    ```\n\n3.  **Look for the device entry** in the output, which will resemble the following:\n\n    ```shell\n    add device 1: /dev/input/event7\n      bus:      0005\n      vendor    054c\n      product   09cc\n      version   8000\n      name:     \"Wireless Controller\"\n      location: \"70:28:04:61:45:ee\"\n      id:       \"a4:53:85:5e:ec:b1\"\n      version:  1.0.1\n      events:\n        KEY (0001): 0130  0131  0133  0134  0136  0137  0138 0139\n                    013a  013b  013c  013d  013e\n        ABS (0003): 0000  : value 144, min 0, max 255, fuzz 0, flat 15, resolution 0\n                    0001  : value 122, min 0, max 255, fuzz 0, flat 15, resolution 0\n                    0002  : value 27, min 0, max 255, fuzz 0, flat 15, resolution 0\n                    0003  : value 129, min 0, max 255, fuzz 0, flat 15, resolution 0\n                    0004  : value 124, min 0, max 255, fuzz 0, flat 15, resolution 0\n                    0005  : value 0, min 0, max 255, fuzz 0, flat 15, resolution 0\n                    0010  : value 0, min -1, max 1, fuzz 0, flat 0, resolution 0\n                    0011  : value 0, min -1, max 1, fuzz 0, flat 0, resolution 0\n        MSC (0004): 0004\n        FF  (0015): 0050  0051  0058  0059  005a  0060\n      input props:\n        \u003cnone\u003e\n    ```\n\n4.  **Locate the path** of the device in the `add device` line (e.g., `/dev/input/event7`). This is the value you need for `controller_device_path` in the `config.py` file.\n\n5.  **Update** `config.py`\\*\\* with the correct device path:\n\n    ```python\n        # In config.py\n        controller_device_path = \"/dev/input/event7\" # Update this path\n    ```\n\n\u003cspan id=\"vjoy-configuration\"\u003e\u003c/span\u003e\n\n## 🎛️ vJoy Configuration\n\nTo simulate a PS4 controller with vJoy, make sure that the vJoy configuration includes all the necessary buttons and axes. Specifically, you should have `17` buttons defined to simulate all PS4 controller buttons.\nopen `vJoyCon.exe` and edit `Number of Buttons` :\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"./images/vJoyConf.png\" alt=\"vJoyConf\" /\u003e\n\u003c/p\u003e\n\n\u003cspan id=\"running-the-script\"\u003e\u003c/span\u003e\n\n## 🚀 Running the Script\n\nTo run the project, execute the `main.py` script:\n\n```shell\n    python main.py\n```\n\nThis will:\n\n- Start listening for controller input from the Android device via ADB.\n\n- Map the input events (buttons, sticks, D-pad, etc.) to vJoy actions, simulating a PS4 controller on your Windows PC.\n\n### Graceful Shutdown\n\nThe application will continue running, listening for inputs. To shut it down, use `Ctrl+C` or send a `SIGTERM` signal to stop the script gracefully.\n\n\u003cspan id=\"making-it-work-in-games-using-x360ce\"\u003e\u003c/span\u003e\n\n## 🕹️ Making It Work in Games Using x360ce\n\nTo use the simulated PS4 controller in games that require an Xbox 360 controller, you'll need to map the vJoy inputs to Xbox 360 controller inputs using **x360ce**. Here's how to set it up:\n\n1.  **Download and Install x360ce**:\n\n    - Download the **x360ce** software from [x360ce official website](https://www.x360ce.com/).\n\n    - Extract the contents to the folder of the game or to a separate directory where you want to manage the configuration.\n\n2.  **Configure x360ce**:\n\n    - Run the `x360ce.exe` application.\n\n    - The software will scan your connected devices and automatically detect the virtual controller created by vJoy.\n\n    - If it's not automatically detected, make sure the vJoy device is active and try refreshing or restarting x360ce.\n\n3.  **Map vJoy to Xbox 360 Controller**:\n\n    - Once your controller is detected, you'll need to map the buttons and axes correctly. You can do this manually or use the **Auto** feature in x360ce.\n\n4.  **Use the Mapping Image**:\n\n    - To make the mapping process easier, refer to the following screenshot which shows the x360ce controller mapping setup:\n\n    ***\n\n    \u003cp align=\"center\"\u003e \u003cimg src=\"./images/x360ce_mapping.png\" alt=\"x360ce Controller Mapping\" /\u003e \u003c/p\u003e\n\n    The image shows the mapping of buttons, triggers, and axes from the virtual PS4 controller (via vJoy) to Xbox 360 controller inputs. Follow the mapping in the image for a seamless experience in compatible games.\n\n    ***\n\n5.  **Save the Configuration**:\n\n    - After mapping the buttons and axes, save the configuration file (`x360ce.ini`) in the game folder.\n\n    - Make sure to launch the game with the `x360ce` executable or ensure it runs alongside the game as required.\n\n6.  **Test the Controller**:\n\n    - Launch the game and test the controller to verify that all buttons and axes are functioning correctly.\n\n\u003cspan id=\"controller-mapping-table\"\u003e\u003c/span\u003e\n\n## 🎮 Controller Mapping Table\n\n| PS4 Input        | Event Type | Event Code | Event Value                                 | vJoy Mapping   | Notes                                        |\n| ---------------- | ---------- | ---------- | ------------------------------------------- | -------------- | -------------------------------------------- |\n| Cross            | 0x01       | 0x130      | 1 = press, 0 = release                      | Button 1       |                                              |\n| Circle           | 0x01       | 0x131      | 1 / 0                                       | Button 2       |                                              |\n| Triangle         | 0x01       | 0x133      | 1 / 0                                       | Button 3       |                                              |\n| Square           | 0x01       | 0x134      | 1 / 0                                       | Button 4       |                                              |\n| L1               | 0x01       | 0x136      | 1 / 0                                       | Button 5       |                                              |\n| R1               | 0x01       | 0x137      | 1 / 0                                       | Button 6       |                                              |\n| L2 (Analog)      | 0x03       | 0x02       | 0–255                                       | Button 7       | Only triggers if value \u003e `TRIGGER_THRESHOLD` |\n| R2 (Analog)      | 0x03       | 0x05       | 0–255                                       | Button 8       | Only triggers if value \u003e `TRIGGER_THRESHOLD` |\n| Share            | 0x01       | 0x13A      | 1 / 0                                       | Button 9       |                                              |\n| Options          | 0x01       | 0x13B      | 1 / 0                                       | Button 10      |                                              |\n| PS               | 0x01       | 0x13C      | 1 / 0                                       | Button 11      |                                              |\n| L3               | 0x01       | 0x13D      | 1 / 0                                       | Button 12      |                                              |\n| R3               | 0x01       | 0x13E      | 1 / 0                                       | Button 13      |                                              |\n| Left Stick X     | 0x03       | 0x00       | 0–255                                       | Axis X (48)    | Mapped to vJoy axis                          |\n| Left Stick Y     | 0x03       | 0x01       | 0–255                                       | Axis Y (49)    | Mapped to vJoy axis                          |\n| Right Stick X    | 0x03       | 0x03       | 0–255                                       | Axis X (51)    | Mapped to vJoy axis                          |\n| Right Stick Y    | 0x03       | 0x04       | 0–255                                       | Axis Y (52)    | Mapped to vJoy axis                          |\n| D-Pad Left/Right | 0x03       | 0x10       | 0 = released, 1 = right,`0xffffffff` = left | Button 15 / 17 | Parsed as buttons                            |\n| D-Pad Up/Down    | 0x03       | 0x11       | 0 = released, 1 = down, `0xffffffff` = up   | Button 14 / 16 | Parsed as buttons                            |\n\n### ℹ️ Notes\n\n- **L2 \u0026 R2 Axis Only**: The key events (`0x138` for L2 and `0x139` for R2) are ignored. Only the analog axis values (`0x02` and `0x05`) are used. The button is considered **pressed only if value \u003e `TRIGGER_THRESHOLD`**.\n- **D-Pad** values are analog-like and must be parsed:\n  - `0`: Released\n  - `1`: Right / Down\n  - `0xffffffff`: Left / Up\n\n\u003cspan id=\"file-descriptions\"\u003e\u003c/span\u003e\n\n## 🗂️ File Descriptions\n\n- `main.py`: Initializes the application and listens for controller input. Handles graceful shutdown on `SIGINT` or `SIGTERM`.\n\n- `controller.py`: Captures and processes input events from the Android phone and sends them to vJoy.\n\n- `event_handler.py`: Processes individual input events like button presses and stick movements.\n\n- `utils.py`: Contains helper functions like scaling input values and parsing D-pad button states.\n\n- `config.py`: Contains mappings for controller buttons, triggers, and axes.\n\n\u003cspan id=\"troubleshooting\"\u003e\u003c/span\u003e\n\n## ⚠️ Troubleshooting\n\n- **ADB not detecting device**: Ensure that USB debugging is enabled and the phone is properly connected via USB. Run `adb devices` to check if the device is listed.\n\n- **vJoy device not recognized**: Ensure that vJoy is installed and the virtual joystick is set up correctly. Check the vJoy configuration in the vJoy Control Panel.\n\n- **Permission issues**: Make sure you have the necessary permissions to interact with ADB and the vJoy device on your machine.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounes-alhyan%2Fps4-controller-simulator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyounes-alhyan%2Fps4-controller-simulator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounes-alhyan%2Fps4-controller-simulator/lists"}