Skip to content

Latest commit

 

History

36 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎮 Gamepad-Core Host Bridge

Gamepad-Core Host Bridge is a native C++ library that exposes the functionality of Gamepad-Core through a high-level, C-compatible API. The current project version is 1.0.6.

C C++ C%23 Python Rust Go Java JavaScript TypeScript WebAssembly

Live TestsFeaturesAPI LifecycleAPI ReferencesQuick TestingJavaScript, TypeScript & WebAssemblyBuildStructureContributingLicense


✨ Features

  • Device Registry Integration: Support for host applications or external game engines.
  • Platform Bridge Callbacks: Efficient device detection and I/O operations.
  • Handle Management: Support for creating and invalidating device handles natively within the platform.
  • Advanced Forwarding: Seamless forwarding of input, output, and audio-haptics operations.
  • C-Compatible Entry Points: Exported endpoints optimized for managed language integrations.
  • Direct Debugging: Configurable log callbacks for real-time host debugging.

⚙️ Native API Lifecycle

The host application should implement the following lifecycle and update loop steps:

  1. Initialize the Bridge: Set up platform bridge callbacks by calling GCH_InitializePlatformBridge.
  2. Register Policies: Define allocation, dispatch, and disconnection callbacks via GCH_InitializeDeviceRegistryPolicy.
  3. Discover Devices: Continuously poll for new hardware by calling GCH_DiscoverDevices from within the update loop.
  4. Update Controllers: Refresh the state of each connected controller using GCH_UpdateInput.
  5. Retrieve Data: Access input states and hardware information via GCH_GetInputState and GCH_GetDeviceDescriptor.

Callbacks & Shutdown

  • Logging: Bridge logs can be redirected by configuring a function callback via GCH_SetLogCallback.
  • Version Checking: Retrieve the compiled library version with GCH_GetVersion.
  • Safe Shutdown: Upon termination, the host application must call GCH_Shutdown to safely destroy the platform instance and clear callback pointers.

🧪 Live Tests

Try the WebAssembly build directly in your browser:

Open Gamepad-Core Live Tests →

Connect a supported gamepad and test the native C++ bridge running through WASM.


Test quickly with a C# implementation or create an implementation for your preferred language. The C-compatible API is designed to integrate seamlessly with any language that supports FFI (Foreign Function Interface), including Python, Rust, Go, Java, and more.

📥 Precompiled Binaries (Windows x64)

For quick integration without building from source, download the precompiled GamepadCoreHost.dll binary directly from the releases page. This shared library is ready to use with any compatible host application or game engine that supports C-compatible FFI (Foreign Function Interface).

🚀 Client Implementation

Check out the companion command-line application that consumes this API:

Quick Start:

dotnet build .\G-Client-Sharp\G-Client-Sharp.csproj

Running without arguments prints the default DLL location and command-line help:

dotnet run --project .\G-Client-Sharp\G-Client-Sharp.csproj

Start device monitoring with the default DLL path and display the native API descriptor information:

dotnet run --project .\G-Client-Sharp\G-Client-Sharp.csproj -- --info

Pass a different native DLL path with --dll (or -d):

dotnet run --project .\G-Client-Sharp\G-Client-Sharp.csproj -- `
  --dll "C:\path\to\GamepadCoreHost.dll"

The DLL must match the process architecture. Use an x64 DLL with the x64 .NET process.


Check out the companion command-line application that consumes this API:

Use the configured default DLL path:

python main.py

Provide a DLL path explicitly:

python main.py --dll "C:\path\to\GamepadCoreHost.dll"

Continuously discover devices and process inputs:

python main.py --loop

Useful options:

-d, --dll PATH       Path to GamepadCoreHost.dll
-l, --loop           Run continuous discovery and input polling
-i, --interval TIME  Loop interval in seconds
--info                Display native API structure details

🌐 JavaScript, TypeScript & WebAssembly

The C-compatible API can also be consumed from JavaScript and TypeScript through WebAssembly, compiled with Emscripten. This makes Gamepad-Core Host available to browser applications, Node.js tools, and other JavaScript runtimes that support WebAssembly.

The WebAssembly build generates GamepadCoreHost.js and GamepadCoreHost.wasm. For JavaScript callback binding, it exports addFunction/removeFunction and supports callback-table pointers through:

  • GCH_InitializePlatformBridgeWasm
  • GCH_InitializeDeviceRegistryPolicyWasm

Download the precompiled WebAssembly package:

TypeScript integrations can use the generated JavaScript module together with custom type declarations for the exported native functions and callback signatures.


📚 API References

The following functions are exported by the native bridge:

Function Return type
GCH_DiscoverDevices(float DeltaTime) void
GCH_UpdateInput(int DeviceId, float DeltaTime) void
GCH_UpdateOutput(int ControllerId) void
GCH_GetInputState(int DeviceId, FInputContext* OutInputState) bool
GCH_GetDeviceDescriptor(int DeviceId, GamepadDeviceDescriptor* OutDescriptor) bool
GCH_DeviceIsConnected(int ControllerId) bool
GCH_GetDeviceType(int ControllerId) int
GCH_GetConnectionType(int ControllerId) int
GCH_BatteryLevelDevice(int ControllerId) float
GCH_Lightbar(int ControllerId, std::uint8_t R, std::uint8_t G, std::uint8_t B) void
GCH_PlayerLed(int ControllerId, int Led, std::uint8_t Brightness) void
GCH_ResetLights(int ControllerId) void
GCH_ResetGyroOrientation(int ControllerId) void
GCH_EnableGyroscopeValues(int ControllerId, bool EnableGyroscope) void
GCH_EnableTouch(int ControllerId, bool EnableTouch) void
GCH_CustomTrigger(int ControllerId, const std::uint8_t* HexBytes, int ByteCount, int Hand) bool
GCH_StopTrigger(int ControllerId, int Hand) void
GCH_SetVibration(int ControllerId, std::uint8_t LeftRumble, std::uint8_t RightRumble) void

The int parameters used for device type, connection type, LED, and trigger hand correspond to the enum values defined by the native Gamepad-Core/Dualsense-Multiplatform library.

GCH_DualSenseSettings allows you to configure advanced settings exclusive to the DualSense controller, including audio control (microphone, headset, speaker), volumes, vibration modes, and force reduction on adaptive triggers.

GCH_DualSenseSettings(int ControllerId, std::uint8_t bIsMic, std::uint8_t bIsHeadset, std::uint8_t bIsSpeaker, std::uint8_t MicVolume, std::uint8_t AudioVolume, std::uint8_t RumbleMode, std::uint8_t RumbleReduce, std::uint8_t TriggerReduce)

🛠️ Building

Initialization & Build:

If you want to build your custom version, you can start with this example project and consult the available methods at https://github.com/rafaelvaloto/Dualsense-Multiplatform.

Requirements:

  • CMake 3.20 or newer.
  • A C++20 compatible compiler.
  • The 3rdParty/Gamepad-Core submodule included in the project setup.

Initialize the submodule and configure the project by running:

git submodule update --init
cmake -S . -B build -DGCL_DEBUG=OFF
cmake --build build

Note: Set GCL_DEBUG=ON to enable Gamepad-Core host logging. The build process will generate the GamepadCoreHost shared library.

To build the WebAssembly module for JavaScript and TypeScript, configure CMake with the Emscripten toolchain:

cmake -S . -B build-wasm -DGCL_DEBUG=OFF -DCMAKE_TOOLCHAIN_FILE=%EMSDK%/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
cmake --build build-wasm

📂 Project Structure

  • Source/Public — Public bridge policies and adapters.
  • Source/Private — Internal bridge implementations.
  • 3rdParty/Gamepad-Core — The core dependency submodule.

🤝 Contributing

All suggestions and collaborations are welcome! Feel free to open issues, submit pull requests, or share your ideas to help improve this project.


📄 License

This project utilizes the Gamepad-Core (Dualsense-Multiplatform) library.

Copyright (c) 2026 valoto.games. All rights reserved.

About

Gamepad-Core Host Bridge is a native C++ library that exposes the Gamepad-Core functionality through a high-level C-compatible API.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages