about summary refs log tree commit diff
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2010-10-13 12:47:42 +0200
committeroy <Tom_Adams@web.de>2010-10-13 12:47:42 +0200
commite4fe7457c8acdb479e91a79cf832c48d10898be5 (patch)
treee16e3d219060b1f366720c1663ef661086c8224e
parentc828f7d725d9b243e094b44f62a844a9b47790a5 (diff)
downloadzcatch-e4fe7457c8acdb479e91a79cf832c48d10898be5.tar.gz
zcatch-e4fe7457c8acdb479e91a79cf832c48d10898be5.zip
fixed problems with the mouse movement. Closes #214
-rw-r--r--src/engine/client/input.cpp6
-rw-r--r--src/engine/client/input.h2
-rw-r--r--src/engine/input.h2
-rw-r--r--src/game/client/components/emoticon.cpp2
-rw-r--r--src/game/client/gameclient.cpp4
-rw-r--r--src/game/editor/ed_editor.cpp12
6 files changed, 13 insertions, 15 deletions
diff --git a/src/engine/client/input.cpp b/src/engine/client/input.cpp
index bf3e703c..ff41550f 100644
--- a/src/engine/client/input.cpp
+++ b/src/engine/client/input.cpp
@@ -48,7 +48,7 @@ void CInput::Init()
 	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
 }
 
-void CInput::MouseRelative(int *x, int *y)
+void CInput::MouseRelative(float *x, float *y)
 {
 	int nx = 0, ny = 0;
 	float Sens = g_Config.m_InpMousesens/100.0f;
@@ -65,8 +65,8 @@ void CInput::MouseRelative(int *x, int *y)
 		}
 	}
 
-	*x = (int)(nx*Sens);
-	*y = (int)(ny*Sens);
+	*x = nx*Sens;
+	*y = ny*Sens;
 }
 
 void CInput::MouseModeAbsolute()
diff --git a/src/engine/client/input.h b/src/engine/client/input.h
index aeaefca1..2f5b00bf 100644
--- a/src/engine/client/input.h
+++ b/src/engine/client/input.h
@@ -19,7 +19,7 @@ public:
 
 	virtual void Init();
 
-	virtual void MouseRelative(int *x, int *y);
+	virtual void MouseRelative(float *x, float *y);
 	virtual void MouseModeAbsolute();
 	virtual void MouseModeRelative();
 	virtual int MouseDoubleClick();
diff --git a/src/engine/input.h b/src/engine/input.h
index 168614c8..3caf02e7 100644
--- a/src/engine/input.h
+++ b/src/engine/input.h
@@ -72,7 +72,7 @@ public:
 	virtual void MouseModeAbsolute() = 0;
 	virtual int MouseDoubleClick() = 0;
 	
-	virtual void MouseRelative(int *x, int *y) = 0;
+	virtual void MouseRelative(float *x, float *y) = 0;
 };
 
 
diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp
index 9139c2c1..de822b4f 100644
--- a/src/game/client/components/emoticon.cpp
+++ b/src/game/client/components/emoticon.cpp
@@ -102,7 +102,7 @@ void CEmoticon::OnRender()
 	
 	m_WasActive = true;
 	
-	int x, y;
+	float x, y;
 	Input()->MouseRelative(&x, &y);
 
 	m_SelectorMouse.x += x;
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index df6eb889..4728cd73 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -304,9 +304,9 @@ void CGameClient::OnInit()
 void CGameClient::DispatchInput()
 {
 	// handle mouse movement
-	int x=0, y=0;
+	float x = 0.0f, y = 0.0f;
 	Input()->MouseRelative(&x, &y);
-	if(x || y)
+	if(x != 0.0f || y != 0.0f)
 	{
 		for(int h = 0; h < m_Input.m_Num; h++)
 		{
diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp
index 295f72b9..8d1be882 100644
--- a/src/game/editor/ed_editor.cpp
+++ b/src/game/editor/ed_editor.cpp
@@ -3194,8 +3194,8 @@ void CEditor::DoMapBorder()
 
 void CEditor::UpdateAndRender()
 {
-	static int s_MouseX = 0;
-	static int s_MouseY = 0;
+	static float s_MouseX = 0.0f;
+	static float s_MouseY = 0.0f;
 
 	if(m_Animate)
 		m_AnimateTime = (time_get()-m_AnimateStart)/(float)time_freq();
@@ -3205,7 +3205,7 @@ void CEditor::UpdateAndRender()
 
 	// handle mouse movement
 	float mx, my, Mwx, Mwy;
-	int rx, ry;
+	float rx, ry;
 	{
 		Input()->MouseRelative(&rx, &ry);
 		m_MouseDeltaX = rx;
@@ -3217,10 +3217,8 @@ void CEditor::UpdateAndRender()
 			s_MouseY += ry;
 		}
 
-		if(s_MouseX < 0) s_MouseX = 0;
-		if(s_MouseY < 0) s_MouseY = 0;
-		if(s_MouseX > UI()->Screen()->w) s_MouseX = (int)UI()->Screen()->w;
-		if(s_MouseY > UI()->Screen()->h) s_MouseY = (int)UI()->Screen()->h;
+		clamp(s_MouseX, 0.0f, UI()->Screen()->w);
+		clamp(s_MouseY, 0.0f, UI()->Screen()->h);
 
 		// update the ui
 		mx = s_MouseX;