### Build and Run Vimputti Manager Daemon Source: https://context7.com/datcaptainhorse/vimputti/llms.txt These bash commands illustrate how to build the Vimputti manager daemon in release mode and then run it. It shows how to start the service with default settings, specify a custom socket path, or use an instance number to manage virtual devices and client connections. ```bash # Build the manager daemon car go build --release --package vimputti-manager # Run with default socket (/tmp/vimputti-0) ./target/release/vimputti-manager # Run with custom socket path ./target/release/vimputti-manager --socket /tmp/vimputti-custom # Run with instance number (socket: /tmp/vimputti-N) ./target/release/vimputti-manager --instance 1 # The manager creates the following directory structure: # /tmp/vimputti/ # ├── uinput # Emulated /dev/uinput socket # ├── udev # Emulated /run/udev/control socket # ├── devices/ # Virtual device sockets # │ ├── event0 # evdev device socket # │ ├── event0.feedback # Force feedback socket # │ ├── js0 # Joystick device socket # │ └── ... # ├── sysfs/ # Emulated /sys entries # │ ├── class/input/ # │ └── devices/virtual/input/ # └── udev_data/ # Emulated /run/udev/data/ ``` -------------------------------- ### Configure Controller Device with Vimputti (Rust) Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Illustrates how to define and create a custom controller device configuration using the `vimputti` library. This includes setting device identification, bus type, available buttons, and detailed axis configurations with ranges, fuzz, and flat values. Examples for different bus types (USB, Bluetooth, Virtual) are also provided. ```rust use vimputti::{DeviceConfig, BusType, Button, Axis, AxisConfig, VimputtiClient}; #[tokio::main] async fn main() -> anyhow::Result<()> { let client = VimputtiClient::connect_default().await?; // Manual device configuration let config = DeviceConfig { name: "Custom Flight Controller".to_string(), vendor_id: 0x1234, // USB vendor ID product_id: 0x5678, // USB product ID version: 0x0110, // Device version bustype: BusType::Usb, buttons: vec![ Button::A, Button::B, Button::Start, Button::Custom(0x2c0), // Custom button code ], axes: vec![ AxisConfig { axis: Axis::LeftStickX, min: -32768, max: 32767, fuzz: 16, // Noise filter threshold flat: 128, // Deadzone size }, AxisConfig::new(Axis::LeftStickY, -32768, 32767), AxisConfig::new(Axis::Custom(0x28), 0, 1023), ], }; let device = client.create_device(config).await?; // BusType options let usb_config = DeviceConfig { name: "USB Device".to_string(), vendor_id: 0x045e, product_id: 0x028e, version: 0x0110, bustype: BusType::Usb, // 0x03 buttons: vec![Button::A], axes: vec![], }; let bt_config = DeviceConfig { bustype: BusType::Bluetooth, // 0x05 ..usb_config.clone() }; let virtual_config = DeviceConfig { bustype: BusType::Virtual, // 0x06 ..usb_config.clone() }; Ok(()) } ``` -------------------------------- ### Rust: Linux Input Event Constants and Example Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Defines and demonstrates the usage of raw Linux input event type constants for low-level control. It includes assertions for synchronization, key, relative, absolute, and force feedback event types, along with specific codes like FF_RUMBLE and SYN_REPORT. An example shows creating a LinuxInputEvent for a key press and converting it to bytes. Requires the 'vimputti' crate. ```rust use vimputti::protocol::{ EV_SYN, EV_KEY, EV_REL, EV_ABS, EV_FF, FF_RUMBLE, SYN_REPORT, LinuxInputEvent, TimeVal, }; #[tokio::main] async fn main() -> anyhow::Result<()> { // Event type constants assert_eq!(EV_SYN, 0x00); // Synchronization events assert_eq!(EV_KEY, 0x01); // Button/key events assert_eq!(EV_REL, 0x02); // Relative motion (mouse) assert_eq!(EV_ABS, 0x03); // Absolute position (joystick) assert_eq!(EV_FF, 0x15); // Force feedback events // Specific event codes assert_eq!(FF_RUMBLE, 0x50); // Rumble effect assert_eq!(SYN_REPORT, 0); // Synchronization marker // Create raw Linux input event let event = LinuxInputEvent { time: TimeVal::now(), event_type: EV_KEY, code: 0x130, // BTN_SOUTH (A button) value: 1, // Pressed }; // Convert to bytes for socket transmission let bytes: [u8; 24] = event.to_bytes(); Ok(()) } ``` -------------------------------- ### Handle Input Events with Vimputti (Rust) Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Demonstrates how to send various input events to a virtual controller using the `vimputti` library. This includes handling button presses/releases, axis movements, raw Linux input events, and synchronization events. The example also shows using individual methods for simpler event sending. ```rust use vimputti::{VimputtiClient, ControllerTemplates, InputEvent, Button, Axis}; #[tokio::main] async fn main() -> anyhow::Result<()> { let client = VimputtiClient::connect_default().await?; let device = client.create_device(ControllerTemplates::xbox360()).await?; // Send multiple events in one batch device.send_events(vec![ // Button press InputEvent::Button { button: Button::A, pressed: true }, // Button release InputEvent::Button { button: Button::B, pressed: false }, // Axis movement InputEvent::Axis { axis: Axis::LeftStickX, value: 16384 }, // Raw Linux input event (type, code, value) InputEvent::Raw { event_type: 0x01, // EV_KEY code: 0x130, // BTN_SOUTH (A button) value: 1, // Pressed }, // Synchronization event (automatically added if not present) InputEvent::Sync, ]).await?; // Individual event methods (automatically sync) device.button(Button::A, true).await?; device.axis(Axis::LeftStickX, 0).await?; device.raw_event(0x01, 0x130, 0).await?; device.sync().await?; Ok(()) } ``` -------------------------------- ### Utilize Controller Templates for Standard Gamepads (Rust) Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Shows how to use predefined `ControllerTemplates` in Vimputti to create common game controller types like Xbox 360, PlayStation 5, and Nintendo Switch Pro controllers. Each template includes appropriate vendor and product IDs, along with correct button mappings. The example demonstrates basic input actions for each controller type before they are automatically destroyed. ```rust use vimputti::{VimputtiClient, ControllerTemplates, Button, Axis}; use tokio::time::{sleep, Duration}; #[tokio::main] async fn main() -> anyhow::Result<()> { let client = VimputtiClient::connect_default().await?; // Xbox 360 Controller (vendor: 0x045e, product: 0x028e) let xbox = client.create_device(ControllerTemplates::xbox360()).await?; xbox.button_press(Button::A).await?; xbox.axis(Axis::LeftStickX, 16384).await?; sleep(Duration::from_secs(1)).await; drop(xbox); // PlayStation 5 Controller (vendor: 0x054c, product: 0x0ce6) let ps5 = client.create_device(ControllerTemplates::ps5()).await?; ps5.button_press(Button::X).await?; ps5.axis(Axis::RightStickY, 128).await?; sleep(Duration::from_secs(1)).await; drop(ps5); // Nintendo Switch Pro Controller (vendor: 0x057e, product: 0x2009) let switch = client.create_device(ControllerTemplates::switch_pro()).await?; switch.button_press(Button::B).await?; // Other available templates: // - ControllerTemplates::xbox_one() // - ControllerTemplates::ps4() // - ControllerTemplates::generic_gamepad() Ok(()) } ``` -------------------------------- ### Control Analog Axes with Vimputti (Rust) Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Demonstrates how to control analog axes such as sticks, triggers, and D-pads using the `vimputti` crate in Rust. It covers setting specific values for axes and converting between `Axis` enum variants and their raw event codes. The example also shows how to reset axes to their neutral positions. ```rust use vimputti::{Axis, VimputtiClient, ControllerTemplates}; #[tokio::main] async fn main() -> anyhow::Result<()> { let client = VimputtiClient::connect_default().await?; let device = client.create_device(ControllerTemplates::xbox360()).await?; // Left analog stick (range: -32768 to 32767) device.axis(Axis::LeftStickX, 16384).await?; // ABS_X (0x00) - 50% right device.axis(Axis::LeftStickY, -16384).await?; // ABS_Y (0x01) - 50% up // Right analog stick device.axis(Axis::RightStickX, 32767).await?; // ABS_RX (0x03) - full right device.axis(Axis::RightStickY, -32768).await?; // ABS_RY (0x04) - full up // Analog triggers (range: -32768 to 32767) device.axis(Axis::LowerLeftTrigger, 16384).await?; // ABS_Z (0x02) - 50% pressed device.axis(Axis::LowerRightTrigger, 32767).await?; // ABS_RZ (0x05) - fully pressed // D-pad as axes (range: -1, 0, 1) device.axis(Axis::DPadX, 1).await?; // ABS_HAT0X (0x10) - right device.axis(Axis::DPadY, -1).await?; // ABS_HAT0Y (0x11) - up // Custom axis device.axis(Axis::Custom(0x28), 512).await?; // Custom axis code // Axis utility functions let code = Axis::LeftStickX.to_ev_code(); // Returns 0x00 let axis = Axis::from_ev_code(0x03); // Returns Some(Axis::RightStickX) // Reset all axes to center/neutral device.axis(Axis::LeftStickX, 0).await?; device.axis(Axis::LeftStickY, 0).await?; device.axis(Axis::RightStickX, 0).await?; device.axis(Axis::RightStickY, 0).await?; Ok(()) } ``` -------------------------------- ### Build Custom Controller Configurations with ControllerBuilder Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Demonstrates using the ControllerBuilder to create custom controller configurations. It allows specifying vendor ID, product ID, bustype, and adding various buttons and axes. The builder pattern simplifies the creation of complex device configurations. ```rust use vimputti::{VimputtiClient, ControllerBuilder, BusType, Button, Axis, AxisConfig}; #[tokio::main] async fn main() -> anyhow::Result<()> { let client = VimputtiClient::connect_default().await?; // Build a custom controller configuration let custom_config = ControllerBuilder::new("My Custom Racing Wheel") .vendor_id(0x1234) .product_id(0x5678) .version(0x0100) .bustype(BusType::Usb) // Add individual buttons .button(Button::A) .button(Button::B) // Add button sets .face_buttons() // A, B, X, Y .shoulder_buttons() // L1, R1, L2, R2 .menu_buttons() // Start, Select, Guide .stick_buttons() // Left/Right stick clicks .dpad_buttons() // D-pad buttons // Add axes with ranges .dual_analog_sticks() // Left and right sticks (-32768 to 32767) .analog_triggers() // L2, R2 triggers .dpad_axes() // D-pad as axes (-1 to 1) // Add custom axis .axis(Axis::Custom(0x28), 0, 1023) // Custom axis with specific range .build(); let device = client.create_device(custom_config).await?; // Minimal example with only specific buttons let minimal_config = ControllerBuilder::new("Simple Controller") .vendor_id(0xabcd) .product_id(0xef01) .buttons([Button::A, Button::B, Button::Start]) .axis(Axis::LeftStickX, -100, 100) .axis(Axis::LeftStickY, -100, 100) .build(); let simple = client.create_device(minimal_config).await?; Ok(()) } ``` -------------------------------- ### ControllerTemplates - Pre-configured Controllers Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Provides factory functions for generating configurations of standard game controllers, including correct vendor/product IDs and button mappings for seamless integration. ```APIDOC ## ControllerTemplates - Pre-configured Controllers ### Description Factory functions for creating standard game controller configurations with proper vendor/product IDs and button mappings. ### Method Use template functions to define controller types. ### Endpoint N/A (This is a client-side API) ### Parameters #### Path Parameters - **None** #### Query Parameters - **None** #### Request Body - **None** ### Request Example ```rust use vimputti::{VimputtiClient, ControllerTemplates, Button, Axis}; use tokio::time::{sleep, Duration}; #[tokio::main] async fn main() -> anyhow::Result<()> { let client = VimputtiClient::connect_default().await?; // Xbox 360 Controller (vendor: 0x045e, product: 0x028e) let xbox = client.create_device(ControllerTemplates::xbox360()).await?; xbox.button_press(Button::A).await?; xbox.axis(Axis::LeftStickX, 16384).await?; sleep(Duration::from_secs(1)).await; drop(xbox); // PlayStation 5 Controller (vendor: 0x054c, product: 0x0ce6) let ps5 = client.create_device(ControllerTemplates::ps5()).await?; ps5.button_press(Button::X).await?; ps5.axis(Axis::RightStickY, 128).await?; sleep(Duration::from_secs(1)).await; drop(ps5); // Nintendo Switch Pro Controller (vendor: 0x057e, product: 0x2009) let switch = client.create_device(ControllerTemplates::switch_pro()).await?; switch.button_press(Button::B).await?; Ok(()) } ``` ### Response #### Success Response (200) - **ControllerTemplate** (Object) - A configuration object for a specific controller type. #### Response Example ```json { "vendor_id": "0x045e", "product_id": "0x028e", "buttons": [ "A", "B", "X", "Y", "Start", "Select", "Guide", "ThumbLX", "ThumbLY", "ShoulderL", "ShoulderR", "CUpper", "CLower", "CLeft", "CRight", "TriggerL", "TriggerR", "ThumbLPress", "ThumbRPress", "DpadUp", "DpadDown", "DpadLeft", "DpadStart" ], "axes": [ "LeftStickX", "LeftStickY", "RightStickX", "RightStickY", "TriggerLeft", "TriggerRight" ] } ``` ``` -------------------------------- ### Rust: Query Active Virtual Devices with VimputtiClient Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Shows how to use the VimputtiClient to connect to the daemon, create virtual input devices (Xbox 360 and PS5 controllers), list all active devices, and print their details. It also demonstrates accessing specific information from a created VirtualController object. Requires the 'vimputti' crate. ```rust use vimputti::{VimputtiClient, ControllerTemplates}; #[tokio::main] async fn main() -> anyhow::Result<()> { let client = VimputtiClient::connect_default().await?; // Create some devices let xbox = client.create_device(ControllerTemplates::xbox360()).await?; let ps5 = client.create_device(ControllerTemplates::ps5()).await?; // Query all active devices let devices = client.list_devices().await?; for device in devices { println!("Device ID: {}", device.device_id); println!(" Name: {}", device.name); println!(" Event Node: {}", device.event_node); println!(" Joystick Node: {:?}", device.joystick_node); println!(" Vendor ID: 0x{:04x}", device.vendor_id); println!(" Product ID: 0x{:04x}", device.product_id); println!(); } // Access device info from VirtualController println!("Xbox controller:"); println!(" Device ID: {}", xbox.device_id()); println!(" Event Node: {}", xbox.event_node()); Ok(()) } ``` -------------------------------- ### Connect to Vimputti Manager and List Devices (Rust) Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Establishes a connection to the Vimputti manager daemon, either at the default socket path or a custom one. It then pings the server to verify the connection and lists all currently active virtual input devices, displaying their IDs, names, and event node paths. This snippet demonstrates basic client interaction for monitoring and connecting to the emulation service. ```rust use vimputti::{VimputtiClient, ControllerTemplates}; #[tokio::main] async fn main() -> anyhow::Result<()> { // Connect to default manager instance at /tmp/vimputti-0 let client = VimputtiClient::connect_default().await?; // Or connect to custom socket path let custom_client = VimputtiClient::connect("/tmp/vimputti-1").await?; // Verify connection is alive client.ping().await?; println!("Connected to vimputti manager"); // List all active devices let devices = client.list_devices().await?; for device in devices { println!("Device {}: {} at {}", device.device_id, device.name, device.event_node ); } Ok(()) } ``` -------------------------------- ### Build and Use Vimputti LD_PRELOAD Shim Source: https://context7.com/datcaptainhorse/vimputti/llms.txt This set of bash commands details how to build the Vimputti shim library for both 64-bit and 32-bit architectures, which is crucial for container integration and compatibility with applications like Steam. It also shows how to use the shim via LD_PRELOAD in Docker containers and for Steam, explaining the path redirections it performs. ```bash # Build the shim library (64-bit) car go build --release --package vimputti-shim # Output: target/release/libvimputti_shim.so # Build 32-bit shim (for Steam compatibility) rustup target add i686-unknown-linux-gnu car go build --release --package vimputti-shim --target i686-unknown-linux-gnu # Output: target/i686-unknown-linux-gnu/release/libvimputti_shim.so # Use in container with LD_PRELOAD docker run -e LD_PRELOAD=/path/to/libvimputti_shim.so \ -v /tmp/vimputti:/tmp/vimputti:ro \ -v /tmp/vimputti-0:/tmp/vimputti-0 \ your-application # For Steam (32-bit and 64-bit support) export LD_PRELOAD="libvimputti_shim_32.so:libvimputti_shim_64.so" # The shim redirects these paths: # /dev/uinput -> /tmp/vimputti/uinput # /dev/input/event* -> /tmp/vimputti/devices/event* # /dev/input/js* -> /tmp/vimputti/devices/js* # /sys/class/input/* -> /tmp/vimputti/sysfs/class/input/* # /sys/devices/virtual/input/* -> /tmp/vimputti/sysfs/devices/virtual/input/* # /run/udev/control -> /tmp/vimputti/udev # /run/udev/data/* -> /tmp/vimputti/udev_data/* ``` -------------------------------- ### VirtualController - Device Creation and Input Events Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Enables the creation of virtual input devices like game controllers and keyboards, and allows sending button presses, axis movements, and raw input events to them. ```APIDOC ## VirtualController - Device Creation and Input Events ### Description Create virtual input devices and send button presses, axis movements, and raw input events. ### Method Create a virtual device and send input events. ### Endpoint N/A (This is a client-side API) ### Parameters #### Path Parameters - **None** #### Query Parameters - **None** #### Request Body - **ControllerTemplates** (Object) - Configuration for the type of controller to create (e.g., Xbox 360). - **InputEvent** (Enum) - Represents different types of input events (Button, Axis, Sync). ### Request Example ```rust use vimputti::{VimputtiClient, ControllerTemplates, Button, Axis, InputEvent}; use tokio::time::{sleep, Duration}; #[tokio::main] async fn main() -> anyhow::Result<()> { let client = VimputtiClient::connect_default().await?; // Create an Xbox 360 controller let device = client.create_device(ControllerTemplates::xbox360()).await?; println!("Created device: {}", device.event_node()); // Button operations device.button_press(Button::A).await?; sleep(Duration::from_millis(100)).await; device.button_release(Button::A).await?; // Analog stick movement (values: -32768 to 32767) device.axis(Axis::LeftStickX, 16384).await?; device.axis(Axis::LeftStickY, -16384).await?; // Reset to center device.axis(Axis::LeftStickX, 0).await?; device.axis(Axis::LeftStickY, 0).await?; // Send multiple events at once device.send_events(vec![ InputEvent::Button { button: Button::B, pressed: true }, InputEvent::Axis { axis: Axis::RightStickX, value: 20000 }, InputEvent::Sync, ]).await?; // Device is automatically destroyed when dropped Ok(()) } ``` ### Response #### Success Response (200) - **device** (VirtualController) - A handle to the created virtual device. #### Response Example ```json { "message": "Device created successfully", "event_node": "/dev/input/eventY" } ``` ``` -------------------------------- ### Build 32-bit vimputti Shim Source: https://github.com/datcaptainhorse/vimputti/blob/master/README.md Command to build the 32-bit (i686) release version of the vimputti shim library for specific compatibility needs, like those required by Steam. ```bash cargo build --release --package vimputti-shim --target i686-unknown-linux-gnu ``` -------------------------------- ### Map Controller Buttons with Button Enum and Utility Functions Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Illustrates how to use the Button enum in Vimputti to represent standard controller buttons and map them to Linux input event codes. It shows how to press buttons on a created device and provides utility functions for converting between Button and event codes. ```rust use vimputti::{Button, VimputtiClient, ControllerTemplates}; #[tokio::main] async fn main() -> anyhow::Result<()> { let client = VimputtiClient::connect_default().await?; let device = client.create_device(ControllerTemplates::xbox360()).await?; // Face buttons (Xbox/Nintendo layout) device.button_press(Button::A).await?; // BTN_SOUTH (0x130) device.button_press(Button::B).await?; // BTN_EAST (0x131) device.button_press(Button::X).await?; // BTN_NORTH (0x133) device.button_press(Button::Y).await?; // BTN_WEST (0x134) // Shoulder buttons device.button_press(Button::UpperLeftBumper).await?; // L1/LB (0x136) device.button_press(Button::UpperRightBumper).await?; // R1/RB (0x137) device.button_press(Button::LowerLeftTrigger).await?; // L2/LT (0x138) device.button_press(Button::LowerRightTrigger).await?; // R2/RT (0x139) // Analog stick clicks device.button_press(Button::LeftStick).await?; // L3 (0x13d) device.button_press(Button::RightStick).await?; // R3 (0x13e) // D-pad device.button_press(Button::DPadUp).await?; // 0x220 device.button_press(Button::DPadDown).await?; // 0x221 device.button_press(Button::DPadLeft).await?; // 0x222 device.button_press(Button::DPadRight).await?; // 0x223 // Menu buttons device.button_press(Button::Start).await?; // 0x13b device.button_press(Button::Select).await?; // 0x13a (Back/Share) device.button_press(Button::Guide).await?; // 0x13c (Xbox/PS/Home) // Custom button with raw code device.button_press(Button::Custom(0x13f)).await?; // Button utility functions let code = Button::A.to_ev_code(); // Returns 0x130 let button = Button::from_ev_code(0x130); // Returns Some(Button::A) let all_buttons = Button::all_standard(); // Returns array of all standard buttons Ok(()) } ``` -------------------------------- ### Register Force Feedback Rumble in Rust Source: https://context7.com/datcaptainhorse/vimputti/llms.txt This Rust code snippet demonstrates how to connect to the Vimputti client, create a virtual controller, and register a callback function to handle rumble events. The callback receives strong, weak, and duration parameters for the rumble effect. It cleans up by aborting the rumble handle. ```rust use vimputti::{VimputtiClient, ControllerTemplates, Button}; use tokio::time::{sleep, Duration}; #[tokio::main] async fn main() -> anyhow::Result<()> { let client = VimputtiClient::connect_default().await?; let mut device = client.create_device(ControllerTemplates::xbox360()).await?; // Register rumble callback let rumble_handle = device.on_rumble(|strong, weak, duration_ms| { if strong == 0 && weak == 0 { println!("Rumble stopped"); } else { println!("Rumble: strong={}, weak={}, duration={}ms", strong, weak, duration_ms); // strong/weak range: 0-65535 // duration_ms: 0 = infinite until stopped } }).await?; // Simulate gameplay - feedback will be received when game requests rumble device.button_press(Button::A).await?; sleep(Duration::from_secs(10)).await; // Cleanup rumble_handle.abort(); Ok(()) } ``` -------------------------------- ### Build vimputti Manager Daemon Source: https://github.com/datcaptainhorse/vimputti/blob/master/README.md Command to build the release version of the vimputti manager daemon using Cargo. This daemon handles socket messaging and manages virtual input devices. ```bash cargo build --release --package --package vimputti-manager ``` -------------------------------- ### VimputtiClient - Connection Management Source: https://context7.com/datcaptainhorse/vimputti/llms.txt High-level client for connecting to the vimputti manager daemon and managing virtual devices. It allows pinging the daemon, listing active devices, and establishing connections to default or custom socket paths. ```APIDOC ## VimputtiClient - Connection Management ### Description High-level client for connecting to the vimputti manager daemon and creating virtual devices. ### Method Connect to the vimputti manager daemon. ### Endpoint `/tmp/vimputti-` (default or custom socket path) ### Parameters #### Query Parameters - **None** #### Request Body - **None** ### Request Example ```rust use vimputti::VimputtiClient; #[tokio::main] async fn main() -> anyhow::Result<()> { // Connect to default manager instance at /tmp/vimputti-0 let client = VimputtiClient::connect_default().await?; // Or connect to custom socket path let custom_client = VimputtiClient::connect("/tmp/vimputti-1").await?; // Verify connection is alive client.ping().await?; println!("Connected to vimputti manager"); // List all active devices let devices = client.list_devices().await?; for device in devices { println!("Device {}: {} at {}", device.device_id, device.name, device.event_node); } Ok(()) } ``` ### Response #### Success Response (200) - **client** (VimputtiClient) - An active connection to the vimputti manager. - **devices** (Vec) - A list of currently active virtual devices. #### Response Example ```json { "device_id": "some_id", "name": "Virtual Keyboard", "event_node": "/dev/input/eventX" } ``` ``` -------------------------------- ### Build 64-bit vimputti Shim Source: https://github.com/datcaptainhorse/vimputti/blob/master/README.md Command to build the 64-bit release version of the vimputti shim library using Cargo. This is used to intercept API calls within containers. ```bash cargo build --release --package vimputti-shim ``` -------------------------------- ### Rust: Send Ping Command to Manager Daemon Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Demonstrates sending a 'Ping' command to the vimputti manager daemon using a Unix stream. It serializes a ControlMessage to JSON, sends it with a newline, and then reads and parses the ControlResponse to verify the 'Pong' or any errors. Requires the 'tokio', 'serde_json', and 'ulid' crates. ```rust use vimputti::protocol::{ControlMessage, ControlCommand, ControlResponse, ControlResult}; use tokio::net::UnixStream; use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; #[tokio::main] async fn main() -> anyhow::Result<()> { let mut stream = UnixStream::connect("/tmp/vimputti-0").await?; // Create message with ULID for request/response matching let id = ulid::Ulid::new().to_string(); let message = ControlMessage { id: id.clone(), command: ControlCommand::Ping, }; // Send JSON message (newline-delimited) let json = serde_json::to_string(&message)?; stream.write_all(json.as_bytes()).await?; stream.write_all(b"\n").await?; // Read response let mut reader = BufReader::new(&mut stream); let mut response_line = String::new(); reader.read_line(&mut response_line).await?; let response: ControlResponse = serde_json::from_str(&response_line)?; assert_eq!(response.id, id); match response.result { ControlResult::Pong => println!("Manager is alive"), ControlResult::Error { message } => eprintln!("Error: {}", message), _ => {} } // Available commands: // - ControlCommand::Ping // - ControlCommand::CreateDevice { config } // - ControlCommand::DestroyDevice { device_id } // - ControlCommand::SendInput { device_id, events } // - ControlCommand::ListDevices Ok(()) } ``` -------------------------------- ### Create Virtual Controller and Send Input Events (Rust) Source: https://context7.com/datcaptainhorse/vimputti/llms.txt Demonstrates how to create a virtual Xbox 360 controller using Vimputti and send various input events. It covers single button presses and releases, setting analog stick positions within the defined range, and sending multiple events simultaneously using `send_events`. The virtual device is automatically cleaned up when it goes out of scope. ```rust use vimputti::{VimputtiClient, ControllerTemplates, Button, Axis, InputEvent}; use tokio::time::{sleep, Duration}; #[tokio::main] async fn main() -> anyhow::Result<()> { let client = VimputtiClient::connect_default().await?; // Create an Xbox 360 controller let device = client.create_device(ControllerTemplates::xbox360()).await?; println!("Created device: {}", device.event_node()); // Button operations device.button_press(Button::A).await?; sleep(Duration::from_millis(100)).await; device.button_release(Button::A).await?; // Analog stick movement (values: -32768 to 32767) device.axis(Axis::LeftStickX, 16384).await?; device.axis(Axis::LeftStickY, -16384).await?; // Reset to center device.axis(Axis::LeftStickX, 0).await?; device.axis(Axis::LeftStickY, 0).await?; // Send multiple events at once device.send_events(vec![ InputEvent::Button { button: Button::B, pressed: true }, InputEvent::Axis { axis: Axis::RightStickX, value: 20000 }, InputEvent::Sync, ]).await?; // Device is automatically destroyed when dropped Ok(()) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.