Fix Windows build

rope
Armin Burgmeier 2012-04-23 21:45:01 +02:00
parent cd4db8ebaf
commit e11e9845d1
6 changed files with 43 additions and 18 deletions

View File

@ -362,6 +362,8 @@ bool C4EditCursor::KeyDown(C4KeyCode KeyCode, DWORD dwKeyState)
fShiftIsDown = fShiftIsDown || (kcx.ToString(false, false) == "Shift" || kcx.ToString(false, false) == "Shift_L" || kcx.ToString(false, false) == "Shift_R");
if(fShiftIsDown != fShiftWasDown)
fShiftWasDown = fShiftIsDown;
return true;
}
bool C4EditCursor::KeyUp(C4KeyCode KeyCode, DWORD dwKeyState)
@ -384,6 +386,8 @@ bool C4EditCursor::KeyUp(C4KeyCode KeyCode, DWORD dwKeyState)
fShiftIsDown = fShiftIsDown && !(kcx.ToString(false, false) == "Shift" || kcx.ToString(false, false) == "Shift_L" || kcx.ToString(false, false) == "Shift_R");
if(fShiftIsDown != fShiftWasDown)
fShiftWasDown = fShiftIsDown;
return true;
}
#ifdef USE_WIN32_WINDOWS

View File

@ -121,7 +121,7 @@ const C4KeyCodeMapEntry KeyCodeMap [] =
{ VK_SHIFT , "KeyShift" , "Shift" },
{ VK_CONTROL , "KeyControl" , "Control" },
{ VK_MENU , "Menu" , NULL },
{ VK_MENU , "Alt" , NULL },
{ VK_PAUSE , "Pause" , NULL },
{ VK_CAPITAL , "Capital" , NULL },

View File

@ -50,6 +50,7 @@ extern int MK_SHIFT;
extern int MK_CONTROL;
extern int MK_ALT;
#elif defined(USE_WIN32_WINDOWS)
#define MK_ALT 0x10000 // well beyond the pre-defined values
#include <C4windowswrapper.h>
#endif

View File

@ -208,7 +208,7 @@ void C4ViewportWindow::Close()
{
::Viewports.CloseViewport(cvp);
}
void C4ViewportWindow::EditCursorMove(int X, int Y, uint16_t state)
void C4ViewportWindow::EditCursorMove(int X, int Y, uint32_t state)
{
Console.EditCursor.Move(cvp->ViewX + X / cvp->Zoom, cvp->ViewY + Y / cvp->Zoom, state);
}

View File

@ -42,7 +42,7 @@ public:
GtkWidget* h_scrollbar;
GtkWidget* v_scrollbar;
#endif
void EditCursorMove(int X, int Y, uint16_t);
void EditCursorMove(int X, int Y, uint32_t);
using C4Window::Init;
C4Window * Init(int32_t iPlayer);
virtual void Close();

View File

@ -137,16 +137,16 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
Application.MusicSystem.NotifySuccess();
return true;
case WM_KEYUP:
if (Game.DoKeyboardInput(wParam, KEYEV_Up, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), false, NULL))
if (Game.DoKeyboardInput(wParam, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, NULL))
return 0;
break;
case WM_KEYDOWN:
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), !!(lParam & 0x40000000), NULL))
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL))
return 0;
break;
case WM_SYSKEYDOWN:
if (wParam == 18) break;
if (Game.DoKeyboardInput(wParam, KEYEV_Down, Application.IsAltDown(), Application.IsControlDown(), Application.IsShiftDown(), !!(lParam & 0x40000000), NULL))
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL))
return 0;
break;
case WM_CHAR:
@ -230,19 +230,19 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
break;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
default:
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), !!(lParam & 0x40000000), NULL)) return 0;
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) return 0;
break;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
}
break;
//---------------------------------------------------------------------------------------------------------------------------
case WM_KEYUP:
if (Game.DoKeyboardInput(wParam, KEYEV_Up, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), false, NULL)) return 0;
if (Game.DoKeyboardInput(wParam, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, NULL)) return 0;
break;
//------------------------------------------------------------------------------------------------------------
case WM_SYSKEYDOWN:
if (wParam == 18) break;
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), !!(lParam & 0x40000000), NULL)) return 0;
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) return 0;
break;
//----------------------------------------------------------------------------------------------------------------------------------
case WM_DESTROY:
@ -366,21 +366,41 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
// Console edit cursor control
else
{
// The state of the ALT key is not reported in wParam for mouse messages,
// and for keyboard messages the key states are hidden in lParam. It's a mess. Let's just
// query GetKeyState().
DWORD dwKeyState = 0;
if(GetKeyState(VK_CONTROL) < 0) dwKeyState |= MK_CONTROL;
if(GetKeyState(VK_SHIFT) < 0) dwKeyState |= MK_SHIFT;
if(GetKeyState(VK_MENU) < 0) dwKeyState |= MK_ALT;
switch (uMsg)
{
case WM_KEYDOWN:
Console.EditCursor.KeyDown(wParam, dwKeyState);
break;
case WM_KEYUP:
Console.EditCursor.KeyUp(wParam, dwKeyState);
break;
case WM_SYSKEYDOWN:
Console.EditCursor.KeyDown(wParam, dwKeyState);
break;
case WM_SYSKEYUP:
Console.EditCursor.KeyUp(wParam, dwKeyState);
break;
//----------------------------------------------------------------------------------------------------------------------------------
case WM_LBUTTONDOWN:
// movement update needed before, so target is always up-to-date
cvp->pWindow->EditCursorMove(LOWORD(lParam), HIWORD(lParam), wParam);
Console.EditCursor.LeftButtonDown(wParam); break;
cvp->pWindow->EditCursorMove(LOWORD(lParam), HIWORD(lParam), dwKeyState);
Console.EditCursor.LeftButtonDown(dwKeyState); break;
//----------------------------------------------------------------------------------------------------------------------------------
case WM_LBUTTONUP: Console.EditCursor.LeftButtonUp(wParam); break;
case WM_LBUTTONUP: Console.EditCursor.LeftButtonUp(dwKeyState); break;
//----------------------------------------------------------------------------------------------------------------------------------
case WM_RBUTTONDOWN: Console.EditCursor.RightButtonDown(wParam); break;
case WM_RBUTTONDOWN: Console.EditCursor.RightButtonDown(dwKeyState); break;
//----------------------------------------------------------------------------------------------------------------------------------
case WM_RBUTTONUP: Console.EditCursor.RightButtonUp(wParam); break;
case WM_RBUTTONUP: Console.EditCursor.RightButtonUp(dwKeyState); break;
//----------------------------------------------------------------------------------------------------------------------------------
case WM_MOUSEMOVE: cvp->pWindow->EditCursorMove(LOWORD(lParam), HIWORD(lParam), wParam); break;
case WM_MOUSEMOVE: cvp->pWindow->EditCursorMove(LOWORD(lParam), HIWORD(lParam), dwKeyState); break;
//----------------------------------------------------------------------------------------------------------------------------------
}
}
@ -399,16 +419,16 @@ LRESULT APIENTRY DialogWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara
{
//---------------------------------------------------------------------------------------------------------------------------
case WM_KEYDOWN:
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), !!(lParam & 0x40000000), pDlg)) return 0;
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), pDlg)) return 0;
break;
//---------------------------------------------------------------------------------------------------------------------------
case WM_KEYUP:
if (Game.DoKeyboardInput(wParam, KEYEV_Up, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), false, pDlg)) return 0;
if (Game.DoKeyboardInput(wParam, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, pDlg)) return 0;
break;
//------------------------------------------------------------------------------------------------------------
case WM_SYSKEYDOWN:
if (wParam == 18) break;
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), Application.IsControlDown(), Application.IsShiftDown(), !!(lParam & 0x40000000), pDlg)) return 0;
if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), pDlg)) return 0;
break;
//----------------------------------------------------------------------------------------------------------------------------------
case WM_DESTROY: