add sdl2 directive checks

This commit is contained in:
theredbluecube2@gmail.com 2025-12-07 13:54:01 +03:00
parent 92a3b6e20a
commit df951db538

View File

@ -7,7 +7,9 @@
#include <ncurses.h>
#include <ctime>
#include <unistd.h>
#ifdef WITH_SDL2
#include <SDL2/SDL.h>
#endif
#include "Board.h"
#ifndef _WIN32
#include <signal.h>
@ -21,7 +23,9 @@ void handleSIGWINCH(int sig)
#define MAX_TIME 60
#ifdef WITH_SDL2
SDL_GameController *controller;
#endif
void startGame(Board &board)
{
@ -163,6 +167,7 @@ void startGame(Board &board)
}
c = getch();
#ifdef WITH_SDL2
if (c == ERR)
{
if (controller != nullptr)
@ -270,6 +275,7 @@ void startGame(Board &board)
}
}
}
#endif
if (!(c == ERR))
{
@ -438,6 +444,7 @@ void startGame(Board &board)
}
}
#ifdef WITH_SDL2
SDL_GameController *findController()
{
for (int i = 0; i < SDL_NumJoysticks(); i++)
@ -450,6 +457,7 @@ SDL_GameController *findController()
return nullptr;
}
#endif
int main()
{
@ -466,6 +474,7 @@ int main()
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
#endif
#ifdef WITH_SDL2
bool controllerSupport;
if (SDL_Init(SDL_INIT_GAMECONTROLLER) < 0)
@ -481,6 +490,7 @@ int main()
controller = findController();
if (controller != nullptr)
controllerSupport = false; // no controller for you
#endif
start_color();
init_pair(1, COLOR_BLUE, COLOR_BLACK);