Loading keymaps via Python

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
spoyser Offline
Donor
Posts: 376
Joined: Oct 2011
Reputation: 21
Post: #1
I am helping to develop the TVCatchup EPG addin that streams UK television to XBMC.

We want to add custom controls when a stream is playing in full screen, for say changing channel up or down, jumping to channels, showing program information etc;

Code:
<keymap>
  <FullscreenVideo>
    <keyboard>
      <pageup>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, Up)</pageup>
      <pagedown>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, Down)</pagedown>      
      <zero>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, 0)</zero>
      <one>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, 1)</one>
      <two>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, 2)</two>
      <three>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, 3)</three>
      <four>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, 4)</four>
      <five>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, 5)</five>
      <six>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, 6)</six>
      <seven>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, 7)</seven>
      <eight>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, 8)</eight>
      <nine>XBMC.RunScript(special://profile/addon_data/script.tvcatchup/change.py, 9)</nine>
    </keyboard>
  </FullscreenVideo>
</keymap>

We currently acheive this using the custom keymap file shown above in the userdata/keymaps folder. When the addin is run it first checks if the file exists and if not copies the file from the addin folder to the keymap folder and then prompt the user to restart XBMC (obviously this only needs to be done the once).

There are a couple of issue with this, firstly having to restart XBMC the first time isn't ideal, and secondly and more importantly the keymapping we add will not be restricted to our addin but instead will be used when ever fullscreen video is being played (which we would rather not be the case).

So what would be great would be a way (I don't care how hacky) to get XBMC to rescan for new or removed keymaps within the addin.

This way when the addin is first started it could copy the keymap file across to the userdata/keymaps folder, and then force a rescan of the keymaps. When our addin is exited we could then delete the file and force another rescan.

Any one got any ideas, or would this require a new feature to be added to XBMC itself (a new builtin function perhaps)?
(This post was last modified: 2012-06-13 14:18 by spoyser.)
find quote
spoyser Offline
Donor
Posts: 376
Joined: Oct 2011
Reputation: 21
Post: #2
Well after more than a week of searching for a solution I finally stumbled upon what appears to be an undocumented feature:

Code:
xbmc.executebuiltin('Action(reloadkeymaps)')

Obvious when you know how!!
(This post was last modified: 2012-06-14 17:18 by spoyser.)
find quote
Martijn Offline
Team Kodi
Posts: 11,607
Joined: Jul 2011
Reputation: 167
Location: Dawn of time
Post: #3
It more hidden than undocumented Wink

Always read the XBMC online-manual, FAQ and search the forums before posting.
Do NOT e-mail Team-XBMC members asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting, make sure you read this first

For your mediacenter artwork go to
[Image: fanarttv.png]
find quote