mirror of
https://github.com/ctruLua/uCompat.git
synced 2025-10-27 16:49:31 +00:00
Fixed the Stylus offset, and the FPS counter
This commit is contained in:
parent
d35173fc70
commit
1f016ffaf4
2 changed files with 21 additions and 3 deletions
|
|
@ -4,6 +4,10 @@
|
|||
Warning: this HID library will give you headaches. Really.
|
||||
]]
|
||||
|
||||
-- Surprise
|
||||
|
||||
require("uCompat.screen") -- needed for the stylus offset
|
||||
|
||||
-- Local
|
||||
|
||||
local ctr = require("ctr")
|
||||
|
|
@ -39,6 +43,11 @@ function Controls.read()
|
|||
end
|
||||
|
||||
Stylus.X, Stylus.Y = hid.touch()
|
||||
local offsetX, offsetY = screen.offset()
|
||||
Stylus.X = (Stylus.X - offsetX)
|
||||
if Stylus.X < 0 or Stylus.X > 255 then Stylus.X = stylusX end
|
||||
Stylus.Y = (Stylus.Y - offsetY)
|
||||
if Stylus.Y < 0 or Stylus.Y > 191 then Stylus.Y = stylusY end
|
||||
Stylus.deltaX = (stylusX-Stylus.X)
|
||||
Stylus.deltaY = (stylusY-Stylus.Y)
|
||||
stylusX, stylusY = Stylus.X, Stylus.Y
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ local fpstime = ctr.time()
|
|||
|
||||
local function RGB2RGBA(c)
|
||||
if not c then return nil end
|
||||
return (c*256)+(alpha*2.55)
|
||||
return (c*256)+math.floor(alpha*2.55)
|
||||
end
|
||||
|
||||
local function checkBuffer(scr)
|
||||
|
|
@ -65,9 +65,12 @@ end
|
|||
function stopDrawing()
|
||||
|
||||
-- FPS counter
|
||||
if drawScreen == 0 then
|
||||
fpscount = fpscount + 1
|
||||
end
|
||||
if (ctr.time() - fpstime) > 1000 then
|
||||
NB_FPS = fpscount
|
||||
NB_FPS = math.floor(fpscount/2) -- remove the "/2" to enjoy having "60 FPS" displayed :)
|
||||
fpstime = ctr.time()
|
||||
fpscount = 0
|
||||
end
|
||||
|
||||
|
|
@ -193,6 +196,12 @@ function screen.waitForVBL() -- unused
|
|||
|
||||
end
|
||||
|
||||
-- Interface
|
||||
|
||||
function screen.offset()
|
||||
return offsetX, offsetY
|
||||
end
|
||||
|
||||
-- Initialize the thing
|
||||
|
||||
startDrawing()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue