3 # This is a simple example showing how you can send a key press event
4 # to XBMC in a non-queued fashion to achieve a button pressed down
5 # event i.e. a key press that repeats.
7 # The repeat interval is currently hard coded in XBMC but that might
8 # change in the future.
10 # NOTE: Read the comments in 'example_button1.py' for a more detailed
17 if os
.path
.exists("../../lib/python"):
18 # try loading modules from source directory
19 sys
.path
.append("../../lib/python")
21 from xbmcclient
import *
23 ICON_PATH
= "../../icons/"
25 # fallback to system wide modules
27 from kodi
.xbmcclient
import *
28 from kodi
.defs
import *
38 sock
= socket(AF_INET
,SOCK_DGRAM
)
40 # First packet must be HELO and can contain an icon
41 packet
= PacketHELO("Example Remote", ICON_PNG
,
42 ICON_PATH
+ "/bluetooth.png")
43 packet
.send(sock
, addr
)
45 # wait for notification window to close (in XBMC)
48 # send a up key press using the xbox gamepad map "XG" and button
49 # name "dpadup" ( see PacketBUTTON doc for more details)
50 packet
= PacketBUTTON(map_name
="XG", button_name
="dpadup")
51 packet
.send(sock
, addr
)
53 # wait for a few seconds to see its effect
56 # send a down key press using the raw keyboard code
57 packet
= PacketBUTTON(code
=0x28)
58 packet
.send(sock
, addr
)
60 # wait for a few seconds to see its effect
63 # send a right key press using the keyboard map "KB" and button
65 packet
= PacketBUTTON(map_name
="KB", button_name
="right")
66 packet
.send(sock
, addr
)
68 # wait for a few seconds to see its effect
71 # that's enough, release the button. During release, button code
73 packet
= PacketBUTTON(code
=0x28, down
=0)
74 packet
.send(sock
, addr
)
76 # ok we're done, close the connection
77 # Note that closing the connection clears any repeat key that is
78 # active. So in this example, the actual release button event above
79 # need not have been sent.
81 packet
.send(sock
, addr
)
83 if __name__
=="__main__":