No Comment
Posted: Thu Nov 25, 2010 2:26 pm
Scancodes Picker.
Code: Select all
--//______________________________________________________________________________________________
function love.load()
--// screen options
scrx = 640; scry = 480;
love.graphics.setMode(scrx, scry, false, true, 0);
love.graphics.setCaption("Scancodes Picker"); love.graphics.setBackgroundColor(10, 30, 50);
--// font options
love.graphics.setFont(14);
--// global
ke_text="a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|" ..
"0|1|2|3|4|5|6|7|8|9|" ..
"(space)|!|#|$|&|'|(|)|*|+|,|-|.|/|:|;|<|=|>|?|@|[|\|]|^|_|`|" ..
"kp0|kp1|kp2|kp3|kp4|kp5|kp6|kp7|kp8|kp9|kp.|kp/|kp*|kp-|kp+|kpenter|kp=|" ..
"up|down|right|left|home|end|pageup|pagedown|" ..
"insert|backspace|tab|clear|return|delete|" ..
"f1|f2|f3|f4|f5|f6|f7|f8|f9|f10|f11|f12|f13|f14|f15|" ..
"numlock|capslock|scrollock|rshift|lshift|rctrl|lctrl|ralt|lalt|rmeta|lmeta|lsuper|rsuper|mode|compose|" ..
"pause|escape|help|print|sysreq|break|menu|power|euro|undo|";
ke_len = string.len(ke_text);
ke_max = 0; ke_n = {}; ke_mid = 0; ke_i = 0; ke_a = ""; ke_m = 0;
for d = 0, ke_len - 1 do--// for >
--// mid
ke_mid = string.sub(ke_text, 1 + d, 1 + d);
--// object
if ke_mid == "|" then ke_max = ke_max + 1;end;
end;--// for <
for d = 0, ke_max - 1 do--// for >
--// options
ke_n[d] = 0;
end;--// for <
for d = 0, ke_len - 1 do--// for >
--// mid
ke_mid = string.sub(ke_text, 1 + d, 1 + d);
--// text
ke_a = ke_a .. ke_mid; ke_n[ke_i] = ke_a;
--// text
if ke_mid == "|" then ke_a = ""; ke_i = ke_i + 1;end;
end;--// for <
for d = 0, ke_max - 1 do--// for >
if ke_n[d] ~= 0 then
--// len
ke_len = string.len(ke_n[d]);
--// mid
ke_mid = string.sub(ke_n[d], 1, 1 + (ke_len - 2));
--// new text
ke_n[d] = ke_mid;
end;
end;--// for <
end
--//______________________________________________________________________________________________
function love.draw()
--// text
love.graphics.print("fps: " .. love.timer.getFPS(), 10, 20, 0, 1, 1);
love.graphics.print("Scancodes Picker",10, (scry - 10), 0, 1, 1);
--// options
ke_m = 0;
for d = 0, ke_max - 1 do--// for >
--// text
if love.keyboard.isDown(ke_n[d]) then
ke_m = ke_m + 1;
love.graphics.print(ke_m .. " " .. ke_n[d], 10, 40 + (ke_m * 20), 0, 1, 1);
end;
end;--// for <
end