mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2024-11-24 18:02:22 -05:00
Polish sdl
This commit is contained in:
parent
8267a5a01b
commit
15c900cdac
89
main_sdl.c
89
main_sdl.c
@ -198,74 +198,26 @@ int8_t SFG_keyPressed(uint8_t key)
|
|||||||
if (webKeyboardState[key])
|
if (webKeyboardState[key])
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
#define k(x) sdlKeyboardState[SDL_SCANCODE_ ## x]
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case SFG_KEY_UP:
|
case SFG_KEY_UP: return k(UP) || k(W) || k(KP_8); break;
|
||||||
return sdlKeyboardState[SDL_SCANCODE_UP] ||
|
case SFG_KEY_RIGHT: return k(RIGHT) || k(E) || k(KP_6); break;
|
||||||
sdlKeyboardState[SDL_SCANCODE_W] ||
|
case SFG_KEY_DOWN: return k(DOWN) || k(S) || k(KP_5) || k(KP_2); break;
|
||||||
sdlKeyboardState[SDL_SCANCODE_KP_8];
|
case SFG_KEY_LEFT: return k(LEFT) || k(Q) || k(KP_4); break;
|
||||||
break;
|
case SFG_KEY_A: return k(G) || k(RETURN) || k(LSHIFT); break;
|
||||||
|
case SFG_KEY_B: return k(H) || k(LCTRL) || k(RCTRL) ||
|
||||||
case SFG_KEY_RIGHT:
|
sdlMouseButtonState & SDL_BUTTON_LMASK; break;
|
||||||
return sdlKeyboardState[SDL_SCANCODE_RIGHT] ||
|
case SFG_KEY_C: return k(J); break;
|
||||||
sdlKeyboardState[SDL_SCANCODE_E] ||
|
case SFG_KEY_JUMP: return k(SPACE); break;
|
||||||
sdlKeyboardState[SDL_SCANCODE_KP_6];
|
case SFG_KEY_STRAFE_LEFT: return k(A) || k(KP_7); break;
|
||||||
break;
|
case SFG_KEY_STRAFE_RIGHT: return k(D) || k(KP_9); break;
|
||||||
|
case SFG_KEY_MAP: return k(TAB); break;
|
||||||
case SFG_KEY_DOWN:
|
case SFG_KEY_TOGGLE_FREELOOK: return sdlMouseButtonState & SDL_BUTTON_RMASK;
|
||||||
return sdlKeyboardState[SDL_SCANCODE_DOWN] ||
|
break;
|
||||||
sdlKeyboardState[SDL_SCANCODE_S] ||
|
|
||||||
sdlKeyboardState[SDL_SCANCODE_KP_5] ||
|
|
||||||
sdlKeyboardState[SDL_SCANCODE_KP_2];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_LEFT:
|
|
||||||
return sdlKeyboardState[SDL_SCANCODE_LEFT] ||
|
|
||||||
sdlKeyboardState[SDL_SCANCODE_Q] ||
|
|
||||||
sdlKeyboardState[SDL_SCANCODE_KP_4];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_A:
|
|
||||||
return sdlKeyboardState[SDL_SCANCODE_G] ||
|
|
||||||
sdlKeyboardState[SDL_SCANCODE_RETURN] ||
|
|
||||||
sdlKeyboardState[SDL_SCANCODE_LSHIFT];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_B:
|
|
||||||
return sdlKeyboardState[SDL_SCANCODE_H] ||
|
|
||||||
(sdlMouseButtonState & SDL_BUTTON_LMASK) ||
|
|
||||||
sdlKeyboardState[SDL_SCANCODE_LCTRL] ||
|
|
||||||
sdlKeyboardState[SDL_SCANCODE_RCTRL];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_C:
|
|
||||||
return sdlKeyboardState[SDL_SCANCODE_J];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_JUMP:
|
|
||||||
return sdlKeyboardState[SDL_SCANCODE_SPACE];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_STRAFE_LEFT:
|
|
||||||
return sdlKeyboardState[SDL_SCANCODE_A] ||
|
|
||||||
sdlKeyboardState[SDL_SCANCODE_KP_7];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_STRAFE_RIGHT:
|
|
||||||
return sdlKeyboardState[SDL_SCANCODE_D] ||
|
|
||||||
sdlKeyboardState[SDL_SCANCODE_KP_9];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_MAP:
|
|
||||||
return sdlKeyboardState[SDL_SCANCODE_TAB];
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_TOGGLE_FREELOOK:
|
|
||||||
return sdlMouseButtonState & SDL_BUTTON_RMASK;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SFG_KEY_NEXT_WEAPON:
|
case SFG_KEY_NEXT_WEAPON:
|
||||||
if (sdlKeyboardState[SDL_SCANCODE_P] || sdlKeyboardState[SDL_SCANCODE_X])
|
if (k(P) || k(X))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (sdlMouseWheelState > 0)
|
if (sdlMouseWheelState > 0)
|
||||||
@ -278,8 +230,7 @@ int8_t SFG_keyPressed(uint8_t key)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SFG_KEY_PREVIOUS_WEAPON:
|
case SFG_KEY_PREVIOUS_WEAPON:
|
||||||
if (sdlKeyboardState[SDL_SCANCODE_O] || sdlKeyboardState[SDL_SCANCODE_Y]
|
if (k(O) || k(Y) || k(Z))
|
||||||
|| sdlKeyboardState[SDL_SCANCODE_Z])
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (sdlMouseWheelState < 0)
|
if (sdlMouseWheelState < 0)
|
||||||
@ -291,9 +242,7 @@ int8_t SFG_keyPressed(uint8_t key)
|
|||||||
return 0;
|
return 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SFG_KEY_MENU:
|
case SFG_KEY_MENU: return k(ESCAPE); break;
|
||||||
return sdlKeyboardState[SDL_SCANCODE_ESCAPE];
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: return 0; break;
|
default: return 0; break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user