WIP Custom Script Keymaps
#1
I started working on a fork of http://kodi.wiki/view/Keymaps (which I hope to merge with the master when i'm finished).

Goal:

To create a repo/user safe keymap component that will extended user control for python scripts.

Idea:

Kodi scripts can include predefined keymaps which users can enable individually or as a set. Keymap editor will feature three levels of user security. Before script keymaps installation users have to "Allow predefined keymaps" in the keymap editors settings. Second, users have to enable a plugin specific predefined keymap for each individual script that includes predefined keymaps. Lastly, as a fail safe a backup/restore function will be added to maintain the user's original keymap.

I would appreciate suggestions from team developers and script developers.... If a plugin like this has no chance of making it to the official repo, please let me know... I'd rather not waste my time Angel
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#2
Nice! I've been thinking about add-on keymaps recently, too. Only thinking, though, I've already got a lot of projects going on, and only one Kodi project that could use a custom keymap, which may never be finished enough for public release anyway.

One thought that could help this to be safe and clean enough for official repo inclusion is that custom keymaps are loaded alphabetically, so the keymap add-on can keep a separate xml file for each add-on wanting custom keymaps, something like zz_##-addon.id.xml. Adding and removing add-on keymaps won't touch any existing keymaps, and each one can be edited individually without disturbing the others. New add-ons may override existing keymaps, but since the viewer recently opted in to keymaps for an add-on that shouldn't be much of a surprise. The final failsafe is deleting or renaming the zz_* keymaps, and there's no worry that an earlier backup could be restored and clobber any changes that may have been made since.

Good luck!
Reply
#3
My first impression is that this work has to be done on core side, anything else will end up hacky-ish.
The general goal sounds reasonable, but how do you want to accomplish that without messing with a user's installation at this moment?
Some technical details would be nice.
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#4
one thing that might be possible to do is to add core support for script xml windows in keymaps.
that way an addon could copy a keymap to your userdata folder that will only affect it's own script window.

if i'm not mistaken, we already support custom skin windows in keymaps...
perhaps look into how that's being handled and extend it for script windows.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#5
(2016-10-19, 00:45)phil65 Wrote: My first impression is that this work has to be done on core side, anything else will end up hacky-ish.
The general goal sounds reasonable, but how do you want to accomplish that without messing with a user's installation at this moment?
Some technical details would be nice.

Hi @phil65 thanks for participating,

Perhaps I missed something... was core code added to support script keymaps? I'm also a little confused about the term hacky-ish. When has editing a xml file become hackishy? I'd like to avoid any hacky code, however the word is very subjective. For example for me it's hacky to use BeautifulSoup to parse a website and not hacky to use a API. I only ask so that I can expand my understanding...

I do not plan on deviating outside the realm of the pre existing repo approved keymap editor. The only exception being that scripts can include/register a predefined list of actions, users could then browse the list of actions in the editor and choose a appropriate button/key. This new keymap will lay dormant till the corresponding script is launched, at this point a swap and system reload is made.

Currently there are a number of repo approved scripts that "swap" keymaps... and I'm unaware of the particulars that lead to recent events concerning keymaps, I understand there is a right and wrong way. I know a swap can be handled safely, without user concern... and IMO the keymap.xml is no more a protected "core" file than the guisettings.xml is which is regularly written to by skins.

Please, constructive feedback is welcome... If this is a dead horse let me know and i'll move onto another project.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#6
Well overwriting system-critical files without using any well-defined interfaces is quite dangerous. Wink Skins dont write to guisettings.xml directly, but via our core, that´s how it should be.
Basically all of our config XMLs are not intended to get overwritten on-the-fly by external applications, a system like ronie described would be much more elegant to solve this problem.

In case of "keymap editor", that was one of the add-ons we made an exception for because of its utility, and because it is written by a team member (tamland/takoi) who knows about all possible implications since he also maintains core. Afaik that add-on also doesnt use any "system reload", you have to restart kodi in order to have the new keymap applied. ( I think there isnt even a way to refresh the keymap on-the-fly? )
Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
Reply
#7
(2016-10-19, 02:58)phil65 Wrote: Well overwriting system-critical files without using any well-defined interfaces is quite dangerous. Wink Skins dont write to guisettings.xml directly, but via our core, that´s how it should be.
Basically all of our config XMLs are not intended to get overwritten on-the-fly by external applications, a system like ronie described would be much more elegant to solve this problem.

In case of "keymap editor", that was one of the add-ons we made an exception for because of its utility, and because it is written by a team member (tamland/takoi) who knows about all possible implications since he also maintains core. Afaik that add-on also doesnt use any "system reload", you have to restart kodi in order to have the new keymap applied. ( I think there isnt even a way to refresh the keymap on-the-fly? )

You are correct guisettings.xml are not written directly by the skin... I meant to imply that it's not a static file and more of a dynamic file... containing user settings.

I agree 100% with @ronie's suggestion and if this is something the team is interested in... that's great! no need for this plugin.

Yes, there is a indirect way to reload keymaps by reloading kodis skin, as for the exception made for keymap editor. I do not plan on editing the core mechanisms, my only alternations would make this list dynamic https://github.com/Lunatixz/xbmc-keymap-...actions.py and change the temp file name.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#8
(2016-10-19, 02:58)phil65 Wrote: I think there isnt even a way to refresh the keymap on-the-fly?
xbmc.executebuiltin('Action(reloadkeymaps)')
Reply
#9
So should I continue development? Is this something that will be ineligible for repo approval or a near future Kodi core component?
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#10
Any answer will do... Yes, no, maybe?

Sent from my SM-G935T
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#11
the problem is that addons will have to add their mappings to the <global> section on the keymap.
the result is these mappings will apply all throughout kodi and not just within their own addon window.

the second issue is what happens when two addons add their keymap: one will overwrite the other.

hence phil65 mentioned it's hacky at best. a real solution can only be done in core.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#12
(2016-10-29, 21:02)ronie Wrote: the problem is that addons will have to add their mappings to the <global> section on the keymap.
the result is these mappings will apply all throughout kodi and not just within their own addon window.

the second issue is what happens when two addons add their keymap: one will overwrite the other.

hence phil65 mentioned it's hacky at best. a real solution can only be done in core.

Okay, I'll move on... If I was familiar enough with Kodis core i'd start implementing it myself. Could this be added as a milestone so it's not forgotten? Maybe add custom fonts for scripts as well Wink
Thanks
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply

Logout Mark Read Team Forum Stats Members Help
Custom Script Keymaps0