BUG in touch/mouse callbacks on Windows

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Silver Ankh
Prole
Posts: 11
Joined: Tue Dec 19, 2017 10:29 am

BUG in touch/mouse callbacks on Windows

Post by Silver Ankh »

When touch is RELEASED two callbacks are triggered: love.touchreleased() and love.mousereleased() and it seems to be OK,but
when touch is PRESSED only love.touchpressed() is triggered, however love.mousepressed() is triggered when touch is moved or when touch is released (together with love.mousereleased()).
Try this simple program for better understanding.

Code: Select all

love.window.setFullscreen(true, "desktop")
local cMP, cMR, cTP, cTR = 0, 0, 0, 0
local cMPX, cMPY = 0, 0
local cMRX, cMRY = 0, 0
local cTPX, cTPY = 0, 0
local cTRX, cTRY = 0, 0
local xMP, xMR, xTP, xTR = "", "", "", ""

function love.mousepressed(x, y, button, isTouch)
    if x < 40 and y < 40 then
        love.event.quit()
    end
    cMP = cMP + 1
    xMP = "#" .. tostring(cMP) .. "." .. " X: " .. tostring(x) .. ", Y: " .. tostring(y)
    if isTouch then
        xMP = xMP .. " (Touch)"
    end
end

function love.mousereleased(x, y, button, isTouch)
    cMR = cMR + 1
    xMR = "#" .. tostring(cMR) .. "." .. " X: " .. tostring(x) .. ", Y: " .. tostring(y)
    if isTouch then
        xMR = xMR .. " (Touch)"
    end
end

function love.touchpressed(id, x, y, dx, dy, pressure)
    if x < 40 and y < 40 then
        love.event.quit()
    end
    cTP = cTP + 1
    xTP = "#" .. tostring(cTP) .. "." .. " X: " .. tostring(x) .. ", Y: " .. tostring(y)
end

function love.touchreleased(id, x, y, dx, dy, pressure)
    cTR = cTR + 1
    xTR = "#" .. tostring(cTR) .. "." .. " X: " .. tostring(x) .. ", Y: " .. tostring(y)
end

function love.update(dt)
end

function love.draw()
    love.graphics.setColor(1, 1, 1, 1)
    love.graphics.rectangle("fill", 0, 0, 40, 40)
    love.graphics.setColor(0, 0, 0, 1)
    love.graphics.print("QUIT", 5, 13)
    love.graphics.setColor(1, 1, 1, 1)
    love.graphics.print("Last .mousepressed()", 0, 50);   love.graphics.print(xMP, 160, 50)
    love.graphics.print("Last .mousereleased()", 0, 70);  love.graphics.print(xMR, 160, 70)
    love.graphics.print("Last .touchpressed()", 0, 90);   love.graphics.print(xTP, 160, 90)
    love.graphics.print("Last .touchreleased()", 0, 110); love.graphics.print(xTR, 160, 110)
end
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: BUG in touch/mouse callbacks on Windows

Post by slime »

love uses SDL for input, and SDL's touch/mouse event code on Windows uses Microsoft's Windows APIs pretty directly. This might be an issue with Windows or your touchscreen's drivers.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: BUG in touch/mouse callbacks on Windows

Post by davisdude »

You can use the isTouch parameter for mousepressed/released to determine if it originated as a touch or click.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Silver Ankh
Prole
Posts: 11
Joined: Tue Dec 19, 2017 10:29 am

Re: BUG in touch/mouse callbacks on Windows

Post by Silver Ankh »

slime wrote: Mon Jan 01, 2018 4:19 pm love uses SDL for input, and SDL's touch/mouse event code on Windows uses Microsoft's Windows APIs pretty directly. This might be an issue with Windows or your touchscreen's drivers.
OK, love.touchpressed() and love.touchreleased() working fine, I can use them for touch instead of mouse callbacks, no problem.
Thank you
Silver Ankh
Prole
Posts: 11
Joined: Tue Dec 19, 2017 10:29 am

Re: BUG in touch/mouse callbacks on Windows

Post by Silver Ankh »

davisdude wrote: Mon Jan 01, 2018 4:50 pm You can use the isTouch parameter for mousepressed/released to determine if it originated as a touch or click.
You probably don't understand what I mean. I can't use isTouch parameter because love.mousepressed() is NOT triggered when I touch the screen. Is triggered in other, wrong moment.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests