- got sdl2 branch compiling and game loads
This commit is contained in:
parent
23ea9f6201
commit
8e439a2325
|
@ -1 +1 @@
|
|||
Subproject commit 736113a2b4b883722279942e11e63bdb414fe39f
|
||||
Subproject commit bf04854ade7cd0fc51483c857e590acfef4fbc26
|
|
@ -4854,10 +4854,11 @@ void Game::keyDown(SDL_KeyboardEvent key) {
|
|||
//char groupHotKey = configKeys.getCharKey(keyName.c_str());
|
||||
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] keyName [%s] group index = %d, key = [%c] [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,keyName.c_str(),idx,groupHotKey,groupHotKey);
|
||||
|
||||
SDLKey groupHotKey = configKeys.getSDLKey(keyName.c_str());
|
||||
SDL_Keycode groupHotKey = configKeys.getSDLKey(keyName.c_str());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] keyName [%s] group index = %d, key = [%c] [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,keyName.c_str(),idx,groupHotKey,groupHotKey);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("input.keysym.mod = %d groupHotKey = %d key = %d (%d) [%s] isgroup = %d\n",key.keysym.mod,groupHotKey,key.keysym.sym,key.keysym.unicode,keyName.c_str(),isKeyPressed(groupHotKey,key));
|
||||
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("input.keysym.mod = %d groupHotKey = %d key = %d (%d) [%s] isgroup = %d\n",key.keysym.mod,groupHotKey,key.keysym.sym,key.keysym.unicode,keyName.c_str(),isKeyPressed(groupHotKey,key));
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("input.keysym.mod = %d groupHotKey = %d key = (%d) [%s] isgroup = %d\n",key.keysym.mod,groupHotKey,keyName.c_str(),isKeyPressed(groupHotKey,key));
|
||||
//printf("input.keysym.mod = %d groupHotKey = %d key = %d (%d) [%s] isgroup = %d\n",key.keysym.mod,groupHotKey,key.keysym.sym,key.keysym.unicode,keyName.c_str(),isKeyPressed(groupHotKey,key));
|
||||
//printf("IS GROUP KEY %d scancode:%d sym:%d groupHotKey=%d \n",idx,key.keysym.scancode,key.keysym.sym,groupHotKey);
|
||||
if(key.keysym.sym==groupHotKey){
|
||||
|
@ -6348,7 +6349,9 @@ void Game::playStreamingVideo(const string &playVideo) {
|
|||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false &&
|
||||
::Shared::Graphics::VideoPlayer::hasBackEndVideoPlayer() == true) {
|
||||
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
||||
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreen();
|
||||
PlatformContextGl *glCtx = static_cast<ContextGl*>(c)->getPlatformContextGlPtr();
|
||||
SDL_Window *window = glCtx->getScreenWindow();
|
||||
SDL_Surface *screen = glCtx->getScreenSurface();
|
||||
|
||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||
|
||||
|
@ -6356,7 +6359,7 @@ void Game::playStreamingVideo(const string &playVideo) {
|
|||
&Renderer::getInstance(),
|
||||
playVideo,
|
||||
"",
|
||||
screen,
|
||||
window,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
|
@ -6374,7 +6377,9 @@ void Game::playStreamingVideo(const string &playVideo) {
|
|||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false &&
|
||||
::Shared::Graphics::VideoPlayer::hasBackEndVideoPlayer() == true) {
|
||||
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
||||
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreen();
|
||||
PlatformContextGl *glCtx = static_cast<ContextGl*>(c)->getPlatformContextGlPtr();
|
||||
SDL_Window *window = glCtx->getScreenWindow();
|
||||
SDL_Surface *screen = glCtx->getScreenSurface();
|
||||
|
||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||
|
||||
|
@ -6382,7 +6387,7 @@ void Game::playStreamingVideo(const string &playVideo) {
|
|||
&Renderer::getInstance(),
|
||||
playVideo,
|
||||
"",
|
||||
screen,
|
||||
window,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
|
|
|
@ -459,11 +459,11 @@ const string Config::getString(const string &key,const char *defaultValueIfNotFo
|
|||
return properties.first.getString(key,defaultValueIfNotFound);
|
||||
}
|
||||
|
||||
SDLKey Config::translateStringToSDLKey(const string &value) const {
|
||||
SDLKey result = SDLK_UNKNOWN;
|
||||
SDL_Keycode Config::translateStringToSDLKey(const string &value) const {
|
||||
SDL_Keycode result = SDLK_UNKNOWN;
|
||||
|
||||
if(IsNumeric(value.c_str()) == true) {
|
||||
result = (SDLKey)strToInt(value);
|
||||
result = (SDL_Keycode)strToInt(value);
|
||||
}
|
||||
else if(value.substr(0,2) == "vk") {
|
||||
if(value == "vkLeft") {
|
||||
|
@ -524,7 +524,7 @@ SDLKey Config::translateStringToSDLKey(const string &value) const {
|
|||
result = SDLK_F12;
|
||||
}
|
||||
else if(value == "vkPrint") {
|
||||
result = SDLK_PRINT;
|
||||
result = SDLK_PRINTSCREEN;
|
||||
}
|
||||
else if(value == "vkPause") {
|
||||
result = SDLK_PAUSE;
|
||||
|
@ -536,13 +536,13 @@ SDLKey Config::translateStringToSDLKey(const string &value) const {
|
|||
}
|
||||
else if(value.length() >= 1) {
|
||||
if(value.length() == 3 && value[0] == '\'' && value[2] == '\'') {
|
||||
result = (SDLKey)value[1];
|
||||
result = (SDL_Keycode)value[1];
|
||||
}
|
||||
else {
|
||||
bool foundKey = false;
|
||||
if(value.length() > 1) {
|
||||
for(int i = SDLK_UNKNOWN; i < SDLK_LAST; ++i) {
|
||||
SDLKey key = static_cast<SDLKey>(i);
|
||||
for(int i = SDLK_UNKNOWN; i < SDL_NUM_SCANCODES; ++i) {
|
||||
SDL_Keycode key = static_cast<SDL_Keycode>(i);
|
||||
string keyName = SDL_GetKeyName(key);
|
||||
if(value == keyName) {
|
||||
result = key;
|
||||
|
@ -553,7 +553,7 @@ SDLKey Config::translateStringToSDLKey(const string &value) const {
|
|||
}
|
||||
|
||||
if(foundKey == false) {
|
||||
result = (SDLKey)value[0];
|
||||
result = (SDL_Keycode)value[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -567,7 +567,7 @@ SDLKey Config::translateStringToSDLKey(const string &value) const {
|
|||
return result;
|
||||
}
|
||||
|
||||
SDLKey Config::getSDLKey(const char *key) const {
|
||||
SDL_Keycode Config::getSDLKey(const char *key) const {
|
||||
if(fileLoaded.second == true &&
|
||||
properties.second.getString(key, defaultNotFoundValue.c_str()) != defaultNotFoundValue) {
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
float getFloat(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
||||
const string getString(const char *key,const char *defaultValueIfNotFound=NULL) const;
|
||||
//char getCharKey(const char *key) const;
|
||||
SDLKey getSDLKey(const char *key) const;
|
||||
SDL_Keycode getSDLKey(const char *key) const;
|
||||
|
||||
void setInt(const string &key, int value, bool tempBuffer=false);
|
||||
void setBool(const string &key, bool value, bool tempBuffer=false);
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
|
||||
string getFileName(bool userFilename) const;
|
||||
|
||||
SDLKey translateStringToSDLKey(const string &value) const;
|
||||
SDL_Keycode translateStringToSDLKey(const string &value) const;
|
||||
|
||||
string toString();
|
||||
|
||||
|
|
|
@ -7610,7 +7610,6 @@ void Renderer::loadConfig() {
|
|||
//if(this->program != NULL) {
|
||||
if(gammaValue != 0.0) {
|
||||
this->program->getWindow()->setGamma(gammaValue);
|
||||
SDL_SetGamma(gammaValue, gammaValue, gammaValue);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
|
|
@ -326,7 +326,9 @@ void BattleEnd::initBackgroundVideo() {
|
|||
printf("videoFile [%s] videoFileFallback [%s]\n",videoFile.c_str(),videoFileFallback.c_str());
|
||||
|
||||
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
||||
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreen();
|
||||
PlatformContextGl *glCtx = static_cast<ContextGl*>(c)->getPlatformContextGlPtr();
|
||||
SDL_Window *window = glCtx->getScreenWindow();
|
||||
SDL_Surface *screen = glCtx->getScreenSurface();
|
||||
|
||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||
//printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel);
|
||||
|
@ -334,7 +336,7 @@ void BattleEnd::initBackgroundVideo() {
|
|||
&Renderer::getInstance(),
|
||||
videoFile,
|
||||
videoFileFallback,
|
||||
screen,
|
||||
window,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
|
|
|
@ -515,7 +515,9 @@ Intro::Intro(Program *program):
|
|||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Intro Video [%s] [%s]\n",introVideoFile.c_str(),introVideoFileFallback.c_str());
|
||||
|
||||
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
||||
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreen();
|
||||
PlatformContextGl *glCtx = static_cast<ContextGl*>(c)->getPlatformContextGlPtr();
|
||||
SDL_Window *window = glCtx->getScreenWindow();
|
||||
SDL_Surface *screen = glCtx->getScreenSurface();
|
||||
|
||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||
//printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel);
|
||||
|
@ -523,7 +525,7 @@ Intro::Intro(Program *program):
|
|||
&Renderer::getInstance(),
|
||||
introVideoFile,
|
||||
introVideoFileFallback,
|
||||
screen,
|
||||
window,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
|
|
|
@ -202,7 +202,7 @@ static void cleanupProcessObjects() {
|
|||
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
showCursor(true);
|
||||
restoreVideoMode(true);
|
||||
restoreVideoMode(::Shared::Platform::Window::getSDLWindow(), true);
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 IRCCLient Cache SHUTDOWN\n");
|
||||
|
@ -4265,7 +4265,7 @@ int glestMain(int argc, char** argv) {
|
|||
print_SDL_version("SDL compile-time version", &ver);
|
||||
|
||||
// Prints the run-time version
|
||||
ver = *SDL_Linked_Version();
|
||||
SDL_GetVersion(&ver);
|
||||
print_SDL_version("SDL runtime version", &ver);
|
||||
//const SDL_VideoInfo *vidInfo = SDL_GetVideoInfo();
|
||||
//printf("Video card Memory: %u\n",vidInfo->video_mem);
|
||||
|
|
|
@ -63,6 +63,10 @@ ProgramState::ProgramState(Program *program) {
|
|||
this->startY=0;
|
||||
}
|
||||
|
||||
void ProgramState::restoreToStartXY() {
|
||||
SDL_WarpMouseInWindow(this->program->getWindow()->getSDLWindow(), startX, startY);
|
||||
}
|
||||
|
||||
void ProgramState::incrementFps() {
|
||||
fps++;
|
||||
}
|
||||
|
@ -887,7 +891,7 @@ void Program::restoreDisplaySettings(){
|
|||
Config &config= Config::getInstance();
|
||||
|
||||
if(!config.getBool("Windowed")){
|
||||
restoreVideoMode();
|
||||
restoreVideoMode(this->getWindow()->getSDLWindow());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public:
|
|||
virtual void keyUp(SDL_KeyboardEvent key){};
|
||||
virtual void keyPress(SDL_KeyboardEvent c){};
|
||||
virtual void setStartXY(int X,int Y) { startX=X; startY=Y; }
|
||||
virtual void restoreToStartXY() { SDL_WarpMouse(startX, startY); }
|
||||
virtual void restoreToStartXY();
|
||||
virtual bool isInSpecialKeyCaptureEvent() { return false; }
|
||||
virtual bool quitTriggered() { return false; }
|
||||
virtual Stats quitAndToggleState() { return Stats(); };
|
||||
|
|
|
@ -119,7 +119,9 @@ void MainMenu::initBackgroundVideo() {
|
|||
string introVideoFileFallback = CoreData::getInstance().getMainMenuVideoFilenameFallback();
|
||||
|
||||
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
||||
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreen();
|
||||
PlatformContextGl *glCtx = static_cast<ContextGl*>(c)->getPlatformContextGlPtr();
|
||||
SDL_Window *window = glCtx->getScreenWindow();
|
||||
SDL_Surface *screen = glCtx->getScreenSurface();
|
||||
|
||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||
//printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel);
|
||||
|
@ -127,7 +129,7 @@ void MainMenu::initBackgroundVideo() {
|
|||
&Renderer::getInstance(),
|
||||
introVideoFile,
|
||||
introVideoFileFallback,
|
||||
screen,
|
||||
window,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
|
@ -404,7 +406,7 @@ bool MenuState::keyPressEditLabel(SDL_KeyboardEvent c, GraphicLabel **activeInpu
|
|||
if(activeInputLabel != NULL) {
|
||||
int maxTextSize= activeInputLabel->getMaxEditWidth();
|
||||
|
||||
SDLKey key = extractKeyPressed(c);
|
||||
SDL_Keycode key = extractKeyPressed(c);
|
||||
if(isKeyPressed(SDLK_ESCAPE,c,false) == true ||
|
||||
isKeyPressed(SDLK_RETURN,c,false) == true ) {
|
||||
setActiveInputLabel(NULL,activeInputLabelPtr);
|
||||
|
|
|
@ -5035,7 +5035,9 @@ void MenuStateConnectedGame::initFactionPreview(const GameSettings *gameSettings
|
|||
string introVideoFileFallback = factionVideoUrlFallback;
|
||||
|
||||
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
||||
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreen();
|
||||
PlatformContextGl *glCtx = static_cast<ContextGl*>(c)->getPlatformContextGlPtr();
|
||||
SDL_Window *window = glCtx->getScreenWindow();
|
||||
SDL_Surface *screen = glCtx->getScreenSurface();
|
||||
|
||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||
//printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel);
|
||||
|
@ -5043,7 +5045,7 @@ void MenuStateConnectedGame::initFactionPreview(const GameSettings *gameSettings
|
|||
&Renderer::getInstance(),
|
||||
introVideoFile,
|
||||
introVideoFileFallback,
|
||||
screen,
|
||||
window,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
|
|
|
@ -3013,7 +3013,8 @@ void MenuStateCustomGame::initFactionPreview(const GameSettings *gameSettings) {
|
|||
string introVideoFileFallback = factionVideoUrlFallback;
|
||||
|
||||
Context *c= GraphicsInterface::getInstance().getCurrentContext();
|
||||
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreen();
|
||||
SDL_Window *window = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreenWindow();
|
||||
SDL_Surface *screen = static_cast<ContextGl*>(c)->getPlatformContextGlPtr()->getScreenSurface();
|
||||
|
||||
string vlcPluginsPath = Config::getInstance().getString("VideoPlayerPluginsPath","");
|
||||
//printf("screen->w = %d screen->h = %d screen->format->BitsPerPixel = %d\n",screen->w,screen->h,screen->format->BitsPerPixel);
|
||||
|
@ -3021,7 +3022,7 @@ void MenuStateCustomGame::initFactionPreview(const GameSettings *gameSettings) {
|
|||
&Renderer::getInstance(),
|
||||
introVideoFile,
|
||||
introVideoFileFallback,
|
||||
screen,
|
||||
window,
|
||||
0,0,
|
||||
screen->w,
|
||||
screen->h,
|
||||
|
|
|
@ -700,11 +700,11 @@ void MenuStateJoinGame::keyPress(SDL_KeyboardEvent c) {
|
|||
|
||||
//Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||
|
||||
SDLKey key = extractKeyPressed(c);
|
||||
SDL_Keycode key = extractKeyPressed(c);
|
||||
|
||||
//if(c>='0' && c<='9') {
|
||||
if( (key >= SDLK_0 && key <= SDLK_9) ||
|
||||
(key >= SDLK_KP0 && key <= SDLK_KP9)) {
|
||||
(key >= SDLK_KP_0 && key <= SDLK_KP_9)) {
|
||||
if((int)labelServerIp.getText().size() < maxTextSize) {
|
||||
string text= labelServerIp.getText();
|
||||
//text.insert(text.end()-1, key);
|
||||
|
|
|
@ -157,12 +157,12 @@ MenuStateKeysetup::MenuStateKeysetup(Program *program, MainMenu *mainMenu,
|
|||
string keyName = mergedProperties[i].second;
|
||||
if(keyName.length() > 0) {
|
||||
//char c = configKeys.translateStringToCharKey(keyName);
|
||||
SDLKey c = configKeys.translateStringToSDLKey(keyName);
|
||||
if(c > SDLK_UNKNOWN && c < SDLK_LAST) {
|
||||
SDLKey keysym = static_cast<SDLKey>(c);
|
||||
SDL_Keycode c = configKeys.translateStringToSDLKey(keyName);
|
||||
if(c > SDLK_UNKNOWN && c < SDL_NUM_SCANCODES) {
|
||||
SDL_Keycode keysym = static_cast<SDL_Keycode>(c);
|
||||
// SDL skips capital letters
|
||||
if(keysym >= 65 && keysym <= 90) {
|
||||
keysym = (SDLKey)((int)keysym + 32);
|
||||
keysym = (SDL_Keycode)((int)keysym + 32);
|
||||
}
|
||||
keyName = SDL_GetKeyName(keysym);
|
||||
}
|
||||
|
@ -492,7 +492,7 @@ void MenuStateKeysetup::keyDown(SDL_KeyboardEvent key) {
|
|||
//printf("\nkeyDown [%d]\n",hotkeyChar);
|
||||
|
||||
string keyName = "";
|
||||
if(hotkeyChar > SDLK_UNKNOWN && hotkeyChar < SDLK_LAST) {
|
||||
if(hotkeyChar > SDLK_UNKNOWN && hotkeyChar < SDL_NUM_SCANCODES) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] keyName [%s] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,keyName.c_str(),hotkeyChar,key.keysym.sym);
|
||||
keyName = SDL_GetKeyName(hotkeyChar);
|
||||
}
|
||||
|
@ -522,7 +522,7 @@ void MenuStateKeysetup::keyDown(SDL_KeyboardEvent key) {
|
|||
char *utfStr = ConvertToUTF8(&szCharText[0]);
|
||||
|
||||
char szBuf[8096] = "";
|
||||
snprintf(szBuf,8096," %s [%s][%d][%d][%d][%d]",keyName.c_str(),utfStr,key.keysym.sym,hotkeyChar,key.keysym.unicode,key.keysym.mod);
|
||||
snprintf(szBuf,8096," %s [%s][%d][%d][%d]",keyName.c_str(),utfStr,key.keysym.sym,hotkeyChar,key.keysym.mod);
|
||||
labelTestValue.setText(szBuf);
|
||||
|
||||
delete [] utfStr;
|
||||
|
@ -541,7 +541,7 @@ void MenuStateKeysetup::keyUp(SDL_KeyboardEvent key) {
|
|||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] char [%d][%d]\n",__FILE__,__FUNCTION__,__LINE__,hotkeyChar,key.keysym.sym);
|
||||
|
||||
string keyName = "";
|
||||
if(hotkeyChar > SDLK_UNKNOWN && hotkeyChar < SDLK_LAST) {
|
||||
if(hotkeyChar > SDLK_UNKNOWN && hotkeyChar < SDL_NUM_SCANCODES) {
|
||||
keyName = SDL_GetKeyName(hotkeyChar);
|
||||
}
|
||||
key.keysym.sym = hotkeyChar;
|
||||
|
|
|
@ -58,7 +58,7 @@ private:
|
|||
|
||||
int hotkeyIndex;
|
||||
//char hotkeyChar;
|
||||
SDLKey hotkeyChar;
|
||||
SDL_Keycode hotkeyChar;
|
||||
|
||||
GraphicLabel labelTestTitle;
|
||||
GraphicLabel labelTestValue;
|
||||
|
|
|
@ -661,7 +661,6 @@ void MenuStateOptionsGraphics::mouseClick(int x, int y, MouseButton mouseButton)
|
|||
if(gammaValue==0.0f) gammaValue=1.0f;
|
||||
if(gammaValue!=0.0){
|
||||
program->getWindow()->setGamma(gammaValue);
|
||||
SDL_SetGamma(gammaValue, gammaValue, gammaValue);
|
||||
}
|
||||
}
|
||||
if(this->parentUI != NULL) {
|
||||
|
@ -725,7 +724,6 @@ void MenuStateOptionsGraphics::mouseClick(int x, int y, MouseButton mouseButton)
|
|||
float gammaValue=strToFloat(listBoxGammaCorrection.getSelectedItem());
|
||||
if(gammaValue!=0.0){
|
||||
program->getWindow()->setGamma(gammaValue);
|
||||
SDL_SetGamma(gammaValue, gammaValue, gammaValue);
|
||||
}
|
||||
}
|
||||
checkBoxTextures3D.mouseClick(x, y);
|
||||
|
|
|
@ -45,7 +45,8 @@ namespace Shared{ namespace Platform{
|
|||
class PlatformContextGl {
|
||||
protected:
|
||||
SDL_Surface *icon;
|
||||
SDL_Window *screen;
|
||||
SDL_Window *window;
|
||||
SDL_GLContext glcontext;
|
||||
|
||||
public:
|
||||
// Example values:
|
||||
|
@ -69,7 +70,8 @@ public:
|
|||
virtual void makeCurrent();
|
||||
virtual void swapBuffers();
|
||||
|
||||
SDL_Window * getScreen() { return screen; }
|
||||
SDL_Window * getScreenWindow() { return window; }
|
||||
SDL_Surface * getScreenSurface();
|
||||
|
||||
DeviceContextHandle getHandle() const { return 0; }
|
||||
};
|
||||
|
|
|
@ -669,9 +669,9 @@ int mainSetup(int argc, char **argv) {
|
|||
return 3;
|
||||
}
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SDL_EnableUNICODE(1);
|
||||
//SDL_EnableUNICODE(1);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
}
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
return 0;
|
||||
|
|
|
@ -30,14 +30,13 @@ using Shared::Graphics::Vec2i;
|
|||
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||
|
||||
typedef SDL_Keysym SDL_keysym;
|
||||
typedef SDL_Keycode SDLKey;
|
||||
|
||||
#endif
|
||||
|
||||
namespace Shared{ namespace Platform{
|
||||
|
||||
class Timer;
|
||||
class PlatformContextGl;
|
||||
//class PlatformContextGl;
|
||||
|
||||
enum MouseButton {
|
||||
mbUnknown,
|
||||
|
@ -95,7 +94,7 @@ enum WindowStyle{
|
|||
|
||||
class Window {
|
||||
private:
|
||||
SDL_Window *sdlWindow;
|
||||
static SDL_Window *sdlWindow;
|
||||
Uint32 lastMouseDown[mbCount];
|
||||
int lastMouseX[mbCount];
|
||||
int lastMouseY[mbCount];
|
||||
|
@ -130,8 +129,9 @@ protected:
|
|||
static int lastShowMouseState;
|
||||
|
||||
public:
|
||||
static SDL_Window *getSDLWindow();
|
||||
static bool handleEvent();
|
||||
static void revertMousePos(SDL_Window *sdlwindow);
|
||||
static void revertMousePos();
|
||||
static Vec2i getOldMousePos();
|
||||
static bool isKeyDown() { return isKeyPressedDown; }
|
||||
static void setupGraphicsScreen(int depthBits=-1, int stencilBits=-1, bool hardware_acceleration=false, bool fullscreen_anti_aliasing=false);
|
||||
|
@ -141,6 +141,7 @@ public:
|
|||
static bool isKeyStateModPressed(int mod);
|
||||
static wchar_t extractLastKeyPressed();
|
||||
|
||||
Window();
|
||||
Window(SDL_Window *sdlWindow);
|
||||
virtual ~Window();
|
||||
|
||||
|
@ -192,6 +193,9 @@ public:
|
|||
static char getRawKey(SDL_keysym keysym);
|
||||
|
||||
protected:
|
||||
|
||||
void setSDLWindow(SDL_Window *window);
|
||||
|
||||
virtual void eventCreate(){}
|
||||
virtual void eventMouseDown(int x, int y, MouseButton mouseButton){}
|
||||
virtual void eventMouseUp(int x, int y, MouseButton mouseButton){}
|
||||
|
@ -218,16 +222,16 @@ private:
|
|||
static MouseButton getMouseButton(int sdlButton);
|
||||
//static char getKey(SDL_keysym keysym, bool skipSpecialKeys=false);
|
||||
//static char getNormalKey(SDL_keysym keysym,bool skipSpecialKeys=false);
|
||||
static void toggleFullscreen(SDL_Window *sdlwindow);
|
||||
static void toggleFullscreen();
|
||||
|
||||
static wchar_t convertStringtoSDLKey(const string &value);
|
||||
};
|
||||
|
||||
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input, vector<int> modifiersToCheck);
|
||||
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input, bool modifiersAllowed=true);
|
||||
bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input, vector<int> modifiersToCheck);
|
||||
bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input, bool modifiersAllowed=true);
|
||||
|
||||
SDLKey extractKeyPressed(SDL_KeyboardEvent input);
|
||||
bool isAllowedInputTextKey(SDLKey key);
|
||||
SDL_Keycode extractKeyPressed(SDL_KeyboardEvent input);
|
||||
bool isAllowedInputTextKey(SDL_Keycode key);
|
||||
|
||||
wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input);
|
||||
vector<int> extractKeyPressedUnicodeLength(string text);
|
||||
|
|
|
@ -24,17 +24,25 @@ namespace Shared{ namespace Platform{
|
|||
// class WindowGl
|
||||
// =====================================================
|
||||
|
||||
class WindowGl: public Window{
|
||||
class WindowGl: public Window {
|
||||
private:
|
||||
ContextGl context;
|
||||
|
||||
static void setGamma(SDL_Window *window,float gammaValue);
|
||||
public:
|
||||
WindowGl();
|
||||
WindowGl(SDL_Window *sdlWindow);
|
||||
virtual ~WindowGl();
|
||||
|
||||
void initGl(int colorBits, int depthBits, int stencilBits,
|
||||
bool hardware_acceleration, bool fullscreen_anti_aliasing,
|
||||
float gammaValue);
|
||||
void makeCurrentGl();
|
||||
void swapBuffersGl();
|
||||
void setGamma(float gammaValue){context.setGammaValue(gammaValue);}
|
||||
void setGamma(float gammaValue);
|
||||
|
||||
SDL_Window * getScreenWindow();
|
||||
SDL_Surface * getScreenSurface();
|
||||
|
||||
virtual bool ChangeVideoMode(bool preserveContext, int resWidth, int resHeight,
|
||||
bool fullscreenWindow, int colorBits, int depthBits, int stencilBits,
|
||||
|
|
|
@ -2481,7 +2481,7 @@ void ServerSocket::NETdiscoverUPnPDevices() {
|
|||
// WATCH OUT! Because the thread takes void * as a parameter we MUST cast to the pointer type
|
||||
// used on the other side (inside the thread)
|
||||
//printf("STARTING UPNP Thread\n");
|
||||
ServerSocket::upnpdiscoverThread = SDL_CreateThread(&UPNP_Tools::upnp_init, dynamic_cast<UPNPInitInterface *>(this));
|
||||
ServerSocket::upnpdiscoverThread = SDL_CreateThread(&UPNP_Tools::upnp_init, "upnpdiscoverThread", dynamic_cast<UPNPInitInterface *>(this));
|
||||
safeMutexUPNP.ReleaseLock();
|
||||
//printf("In [%s::%s] Line: %d safeMutexUPNP\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ int PlatformContextGl::charSet = 1;
|
|||
PlatformContextGl::PlatformContextGl() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
icon = NULL;
|
||||
screen = NULL;
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
PlatformContextGl::~PlatformContextGl() {
|
||||
|
@ -59,6 +59,10 @@ PlatformContextGl::~PlatformContextGl() {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
SDL_Surface * PlatformContextGl::getScreenSurface() {
|
||||
return SDL_GetWindowSurface(window);
|
||||
}
|
||||
|
||||
void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
||||
bool hardware_acceleration,
|
||||
bool fullscreen_anti_aliasing, float gammaValue) {
|
||||
|
@ -92,20 +96,20 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
|||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to set resolution: %d x %d, colorBits = %d.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,resW,resH,colorBits);
|
||||
|
||||
if(screen != NULL) {
|
||||
SDL_FreeSurface(SDL_GetWindowSurface(screen));
|
||||
screen = NULL;
|
||||
if(window != NULL) {
|
||||
SDL_FreeSurface(getScreenSurface());
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
//screen = SDL_CreateWindow(resW, resH, colorBits, flags);
|
||||
screen = SDL_CreateWindow("MG",
|
||||
window = SDL_CreateWindow("MG",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
resW, resH, flags);
|
||||
|
||||
if(screen == 0) {
|
||||
if(window == 0) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
std::ostringstream msg;
|
||||
|
@ -118,35 +122,37 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg.str().c_str());
|
||||
|
||||
//screen = SDL_SetVideoMode(resW, resH, i, flags);
|
||||
screen = SDL_CreateWindow("MG",
|
||||
window = SDL_CreateWindow("MG",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
resW, resH, flags);
|
||||
|
||||
if(screen == 0) {
|
||||
if(window == 0) {
|
||||
// try to switch to native desktop resolution
|
||||
screen = SDL_CreateWindow("MG",
|
||||
window = SDL_CreateWindow("MG",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
0, 0,
|
||||
SDL_WINDOW_FULLSCREEN_DESKTOP|flags);
|
||||
}
|
||||
if(screen == 0) {
|
||||
if(window == 0) {
|
||||
// try to revert to 640x480
|
||||
screen = SDL_CreateWindow("MG",
|
||||
window = SDL_CreateWindow("MG",
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
SDL_WINDOWPOS_UNDEFINED,
|
||||
650, 480,
|
||||
SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
}
|
||||
if(screen == 0) {
|
||||
if(window == 0) {
|
||||
throw std::runtime_error(msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
glcontext = SDL_GL_CreateContext(window);
|
||||
|
||||
int h;
|
||||
int w;
|
||||
SDL_GetWindowSize(screen, &w, &h);
|
||||
SDL_GetWindowSize(window, &w, &h);
|
||||
glViewport( 0, 0, w, h ) ;
|
||||
|
||||
#ifndef WIN32
|
||||
|
@ -219,7 +225,7 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
|||
printf("Icon Load Error #2: %s\n", SDL_GetError());
|
||||
}
|
||||
else {
|
||||
SDL_SetWindowIcon(screen,icon);
|
||||
SDL_SetWindowIcon(window,icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +263,7 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
|||
if(gammaValue != 0.0) {
|
||||
//printf("Attempting to call SDL_SetGamma using value %f\n", gammaValue);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
if (SDL_SetWindowBrightness(screen, gammaValue) < 0) {
|
||||
if (SDL_SetWindowBrightness(window, gammaValue) < 0) {
|
||||
printf("WARNING, SDL_SetWindowBrightness failed using value %f [%s]\n", gammaValue,SDL_GetError());
|
||||
}
|
||||
}
|
||||
|
@ -281,11 +287,11 @@ void PlatformContextGl::end() {
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
if(screen != NULL) {
|
||||
if(window != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
SDL_DestroyWindow(screen);
|
||||
screen = NULL;
|
||||
SDL_DestroyWindow(window);
|
||||
window = NULL;
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
@ -296,7 +302,7 @@ void PlatformContextGl::makeCurrent() {
|
|||
|
||||
void PlatformContextGl::swapBuffers() {
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
SDL_GL_SwapWindow(screen);
|
||||
SDL_GL_SwapWindow(window);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ Thread::~Thread() {
|
|||
|
||||
if(isThreadExecuteCompleteStatus() == false) {
|
||||
printf("**WARNING** thread destructor will KILL thread [%p]...\n",thread);
|
||||
SDL_KillThread(thread);
|
||||
//SDL_KillThread(thread);
|
||||
}
|
||||
else {
|
||||
SDL_WaitThread(thread, NULL);
|
||||
|
@ -248,7 +248,7 @@ void Thread::start() {
|
|||
BaseThread *base_thread = dynamic_cast<BaseThread *>(this);
|
||||
if(base_thread) base_thread->setStarted(true);
|
||||
|
||||
thread = SDL_CreateThread(beginExecution, this);
|
||||
thread = SDL_CreateThread(beginExecution, base_thread->getUniqueID().c_str(), this);
|
||||
if(thread == NULL) {
|
||||
if(base_thread) base_thread->setStarted(false);
|
||||
|
||||
|
@ -380,7 +380,7 @@ void Thread::queueAutoCleanThread() {
|
|||
|
||||
void Thread::kill() {
|
||||
MutexSafeWrapper safeMutex(mutexthreadAccessor);
|
||||
SDL_KillThread(thread);
|
||||
//SDL_KillThread(thread);
|
||||
thread = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ namespace Shared{ namespace Platform{
|
|||
|
||||
static Window* global_window = 0;
|
||||
static int oldX=0,oldY=0;
|
||||
SDL_Window *Window::sdlWindow = 0;
|
||||
int64 Window::lastMouseEvent = 0; /** for use in mouse hover calculations */
|
||||
Vec2i Window::mousePos;
|
||||
MouseState Window::mouseState;
|
||||
|
@ -79,6 +80,35 @@ static HWND GetSDLWindow()
|
|||
|
||||
#endif
|
||||
|
||||
Window::Window() {
|
||||
this->sdlWindow=0;
|
||||
// Default to 1x1 until set by caller to avoid divide by 0
|
||||
this->w = 1;
|
||||
this->h = 1;
|
||||
|
||||
for(int idx = 0; idx < mbCount; idx++) {
|
||||
lastMouseDown[idx] = 0;
|
||||
lastMouseX[idx] = 0;
|
||||
lastMouseY[idx] = 0;
|
||||
}
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
assert(global_window == 0);
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
global_window = this;
|
||||
Window::isActive = true;
|
||||
|
||||
lastMouseEvent = 0;
|
||||
mousePos = Vec2i(0);
|
||||
mouseState.clear();
|
||||
|
||||
#ifdef WIN32
|
||||
init_win32();
|
||||
#endif
|
||||
}
|
||||
|
||||
Window::Window(SDL_Window *sdlWindow) {
|
||||
this->sdlWindow=sdlWindow;
|
||||
// Default to 1x1 until set by caller to avoid divide by 0
|
||||
|
@ -121,6 +151,13 @@ Window::~Window() {
|
|||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void Window::setSDLWindow(SDL_Window *window) {
|
||||
Window::sdlWindow = window;
|
||||
}
|
||||
SDL_Window *Window::getSDLWindow() {
|
||||
return Window::sdlWindow;
|
||||
}
|
||||
|
||||
bool Window::handleEvent() {
|
||||
string codeLocation = "a";
|
||||
|
||||
|
@ -324,8 +361,8 @@ bool Window::handleEvent() {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Window::revertMousePos(SDL_Window *sdlwindow) {
|
||||
SDL_WarpMouseInWindow( sdlwindow,oldX, oldY);
|
||||
void Window::revertMousePos() {
|
||||
SDL_WarpMouseInWindow(sdlWindow,oldX, oldY);
|
||||
}
|
||||
|
||||
Vec2i Window::getOldMousePos() {
|
||||
|
@ -458,7 +495,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
|
|||
}
|
||||
}
|
||||
|
||||
void Window::toggleFullscreen(SDL_Window *sdlwindow) {
|
||||
void Window::toggleFullscreen() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -466,12 +503,12 @@ void Window::toggleFullscreen(SDL_Window *sdlwindow) {
|
|||
|
||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||
//SDL_Surface *cur_surface = SDL_GetVideoSurface();
|
||||
if(sdlwindow != NULL) {
|
||||
if(sdlWindow != NULL) {
|
||||
if(isFullScreen){
|
||||
SDL_SetWindowFullscreen(sdlwindow,SDL_WINDOW_FULLSCREEN);
|
||||
SDL_SetWindowFullscreen(sdlWindow,SDL_WINDOW_FULLSCREEN);
|
||||
}
|
||||
else {
|
||||
SDL_SetWindowFullscreen(sdlwindow,0);
|
||||
SDL_SetWindowFullscreen(sdlWindow,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -563,13 +600,13 @@ wchar_t Window::convertStringtoSDLKey(const string &value) {
|
|||
|
||||
if(value.length() >= 1) {
|
||||
if(value.length() == 3 && value[0] == '\'' && value[2] == '\'') {
|
||||
result = (SDLKey)value[1];
|
||||
result = (SDL_Keycode)value[1];
|
||||
}
|
||||
else {
|
||||
bool foundKey = false;
|
||||
if(value.length() > 1) {
|
||||
for(int i = SDLK_UNKNOWN; i < SDLK_LAST; ++i) {
|
||||
SDLKey key = static_cast<SDLKey>(i);
|
||||
for(int i = SDLK_UNKNOWN; i < SDL_NUM_SCANCODES; ++i) {
|
||||
SDL_Keycode key = static_cast<SDL_Keycode>(i);
|
||||
string keyName = SDL_GetKeyName(key);
|
||||
if(value == keyName) {
|
||||
result = key;
|
||||
|
@ -580,7 +617,7 @@ wchar_t Window::convertStringtoSDLKey(const string &value) {
|
|||
}
|
||||
|
||||
if(foundKey == false) {
|
||||
result = (SDLKey)value[0];
|
||||
result = (SDL_Keycode)value[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -624,14 +661,14 @@ bool Window::isAllowedKey(wchar_t key) {
|
|||
bool result =(iterFind != mapAllowedKeys.end());
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) {
|
||||
string keyName = SDL_GetKeyName((SDLKey)key);
|
||||
string keyName = SDL_GetKeyName((SDL_Keycode)key);
|
||||
printf("key: %d [%s] allowed result: %d\n",key,keyName.c_str(),result);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllowed) {
|
||||
bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input,bool modifiersAllowed) {
|
||||
vector<int> modifiersToCheck;
|
||||
if(modifiersAllowed == false) {
|
||||
modifiersToCheck.push_back(KMOD_LCTRL);
|
||||
|
@ -643,7 +680,7 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllow
|
|||
bool result = isKeyPressed(compareKey, input, modifiersToCheck);
|
||||
return result;
|
||||
}
|
||||
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,vector<int> modifiersToCheck) {
|
||||
bool isKeyPressed(SDL_Keycode compareKey, SDL_KeyboardEvent input,vector<int> modifiersToCheck) {
|
||||
Uint16 c = SDLK_UNKNOWN;
|
||||
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||
if(input.keysym.sym > 0) {
|
||||
|
@ -739,7 +776,7 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,vector<int> modifie
|
|||
}
|
||||
// SDL does NOT handle lowercase
|
||||
if(compareKey >= 'A' && compareKey <= 'Z') {
|
||||
compareKey = (SDLKey)tolower((char)compareKey);
|
||||
compareKey = (SDL_Keycode)tolower((char)compareKey);
|
||||
}
|
||||
|
||||
bool result = (c == compareKey);
|
||||
|
@ -841,7 +878,7 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,vector<int> modifie
|
|||
}
|
||||
}
|
||||
string compareKeyName = SDL_GetKeyName(compareKey);
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string pressKeyName = SDL_GetKeyName((SDL_Keycode)c);
|
||||
|
||||
//printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result);
|
||||
|
||||
|
@ -880,7 +917,7 @@ wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input) {
|
|||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string pressKeyName = SDL_GetKeyName((SDL_Keycode)c);
|
||||
//string inputKeyName = SDL_GetKeyName(input.keysym.sym);
|
||||
|
||||
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
|
||||
|
@ -920,13 +957,13 @@ vector<int> extractKeyPressedUnicodeLength(string text) {
|
|||
return result;
|
||||
}
|
||||
|
||||
SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
|
||||
SDLKey c = SDLK_UNKNOWN;
|
||||
SDL_Keycode extractKeyPressed(SDL_KeyboardEvent input) {
|
||||
SDL_Keycode c = SDLK_UNKNOWN;
|
||||
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||
if(input.keysym.sym > 0) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.sym = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.sym,input.keysym.mod);
|
||||
|
||||
c = (SDLKey)input.keysym.sym;
|
||||
c = (SDL_Keycode)input.keysym.sym;
|
||||
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
||||
// c = SDLKey(c & 0xFF);
|
||||
// }
|
||||
|
@ -946,7 +983,7 @@ SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
|
|||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string pressKeyName = SDL_GetKeyName((SDL_Keycode)c);
|
||||
//string inputKeyName = SDL_GetKeyName(input.keysym.sym);
|
||||
|
||||
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
|
||||
|
@ -1013,14 +1050,14 @@ bool isAllowedInputTextKey(wchar_t &key) {
|
|||
key != SDLK_MENU &&
|
||||
key != SDLK_POWER);
|
||||
|
||||
string inputKeyName = SDL_GetKeyName((SDLKey)key);
|
||||
string inputKeyName = SDL_GetKeyName((SDL_Keycode)key);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isAllowedInputTextKey(SDLKey key) {
|
||||
bool isAllowedInputTextKey(SDL_Keycode key) {
|
||||
if(Window::isAllowedKey(key) == true) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1117,7 +1154,7 @@ wchar_t Window::extractLastKeyPressed() {
|
|||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||
|
||||
string pressKeyName = SDL_GetKeyName((SDLKey)c);
|
||||
string pressKeyName = SDL_GetKeyName((SDL_Keycode)c);
|
||||
//string inputKeyName = SDL_GetKeyName(keystate.sym);
|
||||
|
||||
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
|
||||
|
|
|
@ -31,6 +31,40 @@ namespace Shared{ namespace Platform{
|
|||
// class WindowGl
|
||||
// =====================================================
|
||||
|
||||
WindowGl::WindowGl() : Window() {
|
||||
}
|
||||
WindowGl::WindowGl(SDL_Window *sdlWindow) : Window(sdlWindow) {
|
||||
}
|
||||
WindowGl::~WindowGl() {
|
||||
}
|
||||
|
||||
void WindowGl::setGamma(SDL_Window *window,float gammaValue) {
|
||||
//SDL_SetGamma(gammaValue, gammaValue, gammaValue);
|
||||
//SDL_SetWindowGammaRamp(getSDLWindow(), gammaValue, gammaValue, gammaValue);
|
||||
gammaValue = clamp(gammaValue, 0.1f, 10.0f);
|
||||
|
||||
Uint16 red_ramp[256];
|
||||
Uint16 green_ramp[256];
|
||||
Uint16 blue_ramp[256];
|
||||
|
||||
SDL_CalculateGammaRamp(gammaValue, red_ramp);
|
||||
SDL_memcpy(green_ramp, red_ramp, sizeof(red_ramp));
|
||||
SDL_memcpy(blue_ramp, red_ramp, sizeof(red_ramp));
|
||||
|
||||
SDL_SetWindowGammaRamp(window, red_ramp, green_ramp, blue_ramp);
|
||||
}
|
||||
void WindowGl::setGamma(float gammaValue) {
|
||||
context.setGammaValue(gammaValue);
|
||||
WindowGl::setGamma(getSDLWindow(),gammaValue);
|
||||
}
|
||||
|
||||
SDL_Window * WindowGl::getScreenWindow() {
|
||||
return context.getPlatformContextGlPtr()->getScreenWindow();
|
||||
}
|
||||
SDL_Surface * WindowGl::getScreenSurface() {
|
||||
return context.getPlatformContextGlPtr()->getScreenSurface();
|
||||
}
|
||||
|
||||
void WindowGl::initGl(int colorBits, int depthBits, int stencilBits,
|
||||
bool hardware_acceleration, bool fullscreen_anti_aliasing,
|
||||
float gammaValue) {
|
||||
|
@ -42,6 +76,7 @@ void WindowGl::initGl(int colorBits, int depthBits, int stencilBits,
|
|||
context.setGammaValue(gammaValue);
|
||||
|
||||
context.init();
|
||||
setSDLWindow(context.getPlatformContextGlPtr()->getScreenWindow());
|
||||
}
|
||||
|
||||
void WindowGl::makeCurrentGl() {
|
||||
|
|
Loading…
Reference in New Issue