C++ OpenAPI console example
Windows x64, C17. Requires Visual Studio with **Desktop development with C** and a Windows SDK. No separate runtime or JSON DLL is required for the locally compiled Release executable.
Build and run
Open src/CreativeGolfOpenAPIExample.vcxproj in Visual Studio, choose Release / x64, and build. The project uses the installed Visual Studio's default C++ toolset. Alternatively, in a Visual Studio Developer PowerShell:
msbuild src/CreativeGolfOpenAPIExample.vcxproj /p:Configuration=Release /p:Platform=x64
Game on the same PC:
./src/bin/x64/Release/CreativeGolfOpenAPIExample.exe
Optional: game on another PC. Replace 192.168.1.100 with that PC's IP address. 4356 is the default game port.
./src/bin/x64/Release/CreativeGolfOpenAPIExample.exe 192.168.1.100 4356
The distributed example is source-only. bin and obj are created locally when you build. The GUI TestApp is the ready-to-run application included in the final package.
Try it
Run Creative Golf with OpenAPI selected. Only one client can connect at a time. Defaults are 127.0.0.1:4356; optional arguments select the game PC and port.
Connection failure waits for Enter to retry or Esc to exit. The menu appears after the server's hello:
1 - Send normal shot
2 - Send putt
3 - Set device Ready
4 - Set device Not ready
5 - Show current game state
0 - Disconnect and exit
m - Show this menu
Type a choice and press Enter. Text aliases shot, putt, ready, notready, state, quit, menu also work. Status sends only ballReady, without a reason prompt. On server disconnect, press Enter to leave the input prompt.
TX / RX show sent / received JSON. Each shot has a new UUID. Not-ready commands are discarded, and another shot needs the previous result and a fresh ready state. No automatic reconnect, queuing or replay. State messages replace the full snapshot; omitted fields clear old values. The game may still reject a shot after advertising readiness.
Replace the two presets in openapi_example.cpp with new live measurements from your hardware. Device status is independent of game readiness. See the API reference for fields, units and results.
JSON dependency
src/third_party/json.hpp is the unmodified single-header nlohmann/json v3.12.0, with its MIT licence alongside it. It is compiled into the example; there is no installation/download step during build. Winsock and UUID functions are provided by Windows.
Header SHA-256: aaf127c04cb31c406e5b04a63f1ae89369fccde6d8fa7cdda1ed4f32dfc5de63.