Skip to content

Latest commit

 

History

History
78 lines (62 loc) · 4.24 KB

README.md

File metadata and controls

78 lines (62 loc) · 4.24 KB

Interceptor-Gamepad-Controller console examples

Install this edition with InterceptorSetup.exe, restart Windows if requested, then run one example as administrator. Each program checks the driver before starting and explains its action in English. Close its console or press Ctrl+C to stop. Physical Ctrl+Alt+Delete is available if an intentional keyboard block suppresses shortcuts; that example also exits on Escape.

Each .cpp is independent: Interceptor.h, Interceptor.cpp, and standard/Windows headers are all it needs. There is no shared example runner or behavior header.

Source / executable What it does
Controller_01_Invert_Vertical.cpp Invert every identified stick Y axis. Supports HID, XInput/XUSB, XInputHID and GIP.
Controller_02_Swap_Buttons.cpp Swap controller buttons in pairs: 1/2, 3/4, and so on. Supports all controller families.
Controller_03_Instant_Triggers.cpp Make any positive trigger pressure 100%. Supports HID, XInput/XUSB, XInputHID and GIP.
Controller_04_Deadzone_50.cpp Apply a 50% deadzone per stick axis and rescale the remaining range. Supports all families.
Controller_05_Inverse_Exponential.cpp Apply an inverse exponential stick curve (square root by default). Supports all families.

Receive, change, forward

The essential HID Y axis operation is easy to follow:

auto inputs = Get_Input_With_Timeout(INFINITE);
for (auto& input : inputs) {
    if (auto* controller = input.Get<Controller_Hid_Input>()) {
        for (auto& axis : controller->state.axes) {
            if (axis.usage_page == 1 && axis.usage == 0x31) {
                axis.normalized = -axis.normalized;
            }
        }
    }
}
auto result = Send_Input(inputs);

The complete examples also handle null/relative controls, HID layouts and native XInput/GIP states, check initialization/send failures, and forward unrelated fields/families. INFINITE sleeps until input arrives; there is no polling, countdown, FPS limit, per-packet descriptor query or manually managed context. Buffers and capture lifetime belong to the library. Process exit closes capture in the driver.

Build from the repository root with ./Build.ps1 -Target ExamplesConsole. EXEs are written to bin/Native/. Download precompiled programs from the release's examples ZIP; the SDK ZIP includes their complete sources.

The demo is limited to one hour per boot, shared across applications.

Controller fields

All five controller examples handle HID, XInput/XUSB, XInputHID and GIP in the same receive loop. HID uses dynamic state.axes, state.triggers and state.buttons; XUSB/GIP use their native state fields. Only the current report's decoded controls are edited; unknown fields and raw extensions pass through.

HID descriptors do not universally identify stick/trigger roles. Auto selects X/Y + Z/Rz when present in the same report/collection/element, otherwise X/Y + Rx/Ry. Use --hid-layout xy-rxry or --hid-layout xy-zrz for an ambiguous descriptor. A lone combined-trigger Z, hats, null/relative controls and vendor data are preserved. Button pairing stays within each report/collection/usage page; an odd last button stays unchanged.

The 50% deadzone is per axis, not radial: 40% -> 0%, 75% -> 50%, 100% -> 100%. The inverse exponential uses sign(x) * abs(x)^(1/exponent); use --exponent 2 (default), or a matching value from 1 to 16. It only compensates a game applying the matching power curve, without additional deadzones/acceleration.

Reading an example

Run the EXE directly. Each example prints its action, checks the installed driver, then receives inputs, changes the relevant state and forwards the batch. The source keeps those steps visible in main(); helper functions describe the controller transformation. No shared example runner is required.

Examples without settings use int main() and need no command-line arguments. Controller examples with HID layout or exponent settings keep their documented options. The console setup only prevents text selection from blocking console writes; it is separate from the driver API.