Information What is the difference between Action IDs and Button codes?
#1
I'm not entirely sure if this is the right place to post this but seeing as it's related to a feature I'm working on in my skin, I thought this would be ok. Please feel free to move this if it doesn't belong here.

I'm working on a feature where the user can map a key/button to trigger a function in my python helper that plays the trailer. The feature itself is working correctly. The key is mapped and then the keymap.xml is modified so that the trailer can be played when pressing the programmed key.

That being said, not every key on every remote works. I know that when pressing a key there is an action ID and a button code. But I don't know which one to use because with some keys the action ID works and with others only the button ID will work.

Currently I have it set up this way in my helper:
Code that determines whether to use the Action/Button ID for mapping:

def onAction(self, action):
    button_code = action.getButtonCode()
    action_id = action.getId()

    # Use button code if it's not 0, otherwise use action ID
    self.key = button_code if button_code != 0 else action_id

    # Update the label to show the captured key
    self.getControl(401).setLabel("Key captured successfully!")
    self.getControl(402).setLabel(f"Captured key code: {self.key}")
    xbmc.sleep(2000)
    self.close()

And here's the line that is added into the gen.xml file in the userdata/keymaps folder where the key id is either the action ID or the button code:
Keymap.xml code:

<key id="61637">RunScript(script.my.helper, mode=play_trailer)</key>

My question is what is the difference between the action ID and the button code? Why does it only work sometimes for both?

For example, here are three different versions of the same long press action assigned to a button for the play/pause button on an NVIDIA Shield Pro:
Keymap.xml variations:

#Action ID     <key id="11">RunScript(script.my.helper, mode=play_trailer)</key>
#Button Code   <key id="16838845">RunScript(script.my.helper, mode=play_trailer)</key>
#Action ID?    <play_pause mod="longpress">RunScript(script.my.helper, mode=play_trailer)</play_pause>

The last one with the play_pause mod="longpress" syntax is the only one that works by correctly overriding SHOW_INFO.
Reply

Logout Mark Read Team Forum Stats Members Help
What is the difference between Action IDs and Button codes?0