diff --git a/uCompat/Controls.lua b/uCompat/Controls.lua index 5673799..baf129f 100644 --- a/uCompat/Controls.lua +++ b/uCompat/Controls.lua @@ -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 diff --git a/uCompat/screen.lua b/uCompat/screen.lua index 9c27d1f..45825ef 100644 --- a/uCompat/screen.lua +++ b/uCompat/screen.lua @@ -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 - fpscount = fpscount + 1 + 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()