OSDN Git Service

[Qt][Win32] Fix compilation errors with msys2, still not working.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Sun, 8 Nov 2015 05:13:09 +0000 (14:13 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Sun, 8 Nov 2015 05:13:09 +0000 (14:13 +0900)
source/src/common.h
source/src/qt/common/emu_input.cpp
source/src/qt/common/emu_utils.cpp
source/src/qt/common/emu_utils.h
source/src/qt/common/qt_gldraw.cpp
source/src/qt/common/qt_glevents.cpp
source/src/qt/common/qt_input.h
source/src/qt/common/qt_main.cpp
source/src/qt/gui/qt_input.cpp

index 76c8394..e02f1e1 100644 (file)
@@ -35,7 +35,7 @@
 #elif defined(_USE_QT)
 #include <SDL.h>
 #include <stdarg.h>
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN32) || defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
 #  include <tchar.h>
 # endif
 # if defined(_USE_QT5)
@@ -79,7 +79,7 @@
 #  ifndef BOOL
    typedef int BOOL;
 #  endif
-# ifndef Q_OS_WIN32
+# if !defined(Q_OS_WIN32) && !defined(Q_OS_WIN) && !defined(Q_OS_CYGWIN)
 #  ifndef BYTE
    typedef uint8_t BYTE;
 #  endif
@@ -163,8 +163,12 @@ static inline char *_tcsncat(_TCHAR *d, _TCHAR *s, int n) {
 #endif
 
 #if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)
+# if defined(Q_OS_CYGWIN)
+# define stricmp(a,b) strcmp(a,b)
+# define strnicmp(a,b,n) strncmp(a,b,n)
+# endif
+# if defined(Q_OS_WIN32) || defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
 
-# if defined(Q_OS_WIN32)
    typedef char    _TCHAR;
 # endif
 static int DeleteFile(_TCHAR *path) 
@@ -191,7 +195,7 @@ static int DeleteFile(_TCHAR *path)
 #endif
 
 #if defined(_USE_AGAR) || defined(_USE_SDL) || defined(_USE_QT)
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN32) || defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
 #  include <tchar.h>
 # endif
 
@@ -434,11 +438,6 @@ typedef uint16 scrntype;
 #  define RGB_COLOR(r, g, b) (((uint32)(r) << 16) | ((uint32)(g) << 8) | ((uint32)(b) << 0))
 typedef uint32 scrntype;
 # elif defined(_RGBA888)
-//#  if defined(USE_BITMAP)
-//#   define RGB_COLOR(r, g, b) (((r | g | b) == 0x00) ? \
-//                                     (((uint32)(r) << 16) | ((uint32)(g) << 8) | ((uint32)(b) << 0)) : \
-//                                     (((uint32)(r) << 16) | ((uint32)(g) << 8) | ((uint32)(b) << 0) | (0x000000ff << 24)))
-//#  else
 #   define RGB_COLOR(r, g, b) (((uint32)(r) << 16) | ((uint32)(g) << 8) | ((uint32)(b) << 0)) | ((uint32)0xff << 24)
 //#  endif
 typedef uint32 scrntype;
@@ -482,7 +481,7 @@ typedef int errno_t;
 # endif
 //errno_t _tfopen_s(FILE** pFile, const _TCHAR *filename, const _TCHAR *mode);
 errno_t _strcpy_s(char *strDestination, size_t numberOfElements, const char *strSource);
-# if !defined(Q_OS_WIN32)
+# if !defined(Q_OS_WIN32) && !defined(Q_OS_WIN) //&& !defined(Q_OS_CYGWIN)
 errno_t _tcscpy_s(_TCHAR *strDestination, size_t numberOfElements, const _TCHAR *strSource);
 _TCHAR *_tcstok_s(_TCHAR *strToken, const char *strDelimit, _TCHAR **context);
 # endif
index a6ddefa..f097cef 100644 (file)
@@ -115,7 +115,7 @@ void EMU::update_input()
                        vm->key_up(VK_SHIFT);
 # endif
                        // check l/r shift
-# if defined(Q_OS_WIN32)                       // 
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)                 // 
                        if(!(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
                        if(!(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
 # else            
@@ -130,7 +130,7 @@ void EMU::update_input()
                        vm->key_up(VK_LSHIFT);
 # endif
                        // check l/r shift
-# if defined(Q_OS_WIN32)                       // 
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)                 // 
                        if(!(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
 # else            
                        if(!(GetAsyncKeyState(VK_LSHIFT, modkey_status) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
@@ -143,7 +143,7 @@ void EMU::update_input()
                        vm->key_up(VK_RSHIFT);
 # endif
                        // check l/r shift
-# if defined(Q_OS_WIN32)                       // 
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)                 // 
                        if(!(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
 # else            
                        if(!(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
@@ -354,7 +354,7 @@ void EMU::key_down(int sym, bool repeat)
        uint8 code = sym;
        if(code == VK_SHIFT){
 #ifndef USE_SHIFT_NUMPAD_KEY
-# if defined(Q_OS_WIN32)                       // 
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)                 // 
                if(GetAsyncKeyState(VK_SHIFT) & 0x8000) {
 # else            
                if(GetAsyncKeyState(VK_SHIFT, modkey_status) & 0x8000) {
@@ -366,7 +366,7 @@ void EMU::key_down(int sym, bool repeat)
 #endif
        } else if(code == VK_LSHIFT){
 #ifndef USE_SHIFT_NUMPAD_KEY
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(GetAsyncKeyState(VK_LSHIFT) & 0x8000) key_status[VK_LSHIFT] = 0x80;
 # else
                if(GetAsyncKeyState(VK_LSHIFT, modkey_status) & 0x8000) key_status[VK_LSHIFT] = 0x80;
@@ -374,14 +374,14 @@ void EMU::key_down(int sym, bool repeat)
 #endif
        } else if(code == VK_RSHIFT){
 #ifndef USE_SHIFT_NUMPAD_KEY
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(GetAsyncKeyState(VK_RSHIFT) & 0x8000) key_status[VK_RSHIFT] = 0x80;
 # else
                if(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000) key_status[VK_RSHIFT] = 0x80;
 # endif           
 #endif
        } else if(code == VK_CONTROL) {
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(GetAsyncKeyState(VK_CONTROL) & 0x8000) {
 # else
                if(GetAsyncKeyState(VK_CONTROL, modkey_status) & 0x8000) {
@@ -391,19 +391,19 @@ void EMU::key_down(int sym, bool repeat)
                        key_status[VK_CONTROL] = 0x80;
                }
        } else if(code == VK_LCONTROL) {
-# if defined(Q_OS_WIN32
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN
                if(GetAsyncKeyState(VK_LCONTROL) & 0x8000) key_status[VK_LCONTROL] = 0x80;
 # else
                if(GetAsyncKeyState(VK_LCONTROL, modkey_status) & 0x8000) key_status[VK_LCONTROL] = 0x80;
 # endif           
        } else if(code == VK_RCONTROL) {
-# if defined(Q_OS_WIN32
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN
                if(GetAsyncKeyState(VK_RCONTROL) & 0x8000) key_status[VK_RCONTROL] = 0x80;
 # else
                if(GetAsyncKeyState(VK_RCONTROL, modkey_status) & 0x8000) key_status[VK_RCONTROL] = 0x80;
 # endif           
        } else if(code == VK_MENU) {
-# if defined(Q_OS_WIN32
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN
                if(GetAsyncKeyState(VK_MENU) & 0x8000) {
 # else
                if(GetAsyncKeyState(VK_MENU, modkey_status) & 0x8000) {
@@ -413,13 +413,13 @@ void EMU::key_down(int sym, bool repeat)
                        key_status[VK_MENU] = 0x80;
                }
        } else if(code == VK_LMENU) {
-# if defined(Q_OS_WIN32)          
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)    
                if(GetAsyncKeyState(VK_LMENU) & 0x8000) key_status[VK_LMENU] = 0x80;
 # else    
                if(GetAsyncKeyState(VK_LMENU, modkey_status) & 0x8000) key_status[VK_LMENU] = 0x80;
 # endif           
        } else if(code == VK_RMENU) {
-# if defined(Q_OS_WIN32)          
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)    
                if(GetAsyncKeyState(VK_RMENU) & 0x8000) key_status[VK_RMENU] = 0x80;
 # else    
                if(GetAsyncKeyState(VK_RMENU, modkey_status) & 0x8000) key_status[VK_RMENU] = 0x80;
@@ -476,7 +476,7 @@ void EMU::key_up(int sym)
        uint8 code = sym;
        if(code == VK_SHIFT) {
 #ifndef USE_SHIFT_NUMPAD_KEY
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(!(GetAsyncKeyState(VK_SHIFT) & 0x8000)) {
 # else            
                if(!(GetAsyncKeyState(VK_SHIFT, modkey_status) & 0x8000)) {
@@ -488,7 +488,7 @@ void EMU::key_up(int sym)
 #endif
        } else if(code == VK_LSHIFT) {
 #ifndef USE_SHIFT_NUMPAD_KEY
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(!(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
 # else            
                if(!(GetAsyncKeyState(VK_LSHIFT, modkey_status) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
@@ -496,14 +496,14 @@ void EMU::key_up(int sym)
 #endif
        } else if(code == VK_RSHIFT) {
 #ifndef USE_SHIFT_NUMPAD_KEY
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(!(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
 # else            
                if(!(GetAsyncKeyState(VK_RSHIFT, modkey_status) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
 # endif           
 #endif
        } else if(code == VK_CONTROL) {
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(!(GetAsyncKeyState(VK_CONTROL) & 0x8000)) {
 # else            
                if(!(GetAsyncKeyState(VK_CONTROL, modkey_status) & 0x8000)) {
@@ -513,19 +513,19 @@ void EMU::key_up(int sym)
                        key_status[VK_CONTROL] &= 0x7f;
                }
        } else if(code == VK_LCONTROL) {
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(!(GetAsyncKeyState(VK_LCONTROL) & 0x8000)) key_status[VK_LCONTROL] &= 0x7f;
 # else            
                if(!(GetAsyncKeyState(VK_LCONTROL, modkey_status) & 0x8000)) key_status[VK_LCONTROL] &= 0x7f;
 # endif                   
        } else if(code == VK_RCONTROL) {
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(!(GetAsyncKeyState(VK_RCONTROL) & 0x8000)) key_status[VK_RCONTROL] &= 0x7f;
 # else            
                if(!(GetAsyncKeyState(VK_RCONTROL, modkey_status) & 0x8000)) key_status[VK_RCONTROL] &= 0x7f;
 # endif           
        } else if(code == VK_MENU) {
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(!(GetAsyncKeyState(VK_MENU) & 0x8000)) {
 # else            
                if(!(GetAsyncKeyState(VK_MENU, modkey_status) & 0x8000)) {
@@ -535,13 +535,13 @@ void EMU::key_up(int sym)
                        key_status[VK_MENU] &= 0x7f;
                }
        } else if(code == VK_LMENU) {
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(!(GetAsyncKeyState(VK_LMENU) & 0x8000)) key_status[VK_LMENU] &= 0x7f;
 # else            
                if(!(GetAsyncKeyState(VK_LMENU, modkey_status) & 0x8000)) key_status[VK_LMENU] &= 0x7f;
 # endif           
        } else if(code == VK_RMENU) {
-# if defined(Q_OS_WIN32)
+# if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
                if(!(GetAsyncKeyState(VK_RMENU) & 0x8000)) key_status[VK_RMENU] &= 0x7f;
 # else            
                if(!(GetAsyncKeyState(VK_RMENU, modkey_status) & 0x8000)) key_status[VK_RMENU] &= 0x7f;
index 1419c18..990f958 100644 (file)
@@ -9,6 +9,7 @@
 
 
 // Belows are Wrappers.
+#if !defined(Q_OS_WIN) && !defined(Q_OS_CYGWIN)
 extern "C" {
    
 
@@ -17,7 +18,7 @@ extern "C" {
        return SDL_GetTicks();
      }
 }
-
+#endif
 
 
 #if defined(USE_FD1) || defined(USE_FD2) || defined(USE_FD3) || defined(USE_FD4) || \
index 6535e57..c95fb6d 100644 (file)
@@ -5,7 +5,7 @@
 #include "emu.h"
 #include "qt_main.h"
 
-#if !defined(Q_OS_WIN32)
+#if !defined(Q_OS_WIN) && !defined(Q_OS_CYGWIN)
 extern "C" {
        extern uint32_t timeGetTime(void);
 }
index 229e91f..51daef1 100644 (file)
@@ -17,7 +17,7 @@
 #include <QRect>
 #endif
 //#include <SDL/SDL.h>
-#if defined(_WINDOWS) || defined(Q_OS_WIN32)
+#if defined(_WINDOWS) || defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
 #include <GL/gl.h>
 #include <GL/glext.h>
 #else
index bfc25c3..73e20d1 100644 (file)
@@ -11,7 +11,7 @@
 #include <QtGui>
 #include <QMouseEvent>
 #include <QApplication>
-#if defined(_WINDOWS) || defined(Q_OS_WIN32)
+#if defined(_WINDOWS) || defined(Q_OS_WIN) || defined(Q_OS_CYGWIN)
 #include <GL/gl.h>
 #include <GL/glext.h>
 #else
index 38d42fe..521073b 100644 (file)
@@ -11,6 +11,7 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
+# if !defined(Q_OS_WIN) && !defined(Q_OS_CYGWIN)
    // Include from gui/drv_wgl_keymaps.h , libagar.
    enum {
        VK_LBUTTON = 0x01,
@@ -150,13 +151,16 @@ extern "C" {
        VK_PA1    = 0xfd,
        VK_OEM_CLEAR = 0xfe, 
 };
-
+# else
+#  if defined(Q_OS_CYGWIN)
+#      include <windows.h>
+#  endif  
+# endif
    
-# if !defined(Q_OS_WIN32)
+# if !defined(Q_OS_WIN) && !defined(Q_OS_CYGWIN)
 uint32_t GetAsyncKeyState(uint32_t vk, uint32_t mod);
-# endif   
+# endif
 uint8_t convert_AGKey2VK(uint32_t sym);
-   
 #ifdef __cplusplus
 }
 #endif
index 687bd75..44de11b 100644 (file)
@@ -1019,11 +1019,12 @@ int main(int argc, char *argv[])
        
        my_procname = "emu";
        my_procname = my_procname + CONFIG_NAME;
-#ifdef _WINDOWS
+#if defined(Q_OS_WIN)
        delim = "\\";
 #else
        delim = "/";
 #endif
+#if !defined(Q_OS_WIN)
        p = SDL_getenv("HOME");
        if(p == NULL) {
                p = SDL_getenv("PWD");
@@ -1038,6 +1039,9 @@ int main(int argc, char *argv[])
        } else {
                cpp_homedir = p;
        }
+#else
+       cpp_homedir = ".";
+#endif 
        cpp_homedir = cpp_homedir + delim;
 #ifdef _WINDOWS
        cpp_confdir = cpp_homedir + my_procname + delim;
@@ -1136,12 +1140,12 @@ int main(int argc, char *argv[])
        AGAR_DebugLog(AGAR_LOG_DEBUG, "Supported SIMD: %s", cpp_simdtype.c_str());
        AGAR_DebugLog(AGAR_LOG_DEBUG, " -? is print help(s).");
        AGAR_DebugLog(AGAR_LOG_DEBUG, "Moduledir = %s home = %s", cpp_confdir.c_str(), cpp_homedir.c_str()); // Debug
-
+#if !defined(Q_OS_CYGWIN)      
        {
                QDir dir;
                dir.mkdir( QString::fromStdString(cpp_confdir));
        }
-   
+#endif   
    //AG_MkPath(cpp_confdir.c_str());
    /* Gettext */
 #ifndef RSSDIR
index 666b0e2..acb077c 100644 (file)
@@ -465,7 +465,7 @@ void GLDrawClass::keyPressEvent(QKeyEvent *event)
                return;
        }
    
-       //printf("Key: DOWN: VK=%d SCAN=%04x MOD=%08x\n", vk, scan, mod);
+       printf("Key: DOWN: VK=%d SCAN=%04x MOD=%08x\n", vk, scan, mod);
        emu->LockVM();
        emu->key_mod(mod);
        if(vk != 0) {
@@ -474,7 +474,7 @@ void GLDrawClass::keyPressEvent(QKeyEvent *event)
        emu->UnlockVM();
 }
 
-#if !defined(Q_OS_WIN32)
+#if !defined(Q_OS_WIN) && !defined(Q_OS_CYGWIN)
 extern "C"{   
 uint32_t GetAsyncKeyState(uint32_t vk, uint32_t mod)
 {