EventServer: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Fyfe
m (fixed broken links)
>NedBot
m (Bot: Automated text replacement (-__NOEDITSECTION__ + ); cosmetic changes)
Line 2: Line 2:
{{XBMC faq toc Inline}}
{{XBMC faq toc Inline}}
__TOC__
__TOC__
__NOEDITSECTION__
 
=Introduction=
= Introduction =
EventServer is the part of XBMC that accepts remote device input on all platforms except the original Xbox. EventServer API is used to program event clients and simplifies interfacing input devices with XBMC. EventServer accepts commands from event clients such as LIRC, joysticks, PDAs, and iPhones.
EventServer is the part of XBMC that accepts remote device input on all platforms except the original Xbox. EventServer API is used to program event clients and simplifies interfacing input devices with XBMC. EventServer accepts commands from event clients such as LIRC, joysticks, PDAs, and iPhones.


====The Purpose of EventServer API in XBMC====
==== The Purpose of EventServer API in XBMC ====
The EventServer in XBMC was created to satisfy a need to support many input devices across multiple hardware platforms. Adding direct support for a multitude of devices generally decreases performance and stability, and becomes difficult to maintain. The EventServer was created to provide a simple, reliable way to communicate with and control XBMC.
The EventServer in XBMC was created to satisfy a need to support many input devices across multiple hardware platforms. Adding direct support for a multitude of devices generally decreases performance and stability, and becomes difficult to maintain. The EventServer was created to provide a simple, reliable way to communicate with and control XBMC.


====Event Clients and the EventServer====
==== Event Clients and the EventServer ====
XBMC's EventServer listens for commands from event clients. Anything that can communicate using UDP can be an event client. Many event client software packages are currently available for PCs, Macs, smartphones, PDAs, and more. Some event client software accepts commands from infra-red remotes, gamepad controllers, and others to translate and send to the EventServer. These event client software packages are often run on the same computer as XBMC, essentially as remote control addons.
XBMC's EventServer listens for commands from event clients. Anything that can communicate using UDP can be an event client. Many event client software packages are currently available for PCs, Macs, smartphones, PDAs, and more. Some event client software accepts commands from infra-red remotes, gamepad controllers, and others to translate and send to the EventServer. These event client software packages are often run on the same computer as XBMC, essentially as remote control addons.


====Pros and Cons====
==== Pros and Cons ====
EventServer can be compared to the older web control interface, [[WebServerHTTP-API|Web Server HTTP API (also known as "HTTPAPI")]]. Below are pros and cons of the EventServer system, compared to HTTP-API. '''NOTE: As of Dharma, the HTTP-API is depreciated - use the JSON-RPC interface instead'''
EventServer can be compared to the older web control interface, [[WebServerHTTP-API|Web Server HTTP API (also known as "HTTPAPI")]]. Below are pros and cons of the EventServer system, compared to HTTP-API. '''NOTE: As of Dharma, the HTTP-API is depreciated - use the JSON-RPC interface instead'''


=====EventServer Pros=====
===== EventServer Pros =====
*is always active on localhost, which is much more stable for remotes (Not available on XBMC for Xbox.)
* is always active on localhost, which is much more stable for remotes (Not available on XBMC for Xbox.)
*uses event-based communication instead of request-based communication.
* uses event-based communication instead of request-based communication.
*is much easier to implement in programs.
* is much easier to implement in programs.
*can distinguish between different clients, and therefore have multiple distinct inputs.
* can distinguish between different clients, and therefore have multiple distinct inputs.
*is mappable through keymap.xml.
* is mappable through keymap.xml.
*can notify the user when a connection is made.
* can notify the user when a connection is made.
*is capable of displaying notifications on demand.
* is capable of displaying notifications on demand.


=====EventServer Cons=====
===== EventServer Cons =====


*currently cannot send any information back to clients. This is a planned feature.
* currently cannot send any information back to clients. This is a planned feature.
*is not designed to send built-in XBMC commands like playurl. This may change in the future.
* is not designed to send built-in XBMC commands like playurl. This may change in the future.




=XBMC Options=
= XBMC Options =
[[Image:Settings.network.remoteeveents.jpg|right|600px]]
[[File:Settings.network.remoteeveents.jpg|right|600px]]
;Enable Remote Events
;Enable Remote Events
:Check to enable the EventServer.
:Check to enable the EventServer.
Line 52: Line 52:




=Event Clients=
= Event Clients =
The event clients and EventServer are under heavy development, so for up-to-date information please refer to the [http://xbmc.svn.sourceforge.net/viewvc/xbmc/trunk/tools/EventClients/README.txt readme file]
The event clients and EventServer are under heavy development, so for up-to-date information please refer to the [http://xbmc.svn.sourceforge.net/viewvc/xbmc/trunk/tools/EventClients/README.txt readme file]


Line 59: Line 59:
Event clients can currently be recognized as one of the following:
Event clients can currently be recognized as one of the following:


*Mouse
* Mouse
*Keyboard
* Keyboard
*Xbox Gamepad
* Xbox Gamepad
*Xbox Remote
* Xbox Remote
*Xbox Universal Remote
* Xbox Universal Remote
*LIRC (Only on Linux)
* LIRC (Only on Linux)
*Joystick
* Joystick


==Joysticks==
== Joysticks ==
Joysticks are mappable in keymap.xml using the following convention:
Joysticks are mappable in keymap.xml using the following convention:
   <joystick name="foo">
   <joystick name="foo">
Line 80: Line 80:
There is initial support for the PS3 controller (sixaxis) and  
There is initial support for the PS3 controller (sixaxis) and  


===PS3 Blu-Ray Remote===
=== PS3 Blu-Ray Remote ===
There is initial support for the PS3 Blu-Ray remote.
There is initial support for the PS3 Blu-Ray remote.
The remote needs to be paired using one of two python scripts. 'ps3_remote.py' can be run as a user, but the controller must be paired every time the script is run. 'ps3d.py' will remember remotes between run-instances if it is executed as root, and it supports the PS3 Sixaxis controller as well.
The remote needs to be paired using one of two python scripts. 'ps3_remote.py' can be run as a user, but the controller must be paired every time the script is run. 'ps3d.py' will remember remotes between run-instances if it is executed as root, and it supports the PS3 Sixaxis controller as well.


===PS3 Sixaxis Controller (TODO)===
=== PS3 Sixaxis Controller (TODO) ===
Pairing with the PS3 controller is not yet handled automatically, but it can be done using the program 'sixaxis.c' available from [http://www.pabr.org/sixlinux/sixlinux.en.html]. Or if you want to do it the gui way [http://ubuntuforums.org/showthread.php?t=1190061]
Pairing with the PS3 controller is not yet handled automatically, but it can be done using the program 'sixaxis.c' available from [http://www.pabr.org/sixlinux/sixlinux.en.html]. Or if you want to do it the gui way [http://ubuntuforums.org/showthread.php?t=1190061]


Once paired, disable any existing HID servers that might currently be running and run 'ps3d.py' as root. The program requires root privileges because it listens on Bluetooth L2CAP PSMs 17 and 19. (This is not nessecary using the gui tool)
Once paired, disable any existing HID servers that might currently be running and run 'ps3d.py' as root. The program requires root privileges because it listens on Bluetooth L2CAP PSMs 17 and 19. (This is not nessecary using the gui tool)


====Using the PS3 Sixaxis Controller====
==== Using the PS3 Sixaxis Controller ====
There is xml configuration file for the ps3 controller under your keymaps folder.
There is xml configuration file for the ps3 controller under your keymaps folder.
You need to change the name of the joystick in you xml configfile to containg the mac adress of your controller.  
You need to change the name of the joystick in you xml configfile to containg the mac adress of your controller.  
"grep PLAYSTATION   /proc/bus/input/devices" from a terminal will give you what you need.
"grep PLAYSTATION /proc/bus/input/devices" from a terminal will give you what you need.


===WiiRemote===
=== WiiRemote ===
To use the WiiRemote:
To use the WiiRemote:
1. Open a terminal window and type/paste xbmc-wiiremote (do not press enter yet)
1. Open a terminal window and type/paste xbmc-wiiremote (do not press enter yet)
Line 112: Line 112:
Other commands can be listed with --help
Other commands can be listed with --help


The WiiRemote can be mapped in [[Keymap.xml|keymap.xml]] with the following button IDs:
The WiiRemote can be mapped in [[keymap.xml]] with the following button IDs:
;WiiRemote
;WiiRemote
:1 = Up
:1 = Up
Line 138: Line 138:
There is a nice guide on installing a Wii remote on XBMC-Live 9.11 [http://www.mini-itx.com/projects/xbmc-ion/module/6 here].
There is a nice guide on installing a Wii remote on XBMC-Live 9.11 [http://www.mini-itx.com/projects/xbmc-ion/module/6 here].


==J2ME (Java Phone Application)==
== J2ME (Java Phone Application) ==
The J2ME client requires the following:
The J2ME client requires the following:
*CLDC 1.0 and MIDP 1.0
* CLDC 1.0 and MIDP 1.0
*bluetooth connectivity
* bluetooth connectivity
*client must be able to initialize the connection
* client must be able to initialize the connection


For compiling the Java application, see Clients/J2ME and Client/README (precompiled versions exists in our forum).
For compiling the Java application, see Clients/J2ME and Client/README (precompiled versions exists in our forum).
Line 151: Line 151:
The KeyIDs are generated in terminal using j2me_remote.py.
The KeyIDs are generated in terminal using j2me_remote.py.


==Known Working EventClients==
== Known Working EventClients ==
All clients are able to talk to any server on any OS, but the client software is often OS specific.
All clients are able to talk to any server on any OS, but the client software is often OS specific.


===XBMC for Linux===
=== XBMC for Linux ===
*Sony PlayStation 3 (PS3) Blu-ray Remote
* Sony PlayStation 3 (PS3) Blu-ray Remote
*PS3 Sixaxis GamePad
* PS3 Sixaxis GamePad
*Wii Remote
* Wii Remote
*J2ME (CellPhone)
* J2ME (CellPhone)
*[http://trac.xbmc.org/ticket/8827 HAMA MCE Remote]
* [http://trac.xbmc.org/ticket/8827 HAMA MCE Remote]


===XBMC for Mac OS X===
=== XBMC for Mac OS X ===
*Apple Remote
* Apple Remote
*Sony PlayStation 3 (PS3) Blu-ray Remote
* Sony PlayStation 3 (PS3) Blu-ray Remote
*J2ME (CellPhone)
* J2ME (CellPhone)


===XBMC for Windows===
=== XBMC for Windows ===
*Sony PlayStation 3 (PS3) Blu-ray Remote
* Sony PlayStation 3 (PS3) Blu-ray Remote
*Xbox 360 Controller
* Xbox 360 Controller
*J2ME (CellPhone)
* J2ME (CellPhone)
*[http://forum.xbmc.org/showthread.php?t=38160 EventGhost]
* [http://forum.xbmc.org/showthread.php?t=38160 EventGhost]


===XBMC for Xbox===
=== XBMC for Xbox ===
*There are no EventClients for the Xbox yet.
* There are no EventClients for the Xbox yet.


==Known Caveats==
== Known Caveats ==
*Most of the clients are using python, so PyBluez and Lightblue must be.
* Most of the clients are using python, so PyBluez and Lightblue must be.
*PyBluez only works with broadcom chipsets on 32-bit Windows.
* PyBluez only works with broadcom chipsets on 32-bit Windows.




=Development of EventClients and the EventServer API=
= Development of EventClients and the EventServer API =


==Example demos of EventClients (open source code)==
== Example demos of EventClients (open source code) ==
You can find several open source EventClient examples written in C++, Python, and Java in the XBMC SVN. Look under [http://xbmc.svn.sourceforge.net/viewvc/xbmc/trunk/tools/EventClients/ EventClients]. This directory contains seven event client sample programs that demonstrate XBMC's EventServer API. The different programs are in C++, Python, and Java. XBMC must be running to receive events. Please see README.txt for more information.
You can find several open source EventClient examples written in C++, Python, and Java in the XBMC SVN. Look under [http://xbmc.svn.sourceforge.net/viewvc/xbmc/trunk/tools/EventClients/ EventClients]. This directory contains seven event client sample programs that demonstrate XBMC's EventServer API. The different programs are in C++, Python, and Java. XBMC must be running to receive events. Please see README.txt for more information.


[[Category:EventServer]]
[[Category:EventServer]]
[[category:Inner Workings]]
[[Category:Inner Workings]]
[[category:Development]]
[[Category:Development]]
[[Category:Add-ons]]
[[Category:Add-ons]]
[[Category:To-Do]]
[[Category:To-Do]]

Revision as of 14:48, 7 September 2011

Incomplete.png INCOMPLETE:
This page or section is incomplete. Please add information or correct uncertain data which is marked with a ?

Template:XBMC faq toc Inline

 

Introduction

EventServer is the part of XBMC that accepts remote device input on all platforms except the original Xbox. EventServer API is used to program event clients and simplifies interfacing input devices with XBMC. EventServer accepts commands from event clients such as LIRC, joysticks, PDAs, and iPhones.

The Purpose of EventServer API in XBMC

The EventServer in XBMC was created to satisfy a need to support many input devices across multiple hardware platforms. Adding direct support for a multitude of devices generally decreases performance and stability, and becomes difficult to maintain. The EventServer was created to provide a simple, reliable way to communicate with and control XBMC.

Event Clients and the EventServer

XBMC's EventServer listens for commands from event clients. Anything that can communicate using UDP can be an event client. Many event client software packages are currently available for PCs, Macs, smartphones, PDAs, and more. Some event client software accepts commands from infra-red remotes, gamepad controllers, and others to translate and send to the EventServer. These event client software packages are often run on the same computer as XBMC, essentially as remote control addons.

Pros and Cons

EventServer can be compared to the older web control interface, Web Server HTTP API (also known as "HTTPAPI"). Below are pros and cons of the EventServer system, compared to HTTP-API. NOTE: As of Dharma, the HTTP-API is depreciated - use the JSON-RPC interface instead

EventServer Pros
  • is always active on localhost, which is much more stable for remotes (Not available on XBMC for Xbox.)
  • uses event-based communication instead of request-based communication.
  • is much easier to implement in programs.
  • can distinguish between different clients, and therefore have multiple distinct inputs.
  • is mappable through keymap.xml.
  • can notify the user when a connection is made.
  • is capable of displaying notifications on demand.
EventServer Cons
  • currently cannot send any information back to clients. This is a planned feature.
  • is not designed to send built-in XBMC commands like playurl. This may change in the future.


XBMC Options

Settings.network.remoteeveents.jpg
Enable Remote Events
Check to enable the EventServer.
Remote Events Port
The starting port for the range of ports that EventServer will listen on.
Remote Events Port Range
The number of ports to listen on. Directly determines the port range.
Maximum Number of Clients
The maximum number of simultaneous connections.

Receive events from other computers
Check to listen on the network, not just on the local machine.

Initial Repeat Delay (ms)
Delay, in milliseconds, before a continuously pressed button will begin registering as multiple, repeated presses.
Continuous Repeat Delay (ms)
The speed at which the above repeated presses will be entered.


Event Clients

The event clients and EventServer are under heavy development, so for up-to-date information please refer to the readme file

Most event clients can be configured using CLI. Common CLI arguments are address and port number. The defaults are localhost and port 9777.

Event clients can currently be recognized as one of the following:

  • Mouse
  • Keyboard
  • Xbox Gamepad
  • Xbox Remote
  • Xbox Universal Remote
  • LIRC (Only on Linux)
  • Joystick

Joysticks

Joysticks are mappable in keymap.xml using the following convention:

 <joystick name="foo">
 <button id="1">ACTION1</button>
 <button id="2">ACTIOn2</button>
 <axis id="1" limit="-1">ACTION3</axis>
 <axis id="2" limit="+1">ACTION4</axis>
 </joystick>

See Editing keymap.xml for more information on how to customize the keymap.

There is initial support for the PS3 controller (sixaxis) and

PS3 Blu-Ray Remote

There is initial support for the PS3 Blu-Ray remote. The remote needs to be paired using one of two python scripts. 'ps3_remote.py' can be run as a user, but the controller must be paired every time the script is run. 'ps3d.py' will remember remotes between run-instances if it is executed as root, and it supports the PS3 Sixaxis controller as well.

PS3 Sixaxis Controller (TODO)

Pairing with the PS3 controller is not yet handled automatically, but it can be done using the program 'sixaxis.c' available from [1]. Or if you want to do it the gui way [2]

Once paired, disable any existing HID servers that might currently be running and run 'ps3d.py' as root. The program requires root privileges because it listens on Bluetooth L2CAP PSMs 17 and 19. (This is not nessecary using the gui tool)

Using the PS3 Sixaxis Controller

There is xml configuration file for the ps3 controller under your keymaps folder. You need to change the name of the joystick in you xml configfile to containg the mac adress of your controller. "grep PLAYSTATION /proc/bus/input/devices" from a terminal will give you what you need.

WiiRemote

To use the WiiRemote: 1. Open a terminal window and type/paste xbmc-wiiremote (do not press enter yet) 2. Press 1 and 2 on the WiiRemote 3. press enter 4. leave this terminal open and open xbmc

You should see xbmc recognize the WiiRemote. You can press the power button on the WiiRemote to save battery. To reconnect press the 1 and 2 again. As long as you leave the terminal window with xbmc-wiiremote open you will be able to do this, even if you exit/open xbmc.

The executable depends on libcwiid and libbluetooth and is compiled using

  1. g++ WiiRemote.cpp -lcwiid -o WiiRemote

The WiiRemote will emulate the mouse by default, this can be disabled by passing --disable-mouseemulation on the command line.

The sensitivity of the mouse emulation can be set using the --deadzone_x or --deadzone_y, followed by the percentage of the space to consider "dead." A higher numberm eans higher sensitivity.

Other commands can be listed with --help

The WiiRemote can be mapped in keymap.xml with the following button IDs:

WiiRemote
1 = Up
2 = Down
3 = Left
4 = Right
5 = A
6 = B
7 = Minus
8 = Home
9 = Plus
10 = 1
11 = 2
Nunchuck
21 = Up (axis)
22 = Dow (axis)
23 = Left (axis)
24 = Right (axis)
25 = C
26 = Z

The name is by default WiiRemote, but this can be changed with the --joystick-name argument.

There is a nice guide on installing a Wii remote on XBMC-Live 9.11 here.

J2ME (Java Phone Application)

The J2ME client requires the following:

  • CLDC 1.0 and MIDP 1.0
  • bluetooth connectivity
  • client must be able to initialize the connection

For compiling the Java application, see Clients/J2ME and Client/README (precompiled versions exists in our forum).

The Client can be mapped in the same manner as the PS3 controller in keymap.xml, but with the name J2ME:

   <joystick name="J2ME">

The KeyIDs are generated in terminal using j2me_remote.py.

Known Working EventClients

All clients are able to talk to any server on any OS, but the client software is often OS specific.

XBMC for Linux

  • Sony PlayStation 3 (PS3) Blu-ray Remote
  • PS3 Sixaxis GamePad
  • Wii Remote
  • J2ME (CellPhone)
  • HAMA MCE Remote

XBMC for Mac OS X

  • Apple Remote
  • Sony PlayStation 3 (PS3) Blu-ray Remote
  • J2ME (CellPhone)

XBMC for Windows

  • Sony PlayStation 3 (PS3) Blu-ray Remote
  • Xbox 360 Controller
  • J2ME (CellPhone)
  • EventGhost

XBMC for Xbox

  • There are no EventClients for the Xbox yet.

Known Caveats

  • Most of the clients are using python, so PyBluez and Lightblue must be.
  • PyBluez only works with broadcom chipsets on 32-bit Windows.


Development of EventClients and the EventServer API

Example demos of EventClients (open source code)

You can find several open source EventClient examples written in C++, Python, and Java in the XBMC SVN. Look under EventClients. This directory contains seven event client sample programs that demonstrate XBMC's EventServer API. The different programs are in C++, Python, and Java. XBMC must be running to receive events. Please see README.txt for more information.