diff --git a/tests/interactive/canvasresize/canvasresize.lua b/tests/interactive/canvasresize/canvasresize.lua index 5449a205e..4f64ef7f3 100644 --- a/tests/interactive/canvasresize/canvasresize.lua +++ b/tests/interactive/canvasresize/canvasresize.lua @@ -12,12 +12,13 @@ end function canvasresize_input(iotbl) if (iotbl.kind == "digital" and iotbl.active) then - if (keysym[iotbl.keysym] == "F1") then + local label = keysym.tolabel(iotbl.keysym) + if (label == "F1") then resize_video_canvas(VRESW * 2, VRESH * 2); b = fill_surface(200, 200, 0, 255, 0); show_image(b); move_image(b, VRESW, VRESH, 200); - elseif (keysym[iotbl.keysym] == "F2") then + elseif (label == "F2") then zap_resource("test.png"); save_screenshot("test.png", 1, WORLDID); end diff --git a/tests/interactive/eventtest/eventtest.lua b/tests/interactive/eventtest/eventtest.lua index 9ceb799f8..b00b5bff2 100644 --- a/tests/interactive/eventtest/eventtest.lua +++ b/tests/interactive/eventtest/eventtest.lua @@ -110,11 +110,12 @@ function digital_str(iotbl) end function translate_str(iotbl) + local label = symtable.tolabel(iotbl.keysym) table.insert(translatetbl, string.format("dev(%d:%d)%d[%s] => %s, %s, %s, %s", iotbl.devid, iotbl.subid, iotbl.number, table.concat(decode_modifiers(iotbl.modifiers),","), iotbl.keysym, iotbl.active and "press" or "release", - symtable[iotbl.keysym] and symtable[iotbl.keysym] or "_nil", + label or "_nil", iotbl.utf8) ); diff --git a/tests/interactive/failover/failover.lua b/tests/interactive/failover/failover.lua index 24aa4b89a..fe7582f60 100644 --- a/tests/interactive/failover/failover.lua +++ b/tests/interactive/failover/failover.lua @@ -1,7 +1,12 @@ function failover() - a = list_games({}) symtbl = system_load("builtin/keyboard.lua")(); + a = list_targets(); + + if (#a == 0) then + return shutdown("no targets found, can not run the test"); + end + system_context_size(10); pop_video_context(); @@ -9,7 +14,7 @@ function failover() for i=1,2 do local vid = launch_target( - a[math.random(#a)].gameid, LAUNCH_INTERNAL, cb); + a[math.random(#a)], LAUNCH_INTERNAL, cb); table.insert(fsrvs, vid); print(#fsrvs); end @@ -59,24 +64,25 @@ function failover_adopt(id) end function failover_input(iotbl) + local label = symtbl.tolabel(iotbl.keysym) if (iotbl.kind == "digital" and iotbl.translated and iotbl.active) then - if (symtbl[iotbl.keysym] == "1") then + if (label == "1") then local img = color_surface(32, 32, math.random(127) + 127, math.random(127) + 127, 0); show_image(img); move_image(img, math.random(VRESW), math.random(VRESH)); - elseif (symtbl[iotbl.keysym] == "2") then + elseif (label == "2") then print("request collapse"); x_p = 0; y_p = 0; fsrvs = {}; system_collapse(); - elseif (symtbl[iotbl.keysym] == "3") then + elseif (label == "3") then system_collapse("failadopt"); - elseif (symtbl[iotbl.keysym] == "4") then + elseif (label == "4") then this_should_trigger_perror(); - elseif (symtbl[iotbl.keysym] == "5") then + elseif (label == "5") then print("pacify", #fsrvs); for i=1,#fsrvs do target_pacify(fsrvs[i]); diff --git a/tests/interactive/imagetest/imagetest.lua b/tests/interactive/imagetest/imagetest.lua index 48e5c4b93..f8d1b1bb8 100644 --- a/tests/interactive/imagetest/imagetest.lua +++ b/tests/interactive/imagetest/imagetest.lua @@ -121,46 +121,47 @@ end function imagetest_input(inputtbl) if (inputtbl.kind == "digital" and inputtbl.translated and inputtbl.active) then - if (symtable[ inputtbl.keysym ] == "ESCAPE") then + local label = symtable.tolabel(inputtbl.keysym) + if (label == "ESCAPE") then shutdown(); - elseif (symtable[ inputtbl.keysym ] == "1") then + elseif (label == "1") then print("Running instancing test"); instancing_test(); - elseif (symtable[ inputtbl.keysym ] == "2") then + elseif (label == "2") then print("Running Z order/limit test"); zordervidlim(false); - elseif (symtable[ inputtbl.keysym ] == "3") then + elseif (label == "3") then print("Running image loading stress"); zordervidlim(true); - elseif (symtable[ inputtbl.keysym ] == "4") then + elseif (label == "4") then print("Double stacksize for next layer"); stacksize = stacksize * 2; system_context_size(stacksize); - elseif (symtable[ inputtbl.keysym ] == "l") then + elseif (label == "l") then print("Loading image into context"); local vid = imagefun("imagetest.png"); resize_image(vid, 64, 64); move_image(vid, math.random(VRESW - 64), math.random(VRESH - 64), 0); order_image(vid, 0); show_image(vid); - elseif (symtable[ inputtbl.keysym ] == "s") then + elseif (label == "s") then text_vid = BADID; print("Stack push => " .. tostring ( push_video_context() ) ); - elseif (symtable[ inputtbl.keysym ] == "d") then + elseif (label == "d") then num, vid = storepush_video_context(); show_image(vid); print("Stack push store => " .. tostring(num) .. " => " .. tostring(vid)); - elseif (symtable[ inputtbl.keysym ] == "f") then + elseif (label == "f") then num, vid = storepop_video_context(); show_image(vid); print("Stack pop store => " .. tostring(num) .. " => " .. tostring(vid)); - elseif (symtable[ inputtbl.keysym ] == "p") then + elseif (label == "p") then print("Stack pop => " .. tostring ( pop_video_context() ) ); - elseif (symtable[inputtbl.keysym] == "a") then + elseif (label == "a") then print("Switching image mode\n"); imagefun = imagefun == load_image and load_image_asynch or load_image - elseif (symtable[inputtbl.keysym] == "r") then + elseif (label == "r") then local tbl = {}; for i=1,(256 * 256) do table.insert(tbl, math.random(255)); diff --git a/tests/interactive/kbdtest/kbdtest.lua b/tests/interactive/kbdtest/kbdtest.lua index 69ebc5ccd..22026411b 100644 --- a/tests/interactive/kbdtest/kbdtest.lua +++ b/tests/interactive/kbdtest/kbdtest.lua @@ -54,10 +54,11 @@ end function kbdtest_input(inp) if (inp.translated and inp.active) then + local label = symtable.tolabel(inp.keysym) last_event = 500; table.insert(history, { CLOCK, inp.devid, inp.subid, inp.keysym, - symtable[inp.keysym] and symtable[inp.keysym] or "" + label or "" } ); if (#history > 10) then @@ -72,15 +73,15 @@ function kbdtest_input(inp) upd_period(); end - if (symtable[inp.keysym] == "F1") then + if (label == "F1") then uprd(-per, -del); - elseif (symtable[inp.keysym] == "F2") then + elseif (label == "F2") then uprd(20, 0); - elseif (symtable[inp.keysym] == "F3") then + elseif (label == "F3") then uprd(-20, 0); - elseif (symtable[inp.keysym] == "F4") then + elseif (label == "F4") then uprd(0, 20); - elseif (symtable[inp.keysym] == "F5") then + elseif (label == "F5") then uprd(0, -20); end end diff --git a/tests/interactive/mdispcl/mdispcl.lua b/tests/interactive/mdispcl/mdispcl.lua index 348a6a6d2..287ebe57c 100644 --- a/tests/interactive/mdispcl/mdispcl.lua +++ b/tests/interactive/mdispcl/mdispcl.lua @@ -63,15 +63,15 @@ end -- -- Event callback for display configuration hotplug -- -function mdispcl_display_state(state, arg) +function mdispcl_display_state(state, displayid) if (state == "added") then - table.insert(active_displays, arg[1].displayid); - map_video_display(WORLDID, arg[1].displayid); + table.insert(active_displays, displayid); + map_video_display(WORLDID, displayid); elseif (state == "removed") then for k,v in ipairs(active_displays) do - if (v == arg) then + if (v == displayid) then table.remove(active_displays, k); break; end @@ -81,8 +81,9 @@ function mdispcl_display_state(state, arg) end function mdispcl_input(iotbl) + local label = symtable.tolabel(iotbl.keysym) if (iotbl.translated and iotbl.active and - dispatch[symtable[iotbl.keysym]]) then - dispatch[symtable[iotbl.keysym]](); + dispatch[label]) then + dispatch[label](); end end diff --git a/tests/interactive/mdispwm/mdispwm.lua b/tests/interactive/mdispwm/mdispwm.lua index b5a71eaaf..3db09a945 100644 --- a/tests/interactive/mdispwm/mdispwm.lua +++ b/tests/interactive/mdispwm/mdispwm.lua @@ -19,7 +19,7 @@ meta_key = "LCTRL"; function mdispwm() system_load("scripts/composition_surface.lua")(); - system_load("scripts/mouse.lua")(); + system_load("builtin/mouse.lua")(); symtable = system_load("builtin/keyboard.lua")(); -- ugly red square as mouse cursor @@ -125,12 +125,13 @@ function mdispwm_input(iotbl) end elseif (iotbl.translated) then + local label = symtable.tolabel(iotbl.keysym) -- propagate meta-key state (for resize / drag / etc.) - if (symtable[ iotbl.keysym ] == meta_key) then + if (label == meta_key) then wm.meta = iotbl.active and true or nil; -- spawn a random color surface for testing - elseif (symtable[ iotbl.keysym ] == "F11" and iotbl.active) then + elseif (label == "F11" and iotbl.active) then surf = color_surface(128, 128, math.random(128)+127, math.random(128)+127, math.random(128)+127); @@ -138,7 +139,7 @@ function mdispwm_input(iotbl) wnd:set_border(1); -- delete the selected window - elseif (symtable[ iotbl.keysym ] == "DELETE" and + elseif (label == "DELETE" and wm.meta == true and wm.selected and iotbl.active) then wm.selected:destroy(); diff --git a/tests/interactive/movietest/movietest.lua b/tests/interactive/movietest/movietest.lua index 81ced6f09..378744dc2 100644 --- a/tests/interactive/movietest/movietest.lua +++ b/tests/interactive/movietest/movietest.lua @@ -73,18 +73,19 @@ end function movietest_input( inputtbl ) if (inputtbl.kind == "digital" and inputtbl.translated and inputtbl.active) then - if (symtable[ inputtbl.keysym ] == "d") then + local label = symtable.tolabel(inputtbl.keysym) + if (label == "d") then - elseif (symtable[ inputtbl.keysym ] == "s") then + elseif (label == "s") then vid, aid = launch_decode("movietest.avi"); img.last = vid; move_image(vid, cursor.x, cursor.y); show_image(vid); - elseif (symtable[ inputtbl.keysym ] == "p") then + elseif (label == "p") then pause_movie(img.last); - elseif (symtable[ inputtbl.keysym ] == "w") then + elseif (label == "w") then width = 128 + math.random(1024); height = 128 + math.random(1024); print("Requesting:", "capture:" .. webcam_ind, tostring(width) .. "x" .. tostring(height)); @@ -100,9 +101,9 @@ end ); move_image(vid, cursor.x, cursor.y); show_image(vid); - elseif (symtable[ inputtbl.keysym] == "r") then + elseif (label == "r") then resume_movie(img.last); - elseif (symtable[ inputtbl.keysym] == "ESCAPE") then + elseif (label == "ESCAPE") then shutdown(); end diff --git a/tests/interactive/outputs/outputs.lua b/tests/interactive/outputs/outputs.lua index e2bfb782b..4d7dd5dbc 100644 --- a/tests/interactive/outputs/outputs.lua +++ b/tests/interactive/outputs/outputs.lua @@ -65,7 +65,7 @@ function outputs() end function outputs_input(iotbl) - local sym = symtable[iotbl.keysym]; + local sym = symtable.tolabel(iotbl.keysym); if (iotbl.active and sym and sym == " ") then modes[mode_ind](false); mode_ind = mode_ind + 1; diff --git a/tests/interactive/picktest/picktest.lua b/tests/interactive/picktest/picktest.lua index 46362072e..d7be8f7db 100644 --- a/tests/interactive/picktest/picktest.lua +++ b/tests/interactive/picktest/picktest.lua @@ -108,7 +108,7 @@ function picktest_input(iotbl) print("done\n"); elseif (iotbl.kind == "digital") then if (iotbl.translated) then - local sym = symtable[iotbl.keysym]; + local sym = symtable.tolabel(iotbl.keysym); if (iotbl.active) then if (sym == "UP") then diff --git a/tests/interactive/rtdensity/rtdensity.lua b/tests/interactive/rtdensity/rtdensity.lua index 52423d090..8d89edba5 100644 --- a/tests/interactive/rtdensity/rtdensity.lua +++ b/tests/interactive/rtdensity/rtdensity.lua @@ -15,8 +15,9 @@ end delta = 0; function rtdensity_input(iotbl) if (iotbl.digital and iotbl.active) then - if (iotbl.translated and symtable[iotbl.keysym]) then - if (symtable[iotbl.keysym] == "m") then + local label = symtable.tolabel(iotbl.keysym) + if (iotbl.translated and label) then + if (label == "m") then print("switching to 1"); local lst = rendertarget_vids(rt_2); for k,v in ipairs(lst) do diff --git a/tests/interactive/scan/scan.lua b/tests/interactive/scan/scan.lua index 246e5d50b..aac4644f9 100644 --- a/tests/interactive/scan/scan.lua +++ b/tests/interactive/scan/scan.lua @@ -38,7 +38,7 @@ end function scan_input(iotbl) if (iotbl.translated and iotbl.active) then - local sym = symtable[iotbl.keysym]; + local sym = symtable.tolabel(iotbl.keysym); if (sym == "F1") then local modes = video_displaymodes(0); mode = modes[math.random(1, #modes)]; @@ -68,9 +68,9 @@ function scan_input(iotbl) end end -function scan_display_state(a, b) - if (a == "added") then - video_displaymodes(b[1].displayid, b[1].modeid); - map_video_display(WORLDID, b[1].displayid); +function scan_display_state(event, displayid) + if (event == "added") then + video_displaymodes(displayid); + map_video_display(WORLDID, displayid); end end diff --git a/tests/interactive/segtest/segtest.lua b/tests/interactive/segtest/segtest.lua index b7f241343..3152f4382 100644 --- a/tests/interactive/segtest/segtest.lua +++ b/tests/interactive/segtest/segtest.lua @@ -30,13 +30,14 @@ end function segtest_input(iotbl) if (iotbl.kind == "digital" and iotbl.active) then - if (symtable[iotbl.keysym] == "F10") then + local label = symtable.tolabel(iotbl.keysym) + if (label == "F10") then print("dropping main seg"); delete_image(test); - elseif(symtable[iotbl.keysym] == "F9") then + elseif(label == "F9") then print("dropping alt seg"); delete_image(newvid); - elseif (symtable[iotbl.keysym] == "F8") then + elseif (label == "F8") then target_alloc("mykey", seg2); else print("input to:", newvid); diff --git a/tests/interactive/soundtest/soundtest.lua b/tests/interactive/soundtest/soundtest.lua index 91f38647b..45a640d52 100644 --- a/tests/interactive/soundtest/soundtest.lua +++ b/tests/interactive/soundtest/soundtest.lua @@ -76,7 +76,7 @@ end function soundtest_input( inputtbl ) if (inputtbl.kind == "digital" and inputtbl.active and inputtbl.translated) then - local sym = symtable[ inputtbl.keysym ] + local sym = symtable.tolabel(inputtbl.keysym) local num = tonumber(sym) if num and tones[num] then @@ -97,7 +97,7 @@ function soundtest_input( inputtbl ) print("play", playback) play_audio(playback, 1.0, queue_next) - elseif (symtable[ inputtbl.keysym ] == "f") then + elseif (sym == "f") then if (sample_countdown > 0) then sample_countdown = 0; print("disabling sample spam"); @@ -106,7 +106,7 @@ function soundtest_input( inputtbl ) sample_countdown = 15; end - elseif (symtable[ inputtbl.keysym ] == "ESCAPE") then + elseif (sym == "ESCAPE") then shutdown(); end end diff --git a/tests/interactive/switcher/switcher.lua b/tests/interactive/switcher/switcher.lua index 0951892f2..fb62dbd0c 100644 --- a/tests/interactive/switcher/switcher.lua +++ b/tests/interactive/switcher/switcher.lua @@ -8,7 +8,7 @@ end function switcher_input(iotbl) if (iotbl.translated) then - local key = symtable [ iotbl.keysym ] + local key = symtable.tolabel(iotbl.keysym) local num = tonumber(key) if (num and list[num]) then pop_video_context() diff --git a/tests/interactive/vidtag/vidtag.lua b/tests/interactive/vidtag/vidtag.lua index 96e0a706d..5da380f3e 100644 --- a/tests/interactive/vidtag/vidtag.lua +++ b/tests/interactive/vidtag/vidtag.lua @@ -1,4 +1,5 @@ function vidtag() + local arguments = appl_arguments() fname = arguments[1]; vfc = 0; symtable = system_load("builtin/keyboard.lua")(); @@ -58,7 +59,7 @@ end function vidtag_input(iotbl) if (iotbl.kind == "digital" and iotbl.translated and iotbl.active) then - sym = symtable[iotbl.keysym]; + sym = symtable.tolabel(iotbl.keysym); if (sym == " ") then start_recording(); diff --git a/tests/interactive/vrtest2/vrtest2.lua b/tests/interactive/vrtest2/vrtest2.lua index de8d4750a..2e7727bcf 100644 --- a/tests/interactive/vrtest2/vrtest2.lua +++ b/tests/interactive/vrtest2/vrtest2.lua @@ -276,7 +276,7 @@ function vrtest2_input(iotbl) return; end - local sym = symtable[iotbl.keysym]; + local sym = symtable.tolabel(iotbl.keysym); if (not sym) then return; end diff --git a/tests/interactive/xwmroot/xwm.lua b/tests/interactive/xwmroot/xwmroot.lua similarity index 100% rename from tests/interactive/xwmroot/xwm.lua rename to tests/interactive/xwmroot/xwmroot.lua