You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- After first successful load, OmniPanel-go keeps the DLL loaded for the process lifetime to avoid repeated vJoy reinitialization issues on some systems.
1016
1017
4. **Build with CGO (if building from source):**
1017
1018
Install MinGW-w64 or MSYS2 GCC. Use the maintained build script for reliable builds:
Copy file name to clipboardExpand all lines: docs/tutorials/08-virtual-input.md
+19-4Lines changed: 19 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -354,7 +354,7 @@ vJoy is a signed kernel driver that creates up to 16 virtual joystick devices. E
354
354
355
355
#### CGO Integration and DLL Loading
356
356
357
-
The Windows joystick implementation uses CGO to call `vJoyInterface.dll`. To improve reliability across different Windows installations and build environments, the code uses a **multi-path DLL loading strategy**:
357
+
The Windows joystick implementation uses CGO to call `vJoyInterface.dll`. To improve reliability across different Windows installations and build environments, the code uses a **multi-path DLL loading strategy** and **caches the loaded DLL handle for the process lifetime**:
358
358
359
359
```go
360
360
//go:build windows && cgo
@@ -369,7 +369,11 @@ package devices
369
369
// 2. Standard vJoy x64 install paths
370
370
// 3. Standard vJoy bin paths
371
371
// Returns the loaded module handle, or NULL if all paths fail.
372
+
// The handle is cached to avoid repeated load/unload reinitialization.
> Go CGO can't directly call `__cdecl` functions from a dynamically loaded DLL. The C wrapper functions use `LoadLibraryA`/`GetProcAddress` to dynamically load the DLL at runtime, then call the vJoy functions. This avoids requiring the DLL at link time.
> In `internal/devices/windows.go`, `load_vJoyInterface` stores the first successful `HMODULE` in a static variable and reuses it. This avoids repeated DLL initialization/cleanup cycles, which can trigger startup dialog errors in some `vJoyInterface.dll` builds.
414
+
406
415
> **Why multi-path loading?**
407
416
> vJoy installs to different paths depending on Windows version, user permissions, and upgrade history. By checking multiple paths in order (PATH first for flexibility, then standard install directories), the code gracefully handles various configurations without requiring users to manually add vJoy to PATH or move DLLs around.
408
417
409
418
> **Key Pattern: Graceful fallback chains**
410
419
> The path array is a fallback chain — try the easiest option first, then progressively try more specific locations. This pattern appears throughout systems engineering: DNS resolution, environment variable lookup, and configuration file discovery all use similar strategies to maximize compatibility.
411
420
421
+
> **Concept (JavaScript): stable transport contract**
422
+
> In `static/client/client.js` (`initJoystick`), the browser only sends normalized `simulate-joystick` messages (`0-255` axis range). It does not know about DLL paths or OS APIs. This separation keeps frontend behavior stable while backend internals evolve.
> Keep wire messages small and consistent (`type` + `data` payload), and isolate platform-specific details in backend adapters. The same UI code works for Linux `uinput` and Windows vJoy because both consume the same protocol.
426
+
412
427
#### Axis Mapping
413
428
414
429
OmniPanel-go's 8 axes (0-255 range) are mapped to vJoy HID usage codes:
Copy file name to clipboardExpand all lines: docs/tutorials/19-windows-build-and-ci.md
+12-1Lines changed: 12 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,18 @@ This ensures the built binary has all required runtime dependencies. At runtime,
57
57
2. Standard vJoy installation directories
58
58
3. System PATH
59
59
60
-
This two-pronged approach — build-time bundling + runtime multi-path search — maximizes compatibility across different Windows configurations.
60
+
After the first successful load, the DLL handle is cached and reused for the rest of the process. This avoids repeated load/unload cycles that can produce vJoy startup dialog errors on some systems.
61
+
62
+
This two-pronged approach — build-time bundling + runtime multi-path search with process-lifetime caching — maximizes compatibility across different Windows configurations.
63
+
64
+
> **Concept (Go): cache once, reuse many times**
65
+
> `internal/devices/windows.go` keeps the vJoy module handle after the first successful `LoadLibraryA`. Reusing one handle is safer than repeatedly loading and unloading a DLL that does global initialization.
66
+
67
+
> **Concept (JavaScript): no frontend coupling to runtime DLL state**
68
+
> The panel client (`static/client/client.js`) continues sending the same joystick WebSocket payloads regardless of how Windows loads vJoy. This keeps client behavior predictable for users.
69
+
70
+
> **Key Pattern (Go + JavaScript): transport and adapter split**
71
+
> The frontend speaks a stable protocol (`simulate-joystick` messages), while the backend adapter handles platform-specific DLL and driver details. This split reduces regressions when platform internals change.
Copy file name to clipboardExpand all lines: docs/user-manual/de/12-virtual-joysticks.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,8 @@ Nach der Installation von vJoy findet OmniPanel-go automatisch die `vJoyInterfac
77
77
78
78
Wenn du OmniPanel-go von der Quelle mit dem Script `scripts/build-with-vosk.ps1` gebaut hast, wird die DLL automatisch neben deiner ausführbaren Datei kopiert. Andernfalls findet OmniPanel-go die DLL beim ersten Start im vJoy-Installationsverzeichnis.
79
79
80
+
OmniPanel-go lädt diese DLL einmal und behält sie, solange die App läuft. Dadurch wird eine wiederholte vJoy-Neuinitialisierung beim Start vermieden und die Stabilität auf manchen Windows-Systemen verbessert.
81
+
80
82
**Hinweis:** vJoy wird nur für virtuelle Joysticks benötigt. Virtuelle Maus- und Tastatureingaben nutzen die eingebaute `SendInput`-Funktion von Windows und brauchen keine zusätzlichen Treiber.
81
83
82
84
### macOS
@@ -258,6 +260,8 @@ In den Steuerelement-Einstellungen deines Spiels:
258
260
- Starte OmniPanel-go nach der Installation von vJoy neu
259
261
- Prüfe, dass die DLL nicht von Antivirus-Software unter Quarantäne gestellt wurde
260
262
263
+
Wenn beim Start Popups von `vJoyInterface DLL` erscheinen (zum Beispiel `RegisterClassEx failed` oder `Creation of dummy window failed`), beende OmniPanel-go vollständig und starte es erneut, nachdem du die vJoy-Installation geprüft hast. Aktuelle OmniPanel-go-Versionen laden die DLL pro Lauf nur einmal, um dieses Problem zu reduzieren.
264
+
261
265
**Linux:**
262
266
- Prüfe, ob du Berechtigung für den Zugriff auf `/dev/uinput` hast
Copy file name to clipboardExpand all lines: docs/user-manual/en/12-virtual-joysticks.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,6 +77,8 @@ After installing vJoy, OmniPanel-go will automatically find the `vJoyInterface.d
77
77
78
78
If you built OmniPanel-go from source using the `scripts/build-with-vosk.ps1` script, the DLL will be automatically copied next to your executable. Otherwise, OmniPanel-go will find it in the vJoy installation directory the first time it runs.
79
79
80
+
OmniPanel-go loads this DLL once and keeps it loaded while the app is running. This avoids repeated vJoy re-initialization on startup and improves stability on some Windows systems.
81
+
80
82
**Note:** vJoy is only needed for virtual joysticks. Virtual mouse and keyboard input use Windows' built-in `SendInput` function and don't require any extra drivers.
81
83
82
84
### macOS
@@ -258,6 +260,8 @@ In your game's control settings:
258
260
- Restart OmniPanel-go after installing vJoy
259
261
- Check that the DLL is not quarantined by antivirus software
260
262
263
+
If you see startup popups from `vJoyInterface DLL` (for example `RegisterClassEx failed` or `Creation of dummy window failed`), fully close OmniPanel-go and start it again after verifying your vJoy install. Current versions of OmniPanel-go keep the DLL loaded once per run to reduce this issue.
264
+
261
265
**Linux:**
262
266
- Check that you have permission to access `/dev/uinput`
0 commit comments