|
| 1 | +/* |
| 2 | + Simple DirectMedia Layer |
| 3 | + Copyright (C) 1997-2023 Sam Lantinga <[email protected]> |
| 4 | +
|
| 5 | + This software is provided 'as-is', without any express or implied |
| 6 | + warranty. In no event will the authors be held liable for any damages |
| 7 | + arising from the use of this software. |
| 8 | +
|
| 9 | + Permission is granted to anyone to use this software for any purpose, |
| 10 | + including commercial applications, and to alter it and redistribute it |
| 11 | + freely, subject to the following restrictions: |
| 12 | +
|
| 13 | + 1. The origin of this software must not be misrepresented; you must not |
| 14 | + claim that you wrote the original software. If you use this software |
| 15 | + in a product, an acknowledgment in the product documentation would be |
| 16 | + appreciated but is not required. |
| 17 | + 2. Altered source versions must be plainly marked as such, and must not be |
| 18 | + misrepresented as being the original software. |
| 19 | + 3. This notice may not be removed or altered from any source distribution. |
| 20 | +*/ |
| 21 | + |
| 22 | +#include "../SDL_sysactionset.h" |
| 23 | +#include "SDL_steaminput.h" |
| 24 | +#include "SDL_loadso.h" |
| 25 | + |
| 26 | +#ifdef __WINDOWS__ |
| 27 | + #ifdef _WIN64 |
| 28 | + #define STEAM_DLL "steam_api64.dll" |
| 29 | + #else |
| 30 | + #define STEAM_DLL "steam_api.dll" |
| 31 | + #endif |
| 32 | +#elif defined(__MACOS__) |
| 33 | + #define STEAM_DLL "libsteam_api.dylib" |
| 34 | +#else |
| 35 | + #define STEAM_DLL "libsteam_api.so" |
| 36 | +#endif |
| 37 | + |
| 38 | +static void *steam_dll = NULL; |
| 39 | + |
| 40 | +static void STEAMINPUT_Init(void) |
| 41 | +{ |
| 42 | + steam_dll = SDL_LoadObject(STEAM_DLL); |
| 43 | + if (steam_dll == NULL) { |
| 44 | + SDL_SetError("Steamworks library was not found"); |
| 45 | + return; |
| 46 | + } |
| 47 | + /* TODO: Load entry points, unload if any are missing */ |
| 48 | + /* TODO: if (!SteamAPI_WasInit()) unload and bail */ |
| 49 | + /* TODO: Call ISteamInput_Init(true) */ |
| 50 | + /* TODO: Subscribe to SteamInputConfigurationLoaded_t */ |
| 51 | + /* TODO: Subscribe to SteamInputDeviceConnected_t */ |
| 52 | + /* TODO: Subscribe to SteamInputDeviceDisconnected_t */ |
| 53 | +} |
| 54 | + |
| 55 | +static void STEAMINPUT_Quit(void) |
| 56 | +{ |
| 57 | + if (steam_dll == NULL) { |
| 58 | + return; |
| 59 | + } |
| 60 | + |
| 61 | + /* TODO: Call ISteamInput_Shutdown(), clear entry points */ |
| 62 | + SDL_UnloadObject(steam_dll); |
| 63 | + steam_dll = NULL; |
| 64 | +} |
| 65 | + |
| 66 | +static void STEAMINPUT_Update(void) |
| 67 | +{ |
| 68 | + if (steam_dll == NULL) { |
| 69 | + return; |
| 70 | + } |
| 71 | + |
| 72 | + /* TODO: SteamAPI_ISteamInput_RunFrame() */ |
| 73 | + /* TODO: if (!BNewDataAvailable()) return; */ |
| 74 | + /* TODO: Poll all actions for active set. FIXME: Can we get events...? */ |
| 75 | +} |
| 76 | + |
| 77 | +SDL_ActionSetProvider STEAMINPUT_provider = { |
| 78 | + STEAMINPUT_Init, |
| 79 | + STEAMINPUT_Quit, |
| 80 | + STEAMINPUT_Update |
| 81 | +}; |
0 commit comments