I've been having this issue since I started using UR... My custom Krita remote sometimes doesn't show in the list of available remotes on my android device. After screwing around with things for a while it will eventually show up, but it's not at all clear what it is that has to be done to trigger it to show in the list.
I'm using the "portable archive" 64 bit linux server, and running it from the command line. On the server, I can load and reload the remote, and running "agent action rob.krita" returns an appropriate list of actions... It seems to be loaded on the server end.
But on the android device, the remote doesn't appear in the list of available remotes, even after restarting the app, refreshing the list of available remotes, etc.
This happens whenever I add a new server (I'm currently trying to configure my surface pro)... In the past when configuring a new server, I'll screw around with things until I'm totally frustrated, then for some inscrutable reason, the remote will finally show up in the list. Once it eventually shows up, it's fine - it stays available. But trying to get it to show up is very frustrating, since it's not at all clear what has to be done to make it appear in the list.
Moving the remote into various different filesystem locations doesn't seem to make a difference... It's loading on the server side, but doesn't show on the android side.
I haven't played with widgets yet, so I'm not sure what the practical impact of what you're saying would be...
Are you saying that this function won't work for a widget at all because it is reusable, or just that I should add some help comments like this on my function?
[email protected] Create a keystroke from instring. [email protected] instring: input string - first 4 characters are UTF-8 code, followed immediately by a C, S and/or A if Control, Shift or Alt are to be pressed.
What exactly does the app do with the help comments?
I noticed a lot of the remotes have tons of functions which essentially do the same thing. Here's a function that can be used by all your buttons that send keystrokes in case it's useful to anyone. Speeds up development a lot, and keeps things a lot cleaner when you don't have to add a whole new function (and remember a new function name) every time you want to send a keystroke.
You can pass a parameter string value to a function from a button by appending it to the function name after a comma, like this:
<button text="a button" ontap="theFunction,someValue" />
I used that approach to call this function from all my buttons that send keystrokes:
actions.stroker = function (instring) -- fnf4 - pgup - pgdn - dele - xtab - SPECIAL KEYS THAT CAN'T BE CALLED BY UTF-8 if string.sub(instring,1,4) == "XTAB" then kb.press("tab"); elseif string.sub(instring,1,4) == "fnf4" then kb.press("f4"); elseif string.sub(instring,1,4) == "pgup" then kb.press("pageup"); elseif string.sub(instring,1,4) == "pgdn" then kb.press("pagedown"); elseif string.sub(instring,1,4) == "dele" then kb.press("delete"); else local theChar = string.sub(instring,1,4)+0; --convert to number local mods = string.sub(instring,5); --layout.thebutton.text = mods; local isk = kb.iskey(theChar); local S = string.find(mods, "S") ;--add shift local C = string.find(mods, "C") ;--add control local A = string.find(mods, "A") ;--add alt --type output with mods if S then kb.down("shift") end ; if C then kb.down("ctrl") end ; if A then kb.down("alt") end ; if isk then kb.stroke(theChar) end ; if S then kb.up("shift") end ; if C then kb.up("ctrl") end ; if A then kb.up("alt") end ; end ; end
You send the function the UTF-8 code for the key you want sent by the function (Here's a chart of UTF-8 codes), followed by a C, S, and/or A if you want control, shift, or alt pressed when the key is sent.
I used UTF-8 where possible to work around some apparent bugs in UR relating to recognizing key names. UTF-8 seems reliable, where key name recognition seems not to be reliable at all, at least on Linux.
Here are some example function calls:
<button ontap="stroker,XTAB" /><!-- canvas only: tab --> <button ontap="stroker,0x68" /><!-- color history: H --> <button ontap="stroker,0x6eS" /><!-- min shade sel: shift+ N --> <button ontap="stroker,0x6dS" /><!-- mypaint shade sel: shift + M --> <button ontap="stroker,0x61CS" /><!-- deselect: ctrl + shift + A --> <button ontap="stroker,0x73CA" /><!-- save incremental version: ctrl+alt+s -->
Here's a remote for Krita (an awesome digital painting app) on Linux. I imagine it'll probably work for Krita on other operating systems, but I've only tested it on Linux. It uses the default shortcuts that ship with Krita 2.9.
The top half of the screen controls the brush. Most buttons are self explanatory. The size, opacity, and lightness controls are touchstrips with increase/decrease buttons at the top and bottom. Slide your finger vertically on the center touchstrip part to increase or decrease, or use the buttons at the top and bottom.
On the top-left side, buttons are:
- fullscreen - toggle show canvas only
- toggle eraser mode - jump to last brush used
- previous favourite brush - next fav. brush
- Brush tool - multibrush tool
The bottom half contains four sets of controls that you can switch between using the buttons along the bottom of the remote.
show colour selector
show shade selector
show mypaint shade selector
show popup palette
Pretty self explanatory, except "Space" toggles the space bar on and off - Space+left mouse click (or tablet pressure) pans the canvas.
The middle rotation button resets rotation to normal. Press and hold it to activate drag-rotate mode.
The middle zoom button resets zoom to 100%. Press and hold it to activate drag-zoom mode.
SELECT AND LAYER CONTROLS
Totally self explanatory.
SAVE AND COPY CONTROLS
Totally self explanatory.
LICENSE: do whatever you want with this code. copy it, modify it, reuse it, sell it to an idiot, print it out on a t-shirt, whatever.
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.
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 188.8.131.526 (33)
Platform Linux 3.13.0-37-generic x86_64
UR APP INFO:
Android version: 5.1.1 (CM12)
Linux Mint 17