Anonymous avatar Anonymous committed b3bec82

initial version

Comments (0)

Files changed (4)

+~
+pyc
+import kivy
+
+from kivy.app import App
+from kivy.uix.scrollview import ScrollView
+from kivy.uix.gridlayout import GridLayout
+from kivy.uix.button import Button
+
+from remote import sendKey
+
+
+EVENT_TO_NAME = {
+    'KEY_0': '0',
+    'KEY_1': '1',
+    'KEY_2': '2',
+    'KEY_3': '3',
+    'KEY_4': '4',
+    'KEY_5': '5',
+    'KEY_6': '6',
+    'KEY_7': '7',
+    'KEY_8': '8',
+    'KEY_9': '9',
+    'KEY_UP': 'UP',
+    'KEY_DOWN': 'DOWN',
+    'KEY_LEFT': 'LEFT',
+    'KEY_RIGHT': 'RIGHT',
+    'KEY_MENU': 'MENU',
+    'KEY_PRECH': 'PRECH',
+    'KEY_GUIDE': 'GUIDE',
+    'KEY_INFO': 'INFO',
+    'KEY_RETURN': 'RETURN',
+    'KEY_CH_LIST': 'CH LIST',
+    'KEY_EXIT': 'EXIT',
+    'KEY_ENTER': 'ENTER',
+    'KEY_SOURCE': 'SOURCE',
+    'KEY_AD': 'PLAY', #KEY_PLAY
+    'KEY_PAUSE': 'PAUSE',
+    'KEY_MUTE': 'MUTE',
+    'KEY_PICTURE_SIZE': 'PICTURE SIZE',
+    'KEY_VOLUP': 'VOLUP',
+    'KEY_VOLDOWN': 'VOLDOWN',
+    'KEY_TOOLS': 'TOOLS',
+    'KEY_POWEROFF': 'OFF',
+    'KEY_CHUP': 'CH UP',
+    'KEY_CHDOWN': 'CH DOWN',
+    'KEY_CONTENTS': 'CONTENTS',
+    'KEY_W_LINK': 'MEDIA',  #Media P
+    'KEY_RSS': 'INTERNET', #Internet
+    'KEY_MTS': 'DUAL', #Dual
+    'KEY_CAPTION': 'SUBS', #Subt
+    'KEY_REWIND': 'REWIND',
+    'KEY_FF': 'FORWARD',
+    'KEY_REC': 'REC',
+    'KEY_STOP': 'STOP',
+    'KEY_TV': 'TV',
+}
+
+class KivySamsungRemote(App):
+
+    def build(self):
+        sv = ScrollView(size_hint=(None, None), size=(500, 500))
+        frame = GridLayout(cols=2)
+        for event, name in EVENT_TO_NAME.iteritems():
+            btn = Button(text=name)
+            btn.bind(on_press=lambda x: sendKey(event))
+            frame.add_widget(btn)
+        sv.add_widget(frame)
+        return sv
+
+if __name__ in ('__android__', '__main__'):
+    KivySamsungRemote().run()
+import socket
+import base64
+import time, datetime
+
+#IP Address of TV
+tvip = "192.168.1.30"
+#IP Address of TV
+myip = "100.0.0.112"
+#Used for the access control/validation, but not after that AFAIK
+mymac = "00-0c-29-3e-b1-4f"
+#What the iPhone app reports
+appstring = "kivy.samsung.remote"
+#Might need changing to match your TV type
+tvappstring = "iphone.UE55C8000.iapp.samsung"
+#What gets reported when it asks for permission
+remotename = "Kivy Samsung Remote"
+
+# Key Reference
+# Normal remote keys
+ #KEY_0
+ #KEY_1
+ #KEY_2
+ #KEY_3
+ #KEY_4
+ #KEY_5
+ #KEY_6
+ #KEY_7
+ #KEY_8
+ #KEY_9
+ #KEY_UP
+ #KEY_DOWN
+ #KEY_LEFT
+ #KEY_RIGHT
+ #KEY_MENU
+ #KEY_PRECH
+ #KEY_GUIDE
+ #KEY_INFO
+ #KEY_RETURN
+ #KEY_CH_LIST
+ #KEY_EXIT
+ #KEY_ENTER
+ #KEY_SOURCE
+ #KEY_AD #KEY_PLAY
+ #KEY_PAUSE
+ #KEY_MUTE
+ #KEY_PICTURE_SIZE
+ #KEY_VOLUP
+ #KEY_VOLDOWN
+ #KEY_TOOLS
+ #KEY_POWEROFF
+ #KEY_CHUP
+ #KEY_CHDOWN
+ #KEY_CONTENTS
+ #KEY_W_LINK #Media P
+ #KEY_RSS #Internet
+ #KEY_MTS #Dual
+ #KEY_CAPTION #Subt
+ #KEY_REWIND
+ #KEY_FF
+ #KEY_REC
+ #KEY_STOP
+# Bonus buttons not on the normal remote:
+ #KEY_TV
+#Don't work/wrong codes:
+ #KEY_CONTENT
+ #KEY_INTERNET
+ #KEY_PC
+ #KEY_HDMI1
+ #KEY_OFF
+ #KEY_POWER
+ #KEY_STANDBY
+ #KEY_DUAL
+ #KEY_SUBT
+ #KEY_CHANUP
+ #KEY_CHAN_UP
+ #KEY_PROGUP
+ #KEY_PROG_UP
+
+# First configure the connection
+
+# Function to send keys
+def sendKey(skey):
+    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+    sock.connect((tvip, 55000))
+    ipencoded = base64.b64encode(myip)
+    macencoded = base64.b64encode(mymac)
+    messagepart1 = chr(0x64) + chr(0x00) + chr(len(ipencoded)) \
+        + chr(0x00) + ipencoded + chr(len(macencoded)) + chr(0x00) \
+        + macencoded + chr(len(base64.b64encode(remotename))) + chr(0x00) \
+        + base64.b64encode(remotename)
+
+    part1 = chr(0x00) + chr(len(appstring)) + chr(0x00) + appstring \
+        + chr(len(messagepart1)) + chr(0x00) + messagepart1
+    sock.send(part1)
+
+    messagepart2 = chr(0xc8) + chr(0x00)
+    part2 = chr(0x00) + chr(len(appstring)) + chr(0x00) + appstring \
+        + chr(len(messagepart2)) + chr(0x00) + messagepart2
+    sock.send(part2)
+
+    messagepart3 = chr(0x00) + chr(0x00) + chr(0x00) + chr(len(
+                    base64.b64encode(skey))) + chr(0x00) + base64.b64encode(skey)
+    part3 = chr(0x00) + chr(len(appstring)) + chr(0x00) \
+                        + appstring + chr(len(messagepart3)) + chr(0x00) + messagepart3
+    sock.send(part3)
+
+    sock.close()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.