{"record":{"id":"1f68d180d0043f5a","repo":"stride3d/stride","slug":"simulated-gamepad-does-not-exist","errorCode":null,"errorMessage":"Simulated GamePad does not exist","messagePattern":"Simulated GamePad does not exist","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Input/Simulated/InputSourceSimulated.cs","lineNumber":49,"sourceCode":"            base.Dispose();\n            keyboards.Clear();\n            mice.Clear();\n            gamePads.Clear();\n            pointers.Clear();\n        }\n\n        public GamePadSimulated AddGamePad()\n        {\n            var gamePad = new GamePadSimulated(this);\n            gamePads.Add(gamePad);\n            RegisterDevice(gamePad);\n            return gamePad;\n        }\n\n        public void RemoveGamePad(GamePadSimulated gamePad)\n        {\n            if (!gamePads.Contains(gamePad))\n                throw new InvalidOperationException(\"Simulated GamePad does not exist\");\n            UnregisterDevice(gamePad);\n            gamePads.Remove(gamePad);\n        }\n\n        public void RemoveAllGamePads()\n        {\n            foreach (var gamePad in gamePads)\n                UnregisterDevice(gamePad);\n            gamePads.Clear();\n        }\n\n        public MouseSimulated AddMouse()\n        {\n            var mouse = new MouseSimulated(this);\n            mice.Add(mouse);\n            RegisterDevice(mouse);\n            return mouse;\n        }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Input/Simulated/InputSourceSimulated.cs#L31-L67","documentation":"InputSourceSimulated.RemoveGamePad requires the given GamePadSimulated to be one this source created and currently tracks in its gamePads list. Passing a game pad that is not tracked (never created via the source, already removed, or belonging to another source) throws InvalidOperationException after the membership check fails.","triggerScenarios":"Calling RemoveGamePad with a GamePadSimulated that was not returned by this source's CreateGamePad, or calling it twice for the same instance (first RemoveGamePad removes it from gamePads).","commonSituations":"Tests that create simulated pads and tear down twice; holding stale references to a removed pad; mixing pads from two InputSourceSimulated instances.","solutions":["Only pass GamePadSimulated instances obtained from this source's CreateGamePad","Guard with a Contains-style check or track removal with a bool before calling RemoveGamePad","Call RemoveAllGamePads when tearing down instead of per-instance removal","Keep references to removed pads out of active-use collections"],"exampleFix":"// before\nsource.RemoveGamePad(pad);\nsource.RemoveGamePad(pad); // second call throws\n// after\nif (pad != null && !removed.Contains(pad)) { source.RemoveGamePad(pad); removed.Add(pad); }","handlingStrategy":"validation","validationCode":"bool tracked = sourceCreatedPads.Contains(pad);\nif (tracked) source.RemoveGamePad(pad);","typeGuard":null,"tryCatchPattern":"try { source.RemoveGamePad(pad); } catch (InvalidOperationException) { /* already removed */ }","preventionTips":["Keep a set of pads you created via CreateGamePad and only remove from that set","Null out references after removal","Prefer RemoveAllGamePads in teardown"],"tags":["input","simulated","gamepad","entity-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}