};
static DEVMODE gdevmode, initialdevmode;
+static vid_mode_t desktop_mode;
static qboolean vid_initialized = false;
static qboolean vid_wassuspended = false;
static qboolean vid_usingmouse = false;
//void VID_MenuDraw (void);
//void VID_MenuKey (int key);
-//LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
-//void AppActivate(BOOL fActive, BOOL minimize);
-//void ClearAllStates (void);
-//void VID_UpdateWindowStatus (void);
+LONG WINAPI MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+void AppActivate(BOOL fActive, BOOL minimize);
+static void ClearAllStates(void);
+qboolean VID_InitModeGL(viddef_mode_t *mode);
+qboolean VID_InitModeSOFT(viddef_mode_t *mode);
//====================================
// forward-referenced functions
static void IN_StartupMouse (void);
-
+static void AdjustWindowBounds(int fullscreen, int *width, int *height, viddef_mode_t *mode, DWORD WindowStyle, RECT *rect);
//====================================
//==========================================================================
-
-
static unsigned char scantokey[128] =
{
-// 0 1 2 3 4 5 6 7 8 9 A B C D E F
- 0 ,27 ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' ,'0' ,'-' ,'=' ,K_BACKSPACE,9 ,//0
- 'q' ,'w' ,'e' ,'r' ,'t' ,'y' ,'u' ,'i' ,'o' ,'p' ,'[' ,']' ,13 ,K_CTRL ,'a' ,'s' ,//1
- 'd' ,'f' ,'g' ,'h' ,'j' ,'k' ,'l' ,';' ,'\'' ,'`' ,K_SHIFT ,'\\' ,'z' ,'x' ,'c' ,'v' ,//2
- 'b' ,'n' ,'m' ,',' ,'.' ,'/' ,K_SHIFT,'*' ,K_ALT ,' ' ,0 ,K_F1 ,K_F2 ,K_F3 ,K_F4 ,K_F5 ,//3
- K_F6 ,K_F7 ,K_F8 ,K_F9 ,K_F10,K_PAUSE,0 ,K_HOME,K_UPARROW,K_PGUP,K_KP_MINUS,K_LEFTARROW,K_KP_5,K_RIGHTARROW,K_KP_PLUS ,K_END,//4
- K_DO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K)) & 0xffff) == 0)
+ return result;
+
switch ( result )
{
case K_HOME:
}
else
{
+ if(virtualkey == VK_NUMLOCK)
+ return K_NUMLOCK;
+
switch ( result )
{
case 0x0D:
if (vid_isfullscreen)
{
if (gldll)
- ChangeDisplaySettings (NULL, 0);
+ ChangeDisplaySettings (NULL, CDS_FULLSCREEN);
vid_wassuspended = true;
}
VID_RestoreSystemGamma();
}
}
+#ifdef CONFIG_CD
LONG CDAudio_MessageHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+#endif
static keynum_t buttonremap[16] =
{
LONG lRet = 1;
int fActive, fMinimized, temp;
unsigned char state[256];
- unsigned char asciichar[4];
+ const unsigned int UNICODE_BUFFER_LENGTH = 4;
+ WCHAR unicode[UNICODE_BUFFER_LENGTH];
int vkey;
int charlength;
qboolean down = false;
GetKeyboardState (state);
// alt/ctrl/shift tend to produce funky ToAscii values,
// and if it's not a single character we don't know care about it
- charlength = ToAscii (wParam, lParam >> 16, state, (LPWORD)asciichar, 0);
- if (vkey == K_ALT || vkey == K_CTRL || vkey == K_SHIFT || charlength == 0)
- asciichar[0] = 0;
- else if( charlength == 2 ) {
- asciichar[0] = asciichar[1];
- }
+ charlength = ToUnicode(wParam, lParam >> 16, state, unicode, UNICODE_BUFFER_LENGTH, 0);
+ if(vkey == K_ALT || vkey == K_CTRL || vkey == K_SHIFT || charlength == 0)
+ unicode[0] = 0;
+ else if(charlength == 2)
+ unicode[0] = unicode[1];
if (!VID_JoyBlockEmulatedKeys(vkey))
- Key_Event (vkey, asciichar[0], down);
+ Key_Event(vkey, unicode[0], down);
break;
case WM_SYSCHAR:
// break;
case MM_MCINOTIFY:
+#ifdef CONFIG_CD
lRet = CDAudio_MessageHandler (hWnd, uMsg, wParam, lParam);
+#endif
break;
default:
memset(&initialdevmode, 0, sizeof(initialdevmode));
EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &initialdevmode);
+ desktop_mode.width = initialdevmode.dmPelsWidth;
+ desktop_mode.height = initialdevmode.dmPelsHeight;
+ desktop_mode.bpp = initialdevmode.dmBitsPerPel;
+ desktop_mode.refreshrate = initialdevmode.dmDisplayFrequency;
+ desktop_mode.pixelheight_num = 1;
+ desktop_mode.pixelheight_denom = 1; // Win32 apparently does not provide this (FIXME)
+
IN_Init();
}
int pixelformat, newpixelformat;
UINT numpixelformats;
DWORD WindowStyle, ExWindowStyle;
- int CenterX, CenterY;
const char *gldrivername;
int depth;
DEVMODE thismode;
vid_isfullscreen = false;
if (fullscreen)
{
- if(vid_forcerefreshrate.integer)
+ if(vid_desktopfullscreen.integer)
+ {
+ foundmode = true;
+ gdevmode = initialdevmode;
+ width = mode->width = gdevmode.dmPelsWidth;
+ height = mode->height = gdevmode.dmPelsHeight;
+ bpp = mode->bitsperpixel = gdevmode.dmBitsPerPel;
+ }
+ else if(vid_forcerefreshrate.integer)
{
foundmode = true;
gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
ExWindowStyle = 0;
}
- rect.top = 0;
- rect.left = 0;
- rect.right = width;
- rect.bottom = height;
- AdjustWindowRectEx(&rect, WindowStyle, false, 0);
-
- if (fullscreen)
- {
- CenterX = 0;
- CenterY = 0;
- }
- else
- {
- CenterX = (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) / 2;
- CenterY = (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top)) / 2;
- }
- CenterX = max(0, CenterX);
- CenterY = max(0, CenterY);
-
- // x and y may be changed by WM_MOVE messages
- window_x = CenterX;
- window_y = CenterY;
- rect.left += CenterX;
- rect.right += CenterX;
- rect.top += CenterY;
- rect.bottom += CenterY;
+ AdjustWindowBounds(fullscreen, &width, &height, mode, WindowStyle, &rect);
pixelformat = 0;
newpixelformat = 0;
return true;
}
+static void AdjustWindowBounds(int fullscreen, int *width, int *height, viddef_mode_t *mode, DWORD WindowStyle, RECT *rect)
+{
+ int CenterX, CenterY;
+
+ rect->top = 0;
+ rect->left = 0;
+ rect->right = *width;
+ rect->bottom = *height;
+ AdjustWindowRectEx(rect, WindowStyle, false, 0);
+
+ if (fullscreen)
+ {
+ CenterX = 0;
+ CenterY = 0;
+ }
+ else
+ {
+ RECT workArea;
+ SystemParametersInfo(SPI_GETWORKAREA, NULL, &workArea, 0);
+ int workWidth = workArea.right - workArea.left;
+ int workHeight = workArea.bottom - workArea.top;
+
+ // if height/width matches physical screen height/width, adjust it to available desktop size
+ // and allow 2 pixels on top for the title bar so the window can be moved
+ const int titleBarPixels = 2;
+ if (*width == GetSystemMetrics(SM_CXSCREEN) && (*height == GetSystemMetrics(SM_CYSCREEN) || *height == workHeight - titleBarPixels))
+ {
+ rect->right -= *width - workWidth;
+ *width = mode->width = workWidth;
+ rect->bottom -= *height - (workHeight - titleBarPixels);
+ *height = mode->height = workHeight - titleBarPixels;
+ CenterX = 0;
+ CenterY = titleBarPixels;
+ }
+ else
+ {
+ CenterX = max(0, (workWidth - *width) / 2);
+ CenterY = max(0, (workHeight - *height) / 2);
+ }
+ }
+
+ // x and y may be changed by WM_MOVE messages
+ window_x = CenterX;
+ window_y = CenterY;
+ rect->left += CenterX;
+ rect->right += CenterX;
+ rect->top += CenterY;
+ rect->bottom += CenterY;
+}
+
#ifdef SUPPORTD3D
static D3DADAPTER_IDENTIFIER9 d3d9adapteridentifier;
RECT rect;
MSG msg;
DWORD WindowStyle, ExWindowStyle;
- int CenterX, CenterY;
int bpp = mode->bitsperpixel;
int width = mode->width;
int height = mode->height;
ExWindowStyle = 0;
}
- rect.top = 0;
- rect.left = 0;
- rect.right = width;
- rect.bottom = height;
- AdjustWindowRectEx(&rect, WindowStyle, false, 0);
-
- if (fullscreen)
- {
- CenterX = 0;
- CenterY = 0;
- }
- else
- {
- CenterX = (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) / 2;
- CenterY = (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top)) / 2;
- }
- CenterX = max(0, CenterX);
- CenterY = max(0, CenterY);
-
- // x and y may be changed by WM_MOVE messages
- window_x = CenterX;
- window_y = CenterY;
- rect.left += CenterX;
- rect.right += CenterX;
- rect.top += CenterY;
- rect.bottom += CenterY;
+ AdjustWindowBounds(fullscreen, &width, &height, mode, WindowStyle, &rect);
gl_extensions = "";
gl_platformextensions = "";
vid.support.arb_depth_texture = true;
vid.support.arb_draw_buffers = vid_d3d9caps.NumSimultaneousRTs > 1;
vid.support.arb_occlusion_query = true; // can't find a cap for this
+ vid.support.arb_query_buffer_object = true;
vid.support.arb_shadow = true;
vid.support.arb_texture_compression = true;
vid.support.arb_texture_cube_map = true;
MSG msg;
int pixelformat, newpixelformat;
DWORD WindowStyle, ExWindowStyle;
- int CenterX, CenterY;
int depth;
DEVMODE thismode;
qboolean foundmode, foundgoodmode;
ExWindowStyle = 0;
}
- rect.top = 0;
- rect.left = 0;
- rect.right = width;
- rect.bottom = height;
- AdjustWindowRectEx(&rect, WindowStyle, false, 0);
-
- if (fullscreen)
- {
- CenterX = 0;
- CenterY = 0;
- }
- else
- {
- CenterX = (GetSystemMetrics(SM_CXSCREEN) - (rect.right - rect.left)) / 2;
- CenterY = (GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top)) / 2;
- }
- CenterX = max(0, CenterX);
- CenterY = max(0, CenterY);
-
- // x and y may be changed by WM_MOVE messages
- window_x = CenterX;
- window_y = CenterY;
- rect.left += CenterX;
- rect.right += CenterX;
- rect.top += CenterY;
- rect.bottom += CenterY;
+ AdjustWindowBounds(fullscreen, &width, &height, mode, WindowStyle, &rect);
pixelformat = 0;
newpixelformat = 0;
DestroyWindow(mainwindow);
mainwindow = 0;
if (vid_isfullscreen && isgl)
- ChangeDisplaySettings (NULL, 0);
+ ChangeDisplaySettings (NULL, CDS_FULLSCREEN);
vid_isfullscreen = false;
}
#endif
}
+vid_mode_t *VID_GetDesktopMode(void)
+{
+ return &desktop_mode;
+}
+
size_t VID_ListModes(vid_mode_t *modes, size_t maxcount)
{
int i;