### Manage Composite Devices Source: https://context7.com/rewasd/rewasdclient/llms.txt List all composite devices, save new or updated ones, and delete existing composite devices by their GUID. Ensure you have a valid client instance. ```csharp // List all composite devices List composites = await client.GamepadService.GetCompositeDevices(); foreach (var cd in composites) Console.WriteLine($"Composite: {cd.Name}"); // Save (create or update) a composite device var newComposite = new CompositeDeviceDto { /* populate fields */ }; await client.GamepadService.SaveCompositeDevice(newComposite); // Delete a composite device by its GUID await client.GamepadService.DeleteCompositeDevice(composites.First().Guid); ``` -------------------------------- ### Subscribe to SSE Events with EventClient Source: https://context7.com/rewasd/rewasdclient/llms.txt Manually initialize and manage the EventClient to receive real-time SSE events. Handles various event types like RemapStateChanged, ConfigApplied, and BatteryLevel. Ensure to call InitAndRun() to start, Restart() to reconnect, and StopAndClose()/Dispose() for cleanup. ```csharp using reWASDHttpClient.Http; using reWASDProtocol.Events; using reWASDProtocol.Events.Desktop; using Newtonsoft.Json; // Manual usage (the reWASDClient constructor calls InitAndRun when useEvents=true) var eventClient = new EventClient("127.0.0.1", 35474); eventClient.OnMessageReceived += (sender, args) => { if (!Enum.TryParse(args.EventName, out EventType type)) return; switch (type) { case EventType.RemapStateChanged: var ev = JsonConvert.DeserializeObject(args.Message.Data); Console.WriteLine($"[RemapStateChanged] {ev?.ControllerDisplayName}: {ev?.RemapState}"); break; case EventType.ConfigApplied: var ca = JsonConvert.DeserializeObject(args.Message.Data); Console.WriteLine($"[ConfigApplied] controller: {ca?.ControllerDisplayName}"); break; case EventType.BatteryLevel: var bl = JsonConvert.DeserializeObject(args.Message.Data); Console.WriteLine($"[Battery] {bl?.ControllerDisplayName}: {bl?.BatteryInfo.LevelInPercents}%"); break; case EventType.ControllerAdded: var added = JsonConvert.DeserializeObject(args.Message.Data); Console.WriteLine($"[ControllerAdded] {added?.Controller.DisplayName}"); break; case EventType.AllControllersDisconnected: Console.WriteLine("[AllControllersDisconnected]"); break; } }; eventClient.InitAndRun(); // Later: restart after a connection drop eventClient.Restart(); // Cleanup eventClient.StopAndClose(); eventClient.Dispose(); // Full event type catalogue (data events): // Heartbeat, ServiceProfilesChanged, ConfigApplied, SlotChanged, RemapStateChanged, // BatteryLevel, ShiftChanged, ControllerAdded, ControllerChanged, ControllerRemoved, // ControllerStateChanged, AllControllersDisconnected, ConfigSaved, ShiftShow, ShiftHide, // GyroCalibrationFinished, LicenseChanged, ProfileRelationsChangedByEngine, // ConfigRenamed, ConfigDeleted, GameRenamed, GameDeleted, ExternalDevicesChanged, // CompositeSettingsChanged, HoneypotPairingRejected, PreferencesChanged, ExclusiveAccessChanged ``` -------------------------------- ### List Controllers via REST API Source: https://context7.com/rewasd/rewasdclient/llms.txt Use curl to retrieve a list of connected controllers by making a GET request to the /ControllerService/Controllers endpoint. ```bash BASE="http://127.0.0.1:35474/v2.3" # --- List controllers --- curl "$BASE/ControllerService/Controllers" ``` -------------------------------- ### Create reWASD API Client Connection Source: https://context7.com/rewasd/rewasdclient/llms.txt Instantiates the reWASD API client and verifies the reWASD engine's protocol version. Optionally starts the SSE event stream. ```csharp using reWASDHttpClient.Http; // Connect to the local reWASD engine; pass true to also start the SSE event stream var client = new reWASDClient("127.0.0.1", 35474, useEvents: false); // Verify the engine version matches VERSION_PROTOCOL ("v2.3") bool versionOk = await client.CheckVersion(); if (!versionOk) { Console.WriteLine("Version mismatch – update reWASD or this client."); return; } Console.WriteLine("Connected and version OK"); // Access the two service facades // client.GamepadService → ControllerService // client.GameService → GameService ``` -------------------------------- ### Get Applied Config for a Slot via REST API Source: https://context7.com/rewasd/rewasdclient/llms.txt Use curl to get the currently applied configuration for a specific controller slot. Replace {guid} with the controller's GUID and adjust the slot parameter if necessary. ```bash BASE="http://127.0.0.1:35474/v2.3" # --- Get applied config for a slot --- curl "$BASE/ControllerService/AppliedConfigs/{guid}?slot=Slot1" ``` -------------------------------- ### Get Active Config for Controller Slot Source: https://context7.com/rewasd/rewasdclient/llms.txt Fetches the currently applied configuration for a specific slot on a given controller. Returns null if the slot is empty. ```csharp using reWASDProtocol.Infrastructure.Enums; Guid controllerGuid = controllers.First().Guid; foreach (Slot slot in Enum.GetValues()) { AppliedConfigDto? applied = await client.GamepadService.GetAppliedConfig(controllerGuid, slot); if (applied != null) Console.WriteLine($"{slot}: {applied.Name}"); else Console.WriteLine($"{slot}: (empty)"); } // Output example: // Slot1: MyFPS_Config // Slot2: (empty) // Slot3: (empty) // Slot4: (empty) ``` -------------------------------- ### REST API Reference - Common Operations Source: https://context7.com/rewasd/rewasdclient/llms.txt Provides `curl` examples for common reWASD REST API operations, including version check, listing controllers, and applying configurations. ```APIDOC ## REST API reference (direct HTTP calls) All endpoints live under `http://127.0.0.1:35474/v2.3/`. Below are representative curl equivalents for the most common operations. ```bash BASE="http://127.0.0.1:35474/v2.3" # --- Version check --- curl "$BASE/../Version" # --- List controllers --- curl "$BASE/ControllerService/Controllers" # --- Get applied config for a slot --- curl "$BASE/ControllerService/AppliedConfigs/{guid}?slot=Slot1" # --- Apply a config --- curl -X POST "$BASE/ControllerService/ApplyConfig" \ -H "Content-Type: application/json" \ -d '{"ControllerGuid":"3fa8...","Path":"C:\\...\\Layout.rewasd","Slot":"Slot1","Bundle":null}' # --- Disable remap (specific controller) --- curl -X POST "$BASE/ControllerService/DisableRemap" \ -H "Content-Type: application/json" \ -d '{"Guid":"3fa8..."}' # --- Enable remap --- curl -X POST "$BASE/ControllerService/EnableRemap" \ -H "Content-Type: application/json" \ -d '{"Guid":"3fa8...","RemapNoToggled":true,"Bundle":null}' # --- Vibration --- curl -X POST "$BASE/ControllerService/SendGamepadVibration" \ -H "Content-Type: application/json" \ -d '{"GamepadGuid":"3fa8...","Motors":3,"Duration":300,"Intensity":50}' ``` ``` -------------------------------- ### Get Controller Remapping State Source: https://context7.com/rewasd/rewasdclient/llms.txt Queries the current remapping state for a specific controller. Returns RemapState enum values: NothingApplied, Applied, or Disabled. ```csharp RemapState state = await client.GamepadService.GetRemapState(controllerGuid); // RemapState values: NothingApplied | Applied | Disabled Console.WriteLine($"Current remap state: {state}"); // Output: Current remap state: Applied ``` -------------------------------- ### Check reWASD Version via REST API Source: https://context7.com/rewasd/rewasdclient/llms.txt Use curl to check the reWASD application version by making a GET request to the /../Version endpoint. ```bash BASE="http://127.0.0.1:35474/v2.3" # --- Version check --- curl "$BASE/../Version" ``` -------------------------------- ### Enable Remap for a Controller via REST API Source: https://context7.com/rewasd/rewasdclient/llms.txt Use curl to enable remapping for a specific controller. The RemapNoToggled parameter can be set to true to prevent toggling. Provide the controller's GUID in the JSON payload. ```bash BASE="http://127.0.0.1:35474/v2.3" # --- Enable remap --- curl -X POST "$BASE/ControllerService/EnableRemap" \ -H "Content-Type: application/json" \ -d '{"Guid":"3fa8...","RemapNoToggled":true,"Bundle":null}' ``` -------------------------------- ### Disable Remap for a Controller via REST API Source: https://context7.com/rewasd/rewasdclient/llms.txt Use curl to disable remapping for a specific controller. Provide the controller's GUID in the JSON payload. ```bash BASE="http://127.0.0.1:35474/v2.3" # --- Disable remap (specific controller) --- curl -X POST "$BASE/ControllerService/DisableRemap" \ -H "Content-Type: application/json" \ -d '{"Guid":"3fa8..."}' ``` -------------------------------- ### reWASDClient Initialization and Version Check Source: https://context7.com/rewasd/rewasdclient/llms.txt Demonstrates how to instantiate the reWASDClient, connect to the local reWASD engine, and verify the protocol version. ```APIDOC ## reWASDClient — Create a versioned client connection ### Description `reWASDClient` is the top-level entry point. It instantiates the underlying `HttpClient`, creates `ControllerService` and `GameService`, optionally starts the SSE event stream, and exposes `CheckVersion()` to verify that the running reWASD engine matches the expected protocol version before issuing any commands. ### Method ```csharp using reWASDHttpClient.Http; // Connect to the local reWASD engine; pass true to also start the SSE event stream var client = new reWASDClient("127.0.0.1", 35474, useEvents: false); // Verify the engine version matches VERSION_PROTOCOL ("v2.3") bool versionOk = await client.CheckVersion(); if (!versionOk) { Console.WriteLine("Version mismatch – update reWASD or this client."); return; } Console.WriteLine("Connected and version OK"); // Access the two service facades // client.GamepadService → ControllerService // client.GameService → GameService ``` ``` -------------------------------- ### Create Game Source: https://context7.com/rewasd/rewasdclient/llms.txt Creates a new game configuration. ```APIDOC ## Create Game ### Description Creates a new game configuration. ### Method POST ### Endpoint /GameService/Games ### Parameters #### Request Body - **Name** (string) - Required - The name of the game. ### Request Example ```bash curl -X POST "$BASE/GameService/Games" \ -H "Content-Type: application/json" \ -d '{"Name":"My Game"}' ``` ### Response #### Success Response (200) - game (object) - The created game object. ``` -------------------------------- ### Manage Game Configurations Source: https://context7.com/rewasd/rewasdclient/llms.txt Create, rename, delete, and import configuration files for games. Configurations are created per-game and can target specific virtual gamepad types. Importing requires a valid file path. ```csharp using reWASDProtocol.Infrastructure.Enums; using reWASDProtocol.Infrastructure; Guid gameId = games.First().Id; // Create a new config targeting an Xbox virtual gamepad ConfigDto newCfg = await client.GameService.CreateConfig(gameId, "SpeedrunLayout", VirtualGamepadType.Xbox360); Console.WriteLine($"New config path: {newCfg.Path}"); // Rename await client.GameService.RenameConfig(new RenameConfigParams { Id = newCfg.Id, NewName = "Speedrun_v2" }); // Import an existing file into a game var importResult = await client.GameService.ImportConfig( new ImportConfigInfo { GameId = gameId, FilePath = @"C:\Backups\OldLayout.rewasd" }); Console.WriteLine($"Import status: {importResult.Status}"); // e.g. Success // Delete await client.GameService.DeleteConfig(newCfg.Id); ``` -------------------------------- ### InitializeGamepad / InitializePeripheral / ResetInitialization Source: https://context7.com/rewasd/rewasdclient/llms.txt Manages the device initialization lifecycle for controllers, including virtual gamepads, physical peripherals, and resetting initialization. ```APIDOC ## ControllerService.InitializeGamepad / InitializePeripheral / ResetInitialization — Initialize and reset controller devices Three methods cover the device-initialization lifecycle: `InitializeGamepad` (virtual or physical gamepad), `InitializePeripheral` (keyboard/mouse peripheral), and `ResetInitialization` (restore the controller to an uninitialized state). ### Method POST ### Endpoint /GamepadService/InitializeGamepad /GamepadService/InitializePeripheral /GamepadService/ResetInitialization ### Parameters #### InitializeGamepad - **controllerGuid** (Guid) - Required - The GUID of the controller. - **deviceType** (string) - Optional - The type of device to initialize as a gamepad. An empty string uses the default. #### InitializePeripheral - **controllerGuid** (Guid) - Required - The GUID of the controller. - **peripheralType** (PeripheralPhysicalType) - Required - The physical type of the peripheral (e.g., Keyboard). #### ResetInitialization - **controllerGuid** (Guid) - Required - The GUID of the controller. ### Request Example ```csharp // Initialize as a generic gamepad await client.GamepadService.InitializeGamepad(controllerGuid, deviceType: ""); // Initialize as a peripheral (e.g., keyboard) await client.GamepadService.InitializePeripheral(controllerGuid, PeripheralPhysicalType.Keyboard); // Reset initialization back to original state await client.GamepadService.ResetInitialization(controllerGuid); ``` ### Response #### Success Response (200) (No specific response body documented, typically indicates success) #### Response Example (No example provided) ``` -------------------------------- ### Initialize and Reset Controller Devices Source: https://context7.com/rewasd/rewasdclient/llms.txt Manages the device initialization lifecycle. Use InitializeGamepad for virtual/physical gamepads, InitializePeripheral for keyboards/mice, and ResetInitialization to revert to an uninitialized state. ```csharp using reWASDProtocol.Infrastructure.Enums; // Initialize as a generic gamepad (empty deviceType = default) await client.GamepadService.InitializeGamepad(controllerGuid, deviceType: ""); // Initialize as a peripheral (e.g., keyboard) await client.GamepadService.InitializePeripheral(controllerGuid, PeripheralPhysicalType.Keyboard); // Reset initialization back to original state await client.GamepadService.ResetInitialization(controllerGuid); ``` -------------------------------- ### List Games and Configurations Source: https://context7.com/rewasd/rewasdclient/llms.txt Retrieve all game entries, each containing a collection of associated ConfigDto objects. This includes game ID, name, and configuration details like name and file path. ```csharp List games = await client.GameService.GetGames(); foreach (var game in games) { Console.WriteLine($"Game: {game.Name} ({game.Id})"); foreach (var cfg in game.ConfigCollection) Console.WriteLine($" Config: {cfg.Name} → {cfg.Path}"); } // Output example: // Game: Call of Duty (a1b2c3d4-...) // Config: Warzone_Layout → C:\Users\...\Warzone_Layout.rewasd // Config: Multiplayer_Layout → C:\Users\...\Multiplayer_Layout.rewasd ``` -------------------------------- ### Config Management (CRUD and Import) Source: https://context7.com/rewasd/rewasdclient/llms.txt Manage configuration files per game, including creation, renaming, deletion, and importing from existing files. ```APIDOC ## GameService — Create, rename, delete, and import configs Config files are created per-game, can be renamed, deleted, or imported from an existing `.rewasd` file on disk. ```csharp using reWASDProtocol.Infrastructure.Enums; using reWASDProtocol.Infrastructure; Guid gameId = games.First().Id; // Create a new config targeting an Xbox virtual gamepad ConfigDto newCfg = await client.GameService.CreateConfig(gameId, "SpeedrunLayout", VirtualGamepadType.Xbox360); Console.WriteLine($"New config path: {newCfg.Path}"); // Rename await client.GameService.RenameConfig(new RenameConfigParams { Id = newCfg.Id, NewName = "Speedrun_v2" }); // Import an existing file into a game var importResult = await client.GameService.ImportConfig( new ImportConfigInfo { GameId = gameId, FilePath = @"C:\Backups\OldLayout.rewasd" }); Console.WriteLine($"Import status: {importResult.Status}"); // e.g. Success // Delete await client.GameService.DeleteConfig(newCfg.Id); ``` ``` -------------------------------- ### ConfigApply Source: https://context7.com/rewasd/rewasdclient/llms.txt Applies a configuration file to a specified controller slot. It automatically handles interactive dialogs by selecting default actions. ```APIDOC ## ControllerService.ConfigApply — Apply a config to a controller slot Applies a config file to a controller slot identified by `ConfigApplyInfo`. The method handles interactive dialogs that reWASD may return (e.g., license prompts) by automatically selecting the default button action in a retry loop. ### Method POST ### Endpoint /GamepadService/ConfigApply ### Parameters #### Request Body - **applyInfo** (ConfigApplyInfo) - Required - Information about the configuration to apply, including controller GUID, config path, and slot. ### Request Example ```csharp var applyInfo = new ConfigApplyInfo { ControllerGuid = ctrl.Guid, Path = config.Path, Bundle = null, Slot = Slot.Slot1 }; await client.GamepadService.ConfigApply(applyInfo); ``` ### Response #### Success Response (200) - **success** (bool) - True if the config was applied successfully, false otherwise. #### Response Example ```json { "success": true } ``` ``` -------------------------------- ### List All Games with Configs Source: https://context7.com/rewasd/rewasdclient/llms.txt Retrieve all game entries, each containing a collection of associated configuration objects. ```APIDOC ## GameService.GetGames — List all games with configs Returns all game entries, each containing a collection of associated `ConfigDto` objects (id, name, file path). ```csharp List games = await client.GameService.GetGames(); foreach (var game in games) { Console.WriteLine($"Game: {game.Name} ({game.Id})"); foreach (var cfg in game.ConfigCollection) Console.WriteLine($" Config: {cfg.Name} → {cfg.Path}"); } // Output example: // Game: Call of Duty (a1b2c3d4-...) // Config: Warzone_Layout → C:\Users\...\Warzone_Layout.rewasd // Config: Multiplayer_Layout → C:\Users\...\Multiplayer_Layout.rewasd ``` ``` -------------------------------- ### EventClient - Subscribe to SSE Events Source: https://context7.com/rewasd/rewasdclient/llms.txt Demonstrates how to use the EventClient to establish a Server-Sent Events (SSE) connection and handle various reWASD events in real-time. ```APIDOC ## EventClient — Subscribe to real-time SSE events `EventClient` opens a persistent SSE connection to `http://{ip}:{port}/v2.3/Events` and dispatches typed events via `OnMessageReceived`. UI-prefixed event types (id ≥ 1000) are ignored by default in this client. Pass `useEvents: true` to `reWASDClient` to start automatically, or manage the `EventClient` lifecycle manually. ```csharp using reWASDHttpClient.Http; using reWASDProtocol.Events; using reWASDProtocol.Events.Desktop; using Newtonsoft.Json; // Manual usage (the reWASDClient constructor calls InitAndRun when useEvents=true) var eventClient = new EventClient("127.0.0.1", 35474); eventClient.OnMessageReceived += (sender, args) => { if (!Enum.TryParse(args.EventName, out EventType type)) return; switch (type) { case EventType.RemapStateChanged: var ev = JsonConvert.DeserializeObject(args.Message.Data); Console.WriteLine($"[RemapStateChanged] {ev?.ControllerDisplayName}: {ev?.RemapState}"); break; case EventType.ConfigApplied: var ca = JsonConvert.DeserializeObject(args.Message.Data); Console.WriteLine($"[ConfigApplied] controller: {ca?.ControllerDisplayName}"); break; case EventType.BatteryLevel: var bl = JsonConvert.DeserializeObject(args.Message.Data); Console.WriteLine($"[Battery] {bl?.ControllerDisplayName}: {bl?.BatteryInfo.LevelInPercents}%"); break; case EventType.ControllerAdded: var added = JsonConvert.DeserializeObject(args.Message.Data); Console.WriteLine($"[ControllerAdded] {added?.Controller.DisplayName}"); break; case EventType.AllControllersDisconnected: Console.WriteLine("[AllControllersDisconnected]"); break; } }; eventClient.InitAndRun(); // Later: restart after a connection drop eventClient.Restart(); // Cleanup eventClient.StopAndClose(); eventClient.Dispose(); // Full event type catalogue (data events): // Heartbeat, ServiceProfilesChanged, ConfigApplied, SlotChanged, RemapStateChanged, // BatteryLevel, ShiftChanged, ControllerAdded, ControllerChanged, ControllerRemoved, // ControllerStateChanged, AllControllersDisconnected, ConfigSaved, ShiftShow, ShiftHide, // GyroCalibrationFinished, LicenseChanged, ProfileRelationsChangedByEngine, // ConfigRenamed, ConfigDeleted, GameRenamed, GameDeleted, ExternalDevicesChanged, // CompositeSettingsChanged, HoneypotPairingRejected, PreferencesChanged, ExclusiveAccessChanged ``` ``` -------------------------------- ### List Games Source: https://context7.com/rewasd/rewasdclient/llms.txt Retrieves a list of all configured games. ```APIDOC ## List Games ### Description Retrieves a list of all configured games. ### Method GET ### Endpoint /GameService/Games ### Request Example ```bash curl "$BASE/GameService/Games" ``` ### Response #### Success Response (200) - games (array) - A list of game objects. ``` -------------------------------- ### Manage Blocklisted Devices Source: https://context7.com/rewasd/rewasdclient/llms.txt Retrieve the current blocklist of gamepads, add new devices to the blocklist, and save the updated list atomically. The save operation returns a boolean indicating success. ```csharp List blocklist = await client.GamepadService.GetBlocklistDevices(); Console.WriteLine($"Blocked devices: {blocklist.Count}"); // Add a device to the blocklist and save blocklist.Add(new BlockListGamepadDto { /* populate fields */ }); bool saved = await client.GamepadService.SaveBlocklistDevices(blocklist); Console.WriteLine(saved ? "Blocklist saved." : "Save failed."); ``` -------------------------------- ### Error Handling with reWASDClient Source: https://context7.com/rewasd/rewasdclient/llms.txt Illustrates how to handle `ConnectException` for network issues and `HttpException` for HTTP errors when using the reWASDClient. ```APIDOC ## Error handling — ConnectException and HttpException `HttpClient.SendRequestAsync` wraps network-level failures in `ConnectException`; HTTP 4xx/5xx responses are surfaced as `HttpException` with the status code and a message body extracted from the `400 Bad Request` JSON payload when available. The top-level `Program.cs` pattern handles both cleanly. ```csharp using reWASDHttpClient.Exceptions; using System.Runtime.Serialization; try { var client = new reWASDClient("127.0.0.1", 35474, useEvents: false); await client.CheckVersion(); var controllers = await client.GamepadService.GetControllers(); // ... proceed with controllers } catch (ConnectException ex) { // reWASD not running, port blocked, wrong IP/port Console.WriteLine($"Connection error: {ex.Message}"); } catch (HttpException ex) { // reWASD returned 4xx/5xx Console.WriteLine($"HTTP {(int)ex.StatusCode}: {ex.Message}"); } catch (SerializationException ex) { // Unexpected JSON schema – possible version mismatch Console.WriteLine($"Deserialization failed: {ex.Message}"); } ``` ``` -------------------------------- ### Create Game with reWASD API Source: https://context7.com/rewasd/rewasdclient/llms.txt Use this command to create a new game entry in reWASD. Specify the game name in the JSON payload. Ensure the BASE environment variable is set. ```bash curl -X POST "$BASE/GameService/Games" \ -H "Content-Type: application/json" \ -d '{"Name":"My Game"}' ``` -------------------------------- ### ControllerService.GetAppliedConfig Source: https://context7.com/rewasd/rewasdclient/llms.txt Fetches the currently applied configuration for a specific slot on a given controller. ```APIDOC ## ControllerService.GetAppliedConfig — Get the active config for a slot ### Description Returns the `AppliedConfigDto` (name + path) currently applied to a specific slot on a controller, or `null` if the slot is empty. ### Method ```csharp using reWASDProtocol.Infrastructure.Enums; Guid controllerGuid = controllers.First().Guid; foreach (Slot slot in Enum.GetValues()) { AppliedConfigDto? applied = await client.GamepadService.GetAppliedConfig(controllerGuid, slot); if (applied != null) Console.WriteLine($"{slot}: {applied.Name}"); else Console.WriteLine($"{slot}: (empty)"); } // Output example: // Slot1: MyFPS_Config // Slot2: (empty) // Slot3: (empty) // Slot4: (empty) ``` ``` -------------------------------- ### Create, Rename, and Delete Games Source: https://context7.com/rewasd/rewasdclient/llms.txt Perform full CRUD operations on game entries. A new game is created using NewGameParams, and its server-assigned Id is returned. Ensure necessary using directives are included. ```csharp using reWASDProtocol.DataTransferObjects; using reWASDProtocol.Infrastructure; // Create var newGame = await client.GameService.CreateGame(new NewGameParams { Name = "Elden Ring" }); Console.WriteLine($"Created game ID: {newGame.Id}"); // Rename await client.GameService.RenameGame(newGame.Id, "Elden Ring (Modded)"); // Delete await client.GameService.DeleteGame(newGame.Id); Console.WriteLine("Game deleted."); ``` -------------------------------- ### Send Gamepad Vibration via REST API Source: https://context7.com/rewasd/rewasdclient/llms.txt Use curl to send vibration commands to a specific gamepad. Specify the GamepadGuid, Motors (e.g., 3 for both), Duration in milliseconds, and Intensity (0-100). ```bash BASE="http://127.0.0.1:35474/v2.3" # --- Vibration --- curl -X POST "$BASE/ControllerService/SendGamepadVibration" \ -H "Content-Type: application/json" \ -d '{"GamepadGuid":"3fa8...","Motors":3,"Duration":300,"Intensity":50}' ``` -------------------------------- ### Apply Config to Controller Slot Source: https://context7.com/rewasd/rewasdclient/llms.txt Applies a configuration file to a specified controller slot. Handles interactive dialogs by retrying with default actions. ```csharp using reWASDProtocol.Infrastructure; using reWASDProtocol.Infrastructure.Enums; // Obtain a config path from GameService first var games = await client.GameService.GetGames(); var config = games.First().ConfigCollection.First(); var ctrl = controllers.First(c => c.IsOnline); var applyInfo = new ConfigApplyInfo { ControllerGuid = ctrl.Guid, Path = config.Path, // e.g. "C:\\Users\\...\\MyFPS_Config.rewasd" Bundle = null, // set by ConfigApply internally when dialogs appear Slot = Slot.Slot1 }; bool success = await client.GamepadService.ConfigApply(applyInfo); Console.WriteLine(success ? "Config applied!" : "Failed to apply config."); // Output: Config applied! ``` -------------------------------- ### Game Management (CRUD) Source: https://context7.com/rewasd/rewasdclient/llms.txt Perform the full CRUD lifecycle for game entries, including creation, renaming, and deletion. ```APIDOC ## GameService — Create, rename, and delete games Full CRUD lifecycle for game entries. A new game is created with a `NewGameParams` object; the returned `GameDto` contains the server-assigned `Id`. ```csharp using reWASDProtocol.DataTransferObjects; using reWASDProtocol.Infrastructure; // Create var newGame = await client.GameService.CreateGame(new NewGameParams { Name = "Elden Ring" }); Console.WriteLine($"Created game ID: {newGame.Id}"); // Rename await client.GameService.RenameGame(newGame.Id, "Elden Ring (Modded)"); // Delete await client.GameService.DeleteGame(newGame.Id); Console.WriteLine("Game deleted."); ``` ``` -------------------------------- ### List Games with reWASD API Source: https://context7.com/rewasd/rewasdclient/llms.txt Use this command to retrieve a list of games managed by reWASD. Ensure the BASE environment variable is set to your reWASD API endpoint. ```bash curl "$BASE/GameService/Games" ``` -------------------------------- ### Apply a Config via REST API Source: https://context7.com/rewasd/rewasdclient/llms.txt Use curl to apply a reWASD configuration file to a specific controller slot. Ensure the Content-Type is application/json and provide the correct ControllerGuid, Path to the config file, and Slot. ```bash BASE="http://127.0.0.1:35474/v2.3" # --- Apply a config --- curl -X POST "$BASE/ControllerService/ApplyConfig" \ -H "Content-Type: application/json" \ -d '{"ControllerGuid":"3fa8...","Path":"C:\\...\\Layout.rewasd","Slot":"Slot1","Bundle":null}' ``` -------------------------------- ### SelectSlot / ClearSlot Source: https://context7.com/rewasd/rewasdclient/llms.txt Manages configuration slots for a controller, allowing selection of a slot or clearing configurations from one or more slots. ```APIDOC ## ControllerService.SelectSlot / ClearSlot — Manage config slots `SelectSlot` switches a controller to the specified slot; `ClearSlot` removes the applied config from one or more slots (pass `null` guid to clear slots on all controllers). ### Method POST ### Endpoint /GamepadService/SelectSlot /GamepadService/ClearSlot ### Parameters #### SelectSlot - **controllerGuid** (Guid) - Required - The GUID of the controller. - **slot** (Slot) - Required - The slot to switch to. #### ClearSlot - **controllerGuid** (Guid) - Optional - The GUID of the controller. If null, clears slots on all controllers. - **slots** (List) - Required - A list of slots to clear. ### Request Example ```csharp // Switch to Slot 2 await client.GamepadService.SelectSlot(controllerGuid, Slot.Slot2); // Clear Slot1 and Slot3 on a specific controller await client.GamepadService.ClearSlot(controllerGuid, new List { Slot.Slot1, Slot.Slot3 }); // Clear Slot1 on ALL controllers await client.GamepadService.ClearSlot(null, new List { Slot.Slot1 }); ``` ### Response #### Success Response (200) (No specific response body documented, typically indicates success) #### Response Example (No example provided) ``` -------------------------------- ### SendGamepadVibration Source: https://context7.com/rewasd/rewasdclient/llms.txt Triggers haptic feedback on a controller with configurable motor mask, duration, and intensity. ```APIDOC ## ControllerService.SendGamepadVibration — Trigger haptic feedback Sends a vibration command with configurable motor mask, duration (ms), and intensity (0–100). ### Method POST ### Endpoint /GamepadService/SendGamepadVibration ### Parameters #### Request Body - **vibrationInfo** (VibrationInfo) - Required - Information about the vibration to apply, including controller GUID, motors, duration, and intensity. ### Request Example ```csharp // Uses preset: both motors, 300 ms, 50% intensity await client.GamepadService.SendGamepadVibration(controllerGuid); // For custom parameters, construct VibrationInfo directly: // var info = new VibrationInfo // { // GamepadGuid = controllerGuid, // Motors = MotorMask.Left | MotorMask.Right, // Duration = 500, // milliseconds // Intensity = 75 // 0–100 // }; // await client.GamepadService.SendGamepadVibration(info); ``` ### Response #### Success Response (200) (No specific response body documented, typically indicates success) #### Response Example (No example provided) ``` -------------------------------- ### EnableRemap Source: https://context7.com/rewasd/rewasdclient/llms.txt Re-enables remapping for a controller, with an option to honor profile relations. ```APIDOC ## ControllerService.EnableRemap — Re-enable remapping for a controller Sends an `EnableRemapInfo` request and retries automatically if the engine returns consent dialogs (e.g., confirming slot selection). Set `remapNonToggledFromRelations` to `true` to honour profile relations. ### Method POST ### Endpoint /GamepadService/EnableRemap ### Parameters #### Path Parameters - **controllerGuid** (Guid) - Required - The GUID of the controller for which to enable remapping. #### Query Parameters - **remapNonToggledFromRelations** (bool) - Optional - If true, honours profile relations for remapping. ### Request Example ```csharp Guid controllerGuid = controllers.First(c => c.IsOnline).Guid; await client.GamepadService.EnableRemap(controllerGuid, remapNonToggledFromRelations: true); ``` ### Response #### Success Response (200) - **enabled** (bool) - True if remapping was successfully enabled, false otherwise. #### Response Example ```json { "enabled": true } ``` ``` -------------------------------- ### Composite Device Management Source: https://context7.com/rewasd/rewasdclient/llms.txt Manage composite devices (pairs/groups of physical controllers) by listing, saving, and deleting them. ```APIDOC ## ControllerService — Composite device management Composite devices (pairs/groups of physical controllers treated as one) can be listed, saved, and deleted. ```csharp // List all composite devices List composites = await client.GamepadService.GetCompositeDevices(); foreach (var cd in composites) Console.WriteLine($"Composite: {cd.Name}"); // Save (create or update) a composite device var newComposite = new CompositeDeviceDto { /* populate fields */ }; await client.GamepadService.SaveCompositeDevice(newComposite); // Delete a composite device by its GUID await client.GamepadService.DeleteCompositeDevice(composites.First().Guid); ``` ``` -------------------------------- ### Blocklist Device Management Source: https://context7.com/rewasd/rewasdclient/llms.txt Manage the blocklist to prevent specific gamepads from being captured by reWASD. Retrieve the current list and save an updated one atomically. ```APIDOC ## ControllerService — Blocklist device management The blocklist prevents specific gamepads from being captured by reWASD. Retrieve the current list and save an updated one atomically. ```csharp List blocklist = await client.GamepadService.GetBlocklistDevices(); Console.WriteLine($"Blocked devices: {blocklist.Count}"); // Add a device to the blocklist and save blocklist.Add(new BlockListGamepadDto { /* populate fields */ }); bool saved = await client.GamepadService.SaveBlocklistDevices(blocklist); Console.WriteLine(saved ? "Blocklist saved." : "Save failed."); ``` ``` -------------------------------- ### Manage Controller Config Slots Source: https://context7.com/rewasd/rewasdclient/llms.txt Switches a controller to a specified slot using SelectSlot or removes configs from slots using ClearSlot. ClearSlot can target specific slots on a controller or all controllers. ```csharp // Switch to Slot 2 await client.GamepadService.SelectSlot(controllerGuid, Slot.Slot2); // Clear Slot1 and Slot3 on a specific controller await client.GamepadService.ClearSlot(controllerGuid, new List { Slot.Slot1, Slot.Slot3 }); // Clear Slot1 on ALL controllers await client.GamepadService.ClearSlot(null, new List { Slot.Slot1 }); ``` -------------------------------- ### GetRemapState Source: https://context7.com/rewasd/rewasdclient/llms.txt Queries the current remapping state for a specific controller. ```APIDOC ## ControllerService.GetRemapState — Query remapping state Returns the current `RemapState` enum for a specific controller without fetching the full controller list. ### Method GET ### Endpoint /GamepadService/GetRemapState/{controllerGuid} ### Parameters #### Path Parameters - **controllerGuid** (Guid) - Required - The GUID of the controller to query. ### Response #### Success Response (200) - **state** (RemapState) - The current remapping state. Possible values: `NothingApplied`, `Applied`, `Disabled`. #### Response Example ```json { "state": "Applied" } ``` ``` -------------------------------- ### Send Gamepad Vibration Command Source: https://context7.com/rewasd/rewasdclient/llms.txt Triggers haptic feedback on a controller. Supports preset commands or custom VibrationInfo with motor mask, duration, and intensity. ```csharp using reWASDProtocol.Infrastructure.Enums; // Uses preset: both motors, 300 ms, 50% intensity (defined inside the method) await client.GamepadService.SendGamepadVibration(controllerGuid); // For custom parameters, construct VibrationInfo directly and POST manually: // var info = new VibrationInfo // { // GamepadGuid = controllerGuid, // Motors = MotorMask.Left | MotorMask.Right, // Duration = 500, // milliseconds // Intensity = 75 // 0–100 // }; ``` -------------------------------- ### Subscribe to SSE Events from reWASD API Source: https://context7.com/rewasd/rewasdclient/llms.txt Use this command to establish a Server-Sent Events (SSE) stream for real-time notifications from reWASD. The -N flag prevents curl from outputting the response body, and the Accept header specifies the desired content type. ```bash curl -N -H "Accept: text/event-stream" "$BASE/Events" ``` -------------------------------- ### ControllerService.GetControllers Source: https://context7.com/rewasd/rewasdclient/llms.txt Retrieves a list of all controllers connected to reWASD, including their status and remapping information. ```APIDOC ## ControllerService.GetControllers — List all connected controllers ### Description Returns every controller known to reWASD (online and offline) as a polymorphic list of `BaseControllerDto` (`ControllerDto`, `PeripheralControllerDto`, or `CompositeControllerDto`). The `ControllerConverter` handles the `DataType` discriminator field automatically. ### Method ```csharp using reWASDProtocol.Infrastructure.Enums; List controllers = await client.GamepadService.GetControllers(); foreach (var ctrl in controllers) { Console.WriteLine($"Name: {ctrl.DisplayName}"); Console.WriteLine($"GUID: {ctrl.Guid}"); Console.WriteLine($"Online: {ctrl.IsOnline}"); Console.WriteLine($"RemapState: {ctrl.RemapState}"); // NothingApplied | Applied | Disabled Console.WriteLine($"CurrentSlot: {ctrl.CurrentSlot}"); // Slot1..Slot4 // Richer fields available on ControllerDto subtype if (ctrl is ControllerDto dto) { Console.WriteLine($"Connection: {dto.ConnectionType}"); // Usb | Bluetooth Console.WriteLine($"Battery: {dto.BatteryInfo?.LevelInPercents}% "); } Console.WriteLine(); } // Output example: // Name: DualSense Wireless Controller // GUID: 3fa85f64-5717-4562-b3fc-2c963f66afa6 // Online: True // RemapState: Applied // CurrentSlot: Slot1 // Connection: Bluetooth // Battery: 72% ``` ``` -------------------------------- ### Handle reWASD API Exceptions Source: https://context7.com/rewasd/rewasdclient/llms.txt Catch specific exceptions like ConnectException for network issues (reWASD not running, wrong IP/port) and HttpException for 4xx/5xx responses from the reWASD API. SerializationException can indicate a version mismatch. ```csharp using reWASDHttpClient.Exceptions; using System.Runtime.Serialization; try { var client = new reWASDClient("127.0.0.1", 35474, useEvents: false); await client.CheckVersion(); var controllers = await client.GamepadService.GetControllers(); // ... proceed with controllers } catch (ConnectException ex) { // reWASD not running, port blocked, wrong IP/port Console.WriteLine($"Connection error: {ex.Message}"); } catch (HttpException ex) { // reWASD returned 4xx/5xx Console.WriteLine($"HTTP {(int)ex.StatusCode}: {ex.Message}"); } catch (SerializationException ex) { // Unexpected JSON schema – possible version mismatch Console.WriteLine($"Deserialization failed: {ex.Message}"); } ``` -------------------------------- ### Enable Controller Remapping Source: https://context7.com/rewasd/rewasdclient/llms.txt Re-enables remapping for a controller. Automatically retries if consent dialogs are returned. Set remapNonToggledFromRelations to true to honor profile relations. ```csharp Guid controllerGuid = controllers.First(c => c.IsOnline).Guid; bool enabled = await client.GamepadService.EnableRemap(controllerGuid, remapNonToggledFromRelations: true); Console.WriteLine(enabled ? "Remap enabled." : "Could not enable remap."); // Output: Remap enabled. ``` -------------------------------- ### SSE Event Stream Source: https://context7.com/rewasd/rewasdclient/llms.txt Subscribes to Server-Sent Events (SSE) for real-time state change notifications. ```APIDOC ## SSE Event Stream ### Description Subscribes to Server-Sent Events (SSE) for real-time state change notifications. This stream provides instant push notifications for every meaningful state change, eliminating the need for polling. ### Method GET ### Endpoint /Events ### Headers - **Accept**: text/event-stream ### Request Example ```bash curl -N -H "Accept: text/event-stream" "$BASE/Events" ``` ### Response #### Success Response (200) - Events are streamed in the `text/event-stream` format. ``` -------------------------------- ### List Connected Controllers with reWASD API Source: https://context7.com/rewasd/rewasdclient/llms.txt Retrieves a list of all controllers known to reWASD, including their status and remapping state. Handles polymorphic controller types automatically. ```csharp using reWASDProtocol.Infrastructure.Enums; List controllers = await client.GamepadService.GetControllers(); foreach (var ctrl in controllers) { Console.WriteLine($"Name: {ctrl.DisplayName}"); Console.WriteLine($"GUID: {ctrl.Guid}"); Console.WriteLine($"Online: {ctrl.IsOnline}"); Console.WriteLine($"RemapState: {ctrl.RemapState}"); // NothingApplied | Applied | Disabled Console.WriteLine($"CurrentSlot: {ctrl.CurrentSlot}"); // Slot1..Slot4 // Richer fields available on ControllerDto subtype if (ctrl is ControllerDto dto) { Console.WriteLine($"Connection: {dto.ConnectionType}"); // Usb | Bluetooth Console.WriteLine($"Battery: {dto.BatteryInfo?.LevelInPercents}% "); } Console.WriteLine(); } // Output example: // Name: DualSense Wireless Controller // GUID: 3fa85f64-5717-4562-b3fc-2c963f66afa6 // Online: True // RemapState: Applied // CurrentSlot: Slot1 // Connection: Bluetooth // Battery: 72% ``` -------------------------------- ### DisableRemap Source: https://context7.com/rewasd/rewasdclient/llms.txt Disables remapping for a specific controller or all controllers simultaneously. ```APIDOC ## ControllerService.DisableRemap — Disable remapping for a controller Posts to `DisableRemap` with the controller GUID. Pass `null` to disable remapping on **all** controllers simultaneously. ### Method POST ### Endpoint /GamepadService/DisableRemap ### Parameters #### Path Parameters - **controllerGuid** (Guid) - Optional - The GUID of the controller for which to disable remapping. If null, remapping is disabled for all controllers. ### Request Example ```csharp // Disable remapping for a specific controller Guid controllerGuid = controllers.First(c => c.IsOnline).Guid; await client.GamepadService.DisableRemap(controllerGuid); // Disable remapping on ALL controllers await client.GamepadService.DisableRemap(null); ``` ### Response #### Success Response (200) - **disabled** (bool) - True if remapping was successfully disabled, false otherwise. #### Response Example ```json { "disabled": true } ``` ``` -------------------------------- ### Disable Controller Remapping Source: https://context7.com/rewasd/rewasdclient/llms.txt Disables remapping for a specific controller or all controllers. Pass null to disable remapping on all controllers simultaneously. ```csharp Guid controllerGuid = controllers.First(c => c.IsOnline).Guid; bool disabled = await client.GamepadService.DisableRemap(controllerGuid); Console.WriteLine(disabled ? "Remap disabled." : "Could not disable remap."); // Output: Remap disabled. // Disable remap on ALL controllers at once: await client.GamepadService.DisableRemap(null); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.