mirror of
https://github.com/glest/glest-source.git
synced 2025-08-12 03:14:00 +02:00
Added logic to NOT trigger camera mousemove if keyboard has a key pressed so you can scroll with keys and still move mouse simultaneously
This commit is contained in:
@@ -437,24 +437,26 @@ void Game::mouseMove(int x, int y, const MouseState *ms){
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//main window
|
//main window
|
||||||
if (y < 10) {
|
if(Window::isKeyDown() == false) {
|
||||||
gameCamera.setMoveZ(-scrollSpeed);
|
if (y < 10) {
|
||||||
}
|
gameCamera.setMoveZ(-scrollSpeed);
|
||||||
else if (y > metrics.getVirtualH() - 10) {
|
}
|
||||||
gameCamera.setMoveZ(scrollSpeed);
|
else if (y > metrics.getVirtualH() - 10) {
|
||||||
}
|
gameCamera.setMoveZ(scrollSpeed);
|
||||||
else {
|
}
|
||||||
gameCamera.setMoveZ(0);
|
else {
|
||||||
}
|
gameCamera.setMoveZ(0);
|
||||||
|
}
|
||||||
|
|
||||||
if (x < 10) {
|
if (x < 10) {
|
||||||
gameCamera.setMoveX(-scrollSpeed);
|
gameCamera.setMoveX(-scrollSpeed);
|
||||||
}
|
}
|
||||||
else if (x > metrics.getVirtualW() - 10) {
|
else if (x > metrics.getVirtualW() - 10) {
|
||||||
gameCamera.setMoveX(scrollSpeed);
|
gameCamera.setMoveX(scrollSpeed);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gameCamera.setMoveX(0);
|
gameCamera.setMoveX(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mainMessageBox.getEnabled()) {
|
if (mainMessageBox.getEnabled()) {
|
||||||
|
@@ -111,6 +111,7 @@ private:
|
|||||||
static unsigned int lastMouseEvent; /** for use in mouse hover calculations */
|
static unsigned int lastMouseEvent; /** for use in mouse hover calculations */
|
||||||
static MouseState mouseState;
|
static MouseState mouseState;
|
||||||
static Vec2i mousePos;
|
static Vec2i mousePos;
|
||||||
|
static bool isKeyPressedDown;
|
||||||
|
|
||||||
static void setLastMouseEvent(unsigned int lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;}
|
static void setLastMouseEvent(unsigned int lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;}
|
||||||
static unsigned int getLastMouseEvent() {return Window::lastMouseEvent;}
|
static unsigned int getLastMouseEvent() {return Window::lastMouseEvent;}
|
||||||
@@ -127,6 +128,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
static bool handleEvent();
|
static bool handleEvent();
|
||||||
static void revertMousePos();
|
static void revertMousePos();
|
||||||
|
static bool isKeyDown() { return isKeyPressedDown; }
|
||||||
|
|
||||||
|
|
||||||
Window();
|
Window();
|
||||||
|
@@ -111,6 +111,7 @@ private:
|
|||||||
static unsigned int lastMouseEvent; /** for use in mouse hover calculations */
|
static unsigned int lastMouseEvent; /** for use in mouse hover calculations */
|
||||||
static MouseState mouseState;
|
static MouseState mouseState;
|
||||||
static Vec2i mousePos;
|
static Vec2i mousePos;
|
||||||
|
static bool isKeyPressedDown;
|
||||||
|
|
||||||
static void setLastMouseEvent(unsigned int lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;}
|
static void setLastMouseEvent(unsigned int lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;}
|
||||||
static unsigned int getLastMouseEvent() {return Window::lastMouseEvent;}
|
static unsigned int getLastMouseEvent() {return Window::lastMouseEvent;}
|
||||||
@@ -137,6 +138,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
static bool handleEvent();
|
static bool handleEvent();
|
||||||
static void revertMousePos();
|
static void revertMousePos();
|
||||||
|
static bool isKeyDown() { return isKeyPressedDown; }
|
||||||
|
|
||||||
//contructor & destructor
|
//contructor & destructor
|
||||||
Window();
|
Window();
|
||||||
|
@@ -36,7 +36,7 @@ static int oldX=0,oldY=0;
|
|||||||
unsigned int Window::lastMouseEvent = 0; /** for use in mouse hover calculations */
|
unsigned int Window::lastMouseEvent = 0; /** for use in mouse hover calculations */
|
||||||
Vec2i Window::mousePos;
|
Vec2i Window::mousePos;
|
||||||
MouseState Window::mouseState;
|
MouseState Window::mouseState;
|
||||||
|
bool Window::isKeyPressedDown = false;
|
||||||
|
|
||||||
// ========== PUBLIC ==========
|
// ========== PUBLIC ==========
|
||||||
|
|
||||||
@@ -59,6 +59,7 @@ Window::~Window() {
|
|||||||
bool Window::handleEvent() {
|
bool Window::handleEvent() {
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
SDL_GetMouseState(&oldX,&oldY);
|
SDL_GetMouseState(&oldX,&oldY);
|
||||||
|
|
||||||
while(SDL_PollEvent(&event)) {
|
while(SDL_PollEvent(&event)) {
|
||||||
try {
|
try {
|
||||||
//printf("START [%d]\n",event.type);
|
//printf("START [%d]\n",event.type);
|
||||||
@@ -69,8 +70,8 @@ bool Window::handleEvent() {
|
|||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
|
|
||||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
setLastMouseEvent(Chrono::getCurMillis());
|
setLastMouseEvent(Chrono::getCurMillis());
|
||||||
setMousePos(Vec2i(event.button.x, event.button.y));
|
setMousePos(Vec2i(event.button.x, event.button.y));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,13 +107,14 @@ bool Window::handleEvent() {
|
|||||||
setMouseState(mbCenter, event.motion.state & SDL_BUTTON_MMASK);
|
setMouseState(mbCenter, event.motion.state & SDL_BUTTON_MMASK);
|
||||||
|
|
||||||
if(global_window) {
|
if(global_window) {
|
||||||
global_window->eventMouseMove(event.motion.x, event.motion.y, &getMouseState()); //&ms);
|
global_window->eventMouseMove(event.motion.x, event.motion.y, &getMouseState()); //&ms);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
Window::isKeyPressedDown = true;
|
||||||
/* handle ALT+Return */
|
/* handle ALT+Return */
|
||||||
if(event.key.keysym.sym == SDLK_RETURN
|
if(event.key.keysym.sym == SDLK_RETURN
|
||||||
&& (event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) {
|
&& (event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) {
|
||||||
@@ -125,6 +127,9 @@ bool Window::handleEvent() {
|
|||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
Window::isKeyPressedDown = false;
|
||||||
|
|
||||||
if(global_window) {
|
if(global_window) {
|
||||||
global_window->eventKeyUp(getKey(event.key.keysym));
|
global_window->eventKeyUp(getKey(event.key.keysym));
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest Shared Library (www.glest.org)
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
// Copyright (C) 2001-2008 Martio Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
@@ -38,6 +38,7 @@ unsigned int Window::lastMouseEvent = 0; /** for use in mouse hover calculations
|
|||||||
static int oldX=0,oldY=0;
|
static int oldX=0,oldY=0;
|
||||||
Vec2i Window::mousePos;
|
Vec2i Window::mousePos;
|
||||||
MouseState Window::mouseState;
|
MouseState Window::mouseState;
|
||||||
|
bool Window::isKeyPressedDown = false;
|
||||||
|
|
||||||
// ===================== PUBLIC ========================
|
// ===================== PUBLIC ========================
|
||||||
|
|
||||||
@@ -382,6 +383,8 @@ LRESULT CALLBACK Window::eventRouter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
|
|||||||
|
|
||||||
case WM_KEYDOWN: {
|
case WM_KEYDOWN: {
|
||||||
|
|
||||||
|
Window::isKeyPressedDown = true;
|
||||||
|
|
||||||
eventWindow->eventKeyDown(static_cast<char>(wParam));
|
eventWindow->eventKeyDown(static_cast<char>(wParam));
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
@@ -399,6 +402,8 @@ LRESULT CALLBACK Window::eventRouter(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
|
|||||||
|
|
||||||
case WM_KEYUP: {
|
case WM_KEYUP: {
|
||||||
|
|
||||||
|
Window::isKeyPressedDown = false;
|
||||||
|
|
||||||
eventWindow->eventKeyUp(static_cast<char>(wParam));
|
eventWindow->eventKeyUp(static_cast<char>(wParam));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user