return function(R)
    R.Mouse={}

	function R.Mouse:new()
		local o={
			last=nil,
            now=nil,
		}
		setmetatable(o,self)
		self.__index=self
		return o
	end

    function R.Mouse:update()
        self.last=self.now
        local x,y,lb,mb,rb,sx,sy=mouse()
        self.now={
            x=x,y=y,
            lb=lb,mb=mb,rb=rb,
            sx=sx,sy=sy,
        }
        local lastLb,lastMb,lastRb=false,false,false
        if self.last~=nil then
            lastLb,lastMb,lastRb=self.last.lb,self.last.mb,self.last.rb
        end

        self.now.lbp=self.now.lb and not lastLb
        self.now.mbp=self.now.mb and not lastMb
        self.now.rbp=self.now.rb and not lastRb
        return self.now
    end
end