Browse Source

Removed the 'wu' and 'wd' constants for love.mousepressed, added new love.wheelmoved(x, y) event callback.

+x is mousewheel-right, +y is mousewheel-up.

--HG--
branch : minor
Alex Szpakowski 11 years ago
parent
commit
1b61091aae

+ 5 - 18
src/modules/event/sdl/Event.cpp

@@ -196,24 +196,11 @@ Message *Event::convert(const SDL_Event &e) const
 		}
 		break;
 	case SDL_MOUSEWHEEL:
-		if (e.wheel.y != 0)
-		{
-			button = (e.wheel.y > 0) ? mouse::Mouse::BUTTON_WHEELUP : mouse::Mouse::BUTTON_WHEELDOWN;
-			if (!love::mouse::Mouse::getConstant(button, txt))
-				break;
-
-			int mx, my;
-			SDL_GetMouseState(&mx, &my);
-			windowToPixelCoords(&mx, &my);
-
-			arg1 = new Variant((double) mx);
-			arg2 = new Variant((double) my);
-			arg3 = new Variant(txt, strlen(txt));
-			msg = new Message("mousepressed", arg1, arg2, arg3);
-			arg1->release();
-			arg2->release();
-			arg3->release();
-		}
+		arg1 = new Variant((double) e.wheel.x);
+		arg2 = new Variant((double) e.wheel.y);
+		msg = new Message("wheelmoved", arg1, arg2);
+		arg1->release();
+		arg2->release();
 		break;
 	case SDL_JOYBUTTONDOWN:
 	case SDL_JOYBUTTONUP:

+ 0 - 2
src/modules/mouse/Mouse.cpp

@@ -40,8 +40,6 @@ StringMap<Mouse::Button, Mouse::BUTTON_MAX_ENUM>::Entry Mouse::buttonEntries[] =
 	{"l", Mouse::BUTTON_LEFT},
 	{"m", Mouse::BUTTON_MIDDLE},
 	{"r", Mouse::BUTTON_RIGHT},
-	{"wu", Mouse::BUTTON_WHEELUP},
-	{"wd", Mouse::BUTTON_WHEELDOWN},
 	{"x1", Mouse::BUTTON_X1},
 	{"x2", Mouse::BUTTON_X2},
 };

+ 0 - 2
src/modules/mouse/Mouse.h

@@ -44,8 +44,6 @@ public:
 		BUTTON_RIGHT,
 		BUTTON_X1,
 		BUTTON_X2,
-		BUTTON_WHEELUP,
-		BUTTON_WHEELDOWN,
 		BUTTON_MAX_ENUM
 	};
 

+ 3 - 0
src/scripts/boot.lua

@@ -170,6 +170,9 @@ function love.createhandlers()
 		mousereleased = function (x,y,b)
 			if love.mousereleased then return love.mousereleased(x,y,b) end
 		end,
+		wheelmoved = function (x,y)
+			if love.wheelmoved then return love.wheelmoved(x,y) end
+		end,
 		joystickpressed = function (j,b)
 			if love.joystickpressed then return love.joystickpressed(j,b) end
 		end,

+ 7 - 0
src/scripts/boot.lua.h

@@ -297,6 +297,13 @@ const unsigned char boot_lua[] =
 	0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x6d, 0x6f, 0x75, 0x73, 0x65, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 
 	0x64, 0x28, 0x78, 0x2c, 0x79, 0x2c, 0x62, 0x29, 0x20, 0x65, 0x6e, 0x64, 0x0a,
 	0x09, 0x09, 0x65, 0x6e, 0x64, 0x2c, 0x0a,
+	0x09, 0x09, 0x77, 0x68, 0x65, 0x65, 0x6c, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x20, 0x3d, 0x20, 0x66, 0x75, 0x6e, 
+	0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x78, 0x2c, 0x79, 0x29, 0x0a,
+	0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x77, 0x68, 0x65, 0x65, 0x6c, 0x6d, 0x6f, 
+	0x76, 0x65, 0x64, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6c, 0x6f, 
+	0x76, 0x65, 0x2e, 0x77, 0x68, 0x65, 0x65, 0x6c, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x28, 0x78, 0x2c, 0x79, 0x29, 
+	0x20, 0x65, 0x6e, 0x64, 0x0a,
+	0x09, 0x09, 0x65, 0x6e, 0x64, 0x2c, 0x0a,
 	0x09, 0x09, 0x6a, 0x6f, 0x79, 0x73, 0x74, 0x69, 0x63, 0x6b, 0x70, 0x72, 0x65, 0x73, 0x73, 0x65, 0x64, 0x20, 
 	0x3d, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x28, 0x6a, 0x2c, 0x62, 0x29, 0x0a,
 	0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x6a, 0x6f, 0x79, 0x73, 0x74, 0x69, 0x63,