mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-29 20:20:43 +00:00
pull the input code out of vid_wgl into in_win
This commit is contained in:
parent
82aa0fde58
commit
52252616ff
2 changed files with 288 additions and 281 deletions
|
@ -42,12 +42,14 @@ static const char rcsid[] =
|
||||||
|
|
||||||
#include "QF/cmd.h"
|
#include "QF/cmd.h"
|
||||||
#include "QF/console.h"
|
#include "QF/console.h"
|
||||||
|
#include "QF/cvar.h"
|
||||||
#include "QF/input.h"
|
#include "QF/input.h"
|
||||||
#include "QF/keys.h"
|
#include "QF/keys.h"
|
||||||
#include "QF/qargs.h"
|
#include "QF/qargs.h"
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
#include "in_win.h"
|
||||||
|
|
||||||
#define DINPUT_BUFFERSIZE 16
|
#define DINPUT_BUFFERSIZE 16
|
||||||
#define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d)
|
#define iDirectInputCreate(a,b,c,d) pDirectInputCreate(a,b,c,d)
|
||||||
|
@ -56,6 +58,11 @@ HRESULT (WINAPI * pDirectInputCreate) (HINSTANCE hinst, DWORD dwVersion,
|
||||||
LPDIRECTINPUT * lplpDirectInput,
|
LPDIRECTINPUT * lplpDirectInput,
|
||||||
LPUNKNOWN punkOuter);
|
LPUNKNOWN punkOuter);
|
||||||
|
|
||||||
|
void VID_UpdateWindowStatus (int window_x, int window_y);
|
||||||
|
|
||||||
|
extern DEVMODE win_gdevmode;
|
||||||
|
extern qboolean win_canalttab;
|
||||||
|
|
||||||
// mouse public variables
|
// mouse public variables
|
||||||
unsigned int uiWheelMessage;
|
unsigned int uiWheelMessage;
|
||||||
|
|
||||||
|
@ -80,6 +87,8 @@ static HINSTANCE hInstDI;
|
||||||
|
|
||||||
static qboolean dinput;
|
static qboolean dinput;
|
||||||
|
|
||||||
|
static qboolean vid_wassuspended = false;
|
||||||
|
|
||||||
typedef struct MYDATA {
|
typedef struct MYDATA {
|
||||||
LONG lX; // X axis goes here
|
LONG lX; // X axis goes here
|
||||||
LONG lY; // Y axis goes here
|
LONG lY; // Y axis goes here
|
||||||
|
@ -530,3 +539,266 @@ IN_LL_SendKeyEvents (void)
|
||||||
SetCursorPos (window_center_x, window_center_y);
|
SetCursorPos (window_center_x, window_center_y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
byte 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_LCTRL, 'a', 's', // 1
|
||||||
|
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
||||||
|
'\'', '`', K_LSHIFT, '\\', 'z', 'x', 'c', 'v', // 2
|
||||||
|
'b', 'n', 'm', ',', '.', '/', K_RSHIFT, K_KP_MULTIPLY,
|
||||||
|
K_LALT, ' ', K_CAPSLOCK, K_F1, K_F2, K_F3, K_F4, K_F5, // 3
|
||||||
|
K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE, K_SCROLLOCK, K_KP7,
|
||||||
|
K_KP8, K_KP9, K_KP_MINUS, K_KP4, K_KP5, K_KP6, K_KP_PLUS, K_KP1, // 4
|
||||||
|
K_KP2, K_KP3, K_KP0, K_KP_PERIOD, 0, 0, 0, K_F11,
|
||||||
|
K_F12, 0, 0, 0, 0, 0, 0, 0, // 5
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
byte extscantokey[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', '[', ']', K_KP_ENTER, K_RCTRL, 'a', 's', // 1
|
||||||
|
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
||||||
|
'\'', '`', K_LSHIFT, '\\', 'z', 'x', 'c', 'v', // 2
|
||||||
|
'b', 'n', 'm', ',', '.', K_KP_DIVIDE, K_RSHIFT, '*',
|
||||||
|
K_RALT, ' ', K_CAPSLOCK, K_F1, K_F2, K_F3, K_F4, K_F5, // 3
|
||||||
|
K_F6, K_F7, K_F8, K_F9, K_F10, K_NUMLOCK, 0, K_HOME,
|
||||||
|
K_UP, K_PAGEUP, '-', K_LEFT, '5', K_RIGHT, '+', K_END, // 4
|
||||||
|
K_DOWN, K_PAGEDOWN, K_INSERT, K_DELETE, 0, 0, 0, K_F11,
|
||||||
|
K_F12, 0, 0, 0, 0, 0, 0, 0, // 5
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
MapKey
|
||||||
|
|
||||||
|
Map from windows to quake keynums
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
MapKey (int key, int *k, int *u)
|
||||||
|
{
|
||||||
|
int extended;
|
||||||
|
|
||||||
|
extended = (key >> 24) & 1;
|
||||||
|
|
||||||
|
key = (key >> 16) & 255;
|
||||||
|
if (key > 127) {
|
||||||
|
*u = *k = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extended)
|
||||||
|
key = extscantokey[key];
|
||||||
|
else
|
||||||
|
key = scantokey[key];
|
||||||
|
if (key >= 0 && key <= 255)
|
||||||
|
*u = key;
|
||||||
|
else
|
||||||
|
*u = 0;
|
||||||
|
if (key >= 'A' && key <= 'Z')
|
||||||
|
key += 'a' - 'A';
|
||||||
|
*k = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
MAIN WINDOW
|
||||||
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
ClearAllStates (void)
|
||||||
|
{
|
||||||
|
IN_ClearStates ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
AppActivate
|
||||||
|
|
||||||
|
fActive - True if app is activating
|
||||||
|
If the application is activating, then swap the system into SYSPAL_NOSTATIC
|
||||||
|
mode so that our palettes will display correctly.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
AppActivate (BOOL fActive, BOOL minimize)
|
||||||
|
{
|
||||||
|
static BOOL sound_active;
|
||||||
|
|
||||||
|
ActiveApp = fActive;
|
||||||
|
Minimized = minimize;
|
||||||
|
|
||||||
|
// enable/disable sound on focus gain/loss
|
||||||
|
if (!ActiveApp && sound_active) {
|
||||||
|
S_BlockSound ();
|
||||||
|
sound_active = false;
|
||||||
|
} else if (ActiveApp && !sound_active) {
|
||||||
|
S_UnblockSound ();
|
||||||
|
sound_active = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fActive) {
|
||||||
|
if (modestate == MS_FULLDIB) {
|
||||||
|
IN_ActivateMouse ();
|
||||||
|
IN_HideMouse ();
|
||||||
|
if (win_canalttab && vid_wassuspended) {
|
||||||
|
vid_wassuspended = false;
|
||||||
|
|
||||||
|
if (ChangeDisplaySettings (&win_gdevmode, CDS_FULLSCREEN) !=
|
||||||
|
DISP_CHANGE_SUCCESSFUL) {
|
||||||
|
IN_ShowMouse ();
|
||||||
|
Sys_Error ("Couldn't set fullscreen DIB mode\n(try "
|
||||||
|
"upgrading your video drivers)\r\n (%lx)",
|
||||||
|
GetLastError());
|
||||||
|
}
|
||||||
|
ShowWindow (mainwindow, SW_SHOWNORMAL);
|
||||||
|
|
||||||
|
// Fix for alt-tab bug in NVidia drivers
|
||||||
|
MoveWindow(mainwindow, 0, 0, win_gdevmode.dmPelsWidth,
|
||||||
|
win_gdevmode.dmPelsHeight, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((modestate == MS_WINDOWED) && in_grab->int_val
|
||||||
|
&& key_dest == key_game) {
|
||||||
|
IN_ActivateMouse ();
|
||||||
|
IN_HideMouse ();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (modestate == MS_FULLDIB) {
|
||||||
|
IN_DeactivateMouse ();
|
||||||
|
IN_ShowMouse ();
|
||||||
|
if (win_canalttab) {
|
||||||
|
ChangeDisplaySettings (NULL, 0);
|
||||||
|
vid_wassuspended = true;
|
||||||
|
}
|
||||||
|
} else if ((modestate == MS_WINDOWED) && in_grab->int_val) {
|
||||||
|
IN_DeactivateMouse ();
|
||||||
|
IN_ShowMouse ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* main window procedure */
|
||||||
|
LONG WINAPI
|
||||||
|
MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
LONG lRet = 1;
|
||||||
|
int fActive, fMinimized, temp;
|
||||||
|
int key, unicode;
|
||||||
|
extern unsigned int uiWheelMessage;
|
||||||
|
|
||||||
|
if (uMsg == uiWheelMessage)
|
||||||
|
uMsg = WM_MOUSEWHEEL;
|
||||||
|
|
||||||
|
switch (uMsg) {
|
||||||
|
case WM_KILLFOCUS:
|
||||||
|
if (modestate == MS_FULLDIB)
|
||||||
|
ShowWindow (mainwindow, SW_SHOWMINNOACTIVE);
|
||||||
|
break;
|
||||||
|
case WM_CREATE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_MOVE:
|
||||||
|
VID_UpdateWindowStatus ((int) LOWORD (lParam), (int) HIWORD (lParam));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
MapKey (lParam, &key, &unicode);
|
||||||
|
Key_Event (key, unicode, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_KEYUP:
|
||||||
|
case WM_SYSKEYUP:
|
||||||
|
MapKey (lParam, &key, &unicode);
|
||||||
|
Key_Event (key, unicode, false);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_SYSCHAR:
|
||||||
|
// keep Alt-Space from happening
|
||||||
|
break;
|
||||||
|
|
||||||
|
// this is complicated because Win32 seems to pack multiple mouse events
|
||||||
|
// into one update sometimes, so we always check all states and look for
|
||||||
|
// events
|
||||||
|
case WM_LBUTTONDOWN:
|
||||||
|
case WM_LBUTTONUP:
|
||||||
|
case WM_RBUTTONDOWN:
|
||||||
|
case WM_RBUTTONUP:
|
||||||
|
case WM_MBUTTONDOWN:
|
||||||
|
case WM_MBUTTONUP:
|
||||||
|
case WM_MOUSEMOVE:
|
||||||
|
temp = 0;
|
||||||
|
|
||||||
|
if (wParam & MK_LBUTTON)
|
||||||
|
temp |= 1;
|
||||||
|
if (wParam & MK_RBUTTON)
|
||||||
|
temp |= 2;
|
||||||
|
if (wParam & MK_MBUTTON)
|
||||||
|
temp |= 4;
|
||||||
|
IN_MouseEvent (temp);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
// JACK: This is the mouse wheel with the Intellimouse
|
||||||
|
// It's delta is either positive or neg, and we generate the proper Event.
|
||||||
|
case WM_MOUSEWHEEL:
|
||||||
|
if ((short) HIWORD (wParam) > 0) {
|
||||||
|
Key_Event (M_WHEEL_UP, -1, true);
|
||||||
|
Key_Event (M_WHEEL_UP, -1, false);
|
||||||
|
} else {
|
||||||
|
Key_Event (M_WHEEL_DOWN, -1, true);
|
||||||
|
Key_Event (M_WHEEL_DOWN, -1, false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_SIZE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_CLOSE:
|
||||||
|
if (MessageBox
|
||||||
|
(mainwindow, "Are you sure you want to quit?", "Confirm Exit",
|
||||||
|
MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES) {
|
||||||
|
Sys_Quit ();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_ACTIVATE:
|
||||||
|
fActive = LOWORD (wParam);
|
||||||
|
fMinimized = (BOOL) HIWORD (wParam);
|
||||||
|
AppActivate (!(fActive == WA_INACTIVE), fMinimized);
|
||||||
|
// fix leftover Alt from any Alt-Tab or the like that switched us away
|
||||||
|
ClearAllStates ();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WM_DESTROY:
|
||||||
|
if (mainwindow)
|
||||||
|
DestroyWindow (mainwindow);
|
||||||
|
PostQuitMessage (0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MM_MCINOTIFY:
|
||||||
|
//FIXME lRet = CDAudio_MessageHandler (hWnd, uMsg, wParam, lParam);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* pass all unhandled messages to DefWindowProc */
|
||||||
|
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return 1 if handled message, 0 if not */
|
||||||
|
return lRet;
|
||||||
|
}
|
||||||
|
|
|
@ -121,10 +121,9 @@ static vmode_t modelist[MAX_MODE_LIST];
|
||||||
static int nummodes;
|
static int nummodes;
|
||||||
static vmode_t badmode;
|
static vmode_t badmode;
|
||||||
|
|
||||||
static DEVMODE gdevmode;
|
DEVMODE win_gdevmode;
|
||||||
|
qboolean win_canalttab = false;
|
||||||
static qboolean windowed, leavecurrentmode;
|
static qboolean windowed, leavecurrentmode;
|
||||||
static qboolean vid_canalttab = false;
|
|
||||||
static qboolean vid_wassuspended = false;
|
|
||||||
static int windowed_mouse;
|
static int windowed_mouse;
|
||||||
static HICON hIcon;
|
static HICON hIcon;
|
||||||
|
|
||||||
|
@ -155,7 +154,7 @@ LONG WINAPI MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||||
void AppActivate (BOOL fActive, BOOL minimize);
|
void AppActivate (BOOL fActive, BOOL minimize);
|
||||||
char *VID_GetModeDescription (int mode);
|
char *VID_GetModeDescription (int mode);
|
||||||
void ClearAllStates (void);
|
void ClearAllStates (void);
|
||||||
void VID_UpdateWindowStatus (void);
|
void VID_UpdateWindowStatus (int window_x, int window_y);
|
||||||
void GL_Init (void);
|
void GL_Init (void);
|
||||||
|
|
||||||
//====================================
|
//====================================
|
||||||
|
@ -269,17 +268,17 @@ VID_SetFullDIBMode (int modenum)
|
||||||
int lastmodestate, width, height;
|
int lastmodestate, width, height;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
|
||||||
memset(&gdevmode,0,sizeof(gdevmode));
|
memset(&win_gdevmode,0,sizeof(win_gdevmode));
|
||||||
|
|
||||||
if (!leavecurrentmode) {
|
if (!leavecurrentmode) {
|
||||||
gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
win_gdevmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
||||||
gdevmode.dmBitsPerPel = modelist[modenum].bpp;
|
win_gdevmode.dmBitsPerPel = modelist[modenum].bpp;
|
||||||
gdevmode.dmPelsWidth = modelist[modenum].width <<
|
win_gdevmode.dmPelsWidth = modelist[modenum].width <<
|
||||||
modelist[modenum].halfscreen;
|
modelist[modenum].halfscreen;
|
||||||
gdevmode.dmPelsHeight = modelist[modenum].height;
|
win_gdevmode.dmPelsHeight = modelist[modenum].height;
|
||||||
gdevmode.dmSize = sizeof (gdevmode);
|
win_gdevmode.dmSize = sizeof (win_gdevmode);
|
||||||
|
|
||||||
if (ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) !=
|
if (ChangeDisplaySettings (&win_gdevmode, CDS_FULLSCREEN) !=
|
||||||
DISP_CHANGE_SUCCESSFUL)
|
DISP_CHANGE_SUCCESSFUL)
|
||||||
Sys_Error ("Couldn't set fullscreen DIB mode (%lx)\r\n",
|
Sys_Error ("Couldn't set fullscreen DIB mode (%lx)\r\n",
|
||||||
GetLastError());
|
GetLastError());
|
||||||
|
@ -392,7 +391,7 @@ VID_SetMode (int modenum, unsigned char *palette)
|
||||||
Sys_Error ("VID_SetMode: Bad mode type in modelist");
|
Sys_Error ("VID_SetMode: Bad mode type in modelist");
|
||||||
}
|
}
|
||||||
|
|
||||||
VID_UpdateWindowStatus ();
|
VID_UpdateWindowStatus (window_x, window_y);
|
||||||
|
|
||||||
CDAudio_Resume ();
|
CDAudio_Resume ();
|
||||||
scr_disabled_for_loading = temp;
|
scr_disabled_for_loading = temp;
|
||||||
|
@ -437,11 +436,11 @@ VID_SetMode (int modenum, unsigned char *palette)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
VID_UpdateWindowStatus (void)
|
VID_UpdateWindowStatus (int w_x, int w_y)
|
||||||
{
|
{
|
||||||
|
|
||||||
window_rect.left = window_x;
|
window_rect.left = window_x = w_x;
|
||||||
window_rect.top = window_y;
|
window_rect.top = window_y = w_y;
|
||||||
window_rect.right = window_x + window_width;
|
window_rect.right = window_x + window_width;
|
||||||
window_rect.bottom = window_y + window_height;
|
window_rect.bottom = window_y + window_height;
|
||||||
window_center_x = (window_rect.left + window_rect.right) / 2;
|
window_center_x = (window_rect.left + window_rect.right) / 2;
|
||||||
|
@ -506,7 +505,7 @@ VID_Shutdown (void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (vid.initialized) {
|
if (vid.initialized) {
|
||||||
vid_canalttab = false;
|
win_canalttab = false;
|
||||||
hRC = qf_wglGetCurrentContext ();
|
hRC = qf_wglGetCurrentContext ();
|
||||||
hDC = qf_wglGetCurrentDC ();
|
hDC = qf_wglGetCurrentDC ();
|
||||||
|
|
||||||
|
@ -566,270 +565,6 @@ bSetupPixelFormat (HDC hDC)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
byte 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_LCTRL, 'a', 's', // 1
|
|
||||||
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
|
||||||
'\'', '`', K_LSHIFT, '\\', 'z', 'x', 'c', 'v', // 2
|
|
||||||
'b', 'n', 'm', ',', '.', '/', K_RSHIFT, K_KP_MULTIPLY,
|
|
||||||
K_LALT, ' ', K_CAPSLOCK, K_F1, K_F2, K_F3, K_F4, K_F5, // 3
|
|
||||||
K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE, K_SCROLLOCK, K_KP7,
|
|
||||||
K_KP8, K_KP9, K_KP_MINUS, K_KP4, K_KP5, K_KP6, K_KP_PLUS, K_KP1, // 4
|
|
||||||
K_KP2, K_KP3, K_KP0, K_KP_PERIOD, 0, 0, 0, K_F11,
|
|
||||||
K_F12, 0, 0, 0, 0, 0, 0, 0, // 5
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
byte extscantokey[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', '[', ']', K_KP_ENTER, K_RCTRL, 'a', 's', // 1
|
|
||||||
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
|
||||||
'\'', '`', K_LSHIFT, '\\', 'z', 'x', 'c', 'v', // 2
|
|
||||||
'b', 'n', 'm', ',', '.', K_KP_DIVIDE, K_RSHIFT, '*',
|
|
||||||
K_RALT, ' ', K_CAPSLOCK, K_F1, K_F2, K_F3, K_F4, K_F5, // 3
|
|
||||||
K_F6, K_F7, K_F8, K_F9, K_F10, K_NUMLOCK, 0, K_HOME,
|
|
||||||
K_UP, K_PAGEUP, '-', K_LEFT, '5', K_RIGHT, '+', K_END, // 4
|
|
||||||
K_DOWN, K_PAGEDOWN, K_INSERT, K_DELETE, 0, 0, 0, K_F11,
|
|
||||||
K_F12, 0, 0, 0, 0, 0, 0, 0, // 5
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
MapKey
|
|
||||||
|
|
||||||
Map from windows to quake keynums
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
MapKey (int key, int *k, int *u)
|
|
||||||
{
|
|
||||||
int extended;
|
|
||||||
|
|
||||||
extended = (key >> 24) & 1;
|
|
||||||
|
|
||||||
key = (key >> 16) & 255;
|
|
||||||
if (key > 127) {
|
|
||||||
*u = *k = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extended)
|
|
||||||
key = extscantokey[key];
|
|
||||||
else
|
|
||||||
key = scantokey[key];
|
|
||||||
if (key >= 0 && key <= 255)
|
|
||||||
*u = key;
|
|
||||||
else
|
|
||||||
*u = 0;
|
|
||||||
if (key >= 'A' && key <= 'Z')
|
|
||||||
key += 'a' - 'A';
|
|
||||||
*k = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
MAIN WINDOW
|
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
|
||||||
ClearAllStates (void)
|
|
||||||
{
|
|
||||||
IN_ClearStates ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
AppActivate
|
|
||||||
|
|
||||||
fActive - True if app is activating
|
|
||||||
If the application is activating, then swap the system into SYSPAL_NOSTATIC
|
|
||||||
mode so that our palettes will display correctly.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
AppActivate (BOOL fActive, BOOL minimize)
|
|
||||||
{
|
|
||||||
static BOOL sound_active;
|
|
||||||
|
|
||||||
ActiveApp = fActive;
|
|
||||||
Minimized = minimize;
|
|
||||||
|
|
||||||
// enable/disable sound on focus gain/loss
|
|
||||||
if (!ActiveApp && sound_active) {
|
|
||||||
S_BlockSound ();
|
|
||||||
sound_active = false;
|
|
||||||
} else if (ActiveApp && !sound_active) {
|
|
||||||
S_UnblockSound ();
|
|
||||||
sound_active = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fActive) {
|
|
||||||
if (modestate == MS_FULLDIB) {
|
|
||||||
IN_ActivateMouse ();
|
|
||||||
IN_HideMouse ();
|
|
||||||
if (vid_canalttab && vid_wassuspended) {
|
|
||||||
vid_wassuspended = false;
|
|
||||||
|
|
||||||
if (ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN) !=
|
|
||||||
DISP_CHANGE_SUCCESSFUL) {
|
|
||||||
IN_ShowMouse ();
|
|
||||||
Sys_Error ("Couldn't set fullscreen DIB mode\n(try "
|
|
||||||
"upgrading your video drivers)\r\n (%lx)",
|
|
||||||
GetLastError());
|
|
||||||
}
|
|
||||||
ShowWindow (mainwindow, SW_SHOWNORMAL);
|
|
||||||
|
|
||||||
// Fix for alt-tab bug in NVidia drivers
|
|
||||||
MoveWindow(mainwindow, 0, 0, gdevmode.dmPelsWidth,
|
|
||||||
gdevmode.dmPelsHeight, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ((modestate == MS_WINDOWED) && in_grab->int_val
|
|
||||||
&& key_dest == key_game) {
|
|
||||||
IN_ActivateMouse ();
|
|
||||||
IN_HideMouse ();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (modestate == MS_FULLDIB) {
|
|
||||||
IN_DeactivateMouse ();
|
|
||||||
IN_ShowMouse ();
|
|
||||||
if (vid_canalttab) {
|
|
||||||
ChangeDisplaySettings (NULL, 0);
|
|
||||||
vid_wassuspended = true;
|
|
||||||
}
|
|
||||||
} else if ((modestate == MS_WINDOWED) && in_grab->int_val) {
|
|
||||||
IN_DeactivateMouse ();
|
|
||||||
IN_ShowMouse ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* main window procedure */
|
|
||||||
LONG WINAPI
|
|
||||||
MainWndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
LONG lRet = 1;
|
|
||||||
int fActive, fMinimized, temp;
|
|
||||||
int key, unicode;
|
|
||||||
extern unsigned int uiWheelMessage;
|
|
||||||
|
|
||||||
if (uMsg == uiWheelMessage)
|
|
||||||
uMsg = WM_MOUSEWHEEL;
|
|
||||||
|
|
||||||
switch (uMsg) {
|
|
||||||
case WM_KILLFOCUS:
|
|
||||||
if (modestate == MS_FULLDIB)
|
|
||||||
ShowWindow (mainwindow, SW_SHOWMINNOACTIVE);
|
|
||||||
break;
|
|
||||||
case WM_CREATE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_MOVE:
|
|
||||||
window_x = (int) LOWORD (lParam);
|
|
||||||
window_y = (int) HIWORD (lParam);
|
|
||||||
VID_UpdateWindowStatus ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_KEYDOWN:
|
|
||||||
case WM_SYSKEYDOWN:
|
|
||||||
MapKey (lParam, &key, &unicode);
|
|
||||||
Key_Event (key, unicode, true);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_KEYUP:
|
|
||||||
case WM_SYSKEYUP:
|
|
||||||
MapKey (lParam, &key, &unicode);
|
|
||||||
Key_Event (key, unicode, false);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_SYSCHAR:
|
|
||||||
// keep Alt-Space from happening
|
|
||||||
break;
|
|
||||||
|
|
||||||
// this is complicated because Win32 seems to pack multiple mouse events
|
|
||||||
// into one update sometimes, so we always check all states and look for
|
|
||||||
// events
|
|
||||||
case WM_LBUTTONDOWN:
|
|
||||||
case WM_LBUTTONUP:
|
|
||||||
case WM_RBUTTONDOWN:
|
|
||||||
case WM_RBUTTONUP:
|
|
||||||
case WM_MBUTTONDOWN:
|
|
||||||
case WM_MBUTTONUP:
|
|
||||||
case WM_MOUSEMOVE:
|
|
||||||
temp = 0;
|
|
||||||
|
|
||||||
if (wParam & MK_LBUTTON)
|
|
||||||
temp |= 1;
|
|
||||||
if (wParam & MK_RBUTTON)
|
|
||||||
temp |= 2;
|
|
||||||
if (wParam & MK_MBUTTON)
|
|
||||||
temp |= 4;
|
|
||||||
IN_MouseEvent (temp);
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
// JACK: This is the mouse wheel with the Intellimouse
|
|
||||||
// It's delta is either positive or neg, and we generate the proper Event.
|
|
||||||
case WM_MOUSEWHEEL:
|
|
||||||
if ((short) HIWORD (wParam) > 0) {
|
|
||||||
Key_Event (M_WHEEL_UP, -1, true);
|
|
||||||
Key_Event (M_WHEEL_UP, -1, false);
|
|
||||||
} else {
|
|
||||||
Key_Event (M_WHEEL_DOWN, -1, true);
|
|
||||||
Key_Event (M_WHEEL_DOWN, -1, false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_SIZE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_CLOSE:
|
|
||||||
if (MessageBox
|
|
||||||
(mainwindow, "Are you sure you want to quit?", "Confirm Exit",
|
|
||||||
MB_YESNO | MB_SETFOREGROUND | MB_ICONQUESTION) == IDYES) {
|
|
||||||
Sys_Quit ();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_ACTIVATE:
|
|
||||||
fActive = LOWORD (wParam);
|
|
||||||
fMinimized = (BOOL) HIWORD (wParam);
|
|
||||||
AppActivate (!(fActive == WA_INACTIVE), fMinimized);
|
|
||||||
// fix leftover Alt from any Alt-Tab or the like that switched us away
|
|
||||||
ClearAllStates ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_DESTROY:
|
|
||||||
if (mainwindow)
|
|
||||||
DestroyWindow (mainwindow);
|
|
||||||
PostQuitMessage (0);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MM_MCINOTIFY:
|
|
||||||
//FIXME lRet = CDAudio_MessageHandler (hWnd, uMsg, wParam, lParam);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
/* pass all unhandled messages to DefWindowProc */
|
|
||||||
lRet = DefWindowProc (hWnd, uMsg, wParam, lParam);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* return 1 if handled message, 0 if not */
|
|
||||||
return lRet;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
VID_NumModes (void)
|
VID_NumModes (void)
|
||||||
|
@ -1369,7 +1104,7 @@ VID_Init (unsigned char *palette)
|
||||||
vid_realmode = vid_modenum;
|
vid_realmode = vid_modenum;
|
||||||
|
|
||||||
strcpy (badmode.modedesc, "Bad mode");
|
strcpy (badmode.modedesc, "Bad mode");
|
||||||
vid_canalttab = true;
|
win_canalttab = true;
|
||||||
|
|
||||||
if (COM_CheckParm ("-nofullsbar"))
|
if (COM_CheckParm ("-nofullsbar"))
|
||||||
fullsbardraw = false;
|
fullsbardraw = false;
|
||||||
|
|
Loading…
Reference in a new issue