Skip to content
Browse files

new file: MouseInteractor.lua

	deleted:    test_tv_service.lua
	renamed:    test_syscall.lua -> tests/test_syscall.lua
  • Loading branch information...
1 parent e5452d4 commit a03359210de8597fce1d264a5057279fcf631255 @Wiladams committed Oct 30, 2012
Showing with 56 additions and 0 deletions.
  1. +54 −0 MouseInteractor.lua
  2. 0 test_tv_service.lua
  3. +2 −0 { → tests}/test_syscall.lua
View
54 MouseInteractor.lua
@@ -0,0 +1,54 @@
+
+MouseInteractor = {}
+MouseInteractor_mt = {
+ __index = MouseInteractor,
+}
+
+
+MouseInteractor.new = function(devicename)
+ local obj = {
+ MouseDeviceName = devicename,
+ MouseInteractors = {},
+ MouseMovers = {},
+ MouseDowners = {},
+ MouseUppers = {},
+ }
+ setmetatable(obj, MouseInteractor_mt);
+
+ return obj;
+end
+
+MouseInteractor.OnDeviceReadyForRead = function(self)
+ -- read from the device
+end
+
+MouseInteractor.OnMouseMove = function(self, x, y, flags, device)
+ for i,interactor in ipairs(self.MouseInteractors) do
+ observer:OnMouseMove(x, y, flags, device)
+ end
+
+ for i,mover in ipairs(self.MouseMovers) do
+ mover(x,y,flags, device)
+ end
+end
+
+MouseInteractor.OnMouseDown = function(self, x, y, button, flags, device)
+ for i,downer in ipairs(self.MouseDowners) do
+ downer(x, y, button, flags, device)
+ end
+end
+
+MouseInteractor.OnMouseUp = function(self, x, y, button, flags, device)
+ for i,upper in ipairs(self.MouseUppers) do
+ upper(x, y, button, flags, device)
+ end
+end
+
+
+MouseInteractor.AddMouseInteractor = function(self, observer)
+ table.insert(self.MouseInteractors, observer)
+
+ return true
+end
+
+MouseInteractor.Add
View
0 test_tv_service.lua
No changes.
View
2 test_syscall.lua → tests/test_syscall.lua
@@ -1,3 +1,5 @@
+package.path = package.path..";../?.lua"
+
-- test suite for ljsyscall.
local strict = require "strict"

0 comments on commit a033592

Please sign in to comment.
Something went wrong with that request. Please try again.