You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
functionlove.load()
WIDTH,HEIGHT=love.graphics.getDimensions()
R,G,B=1,1,1EXPECT_X,EXPECT_Y=0,0WTF_X, WTF_Y=nil,nildolocaloverride=trueifoverridethenffi=require('ffi')
localsdl=ffi.load('SDL2.dll')
ffi.cdef[[typedefenum {SDL_HINT_DEFAULT , SDL_HINT_NORMAL , SDL_HINT_OVERRIDE } SDL_HintPriority ;
boolSDL_SetHintWithPriority(constchar*name, constchar*value, SDL_HintPrioritypriority);
intShowCursor(boolbShow);
intSetCursor(inthCursor);
intLoadImageA(inthInstance, constchar*lpCursorName, unsignedinttype, intcx, intcy, unsignedintfuload);
intLoadCursorA(inta, uint64_t);
]]sdl.SDL_SetHintWithPriority('SDL_MOUSE_RELATIVE_SPEED_SCALE','1',ffi.C.SDL_HINT_OVERRIDE)
endendhCur=ffi.C.LoadCursorA(0,32515)
love.mouse.setCursor(love.mouse.getSystemCursor("crosshair"))
endfunctionlove.draw()
localx,y=love.mouse.getPosition()
iflove.mouse.getRelativeMode() thenifEXPECT_X~=xorEXPECT_Y~=ythenR,G,B=1,0,0WTF_X,WTF_Y=x,yendendlove.graphics.setColor(R,G,B)
localstr=x..','..yifWTF_X~=nilandWTF_Y~=nilthenstr=str..'\n' ..WTF_X..',' ..WTF_Yendlove.graphics.print(str)
endfunctionlove.keypressed(key)
ifkey=='f10' thenlocalenabled=love.mouse.getRelativeMode()
ifnotenabledthenlove.mouse.setPosition(WIDTH/2,HEIGHT/2)
EXPECT_X,EXPECT_Y=love.mouse.getPosition()
WTF_X, WTF_Y=nil,nilendR,G,B=1,1,1love.mouse.setRelativeMode(notenabled)
endendfunctionlove.mousemoved()
iflove.mouse.getRelativeMode() thenlove.mouse.setPosition(WIDTH/2,HEIGHT/2) endendfunctionlove.run()
iflove.loadthenlove.load(love.arg.parseGameArguments(arg), arg) end-- We don't want the first frame's dt to include time taken by love.load.iflove.timerthenlove.timer.step() endlocaldt=0-- Main loop time.returnfunction()
-- Process events.iflove.eventthenlove.event.pump()
ffi.C.SetCursor(hCur)
forname, a,b,c,d,e,finlove.event.poll() doifname=="quit" thenifnotlove.quitornotlove.quit() thenreturnaor0endendlove.handlers[name](a,b,c,d,e,f)
endend-- Update dt, as we'll be passing it to updateiflove.timerthendt=love.timer.step() end-- Call update and drawiflove.updatethenlove.update(dt) end-- will pass 0 if love.timer is disablediflove.graphicsandlove.graphics.isActive() thenlove.graphics.origin()
love.graphics.clear(love.graphics.getBackgroundColor())
iflove.drawthenlove.draw() endlove.graphics.present()
endiflove.timerthenlove.timer.sleep(0.001) endendend
Then, start spamming your left and right mouse buttons while shaking your mouse. You will observe the following:
The cursor sometimes flashing invisible for a split second (expected, since callbacks in Love2D could not catch up to SDL's instantaneous WM_SETCURSOR response to Windows
The cursor sometimes flashing to a different spot on the screen for a split second (this should not happen under any circumstance, regardless of whether or not RelativeMode is meant to have the cursor visible. Somewhere in the code SDL is issuing an errenous WarpCursor or unclip-cursor-then-reclip for no good reason that is separate from the pre-drawing warp calback being issued from Lua)
The SDL's internal position slightly warping from the logical center, despite the mousemoved callback warping it back to center before drawing the frame.
The text was updated successfully, but these errors were encountered:
No.1 is directly addressed by the change, but I have no idea why it would also fix no.2, so the latent issue is probably still there related to erroneous window focus events.
Run the following Love2D script:
Then, start spamming your left and right mouse buttons while shaking your mouse. You will observe the following:
WM_SETCURSOR
response to WindowsThe text was updated successfully, but these errors were encountered: