### Rust Mouse Quick Start Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/README.md Provides a basic example of setting up and moving a mouse in Rust using the inputtino library. Requires a DeviceDefinition and handles potential errors. ```rust use inputtino::DeviceDefinition; let device = DeviceDefinition::new("Mouse", 0xAB00, 0xAB01, 0xAB00, "", "")?; let mouse = Mouse::new(&device)?; mouse.move_rel(100, 50); ``` -------------------------------- ### Setup inputtino-python with pip Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/README.md Clones the inputtino repository and sets up a virtual environment using pip for installing the library. ```bash git clone https://github.com/your-username/inputtino.git cd inputtino/bindings/python python -m venv ./venv source ./venv/bin/activate pip install . ``` -------------------------------- ### PS5 Joypad Example Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-rust.md Shows how to use the PS5Joypad, including initializing, getting the MAC address, interacting with the touchpad, setting motion sensor data, updating battery status, and registering an LED callback. ```rust use inputtino::{PS5Joypad, DeviceDefinition, JoypadMotionType, BatteryState}; let device = DeviceDefinition::new( "PS5 Controller", 0x054C, 0x0CE6, 0x8111, "", "" )?; let mut joypad = PS5Joypad::new(&device)?; println!("MAC Address: {}", joypad.get_mac_address()); // Touchpad joypad.place_finger(0, 960, 540); joypad.release_finger(0); // Motion sensors joypad.set_motion(JoypadMotionType::ACCELERATION, 0.0, 9.81, 0.0); // Battery status joypad.set_battery(BatteryState::BATTERY_CHARGING, 75); // LED callback joypad.set_on_led(|r, g, b| { println!("LED Color: RGB({}, {}, {})", r, g, b); }); ``` -------------------------------- ### Python Device Creation Example Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/configuration.md Example of creating and configuring a DeviceDefinition object in Python. ```python device = DeviceDefinition() device.name = "My Custom Device" device.vendor_id = 0xAB00 device.product_id = 0xAB01 device.version = 0x0100 ``` -------------------------------- ### Setup inputtino-python with uv Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/README.md Clones the inputtino repository and sets up the Python environment using uv for dependency management. ```bash git clone https://github.com/your-username/inputtino.git cd inputtino/bindings/python uv sync ``` -------------------------------- ### Install inputtino-python from Git Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/README.md Installs the inputtino-python library directly from its GitHub repository using pip. ```bash pip install "git+https://github.com/games-on-whales/inputtino.git#subdirectory=bindings/python&branch=stable" ``` -------------------------------- ### Rust Device Creation Example Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/configuration.md Example of creating a DeviceDefinition object in Rust using the new constructor. ```rust let device = DeviceDefinition::new( "My Device", 0xAB00, 0xAB01, 0x0100, "", "" ); ``` -------------------------------- ### Example Usage of PenTablet Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-python.md Demonstrates how to create a virtual pen tablet, place a tool, and press a button. ```python from inputtino import PenTablet, PenToolType, PenButtonType, DeviceDefinition device = DeviceDefinition() tablet = PenTablet.create(device) tablet.place_tool(PenToolType.PEN, 0.5, 0.5, 0.8, -1.0, 0.0, 0.0) tablet.set_btn(PenButtonType.PRIMARY, True) ``` -------------------------------- ### Python Mouse Quick Start Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/README.md Illustrates creating and moving a mouse device in Python with inputtino. Uses DeviceDefinition for configuration. ```python from inputtino import Mouse, DeviceDefinition mouse = Mouse.create(DeviceDefinition()) mouse.move(100, 50); ``` -------------------------------- ### C Mouse Quick Start Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/README.md Shows how to initialize and control a mouse device in C using the inputtino library. Remember to destroy the mouse object when done. ```c #include InputtinoMouse *mouse = inputtino_mouse_create(NULL, NULL); inputtino_mouse_move(mouse, 100, 50); inputtino_mouse_destroy(mouse); ``` -------------------------------- ### Example: Create and Use Keyboard Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-keyboard.md Demonstrates how to create a Keyboard instance and perform basic key press and release operations using Win32 Virtual Key codes. ```cpp #include auto result = Keyboard::create(); if (result) { auto keyboard = *result; keyboard.press(0x41); // Press key A (VK code) keyboard.release(0x41); // Release key A } ``` -------------------------------- ### C++ Mouse Quick Start Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/README.md Demonstrates basic mouse control in C++ using the inputtino library. Requires including the inputtino header. ```cpp #include auto mouse = *Mouse::create(); mouse.move(100, 50); mouse.press(Mouse::LEFT); ``` -------------------------------- ### Virtual Mouse Example Nodes Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/configuration.md Example device node paths for a virtual mouse, illustrating the different types of nodes created. ```text /dev/input/event10 /dev/input/event11 /dev/input/by-id/usb-Wolf_mouse_virtual_device_XXXXX-event-mouse /dev/input/by-id/usb-Wolf_mouse_virtual_device_XXXXX-event-kbd ``` -------------------------------- ### Install System Dependencies (Fedora) Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/README.md Installs essential system packages for inputtino-python on Fedora. ```shell sudo dnf install git cmake gcc gcc-c++ make pkgconf-pkg-config libevdev-devel # Optional python3-devel ``` -------------------------------- ### Example Python Usage of Inputtino Mouse Source: https://github.com/games-on-whales/inputtino/blob/stable/README.md Shows how to use the inputtino Python bindings to control the mouse. Includes examples for moving the cursor, clicking, and scrolling. ```python from inputtino import Mouse, MouseButton # Initialize mouse device mouse = Mouse() # Move mouse mouse.move(100, 50) # Move right 100, down 50 mouse.move_abs(500, 300, 1920, 1080) # Move to absolute position # Click operations mouse.click(MouseButton.LEFT) mouse.click(MouseButton.RIGHT, duration=0.5) # Hold for 0.5 seconds # Scrolling mouse.scroll_vertical(120) # Scroll up mouse.scroll_horizontal(-120) # Scroll left ``` -------------------------------- ### Install Rules for Inputtino Library Source: https://github.com/games-on-whales/inputtino/blob/stable/CMakeLists.txt Defines installation rules for the libinputtino target, including components, include directories, and pkgconfig files, only when LIBINPUTTINO_INSTALL is enabled and not skipping install rules. ```cmake if (LIBINPUTTINO_INSTALL AND NOT CMAKE_SKIP_INSTALL_RULES) install(TARGETS libinputtino EXPORT libinputtino_export RUNTIME COMPONENT libinputtino LIBRARY COMPONENT libinputtino NAMELINK_COMPONENT libinputtino-dev ARCHIVE COMPONENT libinputtino-dev INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install(DIRECTORY include/ TYPE INCLUDE COMPONENT libinputtino-dev) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/inputtino/${export_file_name}" COMPONENT libinputtino-dev DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/inputtino") configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/share/pkgconfig/libinputtino.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libinputtino.pc @ONLY ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libinputtino.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) endif () ``` -------------------------------- ### Trackpad Place Finger Example Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-other-devices.md Demonstrates how to simulate placing one or more fingers on the virtual trackpad. Finger ID, coordinates, pressure, and orientation can be specified. ```cpp auto trackpad = *Trackpad::create(); trackpad.place_finger(0, 0.5, 0.5, 0.8, 0); // Place finger at center trackpad.place_finger(1, 0.3, 0.7, 0.9, 45); // Multi-touch second finger ``` -------------------------------- ### Install Python Module Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/CMakeLists.txt Installs the compiled Python extension module '_core' into the 'inputtino' directory within the installation prefix. ```cmake install(TARGETS _core DESTINATION inputtino) ``` -------------------------------- ### Installation Command Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-python.md Installs the inputtino-python package using pip. Requires Python 3.10+ and Linux with uinput/evdev support. ```bash pip install inputtino-python ``` -------------------------------- ### Install System Dependencies (Ubuntu/Debian) Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/README.md Installs necessary system packages for inputtino-python on Ubuntu or Debian-based systems. ```shell sudo apt install git cmake build-essential pkg-config libevdev-dev ``` -------------------------------- ### Xbox One Joypad Example Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-rust.md Demonstrates how to initialize an Xbox One joypad, set button presses, move sticks, set triggers, and register a rumble callback. ```rust use inputtino::{XboxOneJoypad, DeviceDefinition, JoypadButton, JoypadStickPosition}; let device = DeviceDefinition::new( "Xbox Controller", 0x045E, 0x02EA, 0x0408, "", "" )?; let mut joypad = XboxOneJoypad::new(&device)?; // Press buttons joypad.set_pressed((JoypadButton::A | JoypadButton::B) as i32); // Move sticks joypad.set_stick(JoypadStickPosition::LS, 0, 32767); // Set triggers joypad.set_triggers(0, 32767); // Register rumble callback joypad.set_on_rumble(|low, high| { println!("Rumble: low={}, high={}", low, high); }); ``` -------------------------------- ### PS5Joypad Usage Example Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-python.md Demonstrates how to create and interact with a virtual PS5 DualSense controller, including setting touchpad, motion, and battery states, and registering an LED callback. ```python from inputtino import PS5Joypad, PS5MotionType, PS5BatteryState, DeviceDefinition device = DeviceDefinition() joypad = PS5Joypad.create(device) print(f"MAC Address: {joypad.get_mac_address()}") # Touchpad joypad.place_finger(0, 960, 540) joypad.release_finger(0) # Motion joypad.set_motion(PS5MotionType.ACCELERATION, 0.0, 9.81, 0.0) # Battery joypad.set_battery(PS5BatteryState.BATTERY_CHARGING, 75) # LED def on_led(r, g, b): print(f"LED Color: RGB({r}, {g}, {b})") joypad.set_on_led(on_led) ``` -------------------------------- ### Install System Dependencies (Arch Linux) Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/README.md Installs required system packages for inputtino-python on Arch Linux. ```shell sudo pacman -Sy git cmake base-devel pkgconf libevdev ``` -------------------------------- ### Example Usage of XboxOneJoypad Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-python.md Demonstrates how to create an Xbox One joypad, press buttons, move sticks, set triggers, and register a rumble callback. ```python from inputtino import XboxOneJoypad, ControllerButton, StickPosition, DeviceDefinition device = DeviceDefinition() joypad = XboxOneJoypad.create(device) # Press button joypad.set_pressed_buttons(ControllerButton.A.value) # Move stick joypad.set_stick(StickPosition.LS, 0, 32767) # Set triggers joypad.set_triggers(0, 32767) # Register rumble callback def on_rumble(low, high): print(f"Rumble: low={low}, high={high}") joypad.set_on_rumble(on_rumble) ``` -------------------------------- ### Create Pen Tablet Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Initializes a new InputtinoPenTablet object. Requires device definition and error handling setup. ```c InputtinoPenTablet* inputtino_pen_tablet_create( const InputtinoDeviceDefinition *device, const InputtinoErrorHandler *eh ) ``` -------------------------------- ### Example Rust Usage of Inputtino Keyboard Source: https://github.com/games-on-whales/inputtino/blob/stable/README.md Demonstrates creating and using a virtual keyboard with the inputtino Rust bindings. Shows how to press and release keys. ```rust let device = DeviceDefinition::new( "Rusty Keyboard", 0xAB, 0xCD, 0xEF, "Rusty Keyboard Phys", "Rusty Keyboard Uniq", ); let keyboard = Keyboard::new(&device).unwrap(); keyboard.press_key(0x41); // KEY_A keyboard.release_key(0x41); ``` -------------------------------- ### Create and Control a Virtual Mouse Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md This example demonstrates how to create a virtual mouse device, move its cursor, simulate button clicks, and retrieve associated nodes using the Inputtino C API. Ensure necessary headers are included. ```c #include #include int main() { InputtinoDeviceDefinition mouse_def = { .name = "My Virtual Mouse", .vendor_id = 0xAB00, .product_id = 0xAB01, .version = 0xAB00, .device_phys = NULL, .device_uniq = NULL }; InputtinoMouse *mouse = inputtino_mouse_create(&mouse_def, NULL); if (!mouse) { printf("Failed to create mouse\n"); return 1; } // Move mouse inputtino_mouse_move(mouse, 100, 50); // Click inputtino_mouse_press_button(mouse, LEFT); inputtino_mouse_release_button(mouse, LEFT); // Get nodes int num_nodes = 0; char **nodes = inputtino_mouse_get_nodes(mouse, &num_nodes); printf("Mouse has %d nodes\n", num_nodes); inputtino_mouse_destroy(mouse); return 0; } ``` -------------------------------- ### Create Custom Mouse Device Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-other-devices.md Provides an example of creating a custom mouse device by defining a `DeviceDefinition` structure with specific configuration parameters and then calling the `create` method. ```cpp DeviceDefinition custom_mouse = { .name = "My Custom Mouse", .vendor_id = 0x1234, .product_id = 0x5678, .version = 0x0100, .device_phys = "usb-0000:00:1d.7-1/input0", .device_uniq = "12345ABCDE" }; auto mouse = Mouse::create(custom_mouse); ``` -------------------------------- ### Docker Run Command for inputtino Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/README.md Example docker run command with volume mounts, device mapping, and privileged mode enabled for inputtino-python. ```bash docker run -it --rm \ -v /dev/input:/dev/input:rw \ -v /dev/uhid:/dev/uhid \ --device /dev/uinput \ --privileged \ your-image-name ``` -------------------------------- ### Python Function Docstring Example (Google Style) Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/README.md An example illustrating the Google Style docstring format for Python functions, including sections for arguments, return values, and raised exceptions. ```python def function_name(param1: str, param2: list[int]) -> bool: """Short description of function. Args: param1: Description of first parameter param2: Description of second parameter Returns: Description of return value Raises: ValueError: Description of when this is raised """ pass ``` -------------------------------- ### TouchScreen Finger Interaction Example Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-other-devices.md Illustrates placing a finger on the touchscreen, simulating a touch event, and then releasing it after a short delay. This is useful for emulating user interaction. ```cpp auto touchscreen = *TouchScreen::create(); touchscreen.place_finger(0, 0.2, 0.4, 0.7, 0); // Touch at (20%, 40%) std::this_thread::sleep_for(std::chrono::milliseconds(100)); touchscreen.release_finger(0); // Lift finger ``` -------------------------------- ### Create and Control Mouse (Python) Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/INDEX.md Illustrates the creation of a virtual mouse object in Python and its subsequent movement. This example requires importing Mouse and DeviceDefinition from the inputtino library. ```python from inputtino import Mouse, DeviceDefinition mouse = Mouse.create(DeviceDefinition()) mouse.move(100, 50) ``` -------------------------------- ### Docker Compose Configuration for inputtino Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/README.md Example docker-compose.yml snippet showing the necessary volume mounts, devices, and privileged settings for inputtino-python to access host devices. ```yaml # docker-compose.yml example services: your-service: volumes: - /dev/input:/dev/input:rw # For input device access - /dev/uhid:/dev/uhid # For PS5 controller support devices: - /dev/uinput # For virtual device creation privileged: true # Required for device access ``` -------------------------------- ### C Error Handling Example Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/errors.md Shows how to define an error callback function and register it with the Inputtino library during device creation. The callback is invoked if device creation fails. ```c void error_callback(const char *error_message, void *user_data) { printf("Error: %s\n", error_message); } InputtinoErrorHandler handler = { .eh = error_callback, .user_data = NULL }; InputtinoMouse *mouse = inputtino_mouse_create(&device_def, &handler); if (!mouse) { printf("Failed to create mouse\n"); } ``` -------------------------------- ### Rust Error Handling Example Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/errors.md Demonstrates creating a device definition and then attempting to instantiate a Mouse. It uses a match statement to handle potential InputtinoError::Generic during creation. ```rust use inputtino::{Mouse, DeviceDefinition}; let device = DeviceDefinition::new("Mouse", 0xAB00, 0xAB01, 0xAB00, "", "")?; match Mouse::new(&device) { Ok(mouse) => { mouse.move_rel(100, 50); } Err(InputtinoError::Generic(msg)) => { eprintln!("Failed to create mouse: {}", msg); } } ``` -------------------------------- ### Example C++ Usage of Inputtino Joypad Source: https://github.com/games-on-whales/inputtino/blob/stable/README.md Demonstrates creating and controlling a virtual joypad using the inputtino C++ API. Supports features like stick movement, button presses, and rumble callbacks. ```c++ #include auto joypad = Joypad::create(Joypad::PS, Joypad::RUMBLE | Joypad::ANALOG_TRIGGERS); joypad->set_stick(Joypad::LS, 1000, 2000); joypad->set_pressed_buttons(Joypad::X | Joypad::DPAD_RIGHT); auto rumble_data = std::make_shared>(); joypad.set_on_rumble([rumble_data](int low_freq, int high_freq) { rumble_data->first = low_freq; rumble_data->second = high_freq; }); ``` -------------------------------- ### Create Xbox One Joypad Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Initializes a new InputtinoXOneJoypad object. Requires device definition and error handling setup. ```c InputtinoXOneJoypad* inputtino_joypad_xone_create( const InputtinoDeviceDefinition *device, const InputtinoErrorHandler *eh ) ``` -------------------------------- ### Create Nintendo Switch Joypad Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Initializes a new InputtinoSwitchJoypad object. Requires device definition and error handling setup. ```c InputtinoSwitchJoypad* inputtino_joypad_switch_create( const InputtinoDeviceDefinition *device, const InputtinoErrorHandler *eh ) ``` -------------------------------- ### Create and Control Mouse (Rust) Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/INDEX.md Provides an example of creating a virtual mouse in Rust, including defining the device and performing relative movement. This snippet requires importing Mouse and DeviceDefinition from the inputtino crate and uses the Result type for error handling. ```rust use inputtino::{Mouse, DeviceDefinition}; let device = DeviceDefinition::new("Mouse", 0xAB00, 0xAB01, 0xAB00, "", "")?; let mouse = Mouse::new(&device)?; mouse.move_rel(100, 50); ``` -------------------------------- ### Set Target Include Directories Source: https://github.com/games-on-whales/inputtino/blob/stable/CMakeLists.txt Configures public include directories for the libinputtino target, specifying both build and install interfaces. ```cmake target_include_directories(libinputtino PUBLIC "$" "$") ``` -------------------------------- ### Python Error Handling Example Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/errors.md Illustrates creating a Mouse device in Python using a try-except block. This catches potential exceptions raised by the Inputtino library during device creation or operation. ```python from inputtino import Mouse, DeviceDefinition device = DeviceDefinition() device.name = "My Mouse" device.vendor_id = 0xAB00 device.product_id = 0xAB01 device.version = 0xAB00 try: mouse = Mouse.create(device) mouse.move(100, 50) except Exception as e: print(f"Failed to create mouse: {e}") ``` -------------------------------- ### Create PenTablet Instance Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-other-devices.md Demonstrates how to create a new virtual pen tablet device using the static `create` method. It shows how to handle the Result object returned on success or failure. ```cpp auto pen_tablet = *PenTablet::create(); ``` -------------------------------- ### Create and Control Mouse (C++) Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/INDEX.md Demonstrates creating a virtual mouse instance and performing basic actions like moving the cursor and clicking the left button. Requires including the inputtino/input.hpp header. ```cpp #include auto mouse = *Mouse::create(); mouse.move(100, 50); mouse.press(Mouse::LEFT); mouse.release(Mouse::LEFT); ``` -------------------------------- ### Get Touchscreen Nodes Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Retrieves the node names associated with an InputtinoTouchscreen. ```c char** inputtino_touchscreen_get_nodes(InputtinoTouchscreen *touchscreen, int *num_nodes) ``` -------------------------------- ### Create Virtual Mouse Device Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-mouse.md Demonstrates how to create a virtual mouse instance. Handles potential creation errors. ```cpp #include auto result = Mouse::create(); if (result) { auto mouse = *result; mouse.move(100, -50); } else { std::cerr << "Failed to create mouse: " << result.getErrorMessage() << std::endl; } ``` -------------------------------- ### Get Pen Tablet Nodes Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Retrieves the node names associated with an InputtinoPenTablet. ```c char** inputtino_pen_tablet_get_nodes(InputtinoPenTablet *pen_tablet, int *num_nodes) ``` -------------------------------- ### Get Nintendo Switch Joypad Nodes Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Retrieves the node names associated with an InputtinoSwitchJoypad. ```c char** inputtino_joypad_switch_get_nodes(InputtinoSwitchJoypad *joypad, int *num_nodes) ``` -------------------------------- ### Get Xbox One Joypad Nodes Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Retrieves the node names associated with an InputtinoXOneJoypad. ```c char** inputtino_joypad_xone_get_nodes(InputtinoXOneJoypad *joypad, int *num_nodes) ``` -------------------------------- ### Create XboxOneJoypad Instance Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-joypad.md Demonstrates how to create a new virtual Xbox One joypad instance using the static `create` method. Handles potential creation errors by checking the returned Result. ```cpp auto result = XboxOneJoypad::create(); if (result) { auto joypad = *result; joypad.set_pressed_buttons(XboxOneJoypad::A | XboxOneJoypad::B); } ``` -------------------------------- ### Create and Use Mouse Device Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-other-devices.md Demonstrates how to create a mouse device and perform a move operation. Includes error handling for device creation failure. ```cpp auto result = Mouse::create(); if (result) { auto mouse = *result; mouse.move(100, 50); } else { std::cerr << "Error: " << result.getErrorMessage() << std::endl; } ``` -------------------------------- ### Place Tool on Pen Tablet Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-other-devices.md Shows how to simulate placing different tools on the virtual pen tablet with varying parameters like position, pressure, and tilt. It illustrates using `SAME_AS_BEFORE` to maintain the current tool type. ```cpp pen_tablet.place_tool(PenTablet::PEN, 0.5, 0.5, 0.8, -1.0, 0.0, 0.0); // Place eraser with tilt pen_tablet.place_tool(PenTablet::ERASER, 0.3, 0.7, 0.6, -1.0, 15.0, -10.0); // Continue with same tool, no type change needed pen_tablet.place_tool(PenTablet::SAME_AS_BEFORE, 0.4, 0.8, 0.7, -1.0, 10.0, -5.0); ``` -------------------------------- ### Create and Configure SwitchJoypad Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-joypad.md Demonstrates how to create a virtual Nintendo Switch joypad, set its buttons, and register a rumble callback. Ensure the Joypad class is included and the create method returns a valid result before proceeding. ```cpp class SwitchJoypad : public Joypad { public: static Result create( const DeviceDefinition &device = { .name = "Wolf Nintendo (virtual) pad", .vendor_id = 0x057e, .product_id = 0x2009, .version = 0x8111 } ); void set_pressed_buttons(unsigned int newly_pressed) override; void set_triggers(int16_t left, int16_t right) override; void set_stick(STICK_POSITION stick_type, short x, short y) override; void set_on_rumble(const std::function &callback); std::vector get_nodes() const override; ~SwitchJoypad() override; }; ``` ```cpp auto result = SwitchJoypad::create(); if (result) { auto joypad = *result; joypad.set_pressed_buttons(SwitchJoypad::A); joypad.set_on_rumble([](int low, int high) { std::cout << "Switch rumble: " << low << ", " << high << std::endl; }); } ``` -------------------------------- ### Get Mouse Device Nodes Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-mouse.md Retrieves the device node paths associated with the mouse. Use this to identify the specific input devices on the system. ```cpp std::vector get_nodes() const override ``` ```cpp auto nodes = mouse.get_nodes(); for (const auto &node : nodes) { std::cout << "Device node: " << node << std::endl; } ``` -------------------------------- ### PS5 Controller Simulation with inputtino-python Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/README.md Illustrates how to control a simulated PS5 controller, including setting button states, analog stick positions, and trigger pressures. ```python from inputtino import PS5Joypad, ControllerButton, StickPosition # Initialize PS5 controller joypad = PS5Joypad() # Set button states joypad.set_pressed_buttons(ControllerButton.X | ControllerButton.DPAD_UP) # Move analog sticks joypad.set_stick(StickPosition.LS, x=100, y=200) # Set trigger pressure joypad.set_triggers(left=32000, right=16000) # Handle rumble feedback joypad.set_on_rumble(lambda low, high: print(f"Rumble: {low}, {high}")) ``` -------------------------------- ### Get Device Node Paths Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-keyboard.md Retrieves the device node paths associated with the keyboard, typically used for low-level input event handling. ```cpp std::vector get_nodes() const override ``` ```cpp auto nodes = keyboard.get_nodes(); for (const auto &node : nodes) { std::cout << "Keyboard device: " << node << std::endl; } ``` -------------------------------- ### Keyboard Control with inputtino-python Source: https://github.com/games-on-whales/inputtino/blob/stable/bindings/python/README.md Shows how to simulate keyboard input, including pressing, releasing, and typing keys using the Keyboard class. ```python from inputtino import Keyboard, KeyCode # Initialize keyboard device keyboard = Keyboard() # Type individual keys keyboard.press(KeyCode.A) keyboard.release(KeyCode.A) # Convenient typing with auto-release keyboard.type(KeyCode.ENTER) keyboard.type(KeyCode.from_str("space")) # From string representation ``` -------------------------------- ### Get Trackpad Device Nodes Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Retrieves an array of device node paths for the virtual trackpad. The number of nodes is returned via the num_nodes output parameter. ```c char** inputtino_trackpad_get_nodes(InputtinoTrackpad *trackpad, int *num_nodes) ``` -------------------------------- ### Get Mouse Device Nodes Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Retrieves an array of device node paths for the virtual mouse. The number of nodes is returned via the num_nodes output parameter. ```c char** inputtino_mouse_get_nodes(InputtinoMouse *mouse, int *num_nodes) ``` -------------------------------- ### Create Mouse Device with Definition Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/INDEX.md Demonstrates how to create a mouse device using an optional DeviceDefinition. The result is a std::optional which can be checked for success. ```cpp auto result = Mouse::create(device_definition); if (result) { auto mouse = *result; } ``` -------------------------------- ### Logging Device Creation Errors in C++ Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/errors.md Log detailed error messages using a logging library like spdlog when device creation fails. Include relevant context such as the device name and the specific error message returned. ```cpp auto result = Mouse::create(custom_device); if (!result) { spdlog::error("Failed to create mouse device '{}': {}", custom_device.name, result.getErrorMessage()); } ``` -------------------------------- ### Keyboard::create() Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-keyboard.md Creates a new virtual keyboard device. It can be configured with a DeviceDefinition and a key re-press interval. ```APIDOC ## Keyboard::create() ### Description Creates a new virtual keyboard device. It can be configured with a DeviceDefinition and a key re-press interval. ### Method `static Result create( const DeviceDefinition &device = {...}, int millis_repress_key = 50 )` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **device** (`const DeviceDefinition&`): Device configuration with name, vendor ID, product ID, and version. Defaults to a predefined virtual keyboard configuration. - **millis_repress_key** (`int`): Time interval in milliseconds to automatically re-press held keys. If a key is pressed, it is automatically re-pressed at this interval until released. Defaults to 50ms. ### Response #### Success Response `Result`: A Result object containing the Keyboard instance on success. #### Error Response `Result`: An Error object if the keyboard creation fails. ### Example ```cpp #include auto result = Keyboard::create(); if (result) { auto keyboard = *result; keyboard.press(0x41); // Press key A (VK code) keyboard.release(0x41); // Release key A } ``` ``` -------------------------------- ### Get Keyboard Device Nodes Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Retrieves an array of device node paths for the virtual keyboard. The total number of nodes is returned via the num_nodes output parameter. ```c char** inputtino_keyboard_get_nodes(InputtinoKeyboard *keyboard, int *num_nodes) ``` -------------------------------- ### Rust Keyboard Creation with Defaults Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/configuration.md Creates a Keyboard device in Rust using default parameters. ```rust # Rust: no direct parameter, create with defaults let keyboard = Keyboard::new(&device)?; ``` -------------------------------- ### inputtino_keyboard_create Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Creates a virtual keyboard device. It takes device configuration and an optional error handler. ```APIDOC ## inputtino_keyboard_create ### Description Create a virtual keyboard device. ### Method ```c InputtinoKeyboard* inputtino_keyboard_create( const InputtinoDeviceDefinition *device, const InputtinoErrorHandler *eh ) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **device** (`const InputtinoDeviceDefinition*`) - Device configuration (NULL for defaults) - **eh** (`const InputtinoErrorHandler*`) - Error handler (may be NULL) ### Returns `InputtinoKeyboard*` — Pointer to created keyboard, or NULL on failure. ``` -------------------------------- ### static Result create() Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-joypad.md Creates a new virtual Xbox One joypad instance, allowing for custom device definitions. ```APIDOC ## create() ### Description Creates a new virtual Xbox One joypad. ### Method static ### Endpoint XboxOneJoypad::create() ### Parameters #### Path Parameters - **device** (const DeviceDefinition&) - Optional - Device configuration (default: Xbox One defaults) ### Request Example ```cpp auto result = XboxOneJoypad::create(); if (result) { auto joypad = *result; joypad.set_pressed_buttons(XboxOneJoypad::A | XboxOneJoypad::B); } ``` ### Response #### Success Response (Result) - **Result** (Result) - A Result containing the XboxOneJoypad on success or Error on failure. ``` -------------------------------- ### C++ Result Checking Example Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/errors.md Demonstrates how to check the success or failure of a Result object. Access the value on success using operator*() or retrieve the error message using getErrorMessage() on failure. ```cpp auto result = Mouse::create(); if (result) { // Success: access value with operator*() auto mouse = *result; } else { // Failure: get error message std::cerr << "Error: " << result.getErrorMessage() << std::endl; } ``` -------------------------------- ### Generic Joypad Enum Usage Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-rust.md Illustrates how to use the generic `Joypad` enum to interact with different joypad types through a unified interface. This example shows setting common controls and registering a rumble callback. ```rust use inputtino::Joypad; let mut joypad: Joypad = Joypad::PS5(ps5_joypad); joypad.set_pressed((JoypadButton::A as i32)); joypad.set_stick(JoypadStickPosition::LS, 0, 32767); joypad.set_triggers(0, 32767); joypad.set_on_rumble(|low, high| { println!("Rumble: low={}, high={}", low, high); }); ``` -------------------------------- ### TouchScreen Create Method Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-other-devices.md Static method to create a new virtual touchscreen instance. Custom device properties can be provided. ```cpp static Result create(const DeviceDefinition &device = {...}) ``` -------------------------------- ### PenTablet::create() Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-other-devices.md Creates a new virtual pen tablet device. It can be configured with a default or custom DeviceDefinition. ```APIDOC ## PenTablet::create() ### Description Creates a new virtual pen tablet device. It can be configured with a default or custom DeviceDefinition. ### Method `static Result create(const DeviceDefinition &device = {...})` ### Parameters #### Request Body - **device** (`DeviceDefinition`) - Optional - Configuration for the virtual pen tablet, including name, vendor ID, product ID, and version. Defaults to a predefined 'Wolf (virtual) pen tablet' configuration. ### Response #### Success Response - **PenTablet** - An instance of the created PenTablet. #### Error Response - **Error** - An error object if the device creation fails. ### Example ```cpp // Using default device definition auto pen_tablet_default = *PenTablet::create(); // Using custom device definition DeviceDefinition custom_device = { .name = "My Custom Tablet", .vendor_id = 0xABCD, .product_id = 0x1234, .version = 0x0100 }; auto pen_tablet_custom = *PenTablet::create(custom_device); ``` ``` -------------------------------- ### PenTablet::place_tool() Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-other-devices.md Simulates placing a tool on the pen tablet at specified coordinates and pressure. Supports various tool types and tilt. ```APIDOC ## PenTablet::place_tool() ### Description Place a tool (pen, eraser, etc.) on the tablet at the specified coordinates, pressure, and tilt. Pressure and distance are mutually exclusive. ### Method `void place_tool(TOOL_TYPE tool_type, float x, float y, float pressure, float distance, float tilt_x, float tilt_y)` ### Parameters #### Path Parameters - **tool_type** (`TOOL_TYPE`) - Required - Type of tool: PEN, ERASER, BRUSH, PENCIL, AIRBRUSH, TOUCH, or SAME_AS_BEFORE. - **x** (`float`) - Required - X coordinate in normalized range [0.0, 1.0]. - **y** (`float`) - Required - Y coordinate in normalized range [0.0, 1.0]. - **pressure** (`float`) - Required - Tool pressure in normalized range [0.0, 1.0]. Use negative value to disable (report distance instead). - **distance** (`float`) - Required - Tool distance from surface in normalized range [0.0, 1.0]. Use negative value to disable (report pressure instead). Pressure and distance should never both be positive. - **tilt_x** (`float`) - Required - X-axis tilt in degrees [-90.0, 90.0]. - **tilt_y** (`float`) - Required - Y-axis tilt in degrees [-90.0, 90.0]. ### Notes - Pressure and distance are mutually exclusive; use negative values to disable one. - `SAME_AS_BEFORE` tool type is useful when switching between tool types without needing to re-report the type. ### Example ```cpp // Assuming pen_tablet is an initialized PenTablet object // Place pen with pressure pen_tablet.place_tool(PenTablet::PEN, 0.5, 0.5, 0.8, -1.0, 0.0, 0.0); // Place eraser with tilt pen_tablet.place_tool(PenTablet::ERASER, 0.3, 0.7, 0.6, -1.0, 15.0, -10.0); // Continue with same tool, no type change needed pen_tablet.place_tool(PenTablet::SAME_AS_BEFORE, 0.4, 0.8, 0.7, -1.0, 10.0, -5.0); ``` ``` -------------------------------- ### inputtino_touchscreen_create Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Creates a virtual touchscreen device. It takes device configuration and an optional error handler. ```APIDOC ## inputtino_touchscreen_create ### Description Create a virtual touchscreen device. ### Method ```c InputtinoTouchscreen* inputtino_touchscreen_create( const InputtinoDeviceDefinition *device, const InputtinoErrorHandler *eh ) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **device** (`const InputtinoDeviceDefinition*`) - Device configuration (NULL for defaults) - **eh** (`const InputtinoErrorHandler*`) - Error handler (may be NULL) ### Returns `InputtinoTouchscreen*` — Pointer to created touchscreen, or NULL on failure. ``` -------------------------------- ### Create Inputtino Library and Alias Source: https://github.com/games-on-whales/inputtino/blob/stable/CMakeLists.txt Defines the main library 'libinputtino' and creates an alias 'inputtino::libinputtino' for easier referencing. ```cmake add_library(libinputtino) add_library(inputtino::libinputtino ALIAS libinputtino) ``` -------------------------------- ### Create Keyboard Device Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-keyboard.md Instantiates a new virtual keyboard device. The default device configuration includes a name, vendor ID, product ID, and version. The `millis_repress_key` parameter controls the auto-repress interval for held keys. ```cpp static Result create( const DeviceDefinition &device = { .name = "Wolf (virtual) keyboard", .vendor_id = 0xAB00, .product_id = 0xAB05, .version = 0xAB00 }, int millis_repress_key = 50 ) ``` -------------------------------- ### Trackpad Create Method Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-other-devices.md Static method to instantiate a new virtual trackpad. It accepts an optional DeviceDefinition for custom configuration. ```cpp static Result create(const DeviceDefinition &device = {...}) ``` -------------------------------- ### Define a Virtual Input Device Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-rust.md Use `DeviceDefinition` to configure parameters for creating a new virtual input device. This includes name, vendor ID, product ID, version, physical path, and unique identifier. ```rust pub struct DeviceDefinition { pub def: InputtinoDeviceDefinition, // Internal CString storage (name, phys, uniq) } impl DeviceDefinition { pub fn new( name: &str, vendor_id: u16, product_id: u16, version: u16, phys: &str, uniq: &str, ) -> Self } ``` ```rust use inputtino::DeviceDefinition; let device = DeviceDefinition::new( "Rusty Mouse", 0xAB00, 0xAB01, 0xAB00, "usb-0000:00:1d.7-1", "12345ABCDE" ); ``` -------------------------------- ### Mouse::create() Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-mouse.md Creates a new virtual mouse device. It can be configured with a DeviceDefinition, otherwise it uses a default configuration. ```APIDOC ## Mouse::create() ### Description Creates a new virtual mouse device. It can be configured with a DeviceDefinition, otherwise it uses a default configuration. ### Method `static Result create(const DeviceDefinition &device = {...})` ### Parameters #### Path Parameters - **device** (`const DeviceDefinition&`) - Optional - Device configuration with name, vendor ID, product ID, and version. Defaults to a predefined configuration. ### Response #### Success Response - **Mouse** (`Result`) - A Result object containing the Mouse instance on success. #### Error Response - **Error** (`Result`) - A Result object containing an Error on failure. ### Request Example ```cpp #include auto result = Mouse::create(); if (result) { auto mouse = *result; mouse.move(100, -50); } else { std::cerr << "Failed to create mouse: " << result.getErrorMessage() << std::endl; } ``` ``` -------------------------------- ### Mouse Move Semantics Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-mouse.md Demonstrates how to use move semantics to efficiently transfer ownership of a Mouse object. This is useful for avoiding unnecessary copies. ```cpp auto mouse1 = Mouse::create(); auto mouse2 = std::move(*mouse1); // Valid: transfers ownership ``` -------------------------------- ### Create Virtual Keyboard Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Creates a virtual keyboard device. Device configuration and an optional error handler can be provided. ```c InputtinoKeyboard* inputtino_keyboard_create( const InputtinoDeviceDefinition *device, const InputtinoErrorHandler *eh ) ``` -------------------------------- ### Control a Virtual Keyboard Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-rust.md The `Keyboard` struct allows for simulating keyboard input. Use `new` to create a keyboard instance and `get_nodes` to retrieve device paths. The `press` and `release` methods simulate key presses and releases using key codes. ```rust pub struct Keyboard { keyboard: *mut crate::sys::InputtinoKeyboard, } impl Keyboard { pub fn new(device: &DeviceDefinition) -> Result pub fn get_nodes(&self) -> Result, InputtinoError> pub fn press(&self, key_code: i32) pub fn release(&self, key_code: i32) } impl Drop for Keyboard { ... } unsafe impl Send for Keyboard { ... } ``` ```rust use inputtino::{Keyboard, DeviceDefinition}; let device = DeviceDefinition::new("Rusty Keyboard", 0xAB00, 0xAB05, 0xAB00, "", "")?; let keyboard = Keyboard::new(&device)?; keyboard.press(0x41); // Press 'A' keyboard.release(0x41); // Release 'A' ``` -------------------------------- ### inputtino_trackpad_create Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Creates a virtual trackpad device. It takes device configuration and an optional error handler. ```APIDOC ## inputtino_trackpad_create ### Description Create a virtual trackpad device. ### Method ```c InputtinoTrackpad* inputtino_trackpad_create( const InputtinoDeviceDefinition *device, const InputtinoErrorHandler *eh ) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **device** (`const InputtinoDeviceDefinition*`) - Device configuration (NULL for defaults) - **eh** (`const InputtinoErrorHandler*`) - Error handler (may be NULL) ### Returns `InputtinoTrackpad*` — Pointer to created trackpad, or NULL on failure. ``` -------------------------------- ### inputtino_mouse_create Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-c-api.md Creates a virtual mouse device. It takes device configuration and an optional error handler. Returns a pointer to the created mouse or NULL on failure. ```APIDOC ## inputtino_mouse_create ### Description Create a virtual mouse device. ### Method ```c InputtinoMouse* inputtino_mouse_create( const InputtinoDeviceDefinition *device, const InputtinoErrorHandler *eh ) ``` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **device** (`const InputtinoDeviceDefinition*`) - Device configuration (NULL for defaults) - **eh** (`const InputtinoErrorHandler*`) - Error handler (may be NULL) ### Returns `InputtinoMouse*` — Pointer to created mouse, or NULL on failure. ``` -------------------------------- ### Press Mouse Button Source: https://github.com/games-on-whales/inputtino/blob/stable/_autodocs/api-reference-cpp-mouse.md Demonstrates simulating a mouse button press. Supports standard buttons like LEFT and RIGHT. ```cpp mouse.press(Mouse::LEFT); mouse.press(Mouse::RIGHT); ```