mirror of
https://github.com/glest/glest-source.git
synced 2025-08-09 09:56:30 +02:00
first steps for sdl2 ( still many compile errors )
This commit is contained in:
@@ -104,7 +104,7 @@ BREAKPAD_ROOT="$SCRIPTDIR/../../google-breakpad/"
|
|||||||
# by our installers.
|
# by our installers.
|
||||||
# For more cmake/build options refer to
|
# For more cmake/build options refer to
|
||||||
# http://wiki.megaglest.org/Linux_Compiling#Building_using_CMake_by_Hand
|
# http://wiki.megaglest.org/Linux_Compiling#Building_using_CMake_by_Hand
|
||||||
EXTRA_CMAKE_OPTIONS=
|
EXTRA_CMAKE_OPTIONS=-DWANT_USE_SDL2=ON
|
||||||
|
|
||||||
# Build threads
|
# Build threads
|
||||||
# By default we use all physical CPU cores to build.
|
# By default we use all physical CPU cores to build.
|
||||||
|
@@ -298,8 +298,7 @@ void fatal(const char *s, ...) // failure exit
|
|||||||
|
|
||||||
if(errors <= 1) { // avoid recursion
|
if(errors <= 1) { // avoid recursion
|
||||||
if(SDL_WasInit(SDL_INIT_VIDEO)) {
|
if(SDL_WasInit(SDL_INIT_VIDEO)) {
|
||||||
SDL_ShowCursor(1);
|
SDL_SetRelativeMouseMode(SDL_FALSE););
|
||||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
LPWSTR wstr = Ansi2WideString(errText.c_str());
|
LPWSTR wstr = Ansi2WideString(errText.c_str());
|
||||||
|
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct SDL_Surface;
|
struct SDL_Window;
|
||||||
class ctx;
|
class ctx;
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@@ -32,7 +32,7 @@ protected:
|
|||||||
|
|
||||||
string filename;
|
string filename;
|
||||||
string filenameFallback;
|
string filenameFallback;
|
||||||
SDL_Surface *surface;
|
SDL_Window *window;
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int width;
|
int width;
|
||||||
@@ -60,7 +60,7 @@ public:
|
|||||||
VideoPlayer(VideoLoadingCallbackInterface *loadingCB,
|
VideoPlayer(VideoLoadingCallbackInterface *loadingCB,
|
||||||
string filename,
|
string filename,
|
||||||
string filenameFallback,
|
string filenameFallback,
|
||||||
SDL_Surface *surface, int x, int y,
|
SDL_Window *window, int x, int y,
|
||||||
int width, int height, int colorBits,
|
int width, int height, int colorBits,
|
||||||
bool loop, string pluginsPath,bool verboseEnabled=false);
|
bool loop, string pluginsPath,bool verboseEnabled=false);
|
||||||
virtual ~VideoPlayer();
|
virtual ~VideoPlayer();
|
||||||
|
@@ -220,7 +220,7 @@ string extractExtension(const string& filename);
|
|||||||
void getFullscreenVideoModes(vector<ModeInfo> *modeinfos,bool isFullscreen);
|
void getFullscreenVideoModes(vector<ModeInfo> *modeinfos,bool isFullscreen);
|
||||||
void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight,bool isFullscreen);
|
void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight,bool isFullscreen);
|
||||||
void changeVideoModeFullScreen(bool value);
|
void changeVideoModeFullScreen(bool value);
|
||||||
void restoreVideoMode(bool exitingApp=false);
|
void restoreVideoMode(SDL_Window *sdlWindow,bool exitingApp=false);
|
||||||
|
|
||||||
bool StartsWith(const std::string &str, const std::string &key);
|
bool StartsWith(const std::string &str, const std::string &key);
|
||||||
bool EndsWith(const string &str, const string& key);
|
bool EndsWith(const string &str, const string& key);
|
||||||
@@ -241,8 +241,8 @@ off_t getFileSize(string filename);
|
|||||||
bool searchAndReplaceTextInFile(string fileName, string findText, string replaceText, bool simulateOnly);
|
bool searchAndReplaceTextInFile(string fileName, string findText, string replaceText, bool simulateOnly);
|
||||||
void copyFileTo(string fromFileName, string toFileName);
|
void copyFileTo(string fromFileName, string toFileName);
|
||||||
|
|
||||||
int getScreenW();
|
//int getScreenW();
|
||||||
int getScreenH();
|
//int getScreenH();
|
||||||
|
|
||||||
void sleep(int millis);
|
void sleep(int millis);
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ namespace Shared{ namespace Platform{
|
|||||||
class PlatformContextGl {
|
class PlatformContextGl {
|
||||||
protected:
|
protected:
|
||||||
SDL_Surface *icon;
|
SDL_Surface *icon;
|
||||||
SDL_Surface *screen;
|
SDL_Window *screen;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Example values:
|
// Example values:
|
||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
virtual void makeCurrent();
|
virtual void makeCurrent();
|
||||||
virtual void swapBuffers();
|
virtual void swapBuffers();
|
||||||
|
|
||||||
SDL_Surface * getScreen() { return screen; }
|
SDL_Window * getScreen() { return screen; }
|
||||||
|
|
||||||
DeviceContextHandle getHandle() const { return 0; }
|
DeviceContextHandle getHandle() const { return 0; }
|
||||||
};
|
};
|
||||||
|
@@ -44,8 +44,6 @@ enum MouseButton {
|
|||||||
mbLeft,
|
mbLeft,
|
||||||
mbCenter,
|
mbCenter,
|
||||||
mbRight,
|
mbRight,
|
||||||
mbWheelUp,
|
|
||||||
mbWheelDown,
|
|
||||||
mbButtonX1,
|
mbButtonX1,
|
||||||
mbButtonX2,
|
mbButtonX2,
|
||||||
|
|
||||||
@@ -97,6 +95,7 @@ enum WindowStyle{
|
|||||||
|
|
||||||
class Window {
|
class Window {
|
||||||
private:
|
private:
|
||||||
|
SDL_Window *sdlWindow;
|
||||||
Uint32 lastMouseDown[mbCount];
|
Uint32 lastMouseDown[mbCount];
|
||||||
int lastMouseX[mbCount];
|
int lastMouseX[mbCount];
|
||||||
int lastMouseY[mbCount];
|
int lastMouseY[mbCount];
|
||||||
@@ -132,7 +131,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static bool handleEvent();
|
static bool handleEvent();
|
||||||
static void revertMousePos();
|
static void revertMousePos(SDL_Window *sdlwindow);
|
||||||
static Vec2i getOldMousePos();
|
static Vec2i getOldMousePos();
|
||||||
static bool isKeyDown() { return isKeyPressedDown; }
|
static bool isKeyDown() { return isKeyPressedDown; }
|
||||||
static void setupGraphicsScreen(int depthBits=-1, int stencilBits=-1, bool hardware_acceleration=false, bool fullscreen_anti_aliasing=false);
|
static void setupGraphicsScreen(int depthBits=-1, int stencilBits=-1, bool hardware_acceleration=false, bool fullscreen_anti_aliasing=false);
|
||||||
@@ -142,7 +141,7 @@ public:
|
|||||||
static bool isKeyStateModPressed(int mod);
|
static bool isKeyStateModPressed(int mod);
|
||||||
static wchar_t extractLastKeyPressed();
|
static wchar_t extractLastKeyPressed();
|
||||||
|
|
||||||
Window();
|
Window(SDL_Window *sdlWindow);
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
|
|
||||||
static void addAllowedKeys(string keyList);
|
static void addAllowedKeys(string keyList);
|
||||||
@@ -214,11 +213,12 @@ protected:
|
|||||||
private:
|
private:
|
||||||
/// needed to detect double clicks
|
/// needed to detect double clicks
|
||||||
void handleMouseDown(SDL_Event event);
|
void handleMouseDown(SDL_Event event);
|
||||||
|
void handleMouseWheel(SDL_Event event);
|
||||||
|
|
||||||
static MouseButton getMouseButton(int sdlButton);
|
static MouseButton getMouseButton(int sdlButton);
|
||||||
//static char getKey(SDL_keysym keysym, bool skipSpecialKeys=false);
|
//static char getKey(SDL_keysym keysym, bool skipSpecialKeys=false);
|
||||||
//static char getNormalKey(SDL_keysym keysym,bool skipSpecialKeys=false);
|
//static char getNormalKey(SDL_keysym keysym,bool skipSpecialKeys=false);
|
||||||
static void toggleFullscreen();
|
static void toggleFullscreen(SDL_Window *sdlwindow);
|
||||||
|
|
||||||
static wchar_t convertStringtoSDLKey(const string &value);
|
static wchar_t convertStringtoSDLKey(const string &value);
|
||||||
};
|
};
|
||||||
|
@@ -151,12 +151,13 @@ std::pair<SDL_Surface*,unsigned char*> Texture2D::CreateSDLSurface(bool newPixel
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save the alpha blending attributes */
|
// TTSDL
|
||||||
Uint32 savedFlags = result.first->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
|
// /* Save the alpha blending attributes */
|
||||||
Uint8 savedAlpha = result.first->format->alpha;
|
// Uint32 savedFlags = result.first->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
|
||||||
if ( (savedFlags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
|
// Uint8 savedAlpha = result.first->format->alpha;
|
||||||
SDL_SetAlpha(result.first, 0, 0);
|
// if ( (savedFlags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
|
||||||
}
|
// SDL_SetAlpha(result.first, 0, 0);
|
||||||
|
// }
|
||||||
|
|
||||||
SDL_Rect srcArea, destArea;
|
SDL_Rect srcArea, destArea;
|
||||||
/* Copy the surface into the GL texture image */
|
/* Copy the surface into the GL texture image */
|
||||||
@@ -169,10 +170,11 @@ std::pair<SDL_Surface*,unsigned char*> Texture2D::CreateSDLSurface(bool newPixel
|
|||||||
srcArea.h = result.first->h;
|
srcArea.h = result.first->h;
|
||||||
SDL_BlitSurface(result.first, &srcArea, image, &destArea);
|
SDL_BlitSurface(result.first, &srcArea, image, &destArea);
|
||||||
|
|
||||||
/* Restore the alpha blending attributes */
|
// TTSDL
|
||||||
if ((savedFlags & SDL_SRCALPHA) == SDL_SRCALPHA) {
|
// /* Restore the alpha blending attributes */
|
||||||
SDL_SetAlpha(result.first, savedFlags, savedAlpha);
|
// if ((savedFlags & SDL_SRCALPHA) == SDL_SRCALPHA) {
|
||||||
}
|
// SDL_SetAlpha(result.first, savedFlags, savedAlpha);
|
||||||
|
// }
|
||||||
|
|
||||||
/* Turn the image upside-down, because OpenGL textures
|
/* Turn the image upside-down, because OpenGL textures
|
||||||
start at the bottom-left, instead of the top-left
|
start at the bottom-left, instead of the top-left
|
||||||
|
@@ -416,7 +416,7 @@ void callbacks( const libvlc_event_t* event, void* data ) {
|
|||||||
VideoPlayer::VideoPlayer(VideoLoadingCallbackInterface *loadingCB,
|
VideoPlayer::VideoPlayer(VideoLoadingCallbackInterface *loadingCB,
|
||||||
string filename,
|
string filename,
|
||||||
string filenameFallback,
|
string filenameFallback,
|
||||||
SDL_Surface *surface,
|
SDL_Window *window,
|
||||||
int x, int y,int width, int height,int colorBits,
|
int x, int y,int width, int height,int colorBits,
|
||||||
bool loop, string pluginsPath, bool verboseEnabled)
|
bool loop, string pluginsPath, bool verboseEnabled)
|
||||||
: ctxPtr(NULL) {
|
: ctxPtr(NULL) {
|
||||||
@@ -424,7 +424,7 @@ VideoPlayer::VideoPlayer(VideoLoadingCallbackInterface *loadingCB,
|
|||||||
this->loadingCB = loadingCB;
|
this->loadingCB = loadingCB;
|
||||||
this->filename = filename;
|
this->filename = filename;
|
||||||
this->filenameFallback = filenameFallback;
|
this->filenameFallback = filenameFallback;
|
||||||
this->surface = surface;
|
this->window = window;
|
||||||
this->x = x;
|
this->x = x;
|
||||||
this->y = y;
|
this->y = y;
|
||||||
this->width = width;
|
this->width = width;
|
||||||
@@ -919,7 +919,7 @@ bool VideoPlayer::initPlayer(string mediaURL) {
|
|||||||
|
|
||||||
#if !defined(LIBVLC_VERSION_PRE_2) && !defined(LIBVLC_VERSION_PRE_1_1_0)
|
#if !defined(LIBVLC_VERSION_PRE_2) && !defined(LIBVLC_VERSION_PRE_1_1_0)
|
||||||
libvlc_video_set_callbacks(ctxPtr->mp, lock, unlock, display, ctxPtr);
|
libvlc_video_set_callbacks(ctxPtr->mp, lock, unlock, display, ctxPtr);
|
||||||
libvlc_video_set_format(ctxPtr->mp, "RV16", width, height, this->surface->pitch);
|
libvlc_video_set_format(ctxPtr->mp, "RV16", width, height, this->window->pitch);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1229,7 +1229,7 @@ void VideoPlayer::PlayVideo() {
|
|||||||
|
|
||||||
#if !defined(LIBVLC_VERSION_PRE_2) && !defined(LIBVLC_VERSION_PRE_1_1_0)
|
#if !defined(LIBVLC_VERSION_PRE_2) && !defined(LIBVLC_VERSION_PRE_1_1_0)
|
||||||
libvlc_video_set_callbacks(mp, lock, unlock, display, ctxPtr);
|
libvlc_video_set_callbacks(mp, lock, unlock, display, ctxPtr);
|
||||||
libvlc_video_set_format(mp, "RV16", width, height, this->surface->pitch);
|
libvlc_video_set_format(mp, "RV16", width, height, this->window->pitch);
|
||||||
|
|
||||||
// Get an event manager for the media player.
|
// Get an event manager for the media player.
|
||||||
//libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(mp, &ex);
|
//libvlc_event_manager_t *eventManager = libvlc_media_player_event_manager(mp, &ex);
|
||||||
@@ -1355,7 +1355,7 @@ bool VideoPlayer::playFrame(bool swapBuffers) {
|
|||||||
finished = true;
|
finished = true;
|
||||||
break;
|
break;
|
||||||
case SDLK_RETURN:
|
case SDLK_RETURN:
|
||||||
//options ^= SDL_FULLSCREEN;
|
//options ^= SDL_WINDOW_FULLSCREEN;
|
||||||
//screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);
|
//screen = SDL_SetVideoMode(WIDTH, HEIGHT, 0, options);
|
||||||
finished = true;
|
finished = true;
|
||||||
break;
|
break;
|
||||||
@@ -1416,7 +1416,7 @@ bool VideoPlayer::playFrame(bool swapBuffers) {
|
|||||||
glPopAttrib();
|
glPopAttrib();
|
||||||
|
|
||||||
if(swapBuffers == true) {
|
if(swapBuffers == true) {
|
||||||
SDL_GL_SwapBuffers();
|
SDL_GL_SwapWindow(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1539,270 +1539,116 @@ void createDirectoryPaths(string Path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight,bool isFullscreen) {
|
void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight,bool isFullscreen) {
|
||||||
// Get the current video hardware information
|
// TTSDL What does this method do ? I have no clue...
|
||||||
//const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
//
|
||||||
//colorBits = vidInfo->vfmt->BitsPerPixel;
|
// // Get the current video hardware information
|
||||||
//screenWidth = vidInfo->current_w;
|
// //const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
||||||
//screenHeight = vidInfo->current_h;
|
// //colorBits = vidInfo->vfmt->BitsPerPixel;
|
||||||
|
// //screenWidth = vidInfo->current_w;
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
// //screenHeight = vidInfo->current_h;
|
||||||
|
//
|
||||||
/* Get available fullscreen/hardware modes */
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
//
|
||||||
#if defined(WIN32) || defined(__APPLE__)
|
// /* Get available fullscreen/hardware modes */
|
||||||
|
//
|
||||||
int flags = 0;
|
// #if defined(WIN32) || defined(__APPLE__)
|
||||||
|
//
|
||||||
#else
|
// int flags = 0;
|
||||||
|
//
|
||||||
int flags = SDL_RESIZABLE;
|
// #else
|
||||||
|
//
|
||||||
#endif
|
// int flags = SDL_WINDOW_RESIZABLE;
|
||||||
if(isFullscreen) flags = SDL_FULLSCREEN;
|
//
|
||||||
SDL_Rect**modes = SDL_ListModes(NULL, SDL_OPENGL|flags);
|
// #endif
|
||||||
|
// if(isFullscreen) flags = SDL_WINDOW_FULLSCREEN;
|
||||||
/* Check if there are any modes available */
|
// SDL_Rect**modes = SDL_ListModes(NULL, SDL_OPENGL|flags);
|
||||||
if (modes == (SDL_Rect**)0) {
|
//
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] no hardware modes available.\n",__FILE__,__FUNCTION__,__LINE__);
|
// /* Check if there are any modes available */
|
||||||
|
// if (modes == (SDL_Rect**)0) {
|
||||||
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] no hardware modes available.\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
colorBits = vidInfo->vfmt->BitsPerPixel;
|
//
|
||||||
screenWidth = vidInfo->current_w;
|
// const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
||||||
screenHeight = vidInfo->current_h;
|
// colorBits = vidInfo->vfmt->BitsPerPixel;
|
||||||
|
// screenWidth = vidInfo->current_w;
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
// screenHeight = vidInfo->current_h;
|
||||||
}
|
//
|
||||||
/* Check if our resolution is restricted */
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
||||||
else if (modes == (SDL_Rect**)-1) {
|
// }
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] all resolutions available.\n",__FILE__,__FUNCTION__,__LINE__);
|
// /* Check if our resolution is restricted */
|
||||||
|
// else if (modes == (SDL_Rect**)-1) {
|
||||||
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] all resolutions available.\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
colorBits = vidInfo->vfmt->BitsPerPixel;
|
//
|
||||||
screenWidth = vidInfo->current_w;
|
// const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
||||||
screenHeight = vidInfo->current_h;
|
// colorBits = vidInfo->vfmt->BitsPerPixel;
|
||||||
|
// screenWidth = vidInfo->current_w;
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
// screenHeight = vidInfo->current_h;
|
||||||
}
|
//
|
||||||
else{
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
||||||
/* Print valid modes */
|
// }
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] available Modes are:\n",__FILE__,__FUNCTION__,__LINE__);
|
// else{
|
||||||
|
// /* Print valid modes */
|
||||||
int bestW = -1;
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] available Modes are:\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
int bestH = -1;
|
//
|
||||||
for(int i=0; modes[i]; ++i) {
|
// int bestW = -1;
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",modes[i]->w, modes[i]->h);
|
// int bestH = -1;
|
||||||
|
// for(int i=0; modes[i]; ++i) {
|
||||||
if(bestW < modes[i]->w) {
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",modes[i]->w, modes[i]->h);
|
||||||
bestW = modes[i]->w;
|
//
|
||||||
bestH = modes[i]->h;
|
// if(bestW < modes[i]->w) {
|
||||||
}
|
// bestW = modes[i]->w;
|
||||||
}
|
// bestH = modes[i]->h;
|
||||||
|
// }
|
||||||
if(bestW > screenWidth) {
|
// }
|
||||||
screenWidth = bestW;
|
//
|
||||||
screenHeight = bestH;
|
// if(bestW > screenWidth) {
|
||||||
}
|
// screenWidth = bestW;
|
||||||
|
// screenHeight = bestH;
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
// }
|
||||||
}
|
//
|
||||||
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] using current resolution: %d x %d.\n",__FILE__,__FUNCTION__,__LINE__,screenWidth,screenHeight);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void getFullscreenVideoModes(vector<ModeInfo> *modeinfos, bool isFullscreen) {
|
void getFullscreenVideoModes(vector<ModeInfo> *modeinfos, bool isFullscreen) {
|
||||||
// Get the current video hardware information
|
// Get the current video hardware information
|
||||||
//const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
//const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
||||||
//colorBits = vidInfo->vfmt->BitsPerPixel;
|
//colorBits = vidInfo->vfmt->BitsPerPixel;
|
||||||
//screenWidth = vidInfo->current_w;
|
//screenWidth = vidInfo->current_w;
|
||||||
//screenHeight = vidInfo->current_h;
|
//screenHeight = vidInfo->current_h;
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled)
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
SDL_PixelFormat format;
|
SDL_PixelFormat format;
|
||||||
//SDL_Rect **modes;
|
//SDL_Rect **modes;
|
||||||
int loops(0);
|
int loops(0);
|
||||||
int bpp(0);
|
int bpp(0);
|
||||||
std::map<std::string,bool> uniqueResList;
|
std::map<std::string,bool> uniqueResList;
|
||||||
|
|
||||||
do
|
///////////////////////////
|
||||||
{
|
vector<pair<int,int> > allResoltuions;
|
||||||
//format.BitsPerPixel seems to get zeroed out on my windows box
|
SDL_DisplayMode mode = {SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0};
|
||||||
switch(loops)
|
int max=SDL_GetNumDisplayModes(0);
|
||||||
{
|
for (int i = 0; i < max; ++i) {
|
||||||
case 0://32 bpp
|
if(0==SDL_GetDisplayMode(0,i,&mode)) {
|
||||||
format.BitsPerPixel = 32;
|
int bpp;
|
||||||
bpp = 32;
|
Uint32 Rmask;
|
||||||
break;
|
Uint32 Gmask;
|
||||||
case 1://24 bpp
|
Uint32 Bmask;
|
||||||
format.BitsPerPixel = 24;
|
Uint32 Amask;
|
||||||
bpp = 24;
|
SDL_PixelFormatEnumToMasks(mode.format,&bpp,&Rmask,&Gmask,&Bmask,&Amask);
|
||||||
break;
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",allResoltuions[i].first, allResoltuions[i].second,bpp);
|
||||||
case 2://16 bpp
|
string lookupKey = intToStr(mode.w) + "_" + intToStr(mode.h) + "_" + intToStr(bpp);
|
||||||
format.BitsPerPixel = 16;
|
if(uniqueResList.find(lookupKey) == uniqueResList.end()) {
|
||||||
bpp = 16;
|
uniqueResList[lookupKey] = true;
|
||||||
break;
|
modeinfos->push_back(ModeInfo(mode.w,mode.h,bpp));
|
||||||
// case 3://8 bpp
|
}
|
||||||
// format.BitsPerPixel = 8;
|
|
||||||
// bpp = 8;
|
|
||||||
// break;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* Get available fullscreen/hardware modes */
|
//////////////////////////////////
|
||||||
//SDL_Rect**modes = SDL_ListModes(NULL, SDL_OPENGL|SDL_RESIZABLE);
|
std::sort(modeinfos->begin(),modeinfos->end());
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(WIN32) || defined(__APPLE__)
|
|
||||||
|
|
||||||
int flags = 0;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int flags = SDL_RESIZABLE;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
if(isFullscreen) flags = SDL_FULLSCREEN;
|
|
||||||
SDL_Rect**modes = SDL_ListModes(&format, SDL_OPENGL|flags);
|
|
||||||
|
|
||||||
/* Check if there are any modes available */
|
|
||||||
if (modes == (SDL_Rect**)0) {
|
|
||||||
//printf("NO resolutions are usable for format = %d\n",format.BitsPerPixel);
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] no hardware modes available.\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
|
||||||
string lookupKey = intToStr(vidInfo->current_w) + "_" + intToStr(vidInfo->current_h) + "_" + intToStr(vidInfo->vfmt->BitsPerPixel);
|
|
||||||
if(uniqueResList.find(lookupKey) == uniqueResList.end()) {
|
|
||||||
uniqueResList[lookupKey] = true;
|
|
||||||
modeinfos->push_back(ModeInfo(vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel));
|
|
||||||
}
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding only current resolution: %d x %d - %d.\n",__FILE__,__FUNCTION__,__LINE__,vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel);
|
|
||||||
}
|
|
||||||
/* Check if our resolution is restricted */
|
|
||||||
else if (modes == (SDL_Rect**)-1) {
|
|
||||||
//printf("ALL resolutions are usable for format = %d\n",format.BitsPerPixel);
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] all resolutions available.\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
|
|
||||||
string lookupKey = intToStr(vidInfo->current_w) + "_" + intToStr(vidInfo->current_h) + "_" + intToStr(vidInfo->vfmt->BitsPerPixel);
|
|
||||||
if(uniqueResList.find(lookupKey) == uniqueResList.end()) {
|
|
||||||
uniqueResList[lookupKey] = true;
|
|
||||||
modeinfos->push_back(ModeInfo(vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel));
|
|
||||||
}
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding only current resolution: %d x %d - %d.\n",__FILE__,__FUNCTION__,__LINE__,vidInfo->current_w,vidInfo->current_h,vidInfo->vfmt->BitsPerPixel);
|
|
||||||
|
|
||||||
// Lets add these resolutions since sdl said all are supported
|
|
||||||
/*
|
|
||||||
240x160 4:3 GameboyAdvanced
|
|
||||||
256x192 4:3 NintendoDS
|
|
||||||
320x240 4:3 GP2x
|
|
||||||
480x272 ~16:9 PSP
|
|
||||||
480x320 3:2 iPhone
|
|
||||||
640x480 4:3 numerous PDA use this resolution
|
|
||||||
800x480 5:3 ASUS Eee PC, Nokia N800
|
|
||||||
1024x600 ~16:9 ASUS Eee PC 1000
|
|
||||||
1024x768 4:3 common LCD format
|
|
||||||
1200x900 4:3 OLPC
|
|
||||||
1280x1024 5:4 common LCD format
|
|
||||||
1440x900 16:10 common LCD format
|
|
||||||
1680x1050 16:10 common LCD format
|
|
||||||
1600x1200 4:3 common LCD format
|
|
||||||
1366x768 ~16:9 common resolution of HD-TVs, even so its not actually an official HD-TV resolution
|
|
||||||
1368x768 ~16:9 common resolution of HD-TVs, even so its not actually an official HD-TV resolution
|
|
||||||
1920x1200 16:10 common LCD format
|
|
||||||
2560x1600 16:10 30" LCD
|
|
||||||
1280x720 16:9 HD-TV (720p)
|
|
||||||
1920x1080 16:9 HD-TV (1080p)
|
|
||||||
2560x1440 16:9 Apple iMac
|
|
||||||
2560x1600 16:10 Largest Available Consumer Monitor
|
|
||||||
*/
|
|
||||||
|
|
||||||
vector<pair<int,int> > allResoltuions;
|
|
||||||
if(SDL_VideoModeOK(640, 480, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(640, 480));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(800, 480, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(800, 480));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(800, 600, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(800, 600));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(1024, 600, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(1024, 600));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(1024, 768, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(1024, 768));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(1280, 720, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(1280, 720));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(1200, 900, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(1200, 900));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(1280, 1024, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(1280, 1024));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(1440, 900, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(1440, 900));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(1680, 1050, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(1680, 1050));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(1600, 1200, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(1600, 1200));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(1366, 768, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(1366, 768));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(1920, 1080, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(1920, 1080));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(1920, 1200, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(1920, 1200));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(2560, 1600, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(2560, 1600));
|
|
||||||
}
|
|
||||||
if(SDL_VideoModeOK(2560, 1440, bpp, SDL_OPENGL|flags) == bpp) {
|
|
||||||
allResoltuions.push_back(make_pair(2560, 1440));
|
|
||||||
}
|
|
||||||
|
|
||||||
for(unsigned int i=0; i < allResoltuions.size(); ++i) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",allResoltuions[i].first, allResoltuions[i].second,bpp);
|
|
||||||
string lookupKey = intToStr(allResoltuions[i].first) + "_" + intToStr(allResoltuions[i].second) + "_" + intToStr(bpp);
|
|
||||||
if(uniqueResList.find(lookupKey) == uniqueResList.end()) {
|
|
||||||
uniqueResList[lookupKey] = true;
|
|
||||||
modeinfos->push_back(ModeInfo(allResoltuions[i].first, allResoltuions[i].second,bpp));
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding resolution: %d x %d - %d.\n",__FILE__,__FUNCTION__,__LINE__,allResoltuions[i].first, allResoltuions[i].second,bpp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//printf("SOME resolutions are usable for format = %d\n",format.BitsPerPixel);
|
|
||||||
|
|
||||||
/* Print valid modes */
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] available Modes are:\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
for(int i=0; modes[i]; ++i) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"%d x %d\n",modes[i]->w, modes[i]->h,bpp);
|
|
||||||
string lookupKey = intToStr(modes[i]->w) + "_" + intToStr(modes[i]->h) + "_" + intToStr(bpp);
|
|
||||||
if(uniqueResList.find(lookupKey) == uniqueResList.end()) {
|
|
||||||
uniqueResList[lookupKey] = true;
|
|
||||||
modeinfos->push_back(ModeInfo(modes[i]->w,modes[i]->h,bpp));
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding resolution: %d x %d - %d.\n",__FILE__,__FUNCTION__,__LINE__,modes[i]->w,modes[i]->h,bpp);
|
|
||||||
}
|
|
||||||
// fake the missing 16 bit resolutions
|
|
||||||
string lookupKey16 = intToStr(modes[i]->w) + "_" + intToStr(modes[i]->h) + "_" + intToStr(16);
|
|
||||||
if(uniqueResList.find(lookupKey16) == uniqueResList.end()) {
|
|
||||||
uniqueResList[lookupKey16] = true;
|
|
||||||
modeinfos->push_back(ModeInfo(modes[i]->w,modes[i]->h,16));
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] adding resolution: %d x %d - %d.\n",__FILE__,__FUNCTION__,__LINE__,modes[i]->w,modes[i]->h,16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//} while(++loops != 4);
|
|
||||||
} while(++loops != 3);
|
|
||||||
|
|
||||||
std::sort(modeinfos->begin(),modeinfos->end());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1810,22 +1656,21 @@ void changeVideoModeFullScreen(bool value) {
|
|||||||
Private::shouldBeFullscreen = value;
|
Private::shouldBeFullscreen = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void restoreVideoMode(bool exitingApp) {
|
void restoreVideoMode(SDL_Window *sdlWindow,bool exitingApp) {
|
||||||
//SDL_Quit();
|
//SDL_Quit();
|
||||||
if(exitingApp == true && SDL_WasInit(SDL_INIT_VIDEO)) {
|
if(exitingApp == true && SDL_WasInit(SDL_INIT_VIDEO)) {
|
||||||
SDL_ShowCursor(1);
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
SDL_SetWindowBrightness(sdlWindow, 1.0f);
|
||||||
SDL_SetGamma(1, 1, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int getScreenW() {
|
//int getScreenW() {
|
||||||
return SDL_GetVideoSurface()->w;
|
// return SDL_GetVideoSurface()->w; //SDL_GetWindowSurface()
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
int getScreenH() {
|
//int getScreenH() {
|
||||||
return SDL_GetVideoSurface()->h;
|
// return SDL_GetVideoSurface()->h;
|
||||||
}
|
//}
|
||||||
|
|
||||||
void sleep(int millis) {
|
void sleep(int millis) {
|
||||||
SDL_Delay(millis);
|
SDL_Delay(millis);
|
||||||
@@ -1845,7 +1690,7 @@ void showCursor(bool b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//bool isKeyDown(SDLKey key) {
|
//bool isKeyDown(SDLKey key) {
|
||||||
// const Uint8* keystate = SDL_GetKeyState(0);
|
// const Uint8* keystate = SDL_GetKeyboardState(0);
|
||||||
//
|
//
|
||||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
||||||
//
|
//
|
||||||
@@ -1861,7 +1706,7 @@ void showCursor(bool b) {
|
|||||||
|
|
||||||
bool isKeyDown(int virtualKey) {
|
bool isKeyDown(int virtualKey) {
|
||||||
char key = static_cast<char> (virtualKey);
|
char key = static_cast<char> (virtualKey);
|
||||||
const Uint8* keystate = SDL_GetKeyState(0);
|
const Uint8* keystate = SDL_GetKeyboardState(0);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
|
||||||
|
|
||||||
@@ -1871,36 +1716,36 @@ bool isKeyDown(int virtualKey) {
|
|||||||
return (keystate[(unsigned char)key] != 0);
|
return (keystate[(unsigned char)key] != 0);
|
||||||
}
|
}
|
||||||
switch(key) {
|
switch(key) {
|
||||||
case vkAdd:
|
//SDLTT case vkAdd:
|
||||||
return (keystate[SDLK_PLUS] != 0 || keystate[SDLK_KP_PLUS] != 0);
|
// return (keystate[SDL_SCANCODE_PLUS] != 0 || keystate[SDL_SCANCODE_KP_PLUS] != 0);
|
||||||
case vkSubtract:
|
case vkSubtract:
|
||||||
return (keystate[SDLK_MINUS] != 0 || keystate[SDLK_KP_MINUS] != 0);
|
return (keystate[SDL_SCANCODE_MINUS] != 0 || keystate[SDL_SCANCODE_KP_MINUS] != 0);
|
||||||
case vkAlt:
|
case vkAlt:
|
||||||
return (keystate[SDLK_LALT] != 0 || keystate[SDLK_RALT] != 0);
|
return (keystate[SDL_SCANCODE_LALT] != 0 || keystate[SDL_SCANCODE_RALT] != 0);
|
||||||
case vkControl:
|
case vkControl:
|
||||||
return (keystate[SDLK_LCTRL] != 0 || keystate[SDLK_RCTRL] != 0);
|
return (keystate[SDL_SCANCODE_LCTRL] != 0 || keystate[SDL_SCANCODE_RCTRL] != 0);
|
||||||
case vkShift:
|
case vkShift:
|
||||||
return (keystate[SDLK_LSHIFT] != 0 || keystate[SDLK_RSHIFT] != 0);
|
return (keystate[SDL_SCANCODE_LSHIFT] != 0 || keystate[SDL_SCANCODE_RSHIFT] != 0);
|
||||||
case vkEscape:
|
case vkEscape:
|
||||||
return (keystate[SDLK_ESCAPE] != 0);
|
return (keystate[SDL_SCANCODE_ESCAPE] != 0);
|
||||||
case vkUp:
|
case vkUp:
|
||||||
return (keystate[SDLK_UP] != 0);
|
return (keystate[SDL_SCANCODE_UP] != 0);
|
||||||
case vkLeft:
|
case vkLeft:
|
||||||
return (keystate[SDLK_LEFT] != 0);
|
return (keystate[SDL_SCANCODE_LEFT] != 0);
|
||||||
case vkRight:
|
case vkRight:
|
||||||
return (keystate[SDLK_RIGHT] != 0);
|
return (keystate[SDL_SCANCODE_RIGHT] != 0);
|
||||||
case vkDown:
|
case vkDown:
|
||||||
return (keystate[SDLK_DOWN] != 0);
|
return (keystate[SDL_SCANCODE_DOWN] != 0);
|
||||||
case vkReturn:
|
case vkReturn:
|
||||||
return (keystate[SDLK_RETURN] != 0 || keystate[SDLK_KP_ENTER] != 0);
|
return (keystate[SDL_SCANCODE_RETURN] != 0 || keystate[SDL_SCANCODE_KP_ENTER] != 0);
|
||||||
case vkBack:
|
case vkBack:
|
||||||
return (keystate[SDLK_BACKSPACE] != 0);
|
return (keystate[SDL_SCANCODE_BACKSPACE] != 0);
|
||||||
case vkDelete:
|
case vkDelete:
|
||||||
return (keystate[SDLK_DELETE] != 0);
|
return (keystate[SDL_SCANCODE_DELETE] != 0);
|
||||||
case vkPrint:
|
case vkPrint:
|
||||||
return (keystate[SDLK_PRINT] != 0);
|
return (keystate[SDL_SCANCODE_PRINTSCREEN] != 0);
|
||||||
case vkPause:
|
case vkPause:
|
||||||
return (keystate[SDLK_PAUSE] != 0);
|
return (keystate[SDL_SCANCODE_PAUSE] != 0);
|
||||||
default:
|
default:
|
||||||
std::cerr << "isKeyDown called with unknown key.\n";
|
std::cerr << "isKeyDown called with unknown key.\n";
|
||||||
break;
|
break;
|
||||||
|
@@ -73,9 +73,9 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
|||||||
|
|
||||||
//printf("In [%s::%s %d] PlatformCommon::Private::shouldBeFullscreen = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,PlatformCommon::Private::shouldBeFullscreen);
|
//printf("In [%s::%s %d] PlatformCommon::Private::shouldBeFullscreen = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,PlatformCommon::Private::shouldBeFullscreen);
|
||||||
|
|
||||||
int flags = SDL_OPENGL;
|
int flags = SDL_WINDOW_OPENGL;
|
||||||
if(PlatformCommon::Private::shouldBeFullscreen) {
|
if(PlatformCommon::Private::shouldBeFullscreen) {
|
||||||
flags |= SDL_FULLSCREEN;
|
flags |= SDL_WINDOW_FULLSCREEN;
|
||||||
Window::setIsFullScreen(true);
|
Window::setIsFullScreen(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -93,13 +93,18 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
|||||||
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(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) {
|
if(screen != NULL) {
|
||||||
SDL_FreeSurface(screen);
|
SDL_FreeSurface(SDL_GetWindowSurface(screen));
|
||||||
screen = NULL;
|
screen = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("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__);
|
||||||
|
|
||||||
screen = SDL_SetVideoMode(resW, resH, colorBits, flags);
|
//screen = SDL_CreateWindow(resW, resH, colorBits, flags);
|
||||||
|
screen = SDL_CreateWindow("MG",
|
||||||
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
|
resW, resH, flags);
|
||||||
|
|
||||||
if(screen == 0) {
|
if(screen == 0) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("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__);
|
||||||
|
|
||||||
@@ -112,51 +117,37 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
|||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg.str().c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg.str().c_str());
|
||||||
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());
|
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());
|
||||||
|
|
||||||
for(int i = 32; i >= 8; i-=8) {
|
//screen = SDL_SetVideoMode(resW, resH, i, flags);
|
||||||
// try different color bits
|
screen = SDL_CreateWindow("MG",
|
||||||
screen = SDL_SetVideoMode(resW, resH, i, flags);
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
if(screen != 0) {
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
glViewport( 0, 0, resW, resH ) ;
|
resW, resH, flags);
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(screen == 0) {
|
if(screen == 0) {
|
||||||
for(int i = 32; i >= 8; i-=8) {
|
// try to switch to native desktop resolution
|
||||||
// try to revert to 800x600
|
screen = SDL_CreateWindow("MG",
|
||||||
screen = SDL_SetVideoMode(800, 600, i, flags);
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
if(screen != 0) {
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
resW = 800;
|
0, 0,
|
||||||
resH = 600;
|
SDL_WINDOW_FULLSCREEN_DESKTOP|flags);
|
||||||
|
|
||||||
glViewport( 0, 0, resW, resH ) ;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(screen == 0) {
|
if(screen == 0) {
|
||||||
for(int i = 32; i >= 8; i-=8) {
|
// try to revert to 640x480
|
||||||
// try to revert to 640x480
|
screen = SDL_CreateWindow("MG",
|
||||||
screen = SDL_SetVideoMode(640, 480, i, flags);
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
if(screen != 0) {
|
SDL_WINDOWPOS_UNDEFINED,
|
||||||
resW = 640;
|
650, 480,
|
||||||
resH = 480;
|
SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||||
|
|
||||||
glViewport( 0, 0, resW, resH ) ;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(screen == 0) {
|
if(screen == 0) {
|
||||||
throw std::runtime_error(msg.str());
|
throw std::runtime_error(msg.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
glViewport( 0, 0, resW, resH ) ;
|
int h;
|
||||||
//printf("Reset resolution to [%d] x [%d]\n",resW, resH);
|
int w;
|
||||||
}
|
SDL_GetWindowSize(screen, &w, &h);
|
||||||
|
glViewport( 0, 0, w, h ) ;
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
string mg_icon_file = "";
|
string mg_icon_file = "";
|
||||||
@@ -224,18 +215,19 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
|||||||
|
|
||||||
//uint32 colorkey = SDL_MapRGB(icon->format, 255, 0, 255);
|
//uint32 colorkey = SDL_MapRGB(icon->format, 255, 0, 255);
|
||||||
//SDL_SetColorKey(icon, SDL_SRCCOLORKEY, colorkey);
|
//SDL_SetColorKey(icon, SDL_SRCCOLORKEY, colorkey);
|
||||||
if(SDL_SetColorKey(icon, SDL_SRCCOLORKEY, SDL_MapRGB(icon->format, 255, 0, 255))) {
|
if(SDL_SetColorKey(icon, SDL_TRUE, SDL_MapRGB(icon->format, 255, 0, 255))) {
|
||||||
printf("Icon Load Error #2: %s\n", SDL_GetError());
|
printf("Icon Load Error #2: %s\n", SDL_GetError());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_WM_SetIcon(icon, NULL);
|
SDL_SetWindowIcon(screen,icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("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__);
|
||||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
//SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||||
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d] BEFORE glewInit call\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d] BEFORE glewInit call\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
@@ -265,13 +257,15 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,
|
|||||||
if(gammaValue != 0.0) {
|
if(gammaValue != 0.0) {
|
||||||
//printf("Attempting to call SDL_SetGamma using value %f\n", gammaValue);
|
//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(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
if (SDL_SetGamma(gammaValue, gammaValue, gammaValue) < 0) {
|
if (SDL_SetWindowBrightness(screen, gammaValue) < 0) {
|
||||||
printf("WARNING, SDL_SetGamma failed using value %f [%s]\n", gammaValue,SDL_GetError());
|
printf("WARNING, SDL_SetWindowBrightness failed using value %f [%s]\n", gammaValue,SDL_GetError());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_WM_GrabInput(SDL_GRAB_ON);
|
// SDL_WM_GrabInput(SDL_GRAB_ON);
|
||||||
SDL_WM_GrabInput(SDL_GRAB_OFF);
|
// SDL_WM_GrabInput(SDL_GRAB_OFF);
|
||||||
|
SDL_SetRelativeMouseMode(SDL_TRUE);
|
||||||
|
SDL_SetRelativeMouseMode(SDL_FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,7 +284,7 @@ void PlatformContextGl::end() {
|
|||||||
if(screen != NULL) {
|
if(screen != NULL) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
SDL_FreeSurface(screen);
|
SDL_DestroyWindow(screen);
|
||||||
screen = NULL;
|
screen = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +296,7 @@ void PlatformContextGl::makeCurrent() {
|
|||||||
|
|
||||||
void PlatformContextGl::swapBuffers() {
|
void PlatformContextGl::swapBuffers() {
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||||
SDL_GL_SwapBuffers();
|
SDL_GL_SwapWindow(screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -79,7 +79,8 @@ static HWND GetSDLWindow()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Window::Window() {
|
Window::Window(SDL_Window *sdlWindow) {
|
||||||
|
this->sdlWindow=sdlWindow;
|
||||||
// Default to 1x1 until set by caller to avoid divide by 0
|
// Default to 1x1 until set by caller to avoid divide by 0
|
||||||
this->w = 1;
|
this->w = 1;
|
||||||
this->h = 1;
|
this->h = 1;
|
||||||
@@ -157,9 +158,7 @@ bool Window::handleEvent() {
|
|||||||
codeLocation = "f";
|
codeLocation = "f";
|
||||||
|
|
||||||
if(global_window) {
|
if(global_window) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
global_window->handleMouseDown(event);
|
global_window->handleMouseDown(event);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONUP: {
|
case SDL_MOUSEBUTTONUP: {
|
||||||
@@ -174,6 +173,14 @@ bool Window::handleEvent() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SDL_MOUSEWHEEL: {
|
||||||
|
//printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
codeLocation = "g2";
|
||||||
|
if(global_window) {
|
||||||
|
global_window->handleMouseWheel(event);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SDL_MOUSEMOTION: {
|
case SDL_MOUSEMOTION: {
|
||||||
//printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
//MouseState ms;
|
//MouseState ms;
|
||||||
@@ -207,8 +214,8 @@ bool Window::handleEvent() {
|
|||||||
keystate = event.key.keysym;
|
keystate = event.key.keysym;
|
||||||
|
|
||||||
string keyName = SDL_GetKeyName(event.key.keysym.sym);
|
string keyName = SDL_GetKeyName(event.key.keysym.sym);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Raw SDL key [%d - %c] mod [%d] unicode [%d - %c] scancode [%d] keyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.unicode,event.key.keysym.scancode,keyName.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Raw SDL key [%d - %c] mod [%d] scancode [%d] keyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.scancode,keyName.c_str());
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d] keyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode,keyName.c_str());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Raw SDL key [%d] mod [%d] scancode [%d] keyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.scancode,keyName.c_str());
|
||||||
|
|
||||||
/* handle ALT+Return */
|
/* handle ALT+Return */
|
||||||
if((keyName == "return" || keyName == "enter")
|
if((keyName == "return" || keyName == "enter")
|
||||||
@@ -255,7 +262,7 @@ bool Window::handleEvent() {
|
|||||||
|
|
||||||
keystate = event.key.keysym;
|
keystate = event.key.keysym;
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] KEY_UP, Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] KEY_UP, Raw SDL key [%d] mod [%d] scancode [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.scancode);
|
||||||
|
|
||||||
if(global_window) {
|
if(global_window) {
|
||||||
//char key = getKey(event.key.keysym,true);
|
//char key = getKey(event.key.keysym,true);
|
||||||
@@ -266,15 +273,15 @@ bool Window::handleEvent() {
|
|||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYUP ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYUP ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case SDL_ACTIVEEVENT:
|
case SDL_WINDOWEVENT:
|
||||||
{
|
{
|
||||||
// codeLocation = "k";
|
codeLocation = "k";
|
||||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.active.state,event.active.gain);
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.active.state,event.active.gain);
|
||||||
//
|
//
|
||||||
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state);
|
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state);
|
||||||
//
|
//
|
||||||
// // Check if the program has lost window focus
|
// // Check if the program has lost window focus
|
||||||
// if ((event.active.state & SDL_APPACTIVE) == SDL_APPACTIVE) {
|
// if ((event.active.state & (SDL_APPACTIVE | SDL_APPINPUTFOCUS))) {
|
||||||
// if (event.active.gain == 0) {
|
// if (event.active.gain == 0) {
|
||||||
// Window::isActive = false;
|
// Window::isActive = false;
|
||||||
// }
|
// }
|
||||||
@@ -289,47 +296,7 @@ bool Window::handleEvent() {
|
|||||||
// bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
|
// bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
|
||||||
// showCursor(willShowCursor);
|
// showCursor(willShowCursor);
|
||||||
// }
|
// }
|
||||||
// // Check if the program has lost window focus
|
showCursor(true);
|
||||||
// if ((event.active.state & SDL_APPMOUSEFOCUS) != SDL_APPMOUSEFOCUS &&
|
|
||||||
// (event.active.state & SDL_APPINPUTFOCUS) != SDL_APPINPUTFOCUS &&
|
|
||||||
// (event.active.state & SDL_APPACTIVE) != SDL_APPACTIVE) {
|
|
||||||
// if (event.active.gain == 0) {
|
|
||||||
// Window::isActive = false;
|
|
||||||
// }
|
|
||||||
// //else if (event.active.gain == 1) {
|
|
||||||
// else {
|
|
||||||
// Window::isActive = true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive);
|
|
||||||
//
|
|
||||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d, event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state);
|
|
||||||
// bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
|
|
||||||
// showCursor(willShowCursor);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
codeLocation = "k";
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.active.state,event.active.gain);
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state);
|
|
||||||
|
|
||||||
// Check if the program has lost window focus
|
|
||||||
if ((event.active.state & (SDL_APPACTIVE | SDL_APPINPUTFOCUS))) {
|
|
||||||
if (event.active.gain == 0) {
|
|
||||||
Window::isActive = false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Window::isActive = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive);
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive);
|
|
||||||
|
|
||||||
bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
|
|
||||||
showCursor(willShowCursor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -357,8 +324,8 @@ bool Window::handleEvent() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::revertMousePos() {
|
void Window::revertMousePos(SDL_Window *sdlwindow) {
|
||||||
SDL_WarpMouse(oldX, oldY);
|
SDL_WarpMouseInWindow( sdlwindow,oldX, oldY);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec2i Window::getOldMousePos() {
|
Vec2i Window::getOldMousePos() {
|
||||||
@@ -366,8 +333,9 @@ Vec2i Window::getOldMousePos() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string Window::getText() {
|
string Window::getText() {
|
||||||
char* c = 0;
|
const char* c = 0;
|
||||||
SDL_WM_GetCaption(&c, 0);
|
//SDL_WM_GetCaption(&c, 0);
|
||||||
|
c=SDL_GetWindowTitle(sdlWindow);
|
||||||
|
|
||||||
return string(c);
|
return string(c);
|
||||||
}
|
}
|
||||||
@@ -378,7 +346,8 @@ float Window::getAspect() {
|
|||||||
|
|
||||||
void Window::setText(string text) {
|
void Window::setText(string text) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("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__);
|
||||||
SDL_WM_SetCaption(text.c_str(), 0);
|
//SDL_WM_SetCaption(text.c_str(), 0);
|
||||||
|
SDL_SetWindowTitle(sdlWindow,text.c_str());
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("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__);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +440,8 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
|
|||||||
#ifdef SDL_GL_SWAP_CONTROL
|
#ifdef SDL_GL_SWAP_CONTROL
|
||||||
if(Window::tryVSynch == true) {
|
if(Window::tryVSynch == true) {
|
||||||
/* we want vsync for smooth scrolling */
|
/* we want vsync for smooth scrolling */
|
||||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
|
//SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
|
||||||
|
SDL_GL_SetSwapInterval(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -488,146 +458,52 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::toggleFullscreen() {
|
void Window::toggleFullscreen(SDL_Window *sdlwindow) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
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__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
Window::isFullScreen = !Window::isFullScreen;
|
Window::isFullScreen = !Window::isFullScreen;
|
||||||
#ifdef WIN32
|
|
||||||
/* -- Portable Fullscreen Toggling --
|
|
||||||
As of SDL 1.2.10, if width and height are both 0, SDL_SetVideoMode will use the
|
|
||||||
width and height of the current video mode (or the desktop mode, if no mode has been set).
|
|
||||||
Use 0 for Height, Width, and Color Depth to keep the current values. */
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||||
|
//SDL_Surface *cur_surface = SDL_GetVideoSurface();
|
||||||
if(Window::allowAltEnterFullscreenToggle == true) {
|
if(sdlwindow != NULL) {
|
||||||
|
if(isFullScreen){
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
SDL_SetWindowFullscreen(sdlwindow,SDL_WINDOW_FULLSCREEN);
|
||||||
|
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
SDL_Surface *cur_surface = SDL_GetVideoSurface();
|
|
||||||
if(cur_surface != NULL) {
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
Window::isFullScreen = !((cur_surface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
SDL_SetWindowFullscreen(sdlwindow,0);
|
||||||
SDL_Surface *sf = SDL_GetVideoSurface();
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
SDL_Surface **surface = &sf;
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
uint32 *flags = NULL;
|
|
||||||
//void *pixels = NULL;
|
|
||||||
//SDL_Color *palette = NULL;
|
|
||||||
SDL_Rect clip;
|
|
||||||
//int ncolors = 0;
|
|
||||||
Uint32 tmpflags = 0;
|
|
||||||
int w = 0;
|
|
||||||
int h = 0;
|
|
||||||
int bpp = 0;
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
if ( (!surface) || (!(*surface)) ) // don't bother if there's no surface.
|
|
||||||
return;
|
|
||||||
|
|
||||||
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 %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
tmpflags = (*surface)->flags;
|
|
||||||
w = (*surface)->w;
|
|
||||||
h = (*surface)->h;
|
|
||||||
bpp = (*surface)->format->BitsPerPixel;
|
|
||||||
|
|
||||||
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 %d]\n w = %d, h = %d, bpp = %d",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,w,h,bpp);
|
|
||||||
|
|
||||||
if (flags == NULL) // use the surface's flags.
|
|
||||||
flags = &tmpflags;
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
//
|
|
||||||
if ( *flags & SDL_FULLSCREEN )
|
|
||||||
*flags &= ~SDL_FULLSCREEN;
|
|
||||||
//
|
|
||||||
else
|
|
||||||
*flags |= SDL_FULLSCREEN;
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
SDL_GetClipRect(*surface, &clip);
|
|
||||||
|
|
||||||
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 %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
*surface = SDL_SetVideoMode(w, h, bpp, (*flags));
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
if (*surface == NULL) {
|
|
||||||
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 %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
*surface = SDL_SetVideoMode(w, h, bpp, tmpflags);
|
|
||||||
} // if
|
|
||||||
|
|
||||||
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 %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
SDL_SetClipRect(*surface, &clip);
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
HWND handle = GetSDLWindow();
|
|
||||||
if(Window::isFullScreen == true) {
|
|
||||||
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 %d] Window::isFullScreen == true [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,handle);
|
|
||||||
ShowWindow(handle, SW_MAXIMIZE);
|
|
||||||
//if(Window::getUseDefaultCursorOnly() == false) {
|
|
||||||
// showCursor(false);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
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 %d] Window::isFullScreen == false [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,handle);
|
|
||||||
ShowWindow(handle, SW_RESTORE);
|
|
||||||
//showCursor(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("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__);
|
|
||||||
|
|
||||||
#else
|
|
||||||
if(Window::allowAltEnterFullscreenToggle == true) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
|
||||||
SDL_Surface *cur_surface = SDL_GetVideoSurface();
|
|
||||||
if(cur_surface != NULL) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
SDL_WM_ToggleFullScreen(cur_surface);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("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__);
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::handleMouseWheel(SDL_Event event) {
|
||||||
|
int x;
|
||||||
|
int y;
|
||||||
|
|
||||||
|
if (event.type != SDL_MOUSEWHEEL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled)
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
SDL_GetMouseState(&x, &y);
|
||||||
|
|
||||||
|
// // windows implementation uses 120 for the resolution of a standard mouse
|
||||||
|
// // wheel notch. However, newer mice have finer resolutions. I dunno if SDL
|
||||||
|
// // handles those, but for now we're going to say that each mouse wheel
|
||||||
|
// // movement is 120.
|
||||||
|
eventMouseWheel(x, y, event.wheel.y * 120);
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled)
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Window::handleMouseDown(SDL_Event event) {
|
void Window::handleMouseDown(SDL_Event event) {
|
||||||
static const Uint32 DOUBLECLICKTIME = 500;
|
static const Uint32 DOUBLECLICKTIME = 500;
|
||||||
|
|
||||||
@@ -635,24 +511,6 @@ void Window::handleMouseDown(SDL_Event event) {
|
|||||||
|
|
||||||
MouseButton button = getMouseButton(event.button.button);
|
MouseButton button = getMouseButton(event.button.button);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
// windows implementation uses 120 for the resolution of a standard mouse
|
|
||||||
// wheel notch. However, newer mice have finer resolutions. I dunno if SDL
|
|
||||||
// handles those, but for now we're going to say that each mouse wheel
|
|
||||||
// movement is 120.
|
|
||||||
if(button == mbWheelUp) {
|
|
||||||
//printf("button == mbWheelUp\n");
|
|
||||||
eventMouseWheel(event.button.x, event.button.y, 120);
|
|
||||||
return;
|
|
||||||
} else if(button == mbWheelDown) {
|
|
||||||
//printf("button == mbWheelDown\n");
|
|
||||||
eventMouseWheel(event.button.x, event.button.y, -120);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
Uint32 ticks = SDL_GetTicks();
|
Uint32 ticks = SDL_GetTicks();
|
||||||
int n = (int) button;
|
int n = (int) button;
|
||||||
|
|
||||||
@@ -692,10 +550,6 @@ MouseButton Window::getMouseButton(int sdlButton) {
|
|||||||
return mbRight;
|
return mbRight;
|
||||||
case SDL_BUTTON_MIDDLE:
|
case SDL_BUTTON_MIDDLE:
|
||||||
return mbCenter;
|
return mbCenter;
|
||||||
case SDL_BUTTON_WHEELUP:
|
|
||||||
return mbWheelUp;
|
|
||||||
case SDL_BUTTON_WHEELDOWN:
|
|
||||||
return mbWheelDown;
|
|
||||||
default:
|
default:
|
||||||
//throw std::runtime_error("Mouse Button > 3 not handled.");
|
//throw std::runtime_error("Mouse Button > 3 not handled.");
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Mouse Button [%d] not handled.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,sdlButton);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Mouse Button [%d] not handled.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,sdlButton);
|
||||||
@@ -792,74 +646,86 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllow
|
|||||||
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,vector<int> modifiersToCheck) {
|
bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,vector<int> modifiersToCheck) {
|
||||||
Uint16 c = SDLK_UNKNOWN;
|
Uint16 c = SDLK_UNKNOWN;
|
||||||
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||||
if(input.keysym.unicode > 0) {
|
if(input.keysym.sym > 0) {
|
||||||
string unicodeKeyName = SDL_GetKeyName((SDLKey)input.keysym.unicode);
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str());
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str());
|
|
||||||
|
|
||||||
// When modifiers are pressed the unicode result is wrong
|
|
||||||
// example CTRL-3 will give the ESCAPE vslue 27 in unicode
|
|
||||||
if( !(input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) &&
|
|
||||||
!(input.keysym.mod & (KMOD_LALT | KMOD_RALT)) &&
|
|
||||||
!(input.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) ) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
c = input.keysym.unicode;
|
|
||||||
//c = toupper(c);
|
|
||||||
}
|
|
||||||
else if((input.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) &&
|
|
||||||
(input.keysym.unicode == SDLK_QUESTION ||
|
|
||||||
input.keysym.unicode == SDLK_AT ||
|
|
||||||
input.keysym.unicode == SDLK_COLON ||
|
|
||||||
input.keysym.unicode == SDLK_LESS ||
|
|
||||||
input.keysym.unicode == SDLK_GREATER ||
|
|
||||||
input.keysym.unicode == SDLK_CARET ||
|
|
||||||
input.keysym.unicode == SDLK_UNDERSCORE ||
|
|
||||||
input.keysym.unicode == SDLK_BACKQUOTE ||
|
|
||||||
input.keysym.unicode == SDLK_EXCLAIM ||
|
|
||||||
input.keysym.unicode == SDLK_QUOTEDBL ||
|
|
||||||
input.keysym.unicode == SDLK_HASH ||
|
|
||||||
input.keysym.unicode == SDLK_DOLLAR ||
|
|
||||||
input.keysym.unicode == SDLK_AMPERSAND ||
|
|
||||||
input.keysym.unicode == SDLK_QUOTE ||
|
|
||||||
input.keysym.unicode == SDLK_LEFTPAREN ||
|
|
||||||
input.keysym.unicode == SDLK_RIGHTPAREN ||
|
|
||||||
input.keysym.unicode == SDLK_ASTERISK ||
|
|
||||||
input.keysym.unicode == SDLK_KP_MULTIPLY ||
|
|
||||||
input.keysym.unicode == SDLK_PLUS ||
|
|
||||||
input.keysym.unicode == SDLK_COMMA ||
|
|
||||||
input.keysym.unicode == SDLK_MINUS ||
|
|
||||||
input.keysym.unicode == SDLK_PERIOD ||
|
|
||||||
input.keysym.unicode == SDLK_SLASH ||
|
|
||||||
// Need to allow Shift + # key for AZERTY style keyboards
|
|
||||||
(input.keysym.unicode >= SDLK_0 && input.keysym.unicode <= SDLK_9))) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
c = input.keysym.unicode;
|
|
||||||
}
|
|
||||||
else if(input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
if( (input.keysym.unicode >= SDLK_0 && input.keysym.unicode <= SDLK_9) ||
|
|
||||||
(input.keysym.unicode >= SDLK_KP0 && input.keysym.unicode <= SDLK_KP9)) {
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
|
||||||
|
|
||||||
c = input.keysym.unicode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
|
|
||||||
}
|
|
||||||
//if(c == 0) {
|
|
||||||
if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
|
||||||
c = input.keysym.sym;
|
c = input.keysym.sym;
|
||||||
}
|
}
|
||||||
|
//// string unicodeKeyName = SDL_GetKeyName((SDLKey)input.keysym.unicode);
|
||||||
|
////
|
||||||
|
//// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str());
|
||||||
|
//// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str());
|
||||||
|
//
|
||||||
|
// // When modifiers are pressed the unicode result is wrong
|
||||||
|
// // example CTRL-3 will give the ESCAPE vslue 27 in unicode
|
||||||
|
// if( !(input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) &&
|
||||||
|
// !(input.keysym.mod & (KMOD_LALT | KMOD_RALT)) &&
|
||||||
|
// !(input.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) ) {
|
||||||
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
//
|
||||||
|
// c = input.keysym.sym;
|
||||||
|
// //c = toupper(c);
|
||||||
|
// }
|
||||||
|
// else if((input.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) &&
|
||||||
|
// (input.keysym.sym == SDLK_QUESTION ||
|
||||||
|
// input.keysym.sym == SDLK_AT ||
|
||||||
|
// input.keysym.sym == SDLK_COLON ||
|
||||||
|
// input.keysym.sym == SDLK_LESS ||
|
||||||
|
// input.keysym.sym == SDLK_GREATER ||
|
||||||
|
// input.keysym.sym == SDLK_CARET ||
|
||||||
|
// input.keysym.sym == SDLK_UNDERSCORE ||
|
||||||
|
// input.keysym.sym == SDLK_BACKQUOTE ||
|
||||||
|
// input.keysym.sym == SDLK_EXCLAIM ||
|
||||||
|
// input.keysym.sym == SDLK_QUOTEDBL ||
|
||||||
|
// input.keysym.sym == SDLK_HASH ||
|
||||||
|
// input.keysym.sym == SDLK_DOLLAR ||
|
||||||
|
// input.keysym.sym == SDLK_AMPERSAND ||
|
||||||
|
// input.keysym.sym == SDLK_QUOTE ||
|
||||||
|
// input.keysym.sym == SDLK_LEFTPAREN ||
|
||||||
|
// input.keysym.sym == SDLK_RIGHTPAREN ||
|
||||||
|
// input.keysym.sym == SDLK_ASTERISK ||
|
||||||
|
// input.keysym.sym == SDLK_KP_MULTIPLY ||
|
||||||
|
// input.keysym.sym == SDLK_PLUS ||
|
||||||
|
// input.keysym.sym == SDLK_COMMA ||
|
||||||
|
// input.keysym.sym == SDLK_MINUS ||
|
||||||
|
// input.keysym.sym == SDLK_PERIOD ||
|
||||||
|
// input.keysym.sym == SDLK_SLASH ||
|
||||||
|
// // Need to allow Shift + # key for AZERTY style keyboards
|
||||||
|
// input.keysym.sym == SDLK_0 ||
|
||||||
|
// input.keysym.sym == SDLK_1 ||
|
||||||
|
// input.keysym.sym == SDLK_2 ||
|
||||||
|
// input.keysym.sym == SDLK_3 ||
|
||||||
|
// input.keysym.sym == SDLK_4 ||
|
||||||
|
// input.keysym.sym == SDLK_5 ||
|
||||||
|
// input.keysym.sym == SDLK_6 ||
|
||||||
|
// input.keysym.sym == SDLK_7 ||
|
||||||
|
// input.keysym.sym == SDLK_8 ||
|
||||||
|
// input.keysym.sym == SDLK_9
|
||||||
|
// )) {
|
||||||
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
//
|
||||||
|
// c = input.keysym.sym;
|
||||||
|
// }
|
||||||
|
// else if(input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
|
||||||
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
//
|
||||||
|
// if( (input.keysym.sym >= SDLK_0 && input.keysym.sym <= SDLK_9) ||
|
||||||
|
// (input.keysym.sym >= SDLK_KP_0 && input.keysym.sym <= SDLK_KP_9)) {
|
||||||
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
//
|
||||||
|
// c = input.keysym.sym;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
|
||||||
|
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
|
||||||
|
// }
|
||||||
|
// //if(c == 0) {
|
||||||
|
// if(c <= SDLK_UNKNOWN.sym || c >= SDLK_LAST.sym) {
|
||||||
|
// c = input.keysym.sym;
|
||||||
|
// }
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||||
|
|
||||||
@@ -896,67 +762,67 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,vector<int> modifie
|
|||||||
else if( compareKey >= SDLK_0 && compareKey <= SDLK_9) {
|
else if( compareKey >= SDLK_0 && compareKey <= SDLK_9) {
|
||||||
switch(compareKey) {
|
switch(compareKey) {
|
||||||
case SDLK_0:
|
case SDLK_0:
|
||||||
result = (c == SDLK_KP0);
|
result = (c == SDLK_KP_0);
|
||||||
break;
|
break;
|
||||||
case SDLK_1:
|
case SDLK_1:
|
||||||
result = (c == SDLK_KP1);
|
result = (c == SDLK_KP_1);
|
||||||
break;
|
break;
|
||||||
case SDLK_2:
|
case SDLK_2:
|
||||||
result = (c == SDLK_KP2);
|
result = (c == SDLK_KP_2);
|
||||||
break;
|
break;
|
||||||
case SDLK_3:
|
case SDLK_3:
|
||||||
result = (c == SDLK_KP3);
|
result = (c == SDLK_KP_3);
|
||||||
break;
|
break;
|
||||||
case SDLK_4:
|
case SDLK_4:
|
||||||
result = (c == SDLK_KP4);
|
result = (c == SDLK_KP_4);
|
||||||
break;
|
break;
|
||||||
case SDLK_5:
|
case SDLK_5:
|
||||||
result = (c == SDLK_KP5);
|
result = (c == SDLK_KP_5);
|
||||||
break;
|
break;
|
||||||
case SDLK_6:
|
case SDLK_6:
|
||||||
result = (c == SDLK_KP6);
|
result = (c == SDLK_KP_6);
|
||||||
break;
|
break;
|
||||||
case SDLK_7:
|
case SDLK_7:
|
||||||
result = (c == SDLK_KP7);
|
result = (c == SDLK_KP_7);
|
||||||
break;
|
break;
|
||||||
case SDLK_8:
|
case SDLK_8:
|
||||||
result = (c == SDLK_KP8);
|
result = (c == SDLK_KP_8);
|
||||||
break;
|
break;
|
||||||
case SDLK_9:
|
case SDLK_9:
|
||||||
result = (c == SDLK_KP9);
|
result = (c == SDLK_KP_9);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(compareKey >= SDLK_KP0 && compareKey <= SDLK_KP9) {
|
else if(compareKey >= SDLK_KP_0 && compareKey <= SDLK_KP_9) {
|
||||||
switch(compareKey) {
|
switch(compareKey) {
|
||||||
case SDLK_KP0:
|
case SDLK_KP_0:
|
||||||
result = (c == SDLK_0);
|
result = (c == SDLK_0);
|
||||||
break;
|
break;
|
||||||
case SDLK_KP1:
|
case SDLK_KP_1:
|
||||||
result = (c == SDLK_1);
|
result = (c == SDLK_1);
|
||||||
break;
|
break;
|
||||||
case SDLK_KP2:
|
case SDLK_KP_2:
|
||||||
result = (c == SDLK_2);
|
result = (c == SDLK_2);
|
||||||
break;
|
break;
|
||||||
case SDLK_KP3:
|
case SDLK_KP_3:
|
||||||
result = (c == SDLK_3);
|
result = (c == SDLK_3);
|
||||||
break;
|
break;
|
||||||
case SDLK_KP4:
|
case SDLK_KP_4:
|
||||||
result = (c == SDLK_4);
|
result = (c == SDLK_4);
|
||||||
break;
|
break;
|
||||||
case SDLK_KP5:
|
case SDLK_KP_5:
|
||||||
result = (c == SDLK_5);
|
result = (c == SDLK_5);
|
||||||
break;
|
break;
|
||||||
case SDLK_KP6:
|
case SDLK_KP_6:
|
||||||
result = (c == SDLK_6);
|
result = (c == SDLK_6);
|
||||||
break;
|
break;
|
||||||
case SDLK_KP7:
|
case SDLK_KP_7:
|
||||||
result = (c == SDLK_7);
|
result = (c == SDLK_7);
|
||||||
break;
|
break;
|
||||||
case SDLK_KP8:
|
case SDLK_KP_8:
|
||||||
result = (c == SDLK_8);
|
result = (c == SDLK_8);
|
||||||
break;
|
break;
|
||||||
case SDLK_KP9:
|
case SDLK_KP_9:
|
||||||
result = (c == SDLK_9);
|
result = (c == SDLK_9);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -991,10 +857,10 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,vector<int> modifie
|
|||||||
wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input) {
|
wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input) {
|
||||||
wchar_t c = SDLK_UNKNOWN;
|
wchar_t c = SDLK_UNKNOWN;
|
||||||
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||||
if(input.keysym.unicode > 0) {
|
if(input.keysym.sym > 0) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod);
|
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 = input.keysym.unicode;
|
c = input.keysym.sym;
|
||||||
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
||||||
// c = SDLKey(c & 0xFF);
|
// c = SDLKey(c & 0xFF);
|
||||||
// }
|
// }
|
||||||
@@ -1057,10 +923,10 @@ vector<int> extractKeyPressedUnicodeLength(string text) {
|
|||||||
SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
|
SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
|
||||||
SDLKey c = SDLK_UNKNOWN;
|
SDLKey c = SDLK_UNKNOWN;
|
||||||
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||||
if(input.keysym.unicode > 0) {
|
if(input.keysym.sym > 0) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod);
|
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.unicode;
|
c = (SDLKey)input.keysym.sym;
|
||||||
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
||||||
// c = SDLKey(c & 0xFF);
|
// c = SDLKey(c & 0xFF);
|
||||||
// }
|
// }
|
||||||
@@ -1070,7 +936,7 @@ SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
|
|||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
|
||||||
}
|
}
|
||||||
if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
if(c <= SDLK_UNKNOWN) {
|
||||||
c = input.keysym.sym;
|
c = input.keysym.sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1128,24 +994,22 @@ bool isAllowedInputTextKey(wchar_t &key) {
|
|||||||
key != SDLK_F13 &&
|
key != SDLK_F13 &&
|
||||||
key != SDLK_F14 &&
|
key != SDLK_F14 &&
|
||||||
key != SDLK_F15 &&
|
key != SDLK_F15 &&
|
||||||
key != SDLK_NUMLOCK &&
|
key != SDLK_NUMLOCKCLEAR &&
|
||||||
key != SDLK_CAPSLOCK &&
|
key != SDLK_CAPSLOCK &&
|
||||||
key != SDLK_SCROLLOCK &&
|
key != SDLK_SCROLLLOCK &&
|
||||||
key != SDLK_RSHIFT &&
|
key != SDLK_RSHIFT &&
|
||||||
key != SDLK_LSHIFT &&
|
key != SDLK_LSHIFT &&
|
||||||
key != SDLK_RCTRL &&
|
key != SDLK_RCTRL &&
|
||||||
key != SDLK_LCTRL &&
|
key != SDLK_LCTRL &&
|
||||||
key != SDLK_RALT &&
|
key != SDLK_RALT &&
|
||||||
key != SDLK_LALT &&
|
key != SDLK_LALT &&
|
||||||
key != SDLK_RMETA &&
|
key != SDLK_RGUI &&
|
||||||
key != SDLK_LMETA &&
|
key != SDLK_LGUI &&
|
||||||
key != SDLK_LSUPER &&
|
|
||||||
key != SDLK_RSUPER &&
|
|
||||||
key != SDLK_MODE &&
|
key != SDLK_MODE &&
|
||||||
key != SDLK_HELP &&
|
key != SDLK_HELP &&
|
||||||
key != SDLK_PRINT &&
|
key != SDLK_PRINTSCREEN &&
|
||||||
key != SDLK_SYSREQ &&
|
key != SDLK_SYSREQ &&
|
||||||
key != SDLK_BREAK &&
|
key != SDLK_PAUSE &&
|
||||||
key != SDLK_MENU &&
|
key != SDLK_MENU &&
|
||||||
key != SDLK_POWER);
|
key != SDLK_POWER);
|
||||||
|
|
||||||
@@ -1192,24 +1056,22 @@ bool isAllowedInputTextKey(SDLKey key) {
|
|||||||
key != SDLK_F13 &&
|
key != SDLK_F13 &&
|
||||||
key != SDLK_F14 &&
|
key != SDLK_F14 &&
|
||||||
key != SDLK_F15 &&
|
key != SDLK_F15 &&
|
||||||
key != SDLK_NUMLOCK &&
|
key != SDLK_NUMLOCKCLEAR &&
|
||||||
key != SDLK_CAPSLOCK &&
|
key != SDLK_CAPSLOCK &&
|
||||||
key != SDLK_SCROLLOCK &&
|
key != SDLK_SCROLLLOCK &&
|
||||||
key != SDLK_RSHIFT &&
|
key != SDLK_RSHIFT &&
|
||||||
key != SDLK_LSHIFT &&
|
key != SDLK_LSHIFT &&
|
||||||
key != SDLK_RCTRL &&
|
key != SDLK_RCTRL &&
|
||||||
key != SDLK_LCTRL &&
|
key != SDLK_LCTRL &&
|
||||||
key != SDLK_RALT &&
|
key != SDLK_RALT &&
|
||||||
key != SDLK_LALT &&
|
key != SDLK_LALT &&
|
||||||
key != SDLK_RMETA &&
|
key != SDLK_RGUI &&
|
||||||
key != SDLK_LMETA &&
|
key != SDLK_LGUI &&
|
||||||
key != SDLK_LSUPER &&
|
|
||||||
key != SDLK_RSUPER &&
|
|
||||||
key != SDLK_MODE &&
|
key != SDLK_MODE &&
|
||||||
key != SDLK_HELP &&
|
key != SDLK_HELP &&
|
||||||
key != SDLK_PRINT &&
|
key != SDLK_PRINTSCREEN &&
|
||||||
key != SDLK_SYSREQ &&
|
key != SDLK_SYSREQ &&
|
||||||
key != SDLK_BREAK &&
|
key != SDLK_PAUSE &&
|
||||||
key != SDLK_MENU &&
|
key != SDLK_MENU &&
|
||||||
key != SDLK_POWER);
|
key != SDLK_POWER);
|
||||||
|
|
||||||
@@ -1232,10 +1094,10 @@ bool Window::isKeyStateModPressed(int mod) {
|
|||||||
wchar_t Window::extractLastKeyPressed() {
|
wchar_t Window::extractLastKeyPressed() {
|
||||||
wchar_t c = SDLK_UNKNOWN;
|
wchar_t c = SDLK_UNKNOWN;
|
||||||
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
|
||||||
if(keystate.unicode > 0) {
|
if(keystate.sym > 0) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,keystate.unicode,keystate.mod);
|
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__,keystate.sym,keystate.mod);
|
||||||
|
|
||||||
c = keystate.unicode;
|
c = keystate.sym;
|
||||||
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
|
||||||
// c = SDLKey(c & 0xFF);
|
// c = SDLKey(c & 0xFF);
|
||||||
// }
|
// }
|
||||||
|
Reference in New Issue
Block a user