NDS Stylus Input Display script improvements and warnings
This commit is contained in:
parent
1ddbada5e4
commit
70cd0eab16
|
@ -5,6 +5,28 @@ local downColor = 'red'
|
|||
local dotColor = 'blue'
|
||||
|
||||
client.setwindowsize(client.getwindowsize()) -- assert a sane resolution
|
||||
console.writeline("Window size must be at an integer scale for this script to work, this will be asserted now and for screen layout changes")
|
||||
console.writeline("WARNING! Using a higher than support window size for your monitor may cause this script to fail! (e.g. 1980x1080 cannot go past 2x window size) Keep the window size to your resolution!"
|
||||
|
||||
local prevScreenLayout = nds.getscreenlayout()
|
||||
|
||||
function ResolveSettingIssuesIfNeeded()
|
||||
local screenLayout = nds.getscreenlayout()
|
||||
if screenLayout == "Horizontal" and not nds.getscreeninvert() then
|
||||
console.writeline("Non-inverted horizontal screens are unsupported, switching to inverted screens")
|
||||
nds.setscreeninvert(true)
|
||||
end
|
||||
if nds.getscreengap() ~= 0 then
|
||||
console.writeline("Non-zero screen gap is unsupported, setting screen gap to 0 and asserting window size")
|
||||
nds.setscreengap(0)
|
||||
client.setwindowsize(client.getwindowsize())
|
||||
end
|
||||
if prevScreenLayout ~= screenLayout then
|
||||
console.writeline("screen layout changed, asserting window size")
|
||||
client.setwindowsize(client.getwindowsize())
|
||||
prevScreenLayout = screenLayout
|
||||
end
|
||||
end
|
||||
|
||||
function Draw(x, y, maxX, maxY, isDown)
|
||||
color = upColor
|
||||
|
@ -38,6 +60,8 @@ while true do
|
|||
console.log('This script is for Nintendo DS only')
|
||||
break
|
||||
end
|
||||
|
||||
ResolveSettingIssuesIfNeeded()
|
||||
|
||||
local btns = joypad.get()
|
||||
|
||||
|
@ -45,34 +69,23 @@ while true do
|
|||
btns = movie.getinput(emu.framecount() - 1)
|
||||
end
|
||||
|
||||
local invert = nds.getscreeninvert()
|
||||
local wsz = client.getwindowsize()
|
||||
local xo = 0
|
||||
local yo = 0
|
||||
|
||||
if nds.getscreenlayout() == "Horizontal" then
|
||||
if invert then
|
||||
xo = xo - 256
|
||||
else
|
||||
console.writeline("Non-inverted horizontal screens are unsupported, switching to inverted screens")
|
||||
nds.setscreeninvert(true)
|
||||
xo = xo - 256
|
||||
end
|
||||
else -- vertical
|
||||
if invert then
|
||||
yo = yo - 192
|
||||
else
|
||||
-- don't need to do anything here
|
||||
end
|
||||
xo = -256
|
||||
elseif nds.getscreeninvert() then
|
||||
yo = -192
|
||||
end
|
||||
|
||||
local x = btns['Touch X'] + xo
|
||||
local y = btns['Touch Y'] + yo
|
||||
local isDown = btns['Touch']
|
||||
|
||||
pts = client.transformPoint(x, y)
|
||||
local pts = client.transformPoint(x, y)
|
||||
local tx = pts["x"];
|
||||
local ty = pts["y"];
|
||||
local wsz = client.getwindowsize()
|
||||
Draw(tx / wsz, ty / wsz, 10000, 10000, isDown)
|
||||
|
||||
emu.yield()
|
||||
|
|
Loading…
Reference in New Issue