archivemuh

This commit is contained in:
2025-08-20 19:18:38 -05:00
parent 1411c2e96b
commit fbfcbe9578
173 changed files with 2802 additions and 13 deletions

View File

@@ -0,0 +1,44 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "dusksdl2input.h"
inputstate_t inputStateGet() {
inputstate_t state = 0;
#if INPUT_SUPPORT_GAMEPAD
// Get gamepad state.
for(int32_t i = 0; i < SDL_NumJoysticks(); i++) {
if(!SDL_IsGameController(i)) continue;
SDL_GameController *controller = SDL_GameControllerOpen(i);
if(!controller) continue;
inputsdlbuttonmap_t *map = INPUT_SDL_BUTTON_MAP;
do {
if(SDL_GameControllerGetButton(controller, map->button)) {
state |= map->bind;
}
map++;
} while(map->bind != 0);
}
#endif
// Get keyboard state.
#if INPUT_SUPPORT_KEYBOARD
const uint8_t *keyboardState = SDL_GetKeyboardState(NULL);
inputsdlkbmap_t *kbmap = INPUT_SDL_KEYBOARD_MAP;
do {
if(keyboardState[kbmap->code]) {
state |= kbmap->bind;
}
kbmap++;
} while(kbmap->bind != 0);
#endif
return state;
}