soport per a gamepad
This commit is contained in:
@@ -20,6 +20,14 @@ void JI_SetInputBlocked(bool blocked) {
|
||||
input_blocked = blocked;
|
||||
}
|
||||
|
||||
static Uint8 virtual_keystates[SDL_SCANCODE_COUNT] = {0};
|
||||
|
||||
void JI_SetVirtualKey(int scancode, bool pressed) {
|
||||
if (scancode >= 0 && scancode < SDL_SCANCODE_COUNT) {
|
||||
virtual_keystates[scancode] = pressed ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void JI_moveCheats(Uint8 new_key) {
|
||||
cheat[0] = cheat[1];
|
||||
cheat[1] = cheat[2];
|
||||
@@ -47,7 +55,8 @@ bool JI_KeyPressed(int key) {
|
||||
if (input_blocked) return false;
|
||||
// ESC bloquejada pel Director (primera pulsació mostra notificació)
|
||||
if (key == SDL_SCANCODE_ESCAPE && Director::get()->isEscBlocked()) return false;
|
||||
return keystates[key] != 0;
|
||||
if (key < 0 || key >= SDL_SCANCODE_COUNT) return false;
|
||||
return keystates[key] != 0 || virtual_keystates[key] != 0;
|
||||
}
|
||||
|
||||
bool JI_CheatActivated(const char* cheat_code) {
|
||||
|
||||
Reference in New Issue
Block a user