blob: 7c437824283c4e2a77783619380c2f7af566edfe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#!/usr/bin/env python3
# This is a simple example showing how you can send mouse movement
# events to XBMC.
# NOTE: Read the comments in 'example_button1.py' for a more detailed
# explanation.
import os
from socket import *
import sys
if os.path.exists("../../lib/python"):
# try loading modules from source directory
sys.path.append("../../lib/python")
from xbmcclient import *
ICON_PATH = "../../icons/"
else:
# fallback to system wide modules
from kodi.xbmcclient import *
from kodi.defs import *
def main():
import time
import sys
host = "localhost"
port = 9777
addr = (host, port)
sock = socket(AF_INET,SOCK_DGRAM)
# First packet must be HELO and can contain an icon
packet = PacketHELO("Example Mouse", ICON_PNG,
ICON_PATH + "/mouse.png")
packet.send(sock, addr)
# wait for notification window to close (in XBMC)
time.sleep(2)
# send mouse events to take cursor from top left to bottom right of the screen
# here 0 to 65535 will map to XBMC's screen width and height.
# Specifying absolute mouse coordinates is unsupported currently.
for i in range(0, 65535, 2):
packet = PacketMOUSE(i,i)
packet.send(sock, addr)
# ok we're done, close the connection
packet = PacketBYE()
packet.send(sock, addr)
if __name__=="__main__":
main()
|