Fix headless server compile (again) (#23)

This commit is contained in:
Isaac 2022-03-14 07:10:24 +10:00 committed by GitHub
parent 60316c7bc9
commit 013edccfed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -10,7 +10,9 @@
#include <math.h>
#include <limits.h>
#include <dirent.h>
#ifdef HAVE_SDL2
#include <SDL2/SDL.h>
#endif
#ifdef __cplusplus
#include <new>
#include <utility>
@ -35,4 +37,4 @@ extern "C" {
#define DYNOS_AT_STARTUP __attribute__((constructor))
#define DYNOS_AT_EXIT __attribute__((destructor))
#endif
#endif

View File

@ -4,7 +4,7 @@ extern "C" {
}
static bool DynOS_Opt_ControllerIsKeyDown(s32 aCont, s32 aKey) {
#ifdef HAVE_SDL2
// Keyboard
if (aCont == 0 && aKey >= 0 && aKey < SDL_NUM_SCANCODES) {
return SDL_GetKeyboardState(NULL)[aKey];
@ -28,11 +28,13 @@ static bool DynOS_Opt_ControllerIsKeyDown(s32 aCont, s32 aKey) {
}
}
// Invalid
#endif
return false;
}
#define MAX_CONTS 8
bool DynOS_Opt_ControllerUpdate(DynosOption *aOpt, void *aData) {
#ifdef HAVE_SDL2
if (aOpt->mType == DOPT_BIND) {
OSContPad *pad = (OSContPad *) aData;
for (s32 _Cont = 0; _Cont < MAX_CONTS; ++_Cont)
@ -40,12 +42,14 @@ bool DynOS_Opt_ControllerUpdate(DynosOption *aOpt, void *aData) {
pad->button |= aOpt->mBind.mMask * DynOS_Opt_ControllerIsKeyDown(_Cont, aOpt->mBind.mBinds[_Bind]);
}
}
#endif
return false;
}
#define MAX_GKEYS (SDL_CONTROLLER_BUTTON_MAX + SDL_CONTROLLER_AXIS_MAX * 2)
s32 sBindingState = 0; // 0 = No bind, 1 = Wait for all keys released, 2 = Return first pressed key
s32 DynOS_Opt_ControllerGetKeyPressed() {
#ifdef HAVE_SDL2
// Keyboard
for (s32 _Key = 0; _Key < SDL_NUM_SCANCODES; ++_Key) {
@ -66,5 +70,6 @@ s32 DynOS_Opt_ControllerGetKeyPressed() {
// No key
sBindingState = 2;
#endif
return VK_INVALID;
}