Capabilities file I/O from Lua scripts
[jpcrr.git] / lua / generichud.lua
blob92651b1f95c2fed74dbef60588744647fa706135
1 dofile("textrender.lua");
3 keys = {}
4 keys.LEFT = 128 + 75;
5 keys.RIGHT = 128 + 77;
6 keys.UP = 128 + 72;
7 keys.DOWN = 128 + 80;
8 keys.SPACE = 57;
9 keys.LCTRL = 29;
10 keys.LALT = 56;
11 keys.LSHIFT = 42;
12 keys.RCTRL = 128 + 29;
13 keys.RALT = 128 + 56;
14 keys.RSHIFT = 54;
15 keys.ENTER = 28;
16 keys.ESC = 1;
18 print("Loading font...");
19 font, err = io.open_arch_read("unifont.jrsr");
20 if not font then
21 error("Can't open font: " .. err);
22 end
23 set_font_file(font);
24 print("Font loaded.");
26 while true do
27 jpcrr.next_frame();
28 jpcrr.hud.top_gap(3, 60);
29 render_text(3, 0, 0, "Timestamp: " .. tostring(jpcrr.clock_time()), false, 255, 255, 0);
30 index = 0;
31 for k, v in pairs(keys) do
32 if jpcrr.keypressed(v) then
33 render_text(3, index * 8, 20, k, false, 255, 255, 0);
34 end
35 index = index + #k + 1;
36 end
37 if jpcrr.joystick_state then
38 hA, hB, hC, hD, bA, bB, bC, bD = jpcrr.joystick_state();
39 else
40 render_text(3, 0 * 8, 40, false, "<Joystick status not available>", false, 255, 255, 0);
41 end
43 if bA then
44 render_text(3, 0 * 8, 40, "X", false, 255, 255, 0);
45 end
46 if hA then
47 render_text(3, 2 * 8, 40, tostring(hA), false, 255, 255, 0);
48 end
50 if bB then
51 render_text(3, 16 * 8, 40, "X", false, 255, 255, 0);
52 end
53 if hB then
54 render_text(3, 18 * 8, 40, tostring(hB), false, 255, 255, 0);
55 end
57 if bC then
58 render_text(3, 32 * 8, 40, "X", false, 255, 255, 0);
59 end
60 if hC then
61 render_text(3, 34 * 8, 40, tostring(hC), false, 255, 255, 0);
62 end
64 if bD then
65 render_text(3, 48 * 8, 40, "X", false, 255, 255, 0);
66 end
67 if hD then
68 render_text(3, 50 * 8, 40, tostring(hD), false, 255, 255, 0);
69 end
70 end