Skip to content
bh4vyyyyaPublic

About

Your phone. Your controller. No limits.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

Repository files navigation


██████╗  ██████╗  ██████╗██╗  ██╗███████╗████████╗    
██╔══██╗██╔═══██╗██╔════╝██║ ██╔╝██╔════╝╚══██╔══╝    
██████╔╝██║   ██║██║     █████╔╝ █████╗     ██║       
██╔═══╝ ██║   ██║██║     ██╔═██╗ ██╔══╝     ██║       
██║     ╚██████╔╝╚██████╗██║  ██╗███████╗   ██║       
╚═╝      ╚═════╝  ╚═════╝╚═╝  ╚═╝╚══════╝   ╚═╝       
                                                      
██████╗ ██╗ ██████╗                                   
██╔══██╗██║██╔════╝                                   
██████╔╝██║██║  ███╗                                  
██╔══██╗██║██║   ██║                                  
██║  ██║██║╚██████╔╝                                  
╚═╝  ╚═╝╚═╝ ╚═════╝                                   
                                                      

Your phone. Your controller. No limits.

Ever wanted to play a local splitscreen game with friends but realized you only have one physical gamepad? Or maybe you just want to kick back, play a game on your PC from your bed, and don't want to buy another controller?

PocketRig solves this by instantly turning any smartphone or tablet browser into a fully customizable virtual gamepad. Just run the server, scan the generated terminal QR code with your phone, and start playing. No native apps to install, no sketchy drivers—just pure WebSockets and local-network gaming.


Features

  • Zero Installation: Connect instantly through any modern mobile browser.
  • Scan-to-Play QR Code: The command-line interface generates a dynamic QR code directly in the terminal for fast network pairing.
  • Real-time Layout Editor: Rearrange buttons, sticks, and zones on your phone screen in real time. Layouts are saved locally on your phone and adapt to portrait or landscape orientations.
  • Multi-Player Support: Connect multiple phones simultaneously. Each client receives a designated slot (Player 1, Player 2, etc.) with independent mappings.
  • Profiles & Configs: Includes preset profiles for standard layouts, FPS, Emulators, and Minecraft (featuring a swipeable 9-slot hotbar zone).
  • Simulated Keyboard & Mouse: Simulates physical keystrokes, mouse buttons, and fluid mouse movements (using the right-hand touch joysticks or simulated inputs) via pynput.
  • Ultra Low Latency: Built using raw WebSockets (flask-sock) for near-zero delay input injection.

Setup & Installation

PocketRig requires Python 3.7+ and standard dependencies.

1. Prerequisites

Ensure you have Python installed. You can check with:

python --version

2. Clone & Install

Clone this folder, navigate to it, and install the dependencies from requirements.txt:

pip install -r requirements.txt

Note

The dependencies are:

  • flask & flask-sock for running the web server and WebSockets connection.
  • pynput for sending virtual keyboard and mouse inputs.
  • qrcode[pil] to generate the connection QR code directly inside the command line.

Running the Server

Start the gamepad server by running:

python gamepad_server.py

Command Line Options

  • --port <port_number>: Run the server on a custom port (default is 5000).
  • --debug: Print detailed connection events, key presses, and stick movements directly to the console log.
# Example running on port 8080 with debug log enabled
python gamepad_server.py --port 8080 --debug

How to Connect & Play

  1. Make sure your PC and phone are connected to the same local WiFi network.
  2. Launch the script.
  3. Open your phone's camera app and scan the QR code printed in the terminal.
    • Alternatively, type the printed URL (e.g. http://192.168.1.52:5000) into your mobile browser.
  4. Tap Fullscreen on the web page to lock the controller layout into landscape mode.
  5. Select a profile that fits your game or customize bindings to match your favorite configuration!

Terminal Interface Example

When you start the server, you will see a stylized console interface displaying setup configurations, connection diagnostics, and active player inputs in real time:

  ██████╗  ██████╗  ██████╗██╗  ██╗███████╗████████╗        Scan to connect:
  ██╔══██╗██╔═══██╗██╔════╝██║ ██╔╝██╔════╝╚══██╔══╝
  ██████╔╝██║   ██║██║     █████╔╝ █████╗     ██║           ┌─────────────────────────────────┐
  ██╔═══╝ ██║   ██║██║     ██╔═██╗ ██╔══╝     ██║           │  ■■■■■■■  ■   ■  ■  ■■■■■■■  │
  ██║     ╚██████╔╝╚██████╗██║  ██╗███████╗   ██║           │  ■     ■  ■■ ■■  ■  ■     ■  │
  ╚═╝      ╚═════╝  ╚═════╝╚═╝  ╚═╝╚══════╝   ╚═╝           │  ■■■■■■■  ■■ ■  ■■  ■■■■■■■  │
                                                            │  ■■■■■■■  ■   ■     ■■■■■■■  │
  ██████╗ ██╗ ██████╗                                       │  ■     ■     ■■■ ■  ■     ■  │
  ██╔══██╗██║██╔════╝                                       │  ■■■■■■■  ■  ■  ■■  ■■■■■■■  │
  ██████╔╝██║██║  ███╗                                      └─────────────────────────────────┘
  ██╔══██╗██║██║   ██║
  ██║  ██║██║╚██████╔╝                                      http://0.0.0.0:5000(UR ip)
  ╚═╝  ╚═╝╚═╝ ╚═════╝

──────────────────────────────────────────────────────────────────────────────────────────────────
  OS        PocketRig v2.0
  Runtime   Python + Flask + flask-sock
  Input     pynput keyboard + mouse
  Network   WiFi · WebSocket · mDNS
  Profiles  DEFAULT · FPS · MINECRAFT · EMULATOR · RACING
  Controls  16 buttons · 2 sticks · gyro · turbo · macros
  Port      5000 · Admin /admin
──────────────────────────────────────────────────────────────────────────────────────────────────
   __________________________________________________________________
  |                                                                  |
  | [CONNECTION] Player 1 connected from 192.168.1.12                |
  | [PRESS] Player 1 pressed A                                       |
  | [PROFILE] Player 1 switched to profile: FPS                      |
  |__________________________________________________________________|

                      ❝ Your phone. Your controller. No limits. ❞

Key Mappings & Profile Configurations

All controller profiles are loaded from and saved to a local file named config.json. If this file doesn't exist, it will be automatically generated with standard layouts on the first run.

Default Profiles Included:

  • Default: Standard utility layout mapping virtual D-pad and ABXY controls to basic keyboard keys (W/A/S/D, Space, Shift, Ctrl).
  • FPS: Set up for shooter games, mapping sticks to movement, triggers to left/right mouse clicks, and right stick swipes to fluid mouse look.
  • Emulator: Traditional classic retro layout mapping keys like Z, X, C, V for standard emulator controls.
  • Minecraft: Specially crafted to emulate Minecraft PC actions—complete with a swiping hotbar at the bottom to quick-select slots 1-9.

Customizing Key Mappings:

You can edit the config.json file manually using any editor to customize profiles or change bindings. Key names are standard lowercase characters or special names (like space, shift, ctrl, enter, esc, mouse_left, mouse_right):

"Default": {
    "left_stick_up": "w",
    "left_stick_down": "s",
    "left_stick_left": "a",
    "left_stick_right": "d",
    "a": "space",
    "b": "shift",
    "x": "ctrl",
    "y": "e",
    "l2": "mouse_left",
    "r2": "mouse_right",
    "select": "esc",
    "start": "enter"
}

Troubleshooting & Tips

  • Can't connect to the server? Double-check that your phone and your computer are on the same local network. Some public or corporate networks block client-to-client communication.
  • Mouse movements don't register in-game? If you are playing games that capture the mouse raw input (like some 3D shooters), try running the server or the game in windowed mode, or run the server with Administrator/Elevated privileges so Python can inject inputs globally.
  • Layout is broken/offset? Make sure you turn on orientation lock on your phone and hold it in landscape. If things still look misaligned, tap Edit Layout -> Reset Layout to snap them back to default bounds.

Enjoy gaming! 🎮

Preview

demo
Assisted by AI

About

Your phone. Your controller. No limits.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages