A comprehensive virtual input device emulator with modern GUI that emulates USB devices including barcode scanners, bill validators, and coin acceptors as HID keyboard devices on Linux.
- 🎨 Native GNOME interface using GTK4
- ⚡ 115200 baud barcode scanner emulation
- 💰 Bill and coin emulator with serial bridge support
- 📊 Real-time scan history with duration tracking
- 🖥️ Native GUI with system theme support
- 🔒 Safe Rust implementation with proper error handling
All dependencies (Rust, system libraries) are already installed!
./run.shThis will:
- Build the project (if not already built)
- Launch the GUI with sudo (required for
/dev/uinputaccess)
./build.sh
sudo ./target/release/virtusdev- Enter a barcode in the input field
- Click SCAN or press Enter
- The barcode will be sent as keyboard input to the focused application
- View scan history with timing information
The GUI displays:
- Device Name: Virtual Keyboard 115200
- Event Path:
/dev/input/eventX(auto-detected) - Baudrate: 115200 bps
- Vendor ID: 0x1234
- Product ID: 0x5678
- Status: Running / Scanning indicator
- Recent Scans: Last 10 scans with duration
sudo ./target/release/virtusdev# Add your user to the input group
sudo usermod -a -G input $USER
# Create udev rule
echo 'KERNEL=="uinput", MODE="0660", GROUP="input"' | sudo tee /etc/udev/rules.d/99-uinput.rules
# Reload udev rules
sudo udevadm control --reload-rules
sudo udevadm trigger
# Log out and back in for group changes to take effect- Creates a virtual input device via Linux
uinputkernel module - Registers as a USB HID keyboard (
/dev/input/eventX) - Sends keyboard events for each character in the barcode
- Automatically appends Enter key after each scan
- Timing matches 115200 baud rate behavior
The emulator provides comprehensive support for vending machine and payment system testing through the eSSP (Encrypted Serial Protocol):
Note Validator (NV200)
- Simulates an ICT NV200 bill validator
- Supports BRL currency (Brazilian Real)
- 7 denominations: R$2, R$5, R$10, R$20, R$50, R$100, R$200
- Protocol 6 eSSP compliance
- Configurable balances for testing
Coin Acceptor (Smart Hopper)
- Simulates coin acceptance and payout
- USD currency support
- 6 denominations: 1¢, 5¢, 10¢, 25¢, 50¢, $1.00
- Full payout simulation with event tracking
Serial Bridge (PTY)
- Virtual serial port (PTY) for device communication
- Auto-creates
/dev/pts/Xfor payment system integration - Transparent eSSP protocol handling
- Real-time transaction logging
# Run the bill emulator with serial bridge
./target/release/bill_emulator
# The emulator will display:
# ✓ Virtual serial port created: /dev/pts/X
# Configure payment system to use: /dev/pts/XSYNC- Device synchronizationSETUP_REQUEST- Device information queryPOLL- Event polling and statusENABLE/DISABLE- Device controlSET_INHIBITS- Denomination maskingGET_ALL_LEVELS- Current inventoryPAYOUT- Coin dispensing simulationREJECT- Note rejectionSET_ROUTE- Stacking/routing control
RESET(0xF1) - Device resetREAD(0xEF) - Note detectedCREDIT(0xEE) - Note acceptedSTACKING(0xCC) - Note being stackedSTACKED(0xEB) - Note stackedDISPENSING(0xDA) - Coin dispensingDISPENSED(0xD2) - Coin dispensedCOINS_VALUE_ADDED(0xBF) - Coin credit received
src/
├── main.rs # GUI application (GTK4)
├── device.rs # VirtualKeyboard, keymap, event emission
├── bill_emulator.rs # Device state & eSSP command handling
├── essp_protocol.rs # eSSP packet encoding/decoding with CRC-16
├── serial_bridge.rs # PTY serial port & device communication
└── bin/
├── bill_emulator # Standalone bill/coin emulator
└── crc_check # CRC validation utility
Key Components:
VirtualKeyboard: Wrapsevdev::uinput::VirtualDeviceArc<Mutex<>>: Thread-safe device access for async scansglib::spawn_future: Non-blocking scan execution with GTK4DeviceState: Bill validator and coin device emulationEsspPacket: Protocol-compliant packet serialization with CRC-16SerialBridge: PTY-based serial communication
- Alphanumeric: a-z, A-Z, 0-9
- Special: space, enter, tab,
-_=+[]{};:'"<>,./?|\~` - Automatic shift: Uppercase and shifted symbols
# Terminal 1: Start a text editor
nano test.txt
# Terminal 2: Run virtusdev and enter barcodes in the GUI
sudo ./target/release/virtusdev# Find the event device
cat /proc/bus/input/devices | grep -A 5 "Virtual Keyboard 115200"
# Monitor events (requires sudo)
sudo evtest /dev/input/eventX# Terminal 1: Start the emulator
./target/release/bill_emulator
# Terminal 2: Connect using a payment system or test client
# Using socat for testing:
socat - /dev/pts/X
# Send raw eSSP commands and monitor responses
# Check /tmp/emu_cmd.log for transaction logs
tail -f /tmp/emu_cmd.log# Verify CRC calculations
./target/release/crc_checkThe original C implementation is preserved in legacy/ directory for reference.
Run with sudo or follow the permanent permissions setup above.
# Check if uinput module is loaded
lsmod | grep uinput
# Load if missing
sudo modprobe uinputEnsure all system dependencies are installed:
sudo apt-get install -y pkg-config build-essential libgtk-4-devjvwaldrich0
- Baudrate: 115200 bps
- Interface: USB HID (emulated via uinput)
- Character timing: ~87 μs per character
- Protocol: Keyboard wedge (HID keyboard)
- GUI Framework: GTK4 (gtk4-rs 0.9)
- Language: Rust (edition 2021)