Mangled text output, iskey() not returning true, server crashing (linux)
I was having trouble getting keyboard.stroke() to work for anything other than single letters. kb.stroke("a") worked, for example, but kb.stroke("comma") would cause the server to crash. Seems it was crashing because it doesn't recognize "comma" as a valid key name. kb.iskey("comma") returns false.
While debugging this with a very simple layout, I noticed it seems that the scripts are mangling the contents of string variables somewhere along the line. Here's the function I was using:
local kb = libs.keyboard; actions.stroker = function () thevar = "shift" layout.thebutton.text = kb.iskey(thevar); kb.text(thevar); end
Here's what it output with thevar set to "comma", "slash", "rightbracket", and "shift".
commacommacmmmacommacmmmacommacomaacomaacommacommacommacmmmacmmmac slsshslsshslsshslash rightbraceetrigttrrakketrightrraceet siiftshftthhfttshittshiftshiftshifthhftt
UR SERVER INFO:
Version 126.96.36.1996 (33)
Platform Linux 3.13.0-37-generic x86_64
UR APP INFO:
Android version: 5.1.1 (CM12)
Linux Mint 17
Please let me know what input mode your server is using. Check here:
Input mode is X11
A few more notes:
If I update the button text to thevar's value, the button text shows the value properly, without mangling it. It appears that the value is not being mangled on the android end - it's only mangled when the text is output on the server computer.
I originally thought that kb.iskey(thevar) was returning false and kb.stroke(thevar) didn't work for strings like "comma" "rightbracket" and "dot" because the string value was being mangled before it hit the iskey() function. But apparently the two problems are separate - I think those key names are being passed to the kb functions properly, but are not valid for some reason, despite being listed on the "keys" documentation page.
I think the mangling problem probably lies within kb.text(). kb.stroke seems to be working ok except for the unrecognized key names. for example, the following code works as expected (ie: prints the string value of thevar on the server computer):
actions.stroker = function () thevar = "comma" for i = 1, #thevar do local c = thevar:sub(i,i) kb.stroke(c); end end
Using the key names that are output by xev on the server computer (eg: "period" instead of "dot") doesn't seem to work either, but using the UTF-8 keycode (eg: 0x2c for a comma) seems to get kb.stroke() to work as expected. (kb.stroke("shift", 0x2c) outputs a "<").
Also, there appears to be a pretty significant delay between pressing the button and the text being printed on the server computer when using the kb.text(string) function. When using kb.stroke(0x2c) there is no significant delay.
Typing using the keyboard that can be accessed from the bottom row of icons in UR works fine - text is not mangled, and the letters appear without significant delay.