33#include "../../objects/PEnvironment.h"
35#include "../../base/PList.h"
36#include "../../base/PComplexData.h"
45#include "../../utility/PError.h"
46#include "../../utility/PEBLUtility.h"
63 bool windowed,
bool resizeable,
bool unicode):
69 mResizeable(resizeable),
92 out <<
"<SDL PlatformEnvironment>" << flush;
104#ifdef PEBL_EMSCRIPTEN
105#define SDLINIT_FLAGS SDL_INIT_VIDEO
107#define SDLINIT_FLAGS SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE
112 cerr <<
"Unable to init SDL: " << SDL_GetError() << endl;;
117 std::cerr <<
"SDL INITIALIZED\n";
118 const char* audioDriver = SDL_GetCurrentAudioDriver();
120 std::cerr <<
"SDL Audio Driver: " << audioDriver <<
"\n";
122 std::cerr <<
"SDL Audio Driver: NONE\n";
125#ifdef PEBL_EMSCRIPTEN
128 if (!TTF_WasInit() && TTF_Init() < 0 )
132 cerr <<
"Couldn't initialize TTF: " << SDL_GetError() << endl;
136 std::cerr <<
"TTF INITIALIZED\n";
140#ifdef PEBL_EMSCRIPTEN
142 int imgFlags = IMG_INIT_JPG | IMG_INIT_PNG;
144 int imgFlags = IMG_INIT_JPG | IMG_INIT_PNG | IMG_INIT_TIF;
146 cerr <<
"Attempting to initialize SDL_image with flags: " << imgFlags << endl;
147 cerr <<
" IMG_INIT_JPG = " << IMG_INIT_JPG << endl;
148 cerr <<
" IMG_INIT_PNG = " << IMG_INIT_PNG << endl;
150 int imgInitResult = IMG_Init(imgFlags);
151 cerr <<
"IMG_Init returned: " << imgInitResult << endl;
153 if ((imgInitResult & imgFlags) != imgFlags)
155 cerr <<
"WARNING: SDL_image could not initialize all requested formats!" << endl;
156 cerr <<
" Requested flags: " << imgFlags << endl;
157 cerr <<
" Initialized flags: " << imgInitResult << endl;
158 cerr <<
" IMG_Error: " << IMG_GetError() << endl;
160 if (!(imgInitResult & IMG_INIT_JPG)) {
161 cerr <<
" JPEG support NOT available!" << endl;
163 if (!(imgInitResult & IMG_INIT_PNG)) {
164 cerr <<
" PNG support NOT available!" << endl;
168 std::cerr <<
"SDL_image INITIALIZED successfully with all formats" << endl;
169 std::cerr <<
" JPEG support: YES" << endl;
170 std::cerr <<
" PNG support: YES" << endl;
177#define PRINTCONSOLE 0
181 std::ofstream cct1(
"CON1");
182 std::ofstream cct2(
"CON2");
184 freopen(
"CON1",
"w", stdout );
185 freopen(
"CON2",
"w", stderr );
202 list<PWindow*>::iterator p;
235 return SDL_ShowCursor(SDL_ENABLE);
239 return SDL_ShowCursor(SDL_DISABLE);
250 SDL_SetRelativeMouseMode(SDL_FALSE);
252 SDL_Window *win = pw->PlatformWindow::GetSDLWindow();
253 SDL_WarpMouseInWindow(win,x,y);
265 SDL_GetMouseState(&x,&y);
281 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
283 SDL_EnableKeyRepeat(0,0);
292 int button = SDL_GetMouseState(&x,&y);
293 int b1 = button & SDL_BUTTON(1);
294 int b2 = button & SDL_BUTTON(2);
295 int b3 = button & SDL_BUTTON(3);
315 if(SDL_InitSubSystem(SDL_INIT_JOYSTICK)<0)
319 int num = SDL_NumJoysticks();
332 if(index < 1 || index > SDL_NumJoysticks())
355 int numdisplays = SDL_GetNumVideoDisplays();
357 if(screen<0 | screen >=numdisplays)
380 SDL_DisplayMode mode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 };
381 for(
int i = low; i < hi; i++)
383 nummodes = SDL_GetNumDisplayModes(i);
384 totalmodes += nummodes;
386 for(
int modeid = 0;modeid < nummodes; modeid++)
389 SDL_GetDisplayMode(i,modeid,&mode);
416 SDL_Locale *locales = SDL_GetPreferredLocales();
422 std::string result =
"";
423 if (locales[0].language) {
424 result = locales[0].language;
427 if (locales[0].country) {
429 result += locales[0].country;
441 if (locale.empty()) {
446 std::string langCode = locale.substr(0, 2);
447 std::transform(langCode.begin(), langCode.end(), langCode.begin(), ::tolower);
450 return (langCode ==
"ar" || langCode ==
"he" || langCode ==
"iw");
Variant GetProperty(std::string) const
std::list< PWindow * > mWindows
void PushBack(const Variant &v)
void InitializeKeycodeLookups()
void SignalWarning(const std::string &message)
void SignalFatalError(const std::string &message)