----------------------------------------
-- Vita Hardware Test v1.0 by @SMOKE587 --
----------------------------------------
Scr = { w = 960, --The screen resolution of the vita screen 960x544
h = 544};
-- init colors
white = Color.new(255,255,255,255)
yellow = Color.new(255,255,0,255)
red = Color.new(255,0,0,255)
lightred = Color.new(255,102,102,255)
blue = Color.new(0,0,255,255)
lightblue = Color.new(102,102,255,255)
imgDir = "app0:/res/img/"
sndDir = "app0:/res/snd/"
radius=10
-- init images
mainbg = Graphics.loadImage(imgDir .. "mainbg.png")
crossimg = Graphics.loadImage(imgDir .. "cross.png")
squareimg = Graphics.loadImage(imgDir .. "square.png")
circleimg = Graphics.loadImage(imgDir .. "circle.png")
triangleimg = Graphics.loadImage(imgDir .. "triangle.png")
startimg = Graphics.loadImage(imgDir .. "start.png")
selectimg = Graphics.loadImage(imgDir .. "select.png")
rtrigimg = Graphics.loadImage(imgDir .. "rtrig.png")
ltrigimg = Graphics.loadImage(imgDir .. "ltrig.png")
upimg = Graphics.loadImage(imgDir .. "up.png")
downimg = Graphics.loadImage(imgDir .. "down.png")
leftimg = Graphics.loadImage(imgDir .. "left.png")
rightimg = Graphics.loadImage(imgDir .. "right.png")
battlow = Graphics.loadImage(imgDir .. "battlow.png")
batt2550 = Graphics.loadImage(imgDir .. "batt2550.png")
batt5075 = Graphics.loadImage(imgDir .. "batt5075.png")
batt75100 = Graphics.loadImage(imgDir .. "batt75100.png")
battcharge = Graphics.loadImage(imgDir .. "battcharge.png")
-- init short button names
cross = SCE_CTRL_CROSS
square = SCE_CTRL_SQUARE
circle = SCE_CTRL_CIRCLE
triangle = SCE_CTRL_TRIANGLE
start = SCE_CTRL_START
selct = SCE_CTRL_SELECT
rtrigger = SCE_CTRL_RTRIGGER
ltrigger = SCE_CTRL_LTRIGGER
up = SCE_CTRL_UP
down = SCE_CTRL_DOWN
left = SCE_CTRL_LEFT
right = SCE_CTRL_RIGHT
-- init sound
Sound.init()
sndtest = Sound.openOgg(sndDir .. "sndtest.ogg")
Sound.play(sndtest, LOOP)
-- main loop
while true do
-- init sticks/touch stuff
rx,ry = Controls.readRightAnalog()
lx,ly = Controls.readLeftAnalog()
tx1,ty1,tx2,ty2 = Controls.readTouch()
rtx1,rty1,rtx2,rty2 = Controls.readRetroTouch()
-- prevent nil concatenation
if tx2 == nil then
tx2 = 0
ty2 = 0
if tx1 == nil then
tx1 = 0
ty1 = 0
end
end
-- ditto
if rtx2 == nil then
rtx2 = 0
rty2 = 0
if rtx1 == nil then
rtx1 = 0
rty1 = 0
end
end
-- init screen
Graphics.initBlend()
Screen.clear()
--init ui
Graphics.drawImage(0, 0, mainbg)
Graphics.debugPrint(0, 0, "Vita Hardware Test v1.0 by @SMOKE587", yellow)
Graphics.debugPrint(0, 30, "LStick X: " .. lx .. " - LStick Y: " .. ly .. " - RStick X: " .. rx .. " - RStick Y: " .. ry .."\nScreen X1: " .. tx1 .. " - Screen X2: " .. tx2 .. " - Screen Y1: " .. ty1 .. " - Screen Y2: " .. ty2 .."\nRetro X1: " .. rtx1 .. " - Retro X2: " .. rtx2 .. " - Retro Y1: " .. rty1 .. " - Retro Y2: " .. rty2, white)
Screen.flip()
-- check for button input
if Controls.check(Controls.read(), cross) then
Graphics.drawImage(0, 0, crossimg)
end
if Controls.check(Controls.read(), square) then
Graphics.drawImage(0, 0, squareimg)
end
if Controls.check(Controls.read(), circle) then
Graphics.drawImage(0, 0, circleimg)
end
if Controls.check(Controls.read(), triangle) then
Graphics.drawImage(0, 0, triangleimg)
end
if Controls.check(Controls.read(), start) then
Graphics.drawImage(0, 0, startimg)
end
if Controls.check(Controls.read(), selct) then
Graphics.drawImage(0, 0, selectimg)
end
if Controls.check(Controls.read(), rtrigger) then
Graphics.drawImage(0, 0, rtrigimg)
end
if Controls.check(Controls.read(), ltrigger) then
Graphics.drawImage(0, 0, ltrigimg)
end
if Controls.check(Controls.read(), up) then
Graphics.drawImage(0, 0, upimg)
end
if Controls.check(Controls.read(), down) then
Graphics.drawImage(0, 0, downimg)
end
if Controls.check(Controls.read(), left) then
Graphics.drawImage(0, 0, leftimg)
end
if Controls.check(Controls.read(), right) then
Graphics.drawImage(0, 0, rightimg)
end
-- init battstats
battpercent = System.getBatteryPercentage()
if System.isBatteryCharging() then
Graphics.drawImage(0, 0, battcharge)
elseif battpercent >= 75 then
Graphics.drawImage(0, 0, batt75100)
elseif battpercent >= 50 then
Graphics.drawImage(0, 0, batt5075)
elseif battpercent >= 25 then
Graphics.drawImage(0, 0, batt2550)
else Graphics.drawImage(0, 0, battlow)
end
----TOUCH---
if(tx1 + ty1 > 0) then
Graphics.fillCircle( (tx1*( (769-189)/Scr.w) )+168+21 , (ty1*( (469-146)/Scr.h) )+150-3 ,radius, red) --the +21 and -3 is some magic to fix some unknown problem..
end;
if(tx2 + ty2 > 0) then
Graphics.fillCircle( (tx2*( (769-189)/Scr.w) )+168+21 , (ty2*( (469-146)/Scr.h) )+150-3 ,radius, lightred) --the +21 and -3 is some magic to fix some unknown problem..
end;
------
----REAR------- NOTE REAR TOUCH Y AXIS WAY OFF
if(rtx1 + rty1 > 0) then
Graphics.fillCircle( (rtx1*( (769-189)/Scr.w) )+168+21 , (rty1*( (469-146)/Scr.h) )+150-3 ,radius, blue) --the +21 and -3 is some magic to fix some unknown problem..
end;
if(rtx2 + rty2 > 0) then
Graphics.fillCircle( (rtx2*( (769-189)/Scr.w) )+168+21 , (rty2*( (469-146)/Scr.h) )+150-3 ,radius, lightblue) --the +21 and -3 is some magic to fix some unknown problem..
end;
------
Screen.flip()
Graphics.termBlend()
end