1 /*************************************************************************** 2 winsystem.h - A window managing class 3 ------------------- 4 begin : wo jan 15 2003 5 copyright : (C) 2003 by CJP 6 email : cornware-cjp@users.sourceforge.net 7 ***************************************************************************/ 8 9 /*************************************************************************** 10 * * 11 * This program is free software; you can redistribute it and/or modify * 12 * it under the terms of the GNU General Public License as published by * 13 * the Free Software Foundation; either version 2 of the License, or * 14 * (at your option) any later version. * 15 * * 16 ***************************************************************************/ 17 18 #ifndef WINSYSTEM_H 19 #define WINSYSTEM_H 20 21 #include <vector> //STL vector template 22 namespace std {} 23 using namespace std; 24 25 #include "SDL.h" 26 27 #include "cstring.h" 28 #include "usmacros.h" 29 #include "widget.h" 30 31 /** 32 *@author CJP 33 */ 34 35 class CWinSystem { 36 public: 37 CWinSystem(const CString &caption); 38 virtual ~CWinSystem(); 39 40 int runLoop( bool (CALLBACKFUN *loopfunc)(), bool swp = false); 41 bool runLoop(CWidget *widget); 42 43 virtual bool reloadConfiguration(); 44 45 void swapBuffers(); 46 47 bool getKeyState(int c) const; 48 bool wasPressed(int c); 49 bool joyBtnWasPressed(int js, int c); 50 51 void showMouseCursor(bool show=true); 52 getScreen()53 SDL_Surface *getScreen(){return m_Screen;} 54 getWidth()55 unsigned int getWidth() const 56 {return m_W;} getHeight()57 unsigned int getHeight() const 58 {return m_H;} getBPP()59 unsigned int getBPP() const 60 {return m_BPP;} 61 62 protected: 63 void drawCursor(); 64 65 bool m_OpenGLCursor; 66 67 unsigned int m_W, m_H, m_BPP; 68 bool m_Fullscreen; 69 Uint32 m_Flags; 70 71 unsigned int m_DefaultW, m_DefaultH; 72 73 int m_VisibleTiles; 74 75 SDL_Surface *m_Screen; 76 77 //keyboard 78 Uint8 *m_KeyState; 79 bool *m_WasPressed; 80 int m_NumKeys; 81 82 //joystick 83 struct SJoystick 84 { 85 SDL_Joystick *joystick; 86 unsigned int numButtons; 87 bool *buttonWasPressed; 88 }; 89 vector<SJoystick> m_Joysticks; 90 91 /* 92 Emulation of normal keys for joystick buttons. 93 Actual implementation is only in CGameWinsystem. 94 */ 95 virtual unsigned int getJoystickKeyCode(unsigned int joystick, unsigned int button); 96 virtual unsigned int getJoystickAxisCode(unsigned int joystick, unsigned int axis, bool positive); 97 }; 98 99 extern CWinSystem *theWinSystem; 100 101 #endif 102