A low-level Rust library for controlling Razer mouse and keyboard input directly through the Razer Synapse driver on Windows.
use razerctl::{RazerDevice, MouseButton};
fn main() -> Result<(), std::io::Error> {
let mut device = RazerDevice::new()?;
// Move mouse (relative x, y)
device.mouse_move(100, 100)?;
// Click mouse
device.mouse_click(MouseButton::Left, true)?; // Press
device.mouse_click(MouseButton::Left, false)?; // Release
Ok(())
}- ✅ Relative Mouse Movement: Move the mouse cursor by a given x/y offset.
- ✅ Mouse Button Clicks: Simulate press and release events for all standard mouse buttons (Left, Right, Middle, X1, X2).
- ✅ Keyboard Key Presses: Simulate key down and key up events for a comprehensive set of keyboard keys.
- ✅ Safe Abstractions: Provides a safe and simple public API that handles the underlying
unsafeWindows API and driver interactions.
This library works by locating the symbolic link to the RZCONTROL device created by the Razer Synapse driver and communicating with it directly using DeviceIoControl.
Keyboard input is not sent using standard Windows scan codes. Instead, this crate implements a custom translation layer that converts standard Virtual-Key (VK) codes into the specific MakeCode values the Razer driver expects. This logic was ported from the IbInputSimulator C++ project.
- Windows operating system
- Razer Synapse 3 installed
- Rust 1.56 or higher
1. Add razerctl to your project:
cargo add razerctl2. (Recommended) Add win_key_codes for easy keyboard control:
For sending keyboard input, you need to provide Windows Virtual-Key codes. The win_key_codes crate provides convenient constants for these codes.
cargo add win_key_codesThis crate uses unsafe code to interface with the Windows API and the device driver. However, the public API is designed to be a completely safe abstraction over these details. All unsafe blocks are contained internally and have been written with care.
You can run the included examples from the project root:
# --- Mouse Examples ---
cargo run --example left_click
cargo run --example mouse_move1
cargo run --example mouse_move2
# --- Keyboard Example ---
cargo run --example keyboard_testContributions are welcome! If you find a bug or have an idea for an improvement, please feel free to submit an issue or a pull request.
This project is licensed under the MIT License.