Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -430,25 +430,27 @@ function love.mousepressed(x, y, button)
else
local termMouseX = math_bind(math.floor((x - _conf.terminal_guiScale) / Screen.pixelWidth) + 1,1,_conf.terminal_width)
local termMouseY = math_bind(math.floor((y - _conf.terminal_guiScale) / Screen.pixelHeight) + 1,1,_conf.terminal_height)

if button == "l" or button == "m" or button == "r" then
Computer.mouse.isPressed = true
Computer.mouse.lastTermX = termMouseX
Computer.mouse.lastTermY = termMouseY
if button == "l" then button = 1
elseif button == "m" then button = 3
elseif button == "r" then button = 2
end
table.insert(Computer.eventQueue, {"mouse_click", button, termMouseX, termMouseY})
elseif button == "wu" then -- Scroll up
table.insert(Computer.eventQueue, {"mouse_scroll", -1, termMouseX, termMouseY})
elseif button == "wd" then -- Scroll down
table.insert(Computer.eventQueue, {"mouse_scroll", 1, termMouseX, termMouseY})
end

Computer.mouse.isPressed = true
Computer.mouse.lastTermX = termMouseX
Computer.mouse.lastTermY = termMouseY
table.insert(Computer.eventQueue, {"mouse_click", button, termMouseX, termMouseY})
end
end
end

function love.wheelmoved( x, y )
local tx, ty = love.mouse.getPosition()
local termMouseX = math_bind(math.floor((tx - _conf.terminal_guiScale) / Screen.pixelWidth) + 1,1,_conf.terminal_width)
local termMouseY = math_bind(math.floor((ty - _conf.terminal_guiScale) / Screen.pixelHeight) + 1,1,_conf.terminal_height)

if y > 0 then
table.insert(Computer.eventQueue, {"mouse_scroll", -1, termMouseX, termMouseY})
elseif y < 0 then
table.insert(Computer.eventQueue, {"mouse_scroll", 1, termMouseX, termMouseY})
end
end

function love.textinput(unicode)
if not Computer.blockInput then
-- Hack to get around android bug
Expand Down Expand Up @@ -653,7 +655,7 @@ function Computer:update()
self.mouse.lastTermX = termMouseX
self.mouse.lastTermY = termMouseY

table.insert (self.eventQueue, {"mouse_drag", love.mouse.isDown("r") and 2 or 1, termMouseX, termMouseY})
table.insert (self.eventQueue, {"mouse_drag", love.mouse.isDown(2) and 2 or 1, termMouseX, termMouseY})
end
end

Expand Down