Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Typedefs | Enumerations | Functions | Variables
wsdl.cpp File Reference
#include "precompiled.h"
#include "lib/external_libraries/libsdl.h"
#include <stdio.h>
#include <math.h>
#include <queue>
#include <algorithm>
#include "lib/sysdep/os/win/win.h"
#include <process.h>
#include <WindowsX.h>
#include "lib/module_init.h"
#include "lib/posix/posix_pthread.h"
#include "lib/sysdep/sysdep.h"
#include "lib/sysdep/os/win/wutil.h"
#include "lib/sysdep/os/win/winit.h"
#include "lib/sysdep/os/win/wmi.h"
#include "lib/ogl.h"

Go to the source code of this file.

Classes

class  GammaRamp
 

Typedefs

typedef std::queue< SDL_EventQueue
 

Enumerations

enum  SdlActivationType { LOSE = 0, GAIN = 1 }
 
enum  DefWindowProcDisposition { kSkipDefWindowProc, kRunDefWindowProc }
 

Functions

 WINIT_REGISTER_LATE_INIT (wsdl_Init)
 
 WINIT_REGISTER_EARLY_SHUTDOWN (wsdl_Shutdown)
 
int SDL_SetGamma (float r, float g, float b)
 
static DWORD wnd_ChooseWindowStyle (bool fullscreen, HWND previousWindow=(HWND) INVALID_HANDLE_VALUE)
 
static void wnd_UpdateWindowDimensions (DWORD windowStyle, int &w, int &h)
 
static LRESULT CALLBACK OnMessage (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static HWND wnd_CreateWindow (int w, int h)
 
static RECT ClientRect (HWND hWnd)
 
int SDL_GL_SetAttribute (SDL_GLattr attr, int value)
 
static bool video_NeedsChange (int w, int h, int cur_w, int cur_h, bool fullscreen)
 
static void video_SetPixelFormat (HDC hDC, int bpp)
 
SDL_SurfaceSDL_SetVideoMode (int w, int h, int bpp, Uint32 flags)
 
static void video_Shutdown ()
 
void SDL_GL_SwapBuffers ()
 
SDL_VideoInfoSDL_GetVideoInfo ()
 
SDL_SurfaceSDL_GetVideoSurface ()
 
static void QueueEvent (const SDL_Event &ev)
 
static bool DequeueEvent (SDL_Event &ev)
 
static void QueueKeyEvent (Uint8 type, SDLKey sdlk, WCHAR unicode_char)
 
static void key_Init ()
 
static SDLKey SDLKeyFromVK (int vk)
 
static void key_ResetAll ()
 
static LRESULT OnKey (HWND hWnd, UINT vk, BOOL fDown, int cRepeat, UINT flags)
 
Uint8SDL_GetKeyState (int *num_keys)
 
int SDL_EnableUNICODE (int enable)
 
int SDL_NumJoysticks ()
 
int SDL_JoystickEventState (int state)
 
const char * SDL_JoystickName (int device_index)
 
SDL_JoystickSDL_JoystickOpen (int device_index)
 
int SDL_JoystickNumAxes (SDL_Joystick *joystick)
 
Sint16 SDL_JoystickGetAxis (SDL_Joystick *joystick, int axis)
 
static void QueueActiveEvent (SdlActivationType type, size_t changed_app_state)
 
static void active_ChangeState (SdlActivationType type, Uint8 changed_app_state)
 
static LRESULT OnActivate (HWND hWnd, UINT state, HWND hWndActDeact, BOOL fMinimized)
 
Uint8 SDL_GetAppState ()
 
static void QueueQuitEvent ()
 
static void QueueMouseEvent (int x, int y)
 
static void QueueButtonEvent (int button, int state, int x, int y)
 
static void mouse_UpdatePosition (int x, int y)
 
static POINT mouse_ScreenFromClient (int client_x, int client_y)
 
static bool mouse_GetCoords (int screen_x, int screen_y, int &x, int &y)
 
static void mouse_Update ()
 
static LRESULT OnMouseButton (HWND hWnd, UINT uMsg, int client_x, int client_y, UINT flags)
 
static LRESULT OnMouseWheel (HWND hWnd, int screen_x, int screen_y, int zDelta, UINT fwKeys)
 
Uint8 SDL_GetMouseState (int *x, int *y)
 
void SDL_WarpMouse (int x, int y)
 
int SDL_ShowCursor (int toggle)
 
SDL_GrabMode SDL_WM_GrabInput (SDL_GrabMode mode)
 
static bool ResizeEventEnabled (int clientWidth, int clientHeight)
 
static void OnSize (HWND hWnd, UINT state, int clientWidth, int clientHeight)
 
static BOOL OnEraseBkgnd (HWND hWnd, HDC hDC)
 
static LRESULT OnPaint (HWND hWnd)
 
static LRESULT OnDestroy (HWND hWnd)
 
static DefWindowProcDisposition OnSysCommand (WPARAM wParam)
 
void SDL_PumpEvents ()
 
int SDL_PollEvent (SDL_Event *ev)
 
int SDL_PushEvent (SDL_Event *ev)
 
u16 SDL_Swap16 (const u16 x)
 
u32 SDL_Swap32 (const u32 x)
 
u64 SDL_Swap64 (const u64 x)
 
static HANDLE HANDLE_from_sem (SDL_sem *s)
 
static SDL_semsem_from_HANDLE (HANDLE h)
 
SDL_semSDL_CreateSemaphore (int cnt)
 
void SDL_DestroySemaphore (SDL_sem *sem)
 
int SDL_SemPost (SDL_sem *sem)
 
int SDL_SemWait (SDL_sem *sem)
 
void SDL_WM_SetCaption (const char *title, const char *icon)
 
u32 SDL_GetTicks ()
 
void SDL_Delay (Uint32 ms)
 
void * SDL_GL_GetProcAddress (const char *name)
 
static Status Init ()
 
static void Shutdown ()
 
int SDL_Init (Uint32 flags)
 
int SDL_InitSubSystem (Uint32 flags)
 
void SDL_Quit ()
 
static void RedirectStdout ()
 
static Status wsdl_Init ()
 
static Status wsdl_Shutdown ()
 

Variables

static bool fullscreen
 
static bool is_quitting
 
static HWND g_hWnd = (HWND)INVALID_HANDLE_VALUE
 
static HDC g_hDC = (HDC)INVALID_HANDLE_VALUE
 
static GammaRamp gammaRamp
 
static DEVMODE dm
 
static HGLRC hGLRC = (HGLRC)INVALID_HANDLE_VALUE
 
static int depthBufferBits = 24
 
static int stencilBufferBits = 0
 
static int vsyncEnabled = 1
 
static Queue g_queue
 
static Uint8 keys [SDLK_LAST]
 
static SDLKey g_SDLKeyForVK [256]
 
static Uint8 app_state
 
static int mouse_x
 
static int mouse_y
 
static unsigned mouse_buttons
 
static ModuleInitState initState
 

Typedef Documentation

typedef std::queue<SDL_Event> Queue

Definition at line 519 of file wsdl.cpp.

Enumeration Type Documentation

Enumerator
kSkipDefWindowProc 
kRunDefWindowProc 

Definition at line 1241 of file wsdl.cpp.

Enumerator
LOSE 
GAIN 

Definition at line 760 of file wsdl.cpp.

Function Documentation

static void active_ChangeState ( SdlActivationType  type,
Uint8  changed_app_state 
)
static

Definition at line 780 of file wsdl.cpp.

static RECT ClientRect ( HWND  hWnd)
static

Definition at line 265 of file wsdl.cpp.

static bool DequeueEvent ( SDL_Event ev)
static

Definition at line 527 of file wsdl.cpp.

static HANDLE HANDLE_from_sem ( SDL_sem s)
static

Definition at line 1404 of file wsdl.cpp.

static Status Init ( )
static

Definition at line 1476 of file wsdl.cpp.

static void key_Init ( )
static

Definition at line 555 of file wsdl.cpp.

static void key_ResetAll ( )
static

Definition at line 649 of file wsdl.cpp.

static bool mouse_GetCoords ( int  screen_x,
int  screen_y,
int &  x,
int &  y 
)
static

Definition at line 922 of file wsdl.cpp.

static POINT mouse_ScreenFromClient ( int  client_x,
int  client_y 
)
static

Definition at line 912 of file wsdl.cpp.

static void mouse_Update ( )
static

Definition at line 958 of file wsdl.cpp.

static void mouse_UpdatePosition ( int  x,
int  y 
)
static

Definition at line 901 of file wsdl.cpp.

static LRESULT OnActivate ( HWND  hWnd,
UINT  state,
HWND  hWndActDeact,
BOOL  fMinimized 
)
static

Definition at line 795 of file wsdl.cpp.

static LRESULT OnDestroy ( HWND  hWnd)
static

Definition at line 1220 of file wsdl.cpp.

static BOOL OnEraseBkgnd ( HWND  hWnd,
HDC  hDC 
)
static

Definition at line 1197 of file wsdl.cpp.

static LRESULT OnKey ( HWND  hWnd,
UINT  vk,
BOOL  fDown,
int  cRepeat,
UINT  flags 
)
static

Definition at line 666 of file wsdl.cpp.

static LRESULT CALLBACK OnMessage ( HWND  hWnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1268 of file wsdl.cpp.

static LRESULT OnMouseButton ( HWND  hWnd,
UINT  uMsg,
int  client_x,
int  client_y,
UINT  flags 
)
static

Definition at line 989 of file wsdl.cpp.

static LRESULT OnMouseWheel ( HWND  hWnd,
int  screen_x,
int  screen_y,
int  zDelta,
UINT  fwKeys 
)
static

Definition at line 1068 of file wsdl.cpp.

static LRESULT OnPaint ( HWND  hWnd)
static

Definition at line 1211 of file wsdl.cpp.

static void OnSize ( HWND  hWnd,
UINT  state,
int  clientWidth,
int  clientHeight 
)
static

Definition at line 1184 of file wsdl.cpp.

static DefWindowProcDisposition OnSysCommand ( WPARAM  wParam)
static

Definition at line 1247 of file wsdl.cpp.

static void QueueActiveEvent ( SdlActivationType  type,
size_t  changed_app_state 
)
inlinestatic

Definition at line 762 of file wsdl.cpp.

static void QueueButtonEvent ( int  button,
int  state,
int  x,
int  y 
)
static

Definition at line 881 of file wsdl.cpp.

static void QueueEvent ( const SDL_Event ev)
static

Definition at line 522 of file wsdl.cpp.

static void QueueKeyEvent ( Uint8  type,
SDLKey  sdlk,
WCHAR  unicode_char 
)
static

Definition at line 541 of file wsdl.cpp.

static void QueueMouseEvent ( int  x,
int  y 
)
static

Definition at line 871 of file wsdl.cpp.

static void QueueQuitEvent ( )
static

Definition at line 850 of file wsdl.cpp.

static void RedirectStdout ( )
static

Definition at line 1511 of file wsdl.cpp.

static bool ResizeEventEnabled ( int  clientWidth,
int  clientHeight 
)
static

Definition at line 1150 of file wsdl.cpp.

SDL_sem* SDL_CreateSemaphore ( int  cnt)

Definition at line 1414 of file wsdl.cpp.

void SDL_Delay ( Uint32  ms)

Definition at line 1457 of file wsdl.cpp.

void SDL_DestroySemaphore ( SDL_sem sem)

Definition at line 1420 of file wsdl.cpp.

int SDL_EnableUNICODE ( int  enable)

Definition at line 717 of file wsdl.cpp.

Uint8 SDL_GetAppState ( )

Definition at line 844 of file wsdl.cpp.

Uint8* SDL_GetKeyState ( int *  num_keys)

Definition at line 708 of file wsdl.cpp.

Uint8 SDL_GetMouseState ( int *  x,
int *  y 
)

Definition at line 1083 of file wsdl.cpp.

u32 SDL_GetTicks ( )

Definition at line 1451 of file wsdl.cpp.

SDL_VideoInfo* SDL_GetVideoInfo ( )

Definition at line 484 of file wsdl.cpp.

SDL_Surface* SDL_GetVideoSurface ( )

Definition at line 508 of file wsdl.cpp.

void* SDL_GL_GetProcAddress ( const char *  name)

Definition at line 1463 of file wsdl.cpp.

int SDL_GL_SetAttribute ( SDL_GLattr  attr,
int  value 
)

Definition at line 286 of file wsdl.cpp.

void SDL_GL_SwapBuffers ( )

Definition at line 478 of file wsdl.cpp.

int SDL_Init ( Uint32  flags)

Definition at line 1495 of file wsdl.cpp.

int SDL_InitSubSystem ( Uint32  flags)

Definition at line 1500 of file wsdl.cpp.

int SDL_JoystickEventState ( int  state)

Definition at line 731 of file wsdl.cpp.

Sint16 SDL_JoystickGetAxis ( SDL_Joystick joystick,
int  axis 
)

Definition at line 751 of file wsdl.cpp.

const char* SDL_JoystickName ( int  device_index)

Definition at line 736 of file wsdl.cpp.

int SDL_JoystickNumAxes ( SDL_Joystick joystick)

Definition at line 746 of file wsdl.cpp.

SDL_Joystick* SDL_JoystickOpen ( int  device_index)

Definition at line 741 of file wsdl.cpp.

int SDL_NumJoysticks ( )

Definition at line 726 of file wsdl.cpp.

int SDL_PollEvent ( SDL_Event ev)

Definition at line 1343 of file wsdl.cpp.

void SDL_PumpEvents ( )

Definition at line 1324 of file wsdl.cpp.

int SDL_PushEvent ( SDL_Event ev)

Definition at line 1354 of file wsdl.cpp.

void SDL_Quit ( )

Definition at line 1505 of file wsdl.cpp.

int SDL_SemPost ( SDL_sem sem)

Definition at line 1426 of file wsdl.cpp.

int SDL_SemWait ( SDL_sem sem)

Definition at line 1432 of file wsdl.cpp.

int SDL_SetGamma ( float  r,
float  g,
float  b 
)

Definition at line 180 of file wsdl.cpp.

SDL_Surface* SDL_SetVideoMode ( int  w,
int  h,
int  bpp,
Uint32  flags 
)

Definition at line 372 of file wsdl.cpp.

int SDL_ShowCursor ( int  toggle)

Definition at line 1106 of file wsdl.cpp.

u16 SDL_Swap16 ( const u16  x)

Definition at line 1367 of file wsdl.cpp.

u32 SDL_Swap32 ( const u32  x)

Definition at line 1374 of file wsdl.cpp.

u64 SDL_Swap64 ( const u64  x)

Definition at line 1384 of file wsdl.cpp.

void SDL_WarpMouse ( int  x,
int  y 
)

Definition at line 1093 of file wsdl.cpp.

SDL_GrabMode SDL_WM_GrabInput ( SDL_GrabMode  mode)

Definition at line 1123 of file wsdl.cpp.

void SDL_WM_SetCaption ( const char *  title,
const char *  icon 
)

Definition at line 1442 of file wsdl.cpp.

static SDLKey SDLKeyFromVK ( int  vk)
inlinestatic

Definition at line 638 of file wsdl.cpp.

static SDL_sem* sem_from_HANDLE ( HANDLE  h)
static

Definition at line 1409 of file wsdl.cpp.

static void Shutdown ( )
static

Definition at line 1482 of file wsdl.cpp.

static bool video_NeedsChange ( int  w,
int  h,
int  cur_w,
int  cur_h,
bool  fullscreen 
)
static

Definition at line 312 of file wsdl.cpp.

static void video_SetPixelFormat ( HDC  hDC,
int  bpp 
)
static

Definition at line 330 of file wsdl.cpp.

static void video_Shutdown ( )
static

Definition at line 458 of file wsdl.cpp.

WINIT_REGISTER_EARLY_SHUTDOWN ( wsdl_Shutdown  )
WINIT_REGISTER_LATE_INIT ( wsdl_Init  )
static DWORD wnd_ChooseWindowStyle ( bool  fullscreen,
HWND  previousWindow = (HWND)INVALID_HANDLE_VALUE 
)
static

Definition at line 190 of file wsdl.cpp.

static HWND wnd_CreateWindow ( int  w,
int  h 
)
static

Definition at line 232 of file wsdl.cpp.

static void wnd_UpdateWindowDimensions ( DWORD  windowStyle,
int &  w,
int &  h 
)
static

Definition at line 215 of file wsdl.cpp.

static Status wsdl_Init ( )
static

Definition at line 1551 of file wsdl.cpp.

static Status wsdl_Shutdown ( )
static

Definition at line 1561 of file wsdl.cpp.

Variable Documentation

Uint8 app_state
static

Definition at line 778 of file wsdl.cpp.

int depthBufferBits = 24
static

Definition at line 282 of file wsdl.cpp.

DEVMODE dm
static

Definition at line 278 of file wsdl.cpp.

bool fullscreen
static

Definition at line 61 of file wsdl.cpp.

HDC g_hDC = (HDC)INVALID_HANDLE_VALUE
static

Definition at line 71 of file wsdl.cpp.

HWND g_hWnd = (HWND)INVALID_HANDLE_VALUE
static

Definition at line 67 of file wsdl.cpp.

Queue g_queue
static

Definition at line 520 of file wsdl.cpp.

SDLKey g_SDLKeyForVK[256]
static

Definition at line 553 of file wsdl.cpp.

GammaRamp gammaRamp
static

Definition at line 176 of file wsdl.cpp.

HGLRC hGLRC = (HGLRC)INVALID_HANDLE_VALUE
static

Definition at line 279 of file wsdl.cpp.

ModuleInitState initState
static

Definition at line 1474 of file wsdl.cpp.

bool is_quitting
static

Definition at line 65 of file wsdl.cpp.

Uint8 keys[SDLK_LAST]
static

Definition at line 551 of file wsdl.cpp.

unsigned mouse_buttons
static

Definition at line 985 of file wsdl.cpp.

int mouse_x
static

Definition at line 894 of file wsdl.cpp.

int mouse_y
static

Definition at line 894 of file wsdl.cpp.

int stencilBufferBits = 0
static

Definition at line 283 of file wsdl.cpp.

int vsyncEnabled = 1
static

Definition at line 284 of file wsdl.cpp.