mirror of
https://github.com/glest/glest-source.git
synced 2025-08-11 10:54:01 +02:00
Updated camera panning so that holding middle mouse button and moving the mouse changes the camera angle.
This commit is contained in:
@@ -39,7 +39,7 @@ namespace Glest{ namespace Game{
|
|||||||
// ===================== PUBLIC ========================
|
// ===================== PUBLIC ========================
|
||||||
|
|
||||||
Game::Game(Program *program, const GameSettings *gameSettings):
|
Game::Game(Program *program, const GameSettings *gameSettings):
|
||||||
ProgramState(program)
|
ProgramState(program), lastMousePos(0)
|
||||||
{
|
{
|
||||||
this->gameSettings= *gameSettings;
|
this->gameSettings= *gameSettings;
|
||||||
scrollSpeed = Config::getInstance().getFloat("UiScrollSpeed","1.5");
|
scrollSpeed = Config::getInstance().getFloat("UiScrollSpeed","1.5");
|
||||||
@@ -421,14 +421,14 @@ void Game::mouseMove(int x, int y, const MouseState *ms){
|
|||||||
mouseX = x;
|
mouseX = x;
|
||||||
mouseY = y;
|
mouseY = y;
|
||||||
|
|
||||||
/*
|
if (ms->get(mbCenter)) {
|
||||||
if (ms.get(mbCenter)) {
|
/*if (input.isCtrlDown()) {
|
||||||
if (input.isCtrlDown()) {
|
|
||||||
float speed = input.isShiftDown() ? 1.f : 0.125f;
|
float speed = input.isShiftDown() ? 1.f : 0.125f;
|
||||||
float response = input.isShiftDown() ? 0.1875f : 0.0625f;
|
float response = input.isShiftDown() ? 0.1875f : 0.0625f;
|
||||||
gameCamera.moveForwardH((y - lastMousePos.y) * speed, response);
|
gameCamera.moveForwardH((y - lastMousePos.y) * speed, response);
|
||||||
gameCamera.moveSideH((x - lastMousePos.x) * speed, response);
|
gameCamera.moveSideH((x - lastMousePos.x) * speed, response);
|
||||||
} else {
|
} else*/
|
||||||
|
{
|
||||||
//float ymult = Config::getInstance().getCameraInvertYAxis() ? -0.2f : 0.2f;
|
//float ymult = Config::getInstance().getCameraInvertYAxis() ? -0.2f : 0.2f;
|
||||||
//float xmult = Config::getInstance().getCameraInvertXAxis() ? -0.2f : 0.2f;
|
//float xmult = Config::getInstance().getCameraInvertXAxis() ? -0.2f : 0.2f;
|
||||||
float ymult = 0.2f;
|
float ymult = 0.2f;
|
||||||
@@ -436,8 +436,8 @@ void Game::mouseMove(int x, int y, const MouseState *ms){
|
|||||||
|
|
||||||
gameCamera.transitionVH(-(y - lastMousePos.y) * ymult, (lastMousePos.x - x) * xmult);
|
gameCamera.transitionVH(-(y - lastMousePos.y) * ymult, (lastMousePos.x - x) * xmult);
|
||||||
}
|
}
|
||||||
} else */
|
}
|
||||||
{
|
else {
|
||||||
//main window
|
//main window
|
||||||
if (y < 10) {
|
if (y < 10) {
|
||||||
gameCamera.setMoveZ(-scrollSpeed);
|
gameCamera.setMoveZ(-scrollSpeed);
|
||||||
@@ -473,6 +473,9 @@ void Game::mouseMove(int x, int y, const MouseState *ms){
|
|||||||
gui.mouseMoveDisplay(x - metrics.getDisplayX(), y - metrics.getDisplayY());
|
gui.mouseMoveDisplay(x - metrics.getDisplayX(), y - metrics.getDisplayY());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastMousePos.x = x;
|
||||||
|
lastMousePos.y = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::eventMouseWheel(int x, int y, int zDelta) {
|
void Game::eventMouseWheel(int x, int y, int zDelta) {
|
||||||
|
@@ -75,6 +75,7 @@ private:
|
|||||||
//misc ptr
|
//misc ptr
|
||||||
ParticleSystem *weatherParticleSystem;
|
ParticleSystem *weatherParticleSystem;
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
|
Vec2i lastMousePos;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Game(Program *program, const GameSettings *gameSettings);
|
Game(Program *program, const GameSettings *gameSettings);
|
||||||
|
@@ -102,13 +102,29 @@ MainWindow::~MainWindow(){
|
|||||||
delete program;
|
delete program;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventMouseWheel(int x, int y, int zDelta) {
|
void MainWindow::eventMouseDown(int x, int y, MouseButton mouseButton){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
|
||||||
program->eventMouseWheel(x, y, zDelta);
|
const Metrics &metrics = Metrics::getInstance();
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
int vx = metrics.toVirtualX(x);
|
||||||
|
int vy = metrics.toVirtualY(getH() - y);
|
||||||
|
|
||||||
|
ProgramState *programState = program->getState();
|
||||||
|
|
||||||
|
switch(mouseButton) {
|
||||||
|
case mbLeft:
|
||||||
|
programState->mouseDownLeft(vx, vy);
|
||||||
|
break;
|
||||||
|
case mbRight:
|
||||||
|
programState->mouseDownRight(vx, vy);
|
||||||
|
break;
|
||||||
|
case mbCenter:
|
||||||
|
programState->mouseDownCenter(vx, vy);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventMouseDown(int x, int y, MouseButton mouseButton){
|
/*
|
||||||
switch(mouseButton){
|
switch(mouseButton){
|
||||||
case mbLeft:
|
case mbLeft:
|
||||||
program->mouseDownLeft(x, getH() - y);
|
program->mouseDownLeft(x, getH() - y);
|
||||||
@@ -119,22 +135,95 @@ void MainWindow::eventMouseDown(int x, int y, MouseButton mouseButton){
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventMouseUp(int x, int y, MouseButton mouseButton){
|
void MainWindow::eventMouseUp(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
|
const Metrics &metrics = Metrics::getInstance();
|
||||||
|
int vx = metrics.toVirtualX(x);
|
||||||
|
int vy = metrics.toVirtualY(getH() - y);
|
||||||
|
|
||||||
|
ProgramState *programState = program->getState();
|
||||||
|
|
||||||
|
switch(mouseButton) {
|
||||||
|
case mbLeft:
|
||||||
|
programState->mouseUpLeft(vx, vy);
|
||||||
|
break;
|
||||||
|
case mbRight:
|
||||||
|
programState->mouseUpRight(vx, vy);
|
||||||
|
break;
|
||||||
|
case mbCenter:
|
||||||
|
programState->mouseUpCenter(vx, vy);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if(mouseButton==mbLeft){
|
if(mouseButton==mbLeft){
|
||||||
program->mouseUpLeft(x, getH() - y);
|
program->mouseUpLeft(x, getH() - y);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventMouseDoubleClick(int x, int y, MouseButton mouseButton){
|
void MainWindow::eventMouseDoubleClick(int x, int y, MouseButton mouseButton){
|
||||||
|
|
||||||
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
|
int vx = metrics.toVirtualX(x);
|
||||||
|
int vy = metrics.toVirtualY(getH() - y);
|
||||||
|
|
||||||
|
ProgramState *programState = program->getState();
|
||||||
|
|
||||||
|
switch(mouseButton){
|
||||||
|
case mbLeft:
|
||||||
|
programState->mouseDoubleClickLeft(vx, vy);
|
||||||
|
break;
|
||||||
|
case mbRight:
|
||||||
|
programState->mouseDoubleClickRight(vx, vy);
|
||||||
|
break;
|
||||||
|
case mbCenter:
|
||||||
|
programState->mouseDoubleClickCenter(vx, vy);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if(mouseButton == mbLeft){
|
if(mouseButton == mbLeft){
|
||||||
program->mouseDoubleClickLeft(x, getH() - y);
|
program->mouseDoubleClickLeft(x, getH() - y);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventMouseMove(int x, int y, const MouseState *ms){
|
void MainWindow::eventMouseMove(int x, int y, const MouseState *ms){
|
||||||
program->mouseMove(x, getH() - y, ms);
|
|
||||||
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
|
int vx = metrics.toVirtualX(x);
|
||||||
|
int vy = metrics.toVirtualY(getH() - y);
|
||||||
|
|
||||||
|
ProgramState *programState = program->getState();
|
||||||
|
programState->mouseMove(vx, vy, ms);
|
||||||
|
|
||||||
|
//program->mouseMove(x, getH() - y, ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::eventMouseWheel(int x, int y, int zDelta) {
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
|
int vx = metrics.toVirtualX(x);
|
||||||
|
int vy = metrics.toVirtualY(getH() - y);
|
||||||
|
|
||||||
|
ProgramState *programState = program->getState();
|
||||||
|
programState->eventMouseWheel(vx, vy, zDelta);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
//program->eventMouseWheel(x, y, zDelta);
|
||||||
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventKeyDown(char key){
|
void MainWindow::eventKeyDown(char key){
|
||||||
|
@@ -155,6 +155,26 @@ Program::~Program(){
|
|||||||
singleton = NULL;
|
singleton = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Program::eventMouseDown(int x, int y, MouseButton mouseButton) {
|
||||||
|
const Metrics &metrics = Metrics::getInstance();
|
||||||
|
int vx = metrics.toVirtualX(x);
|
||||||
|
int vy = metrics.toVirtualY(window->getH() - y);
|
||||||
|
|
||||||
|
switch(mouseButton) {
|
||||||
|
case mbLeft:
|
||||||
|
programState->mouseDownLeft(vx, vy);
|
||||||
|
break;
|
||||||
|
case mbRight:
|
||||||
|
programState->mouseDownRight(vx, vy);
|
||||||
|
break;
|
||||||
|
case mbCenter:
|
||||||
|
programState->mouseDownCenter(vx, vy);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Program::mouseDownLeft(int x, int y){
|
void Program::mouseDownLeft(int x, int y){
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
programState->mouseDownLeft(metrics.toVirtualX(x), metrics.toVirtualY(y));
|
programState->mouseDownLeft(metrics.toVirtualX(x), metrics.toVirtualY(y));
|
||||||
|
@@ -17,7 +17,9 @@
|
|||||||
#include "window_gl.h"
|
#include "window_gl.h"
|
||||||
#include "socket.h"
|
#include "socket.h"
|
||||||
#include "components.h"
|
#include "components.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
|
using Shared::Platform::MouseButton;
|
||||||
using Shared::Graphics::Context;
|
using Shared::Graphics::Context;
|
||||||
using Shared::Platform::WindowGl;
|
using Shared::Platform::WindowGl;
|
||||||
using Shared::Platform::SizeState;
|
using Shared::Platform::SizeState;
|
||||||
@@ -54,8 +56,13 @@ public:
|
|||||||
virtual void end(){};
|
virtual void end(){};
|
||||||
virtual void mouseDownLeft(int x, int y){};
|
virtual void mouseDownLeft(int x, int y){};
|
||||||
virtual void mouseUpLeft(int x, int y){};
|
virtual void mouseUpLeft(int x, int y){};
|
||||||
|
virtual void mouseUpRight(int x, int y){}
|
||||||
|
virtual void mouseUpCenter(int x, int y){}
|
||||||
virtual void mouseDownRight(int x, int y){};
|
virtual void mouseDownRight(int x, int y){};
|
||||||
|
virtual void mouseDownCenter(int x, int y){}
|
||||||
virtual void mouseDoubleClickLeft(int x, int y){};
|
virtual void mouseDoubleClickLeft(int x, int y){};
|
||||||
|
virtual void mouseDoubleClickRight(int x, int y){}
|
||||||
|
virtual void mouseDoubleClickCenter(int x, int y){}
|
||||||
virtual void eventMouseWheel(int x, int y, int zDelta){}
|
virtual void eventMouseWheel(int x, int y, int zDelta){}
|
||||||
virtual void mouseMove(int x, int y, const MouseState *mouseState) {};
|
virtual void mouseMove(int x, int y, const MouseState *mouseState) {};
|
||||||
virtual void keyDown(char key){};
|
virtual void keyDown(char key){};
|
||||||
@@ -118,6 +125,8 @@ public:
|
|||||||
void mouseDoubleClickLeft(int x, int y);
|
void mouseDoubleClickLeft(int x, int y);
|
||||||
void eventMouseWheel(int x, int y, int zDelta);
|
void eventMouseWheel(int x, int y, int zDelta);
|
||||||
|
|
||||||
|
void eventMouseDown(int x, int y, MouseButton mouseButton);
|
||||||
|
|
||||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||||
void keyDown(char key);
|
void keyDown(char key);
|
||||||
void keyUp(char key);
|
void keyUp(char key);
|
||||||
@@ -128,6 +137,7 @@ public:
|
|||||||
|
|
||||||
//misc
|
//misc
|
||||||
void setState(ProgramState *programState);
|
void setState(ProgramState *programState);
|
||||||
|
ProgramState * getState() { return programState;}
|
||||||
void exit();
|
void exit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -69,6 +69,9 @@ public:
|
|||||||
int64 getMillis() const;
|
int64 getMillis() const;
|
||||||
int64 getSeconds() const;
|
int64 getSeconds() const;
|
||||||
|
|
||||||
|
static int64 getCurTicks();
|
||||||
|
static int64 getCurMillis();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int64 queryCounter(int multiplier) const;
|
int64 queryCounter(int multiplier) const;
|
||||||
};
|
};
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
// ==============================================================
|
// ==============================================================
|
||||||
|
// ==============================================================
|
||||||
// This file is part of Glest Shared Library (www.glest.org)
|
// This file is part of Glest Shared Library (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
// Copyright (C) 2005 Matthias Braun <matze@braunis.de>
|
||||||
@@ -15,11 +16,14 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
#include "vec.h"
|
||||||
|
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
using Shared::Graphics::Vec2i;
|
||||||
|
|
||||||
namespace Shared{ namespace Platform{
|
namespace Shared{ namespace Platform{
|
||||||
|
|
||||||
@@ -27,12 +31,16 @@ class Timer;
|
|||||||
class PlatformContextGl;
|
class PlatformContextGl;
|
||||||
|
|
||||||
enum MouseButton {
|
enum MouseButton {
|
||||||
|
mbUnknown,
|
||||||
mbLeft,
|
mbLeft,
|
||||||
mbRight,
|
|
||||||
mbCenter,
|
mbCenter,
|
||||||
|
mbRight,
|
||||||
mbWheelUp,
|
mbWheelUp,
|
||||||
mbWheelDown
|
mbWheelDown,
|
||||||
|
mbButtonX1,
|
||||||
|
mbButtonX2,
|
||||||
|
|
||||||
|
mbCount
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SizeState{
|
enum SizeState{
|
||||||
@@ -41,6 +49,31 @@ enum SizeState{
|
|||||||
ssRestored
|
ssRestored
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MouseState {
|
||||||
|
private:
|
||||||
|
bool states[mbCount];
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
MouseState() {
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
//MouseState(const MouseState &);
|
||||||
|
//MouseState &operator=(const MouseState &);
|
||||||
|
void clear() { memset(this, 0, sizeof(MouseState)); }
|
||||||
|
|
||||||
|
bool get(MouseButton b) const {
|
||||||
|
assert(b > 0 && b < mbCount);
|
||||||
|
return states[b];
|
||||||
|
}
|
||||||
|
|
||||||
|
void set(MouseButton b, bool state) {
|
||||||
|
assert(b > 0 && b < mbCount);
|
||||||
|
states[b] = state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// keycode constants (unfortunately designed after DirectInput and therefore not
|
// keycode constants (unfortunately designed after DirectInput and therefore not
|
||||||
// very specific)
|
// very specific)
|
||||||
// They also have to fit into a char. The positive numbers seem to be equal
|
// They also have to fit into a char. The positive numbers seem to be equal
|
||||||
@@ -59,11 +92,13 @@ const char vkDown = -10;
|
|||||||
const char vkReturn = -11;
|
const char vkReturn = -11;
|
||||||
const char vkBack = -12;
|
const char vkBack = -12;
|
||||||
|
|
||||||
|
/*
|
||||||
struct MouseState{
|
struct MouseState{
|
||||||
bool leftMouse;
|
bool leftMouse;
|
||||||
bool rightMouse;
|
bool rightMouse;
|
||||||
bool centerMouse;
|
bool centerMouse;
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
enum WindowStyle{
|
enum WindowStyle{
|
||||||
wsFullscreen,
|
wsFullscreen,
|
||||||
@@ -81,6 +116,19 @@ private:
|
|||||||
int lastMouseX[3];
|
int lastMouseX[3];
|
||||||
int lastMouseY[3];
|
int lastMouseY[3];
|
||||||
|
|
||||||
|
static unsigned int lastMouseEvent; /** for use in mouse hover calculations */
|
||||||
|
static MouseState mouseState;
|
||||||
|
static Vec2i mousePos;
|
||||||
|
|
||||||
|
static void setLastMouseEvent(unsigned int lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;}
|
||||||
|
static unsigned int getLastMouseEvent() {return Window::lastMouseEvent;}
|
||||||
|
|
||||||
|
static const MouseState &getMouseState() {return Window::mouseState;}
|
||||||
|
static void setMouseState(MouseButton b, bool state) {Window::mouseState.set(b, state);}
|
||||||
|
|
||||||
|
static const Vec2i &getMousePos() {return Window::mousePos;}
|
||||||
|
static void setMousePos(const Vec2i &mousePos) {Window::mousePos = mousePos;}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
|
@@ -70,6 +70,9 @@ public:
|
|||||||
int64 getMillis() const;
|
int64 getMillis() const;
|
||||||
int64 getSeconds() const;
|
int64 getSeconds() const;
|
||||||
|
|
||||||
|
static int64 getCurTicks();
|
||||||
|
static int64 getCurMillis();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int64 queryCounter(int multiplier) const;
|
int64 queryCounter(int multiplier) const;
|
||||||
};
|
};
|
||||||
|
@@ -115,6 +115,13 @@ int64 Chrono::queryCounter(int multiplier) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64 Chrono::getCurMillis() {
|
||||||
|
return SDL_GetTicks();
|
||||||
|
}
|
||||||
|
int64 Chrono::getCurTicks() {
|
||||||
|
return SDL_GetTicks();
|
||||||
|
}
|
||||||
|
|
||||||
// =====================================
|
// =====================================
|
||||||
// Misc
|
// Misc
|
||||||
// =====================================
|
// =====================================
|
||||||
|
@@ -32,6 +32,10 @@ namespace Shared{ namespace Platform{
|
|||||||
|
|
||||||
// Matze: hack for now...
|
// Matze: hack for now...
|
||||||
static Window* global_window = 0;
|
static Window* global_window = 0;
|
||||||
|
unsigned int Window::lastMouseEvent = 0; /** for use in mouse hover calculations */
|
||||||
|
Vec2i Window::mousePos;
|
||||||
|
MouseState Window::mouseState;
|
||||||
|
|
||||||
|
|
||||||
// ========== PUBLIC ==========
|
// ========== PUBLIC ==========
|
||||||
|
|
||||||
@@ -40,6 +44,10 @@ Window::Window() {
|
|||||||
|
|
||||||
assert(global_window == 0);
|
assert(global_window == 0);
|
||||||
global_window = this;
|
global_window = this;
|
||||||
|
|
||||||
|
lastMouseEvent = 0;
|
||||||
|
mousePos = Vec2i(0);
|
||||||
|
mouseState.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::~Window() {
|
Window::~Window() {
|
||||||
@@ -53,33 +61,55 @@ bool Window::handleEvent() {
|
|||||||
try {
|
try {
|
||||||
//printf("START [%d]\n",event.type);
|
//printf("START [%d]\n",event.type);
|
||||||
|
|
||||||
|
switch(event.type) {
|
||||||
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
case SDL_MOUSEBUTTONUP:
|
||||||
|
case SDL_MOUSEMOTION:
|
||||||
|
|
||||||
|
printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
setLastMouseEvent(Chrono::getCurMillis());
|
||||||
|
setMousePos(Vec2i(event.button.x, event.button.y));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
switch(event.type) {
|
switch(event.type) {
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
|
printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
return false;
|
return false;
|
||||||
case SDL_MOUSEBUTTONDOWN:
|
case SDL_MOUSEBUTTONDOWN:
|
||||||
|
printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
if(global_window) {
|
if(global_window) {
|
||||||
global_window->handleMouseDown(event);
|
global_window->handleMouseDown(event);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONUP: {
|
case SDL_MOUSEBUTTONUP: {
|
||||||
|
printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
if(global_window) {
|
if(global_window) {
|
||||||
|
MouseButton b = getMouseButton(event.button.button);
|
||||||
|
setMouseState(b, false);
|
||||||
|
|
||||||
global_window->eventMouseUp(event.button.x,
|
global_window->eventMouseUp(event.button.x,
|
||||||
event.button.y,getMouseButton(event.button.button));
|
event.button.y,getMouseButton(event.button.button));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_MOUSEMOTION: {
|
case SDL_MOUSEMOTION: {
|
||||||
MouseState ms;
|
printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
ms.leftMouse = (event.motion.state & SDL_BUTTON_LMASK) != 0;
|
//MouseState ms;
|
||||||
ms.rightMouse = (event.motion.state & SDL_BUTTON_RMASK) != 0;
|
//ms.leftMouse = (event.motion.state & SDL_BUTTON_LMASK) != 0;
|
||||||
ms.centerMouse = (event.motion.state & SDL_BUTTON_MMASK) != 0;
|
//ms.rightMouse = (event.motion.state & SDL_BUTTON_RMASK) != 0;
|
||||||
|
//ms.centerMouse = (event.motion.state & SDL_BUTTON_MMASK) != 0;
|
||||||
|
setMouseState(mbLeft, event.motion.state & SDL_BUTTON_LMASK);
|
||||||
|
setMouseState(mbRight, event.motion.state & SDL_BUTTON_RMASK);
|
||||||
|
setMouseState(mbCenter, event.motion.state & SDL_BUTTON_MMASK);
|
||||||
|
|
||||||
if(global_window) {
|
if(global_window) {
|
||||||
global_window->eventMouseMove(event.motion.x, event.motion.y, &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__);
|
||||||
/* 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))) {
|
||||||
@@ -91,6 +121,7 @@ bool Window::handleEvent() {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_KEYUP:
|
case SDL_KEYUP:
|
||||||
|
printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
if(global_window) {
|
if(global_window) {
|
||||||
global_window->eventKeyUp(getKey(event.key.keysym));
|
global_window->eventKeyUp(getKey(event.key.keysym));
|
||||||
}
|
}
|
||||||
|
@@ -116,6 +116,15 @@ int64 Chrono::queryCounter(int multiplier) const{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64 Chrono::getCurMillis() {
|
||||||
|
return getCurTicks() * 1000 / freq;
|
||||||
|
}
|
||||||
|
int64 Chrono::getCurTicks() {
|
||||||
|
int64 now;
|
||||||
|
QueryPerformanceCounter((LARGE_INTEGER*) &now);
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
|
||||||
// =====================================================
|
// =====================================================
|
||||||
// class PlatformExceptionHandler
|
// class PlatformExceptionHandler
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
Reference in New Issue
Block a user