X1 API Documentation

The X1 API provides an Inter-Process Communication (IPC) interface allowing third-party scripts/applications (e.g. Python, AutoHotkey) to send commands to the mouse via the X1 Control Panel.

The API is disabled by default. To use it, tick Enable X1 API in Settings, under App Detection, and click Apply. The X1 Control Panel then offers to restart, which it needs to do to initialize the interface.

Settings, App Detection, with Enable X1 API

Depending on your operating system, connect to the following local endpoint:

Windows

Linux/macOS

\\.\pipe\swiftpoint.x1.v2.command

/tmp/swiftpoint.x1.v2.command

The interface follows a request-response pattern. End each command with a newline. For every command sent, the API will return one of the following:

  • OK: The command was executed successfully.
  • ERROR: The command failed (e.g., ERROR: Unknown command).
  • A command specific response (eg. Profile Get, Profile List)

If no mouse is connected, every command returns ERROR: No active device connected.

Commands:

The following commands are available in X1 API v2, introduced in X1 Control Panel 3.1.0.0. Command names aren't case-sensitive.

Command

Parameters

Description

Profile

Set [Name]

Switches to the specified profile (max 18 chars). The name must match exactly, including capitals. Returns OK even if no profile has that name.

Get

Returns the active profile's name.

List

Returns a list of all X1 profiles, separated by newline characters.

Vibrate

[Duration] [Strength]

Triggers haptic feedback. Duration in ms (default 70), Strength 0-100 (default 100).

DPI

[XValue] [YValue]

Sets mouse DPI to chosen value (rounded to supported DPI step). YValue parameter is optional.

IMU

Zero

Re-zeroes IMU's Pitch, Roll, and Yaw values.

RGB

Fixed #RRGGBB

Sets a static LED color using a hex code.

HueRotation [Brightness] [Duration]

Starts a color cycle. Brightness 0-255 (default 255), Duration in ms 0-65535 (default 500).

Off

Disables the LED.

Override True/False

Set RGB Override to True to lock RGB state to the next RGB command you send.
Set RGB Override back to False to allow profiles and mappings to alter RGB mode.

OLED

Image [Data]

Displays a custom image. Requires 512 hex characters (256 bytes).

Message [Text]

Displays a text string on the OLED (max 19 chars).

Blank, DPI, Profile, Force, Angles, Cube, Firmware or Battery

Switches OLED to specific UI modes.

Override True/False

Set OLED Override to True to lock OLED state to the next OLED command you send.
Set OLED Override back to False to allow profiles and mappings to alter OLED mode.

Example Scripts:

Sending Commands with AutoHotkey (Windows)

The following example function sends a command and reads the response. If the response is an error, it is displayed in a message box. Check the "Example SendCommand Usage" section below for examples of how this can be used.

#Requires AutoHotkey v2.0

SendCommand(Command) {
    ; 1. Open pipe with Read/Write access (0xC0000000)
    hPipe := DllCall("CreateFile", "Str", "\\.\pipe\swiftpoint.x1.v2.command", "UInt", 0xC0000000, "UInt", 0, "Ptr", 0, "UInt", 3, "UInt", 0, "Ptr", 0, "Ptr")

    if (hPipe = -1) {
        ToolTip('Could not connect to the X1 API pipe.')
        SetTimer(() => ToolTip(), -3000)
        return
    }

    ; 2. Write the command
    buf := Buffer(StrPut(Command, "UTF-8"))
    StrPut(Command, buf, "UTF-8")
    DllCall("WriteFile", "Ptr", hPipe, "Ptr", buf.Ptr, "UInt", buf.Size - 1, "UIntP", &bytesWritten := 0, "Ptr", 0)

    ; 3. Read the response
    resBuf := Buffer(1024, 0)
    response := ""
    if DllCall("ReadFile", "Ptr", hPipe, "Ptr", resBuf.Ptr, "UInt", resBuf.Size, "UIntP", &bytesRead := 0, "Ptr", 0) {
        response := StrGet(resBuf, bytesRead, "UTF-8")

        ; 4. Only show MsgBox if response is NOT "OK" (ignoring the newline)
        if (Trim(response, " `n`r") != "OK") {
            MsgBox("API Error/Response: " . response)
        }
    }

    ; 5. Clean up
    DllCall("CloseHandle", "Ptr", hPipe)

    return response
}

Use the SendCommand function above to change mouse profile on keyboard key press and release.

; On Left Shift Press, change profile to "Desktop-Shift". Then On Left Shift Release change profile to "Desktop"
*LShift:: {
    SendCommand("Profile Set Desktop-Shift")
    KeyWait "LShift"
    SendCommand("Profile Set Desktop")
}

Use the SendCommand function above to set DPI when a key is pressed, then change it back when it's released.

; On F6 Press, change DPI to 400. Then On F6 Release change DPI to 800
F6:: {
    SendCommand("DPI 400")
    KeyWait "F6"
    SendCommand("DPI 800")
}

Sending Commands with Python (Windows)

The following example function sends a command and reads the response. Check the "Example SendCommand Usage" section below for examples of how this can be used.

import os

def SendCommand(command):
    pipe_path = r'\\.\pipe\swiftpoint.x1.v2.command'

    # Open the pipe for reading and writing
    pipe = os.open(pipe_path, os.O_RDWR)

    # Send the command
    os.write(pipe, (command + "\n").encode("utf-8"))

    # Read the response (1024 bytes)
    response_bytes = os.read(pipe, 1024)
    response = response_bytes.decode("utf-8").strip()
    print(response)

    os.close(pipe)

Sending Commands with Python (Linux/macOS)

The following example function sends a command and reads the response. Check the "Example SendCommand Usage" section below for examples of how this can be used.

import socket

def SendCommand(command):
    # Standard Unix socket path
    socket_path = "/tmp/swiftpoint.x1.v2.command"

    # Create a Unix domain stream socket
    sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

    # Connect to the socket
    sock.connect(socket_path)

    # Send the command with a newline terminator
    sock.sendall((command + "\n").encode("utf-8"))

    # Receive the response
    response_bytes = sock.recv(1024)
    response = response_bytes.decode("utf-8").strip()
    print(response)

    sock.close()

Example SendCommand Usage

Once you've defined the SendCommand function in AutoHotkey or Python as shown above, you can use it to send commands in the format below.

SendCommand("Profile Set Desktop")
SendCommand("Vibrate 70 100")
SendCommand("DPI 800")
SendCommand("RGB Fixed #00FF00")
SendCommand("RGB HueRotation 255 50")
SendCommand("RGB Override True")
SendCommand("OLED Message Hello World!")
SendCommand("OLED Battery")
SendCommand("OLED Override True")

OLED Image Command Notes and Examples

The OLED Image command works a bit differently to the other OLED modes, so there are a few things you should note when using it.

The image data sent to the mouse is only stored in the OLED's display buffer, so it's lost as soon as anything else is written into the display buffer. For example, if a mouse mapping triggers an OLED command, or if the current display mode refreshes (Tilt/Force levels change).

So if you want your custom image to persist, "OLED Override" must be set to True before sending the image data. This will display the image until the override is disabled, or the mouse is switched off. Even other OLED mode changes sent through the API will be ignored.

The OLED display draws far more power than any other component in the mouse, and the more lit pixels, the more power it consumes.
So displaying an image with many white pixels will have a significant effect on the Z3 battery life. Leaving a static image on the display for long durations will also eventually lead to burn-in.

For these reasons it's recommended not to permanently display a static image on the OLED using this command.

Example OLED Image usage with the SendCommand function defined above:

Clear the display without disabling override:

SendCommand("OLED Image 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")

Display Swiftpoint Logo:

SendCommand("OLED Image 000000000000000000000000000000000000001f80000000000000fff0000000000003fffc000000000007fffe00000000000fffff00000000001fffff80000000003fffffc0000000003fffffc0000000007fe7ffe0000000007fe1ffe0000000007ff1ffe000000000ffe07ff000000000fff03ff000000000ffe01ff000000000ffe00ff000000000fff007f0000000007fe003e000000000ffe001e0000000007ff01fe0000000007fe01fe0000000003ff20fc0000000003fe60fc0000000001fff0780000000000fff87000000000007ff82000000000003ff80000000000000ffc00000000000001f4000000000000000000000000000000000000000")

Still need a hand? 💁‍♂️

If you can't find what you're looking for, reach out to our support team.