Handle csfml wheel

This commit is contained in:
Miloslav Číž 2020-10-26 16:17:03 +01:00
parent 4ca5ea4420
commit 1c3dde5190

View File

@ -43,6 +43,7 @@ sfClock *clock;
sfRenderWindow* window; sfRenderWindow* window;
uint8_t musicOn = 0; uint8_t musicOn = 0;
int8_t mouseWheelState = 0;
int8_t SFG_keyPressed(uint8_t key) int8_t SFG_keyPressed(uint8_t key)
{ {
@ -71,33 +72,29 @@ int8_t SFG_keyPressed(uint8_t key)
break; break;
case SFG_KEY_NEXT_WEAPON: case SFG_KEY_NEXT_WEAPON:
/* TODO if (k(P) || k(X))
if (sdlKeyboardState[SDL_SCANCODE_P] || sdlKeyboardState[SDL_SCANCODE_X])
return 1; return 1;
if (sdlMouseWheelState > 0) if (mouseWheelState > 0)
{ {
sdlMouseWheelState--; mouseWheelState--;
return 1; return 1;
} }
*/
return 0; return 0;
break; break;
case SFG_KEY_PREVIOUS_WEAPON: case SFG_KEY_PREVIOUS_WEAPON:
/* TODO if (k(O) || k(Y) || k(Z))
if (sdlKeyboardState[SDL_SCANCODE_O] || sdlKeyboardState[SDL_SCANCODE_Y]
|| sdlKeyboardState[SDL_SCANCODE_Z])
return 1; return 1;
if (sdlMouseWheelState < 0) if (mouseWheelState < 0)
{ {
sdlMouseWheelState++; mouseWheelState++;
return 1; return 1;
} }
return 0; return 0;
*/
break; break;
case SFG_KEY_MENU: return sfKeyboard_isKeyPressed(sfKeyEscape); break; case SFG_KEY_MENU: return sfKeyboard_isKeyPressed(sfKeyEscape); break;
@ -296,6 +293,8 @@ int main()
while (sfRenderWindow_pollEvent(window,&event)) while (sfRenderWindow_pollEvent(window,&event))
if (event.type == sfEvtClosed) if (event.type == sfEvtClosed)
sfRenderWindow_close(window); sfRenderWindow_close(window);
else if (event.type == sfEvtMouseWheelMoved)
mouseWheelState = event.mouseWheel.delta;
if (!SFG_mainLoopBody()) if (!SFG_mainLoopBody())
break; break;