User File #638446035151128676

Upload All User Files

#638446035151128676 - DS Input Display

DS Display.lua
14 downloads
Uploaded 2/27/2024 4:05 AM by inconsistent (see all 18)
Adds an input display, made for DS but probably easy to put on other systems
-- @inconsistent_dg
-- can be simplified a lot, but will do that later!
-- (x paws, y paws, y width, x width )

function drawBox(x, y, width, height, color1, color2)
    gui.drawBox(x, y, width, height, 0x000000FF, color1)
    gui.drawBox(x, y, width, height, 0x000000FF, color2)
end

local ty = 20  -- l/r trigger y 
local px = 256 -- normal padding
local fx = 320 -- face x padding

local sx = 288 -- start/select x padding
local sy = 36 -- start/select y padding

function display()
    local held_buttons = joypad.getwithmovie()
    
    -- l/r
    drawBox( 0 + px, 16, 16 + px, 0, held_buttons["L"] and 0x77FFFFFF or 0x77002451, 0x77002451)
    drawBox(48 + fx, 16, 32 + fx, 0, held_buttons["R"] and 0x77FFFFFF or 0x77002451, 0x77002451)

    -- dpad
    drawBox(16 + px,  0 + ty, 32 + px, 16 + ty, held_buttons["Up"] and 0x77FFFFFF or 0x77002451, 0x77002451)
    drawBox(16 + px, 48 + ty, 32 + px, 32 + ty, held_buttons["Down"] and 0x77FFFFFF or 0x77002451, 0x77002451)
    drawBox( 0 + px, 32 + ty, 16 + px, 16 + ty, held_buttons["Left"] and 0x77FFFFFF or 0x77002451, 0x77002451)
    drawBox(48 + px, 32 + ty, 32 + px, 16 + ty, held_buttons["Right"] and 0x77FFFFFF or 0x77002451, 0x77002451)

    -- face buttons
    drawBox(16 + fx,  0 + ty, 32 + fx, 16 + ty, held_buttons["X"] and 0x77FFFFFF or 0x77002451, 0x77002451)
    drawBox(16 + fx, 48 + ty, 32 + fx, 32 + ty, held_buttons["B"] and 0x77FFFFFF or 0x77002451, 0x77002451)
    drawBox( 0 + fx, 32 + ty, 16 + fx, 16 + ty, held_buttons["Y"] and 0x77FFFFFF or 0x77002451, 0x77002451)
    drawBox(48 + fx, 32 + ty, 32 + fx, 16 + ty, held_buttons["A"] and 0x77FFFFFF or 0x77002451, 0x77002451)

    -- start/select
    drawBox( 0 + sx, 32 + sy + ty, 16 + sx, 16 + sy + ty, held_buttons["Select"] and 0x77FFFFFF or 0x77002451, 0x77002451)
    drawBox(48 + sx, 32 + sy + ty, 32 + sx, 16 + sy + ty, held_buttons["Start"] and 0x77FFFFFF or 0x77002451, 0x77002451)
end

while true do
    display()
    client.SetGameExtraPadding(0, 0, 113, 0)
    emu.frameadvance()
end