[kodi] Add channel for KODI JSON-RPC call Input.ButtonEvent (#11181)

Signed-off-by: Thomas Schumm <thomas.schumm@yahoo.de>
This commit is contained in:
Thomas 2021-09-19 21:59:19 +02:00 committed by GitHub
parent 8a7f15e232
commit b0cbefdf7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 59 additions and 0 deletions

View File

@ -83,6 +83,7 @@ The Kodi thing supports the following channels:
| input | String | Sends a key stroke to Kodi to navigate in the UI. Valid commands are: `Back`, `ContextMenu`, `Down`, `Home`, `Info`, `Left`, `Right`, `Select`, `ShowCodec`, `ShowOSD`, `ShowPlayerProcessInfo` and `Up`. `ExecuteAction` and `SendText` should be used with the dedicated channels `inputaction` and `inputtext`. |
| inputtext | String | Sends a generic input (unicode) text to Kodi. |
| inputaction | String | Sends a predefined action to Kodi to control the UI and/or perform other tasks. Valid commands are: `left`, `right`, `up`, `down`, `pageup`, `pagedown`, `select`, `highlight`, `parentdir`, `parentfolder`, `back`, `menu`, `previousmenu`, `info`, `pause`, `stop`, `skipnext`, `skipprevious`, `fullscreen`, `aspectratio`, `stepforward`, `stepback`, `bigstepforward`, `bigstepback`, `chapterorbigstepforward`, `chapterorbigstepback`, `osd`, `showsubtitles`, `nextsubtitle`, `cyclesubtitle`, `playerdebug`, `codecinfo`, `playerprocessinfo`, `nextpicture`, `previouspicture`, `zoomout`, `zoomin`, `playlist`, `queue`, `zoomnormal`, `zoomlevel1`, `zoomlevel2`, `zoomlevel3`, `zoomlevel4`, `zoomlevel5`, `zoomlevel6`, `zoomlevel7`, `zoomlevel8`, `zoomlevel9`, `nextcalibration`, `resetcalibration`, `analogmove`, `analogmovex`, `analogmovey`, `rotate`, `rotateccw`, `close`, `subtitledelayminus`, `subtitledelay`, `subtitledelayplus`, `audiodelayminus`, `audiodelay`, `audiodelayplus`, `subtitleshiftup`, `subtitleshiftdown`, `subtitlealign`, `audionextlanguage`, `verticalshiftup`, `verticalshiftdown`, `nextresolution`, `audiotoggledigital`, `number0`, `number1`, `number2`, `number3`, `number4`, `number5`, `number6`, `number7`, `number8`, `number9`, `smallstepback`, `fastforward`, `rewind`, `play`, `playpause`, `switchplayer`, `delete`, `copy`, `move`, `screenshot`, `rename`, `togglewatched`, `scanitem`, `reloadkeymaps`, `volumeup`, `volumedown`, `mute`, `backspace`, `scrollup`, `scrolldown`, `analogfastforward`, `analogrewind`, `moveitemup`, `moveitemdown`, `contextmenu`, `shift`, `symbols`, `cursorleft`, `cursorright`, `showtime`, `analogseekforward`, `analogseekback`, `showpreset`, `nextpreset`, `previouspreset`, `lockpreset`, `randompreset`, `increasevisrating`, `decreasevisrating`, `showvideomenu`, `enter`, `increaserating`, `decreaserating`, `setrating`, `togglefullscreen`, `nextscene`, `previousscene`, `nextletter`, `prevletter`, `jumpsms2`, `jumpsms3`, `jumpsms4`, `jumpsms5`, `jumpsms6`, `jumpsms7`, `jumpsms8`, `jumpsms9`, `filter`, `filterclear`, `filtersms2`, `filtersms3`, `filtersms4`, `filtersms5`, `filtersms6`, `filtersms7`, `filtersms8`, `filtersms9`, `firstpage`, `lastpage`, `guiprofile`, `red`, `green`, `yellow`, `blue`, `increasepar`, `decreasepar`, `volampup`, `volampdown`, `volumeamplification`, `createbookmark`, `createepisodebookmark`, `settingsreset`, `settingslevelchange`, `stereomode`, `nextstereomode`, `previousstereomode`, `togglestereomode`, `stereomodetomono`, `channelup`, `channeldown`, `previouschannelgroup`, `nextchannelgroup`, `playpvr`, `playpvrtv`, `playpvrradio`, `record`, `togglecommskip`, `showtimerrule`, `leftclick`, `rightclick`, `middleclick`, `doubleclick`, `longclick`, `wheelup`, `wheeldown`, `mousedrag`, `mousemove`, `tap`, `longpress`, `pangesture`, `zoomgesture`, `rotategesture`, `swipeleft`, `swiperight`, `swipeup`, `swipedown`, `error`, `noop`. |
| inputbuttonevent | String | Send a button press event. The parameter can have the format "`<button>`", "`<button>;<keymap>`" or "`<button>;<keymap>;<holdtime>`". For details see https://kodi.wiki/view/JSON-RPC_API/v12#Input.ButtonEvent |
| systemcommand | String | This channel allows to send system commands to `Shutdown`, `Suspend`, `Hibernate`, `Reboot` or `Quit` Kodi (channel's state options contains available system commands) |
| mediatype | String | The media type of the current file. Valid return values are: `unknown`, `channel`, `episode`, `movie`, `musicvideo`, `picture`, `radio`, `song`, `video` |
| mediaid | Number | The media_id in database of Kodi |

View File

@ -60,6 +60,7 @@ public class KodiBindingConstants {
public static final String CHANNEL_INPUT = "input";
public static final String CHANNEL_INPUTTEXT = "inputtext";
public static final String CHANNEL_INPUTACTION = "inputaction";
public static final String CHANNEL_INPUTBUTTONEVENT = "inputbuttonevent";
public static final String CHANNEL_SYSTEMCOMMAND = "systemcommand";

View File

@ -262,6 +262,15 @@ public class KodiHandler extends BaseThingHandler implements KodiEventListener {
updateState(CHANNEL_INPUTACTION, UnDefType.UNDEF);
}
break;
case CHANNEL_INPUTBUTTONEVENT:
logger.debug("handleCommand CHANNEL_INPUTBUTTONEVENT {}.", command);
if (command instanceof StringType) {
connection.inputButtonEvent(command.toString());
updateState(CHANNEL_INPUTBUTTONEVENT, UnDefType.UNDEF);
} else if (RefreshType.REFRESH == command) {
updateState(CHANNEL_INPUTBUTTONEVENT, UnDefType.UNDEF);
}
break;
case CHANNEL_SYSTEMCOMMAND:
if (command instanceof StringType) {
handleSystemCommand(command.toString());

View File

@ -1327,6 +1327,46 @@ public class KodiConnection implements KodiClientSocketEventListener {
socket.callMethod("Input.ExecuteAction", params);
}
public void inputButtonEvent(String buttonEvent) {
logger.debug("inputButtonEvent {}.", buttonEvent);
String button = buttonEvent;
String keymap = "KB";
Integer holdtime = null;
if (buttonEvent.contains(";")) {
String[] params = buttonEvent.split(";");
switch (params.length) {
case 2:
button = params[0];
keymap = params[1];
break;
case 3:
button = params[0];
keymap = params[1];
try {
holdtime = Integer.parseInt(params[2]);
} catch (NumberFormatException nfe) {
holdtime = null;
}
break;
}
}
this.inputButtonEvent(button, keymap, holdtime);
}
private void inputButtonEvent(String button, String keymap, Integer holdtime) {
JsonObject params = new JsonObject();
params.addProperty("button", button);
params.addProperty("keymap", keymap);
if (holdtime != null) {
params.addProperty("holdtime", holdtime.intValue());
}
JsonElement result = socket.callMethod("Input.ButtonEvent", params);
logger.debug("inputButtonEvent result {}.", result);
}
public void getSystemProperties() {
KodiSystemProperties systemProperties = null;
if (socket.isConnected()) {

View File

@ -68,6 +68,8 @@ channel-type.kodi.inputtext.label = Texteingabe
channel-type.kodi.inputtext.description = Ermöglicht das Senden eines Eingabetextes (Unicode) an das Kodi Media Center.
channel-type.kodi.inputaction.label = Aktion
channel-type.kodi.inputaction.description = Ermöglicht das Senden einer vordefinierten Aktion an das Kodi Media Center.
channel-type.kodi.inputbuttonevent.label = Button
channel-type.kodi.inputbuttonevent.description = Ermöglicht das Senden einer Buttonevents an das Kodi Media Center.
channel-type.kodi.systemcommand.label = Systembefehl
channel-type.kodi.systemcommand.description = Ermöglicht das Senden eines Systembefehls um das Kodi Media Center neu zu starten, in den Ruhezustand oder Stromsparmodus zu versetzen oder herunterzufahren.
channel-type.kodi.systemcommand.command.option.Shutdown = Herunterfahren

View File

@ -22,6 +22,7 @@
<channel id="input" typeId="input"/>
<channel id="inputtext" typeId="inputtext"/>
<channel id="inputaction" typeId="inputaction"/>
<channel id="inputbuttonevent" typeId="inputbuttonevent"/>
<channel id="systemcommand" typeId="systemcommand"/>
<channel id="title" typeId="system.media-title"/>
<channel id="originaltitle" typeId="system.media-title"/>
@ -395,6 +396,11 @@
</options>
</state>
</channel-type>
<channel-type id="inputbuttonevent" advanced="true">
<item-type>String</item-type>
<label>Sends a button press event as Input</label>
<description>Sends a generic button press event to Kodi</description>
</channel-type>
<channel-type id="systemcommand" advanced="true">
<item-type>String</item-type>
<label>Send System Command</label>