示例#1
0
class PS3RemoteThread ( StoppableThread ):
    def __init__(self, csock, isock, ip=""):
        StoppableThread.__init__(self)
        self.csock = csock
        self.isock = isock
        self.xbmc = XBMCClient("PS3 Blu-Ray Remote", ICON_PATH + "/bluetooth.png")
        self.set_timeout(300)

    def run(self):
        sixaxis.initialize(self.csock, self.isock)
        self.xbmc.connect()
        last_connect = time.time()
        bflags = 0
        psflags = 0
        try:
            while not self.stop():
                if process_remote(self.isock, self.xbmc)=="2":
                    if self.timed_out():
                        raise Exception("PS3 Blu-Ray Remote powering off, "\
                                            "timed out")
                elif process_remote(self.isock, self.xbmc):
                    break
                else:
                    self.reset_timeout()
        except Exception, e:
            print str(e)
        self.close_sockets()
示例#2
0
 def send_action(self, action):
     xbmcClient = XBMCClient("floeps")
     xbmcClient.connect()
     time.sleep(1)
 
     self.log("sending action: " + action)
     xbmcClient.send_action(action, ACTION_EXECBUILTIN)
示例#3
0
 def __init__(self, csock, isock, ip=""):
     StoppableThread.__init__(self)
     self.csock = csock
     self.isock = isock
     self.xbmc = XBMCClient("PS3 Blu-Ray Remote",
                            ICON_PATH + "/bluetooth.png")
     self.set_timeout(300)
示例#4
0
class PS3RemoteThread(StoppableThread):
    def __init__(self, csock, isock, ip=""):
        StoppableThread.__init__(self)
        self.csock = csock
        self.isock = isock
        self.xbmc = XBMCClient("PS3 Blu-Ray Remote",
                               ICON_PATH + "/bluetooth.png")
        self.set_timeout(300)

    def run(self):
        sixaxis.initialize(self.csock, self.isock)
        self.xbmc.connect()
        last_connect = time.time()
        bflags = 0
        psflags = 0
        try:
            while not self.stop():
                if process_remote(self.isock, self.xbmc) == "2":
                    if self.timed_out():
                        raise Exception("PS3 Blu-Ray Remote powering off, "\
                                            "timed out")
                elif process_remote(self.isock, self.xbmc):
                    break
                else:
                    self.reset_timeout()
        except Exception, e:
            print str(e)
        self.close_sockets()
示例#5
0
class PS3SixaxisThread(StoppableThread):
    def __init__(self, csock, isock, ip=""):
        StoppableThread.__init__(self)
        self.csock = csock
        self.isock = isock
        self.xbmc = XBMCClient("PS3 Sixaxis", ICON_PATH + "/bluetooth.png")
        self.set_timeout(300)

    def run(self):
        sixaxis.initialize(self.csock, self.isock)
        self.xbmc.connect()
        bflags = 0
        last_bflags = 0
        psflags = 0
        psdown = 0
        toggle_mouse = 0
        self.reset_timeout()
        try:
            while not self.stop():
                if self.timed_out():
                    raise Exception("PS3 Sixaxis powering off, timed out")
                if self.idle_time() > 50:
                    self.xbmc.connect()
                try:
                    data = sixaxis.read_input(self.isock)
                except Exception, e:
                    print str(e)
                    break
                if not data:
                    continue
                if psflags:
                    self.reset_timeout()
                    if psdown:
                        if (time.time() - psdown) > 5:
                            raise Exception(
                                "PS3 Sixaxis powering off, user request")
                    else:
                        psdown = time.time()
                else:
                    if psdown:
                        toggle_mouse = 1 - toggle_mouse
                    psdown = 0
                (bflags, psflags) = sixaxis.process_input(
                    data, toggle_mouse and self.xbmc or None)
                if bflags != last_bflags:
                    if bflags:
                        try:
                            self.xbmc.send_keyboard_button(
                                keymap_sixaxis[bflags])
                        except:
                            pass
                    else:
                        self.xbmc.release_button()
                    last_bflags = bflags
        except Exception, e:
            print str(e)
        self.close_sockets()
示例#6
0
class PS3SixaxisThread ( StoppableThread ):
    def __init__(self, csock, isock, ip=""):
        StoppableThread.__init__(self)
        self.csock = csock
        self.isock = isock
        self.xbmc = XBMCClient("PS3 Sixaxis", ICON_PATH + "/bluetooth.png")
        self.set_timeout(300)

    def run(self):
        sixaxis.initialize(self.csock, self.isock)
        self.xbmc.connect()
        bflags = 0
        last_bflags = 0
        psflags = 0
        psdown = 0
        toggle_mouse = 0
        self.reset_timeout()
        try:
            while not self.stop():
                if self.timed_out():
                    raise Exception("PS3 Sixaxis powering off, timed out")
                if self.idle_time() > 50:
                    self.xbmc.connect()
                try:
                    data = sixaxis.read_input(self.isock)
                except Exception, e:
                    print str(e)
                    break
                if not data:
                    continue
                if psflags:
                    self.reset_timeout()
                    if psdown:
                        if (time.time() - psdown) > 5:
                            raise Exception("PS3 Sixaxis powering off, user request")
                    else:
                        psdown = time.time()
                else:
                    if psdown:
                        toggle_mouse = 1 - toggle_mouse
                    psdown = 0
                (bflags, psflags) = sixaxis.process_input(data, toggle_mouse
                                                          and self.xbmc
                                                          or None)
                if bflags != last_bflags:
                    if bflags:
                        try:
                            self.xbmc.send_keyboard_button(keymap_sixaxis[bflags])
                        except:
                            pass
                    else:
                        self.xbmc.release_button()
                    last_bflags = bflags
        except Exception, e:
            print str(e)
        self.close_sockets()
示例#7
0
def update_xbmc_object():
    serversettings = server_settings()
    host = serversettings['hostname']

    try:
        icon = RUNDIR + '/static/images/maraschino_logo.png'

        xbmc = XBMCClient('Maraschino', icon, ip=host)

    except:
        xbmc = None

    return xbmc
示例#8
0
def update_xbmc_object():
    host = get_setting_value('server_hostname')
    try:
        icon = os.path.abspath('static/images/maraschino_logo.png')

        if not os.path.exists(icon):
            icon = os.path.abspath(
                'maraschino/static/images/maraschino_logo.png')

        xbmc = XBMCClient('Maraschino', icon, ip=host)

    except:
        xbmc = None

    return xbmc
示例#9
0
 def __init__(self, csock, isock, ipaddr="127.0.0.1"):
     StoppableThread.__init__(self)
     self.csock = csock
     self.isock = isock
     self.xbmc = XBMCClient(name="PS3 Blu-Ray Remote", icon_file=ICON_PATH + "/bluetooth.png", ip=ipaddr)
     self.set_timeout(300)
示例#10
0
class PS3SixaxisThread ( StoppableThread ):
    def __init__(self, csock, isock, ipaddr="127.0.0.1"):
        StoppableThread.__init__(self)
        self.csock = csock
        self.isock = isock
        self.xbmc = XBMCClient(name="PS3 Sixaxis", icon_file=ICON_PATH + "/bluetooth.png", ip=ipaddr)
        self.set_timeout(600)

    def run(self):
        sixaxis.initialize(self.csock, self.isock)
        self.xbmc.connect()
        bflags = 0
        released = set()
        pressed  = set()
        pending  = set()
        held     = set()
        psflags = 0
        psdown = 0
        toggle_mouse = 0
        self.reset_timeout()
        try:
            while not self.stop():
                if self.timed_out():

                    for key in (held | pressed):
                        (mapname, action, amount, axis) = keymap_sixaxis[key]
                        self.xbmc.send_button_state(map=mapname, button=action, amount=0, down=0, axis=axis)

                    raise Exception("PS3 Sixaxis powering off, timed out")
                if self.idle_time() > 50:
                    self.xbmc.connect()
                try:
                    data = sixaxis.read_input(self.isock)
                except Exception, e:
                    print str(e)
                    break
                if not data:
                    continue

                (bflags, psflags, pressure) = sixaxis.process_input(data, self.xbmc, toggle_mouse)

                if psflags:
                    self.reset_timeout()
                    if psdown:
                        if (time.time() - psdown) > 5:

                            for key in (held | pressed):
                                (mapname, action, amount, axis) = keymap_sixaxis[key]
                                self.xbmc.send_button_state(map=mapname, button=action, amount=0, down=0, axis=axis)
  
                            raise Exception("PS3 Sixaxis powering off, user request")
                    else:
                        psdown = time.time()
                else:
                    if psdown:
                        toggle_mouse = 1 - toggle_mouse
                    psdown = 0

                keys = set(getkeys(bflags))
                released = (pressed | held) - keys
                held     = (pressed | held) - released
                pressed  = (keys - held) & pending
                pending  = (keys - held)

                for key in released:
                    (mapname, action, amount, axis) = keymap_sixaxis[key]
                    self.xbmc.send_button_state(map=mapname, button=action, amount=0, down=0, axis=axis)

                for key in held:
                    (mapname, action, amount, axis) = keymap_sixaxis[key]
                    if amount > 0:
                        amount = pressure[amount-1] * 256
                        self.xbmc.send_button_state(map=mapname, button=action, amount=amount, down=1, axis=axis)

                for key in pressed:
                    (mapname, action, amount, axis) = keymap_sixaxis[key]
                    if amount > 0:
                        amount = pressure[amount-1] * 256
                    self.xbmc.send_button_state(map=mapname, button=action, amount=amount, down=1, axis=axis)

                if keys:
                    self.reset_timeout()


        except Exception, e:
            printerr()
        self.close_sockets()
示例#11
0
 def __init__(self, csock, isock, ip=""):
     StoppableThread.__init__(self)
     self.csock = csock
     self.isock = isock
     self.xbmc = XBMCClient("PS3 Sixaxis", ICON_PATH + "/bluetooth.png")
     self.set_timeout(300)
示例#12
0
columns = [21,8,5,16,26,20]
channelEnums = [G.BCM07,G.BCM06,G.BCM12,G.BCM13,G.BCM19,G.BCM21,G.BCM08,G.BCM05,G.BCM16,G.BCM26,G.BCM20]
values = [0,0,0,0,0,0,0,0,0,0]

lock = False

logging.info("Setting up Kodi client")

host = config.get("xbmc", "host")
port = config.getint("xbmc", "port")

logging.info("host: " + str(host))
logging.info("port: " + str(port))

# Create an XBMCClient object and connect
xbmc = XBMCClient("OldPhone", "/etc/lirc/osmc-remote-lircd.png")
xbmc.connect()

setReadWrite(rows, columns)

channelVal = G.NONE
previousChannelVal = G.NONE
previousRow = G.NONE

def row_changed(button, i):
    logging.info("entering row_changed with button: " + str(button) + ", i: " + str(i))
    global channelVal
    
    #switch columns to input to read the values
    setReadWrite(columns, rows)
    
示例#13
0
    if column not in columns:
        columns.append(column)
        GPIO.setup(column, GPIO.OUT)
        GPIO.output(column, 1)


logging.info("Setting up Kodi client")

host = config.get("xbmc", "host")
port = config.getint("xbmc", "port")

logging.info("host: " + str(host))
logging.info("port: " + str(port))

# Create an XBMCClient object and connect (needed because we don't run as the same user as Kodi)
xbmc = XBMCClient("OldPhone", addonFolder + "/icon.png")
xbmc.connect()

while True:
    try:
        sleep(0.02)
    except KeyboardInterrupt:
        logging.info("Exiting...")
        raise
    except:
        GPIO.cleanup()
        xbmc.close()
        logging.error("Unexpected error:", sys.exc_info()[0])
        logging.error("Unexpected error:", sys.exc_info()[1])
        raise
pass
示例#14
0
try:
    import xbmc
    import xbmcaddon
    import xbmcgui

    inXbmc = True
except:
    inXbmc = False
try:
    from xbmc.xbmcclient import XBMCClient, ACTION_EXECBUILTIN, ACTION_BUTTON
except:
    sys.path.append("/usr/share/pyshared/xbmc")
    from xbmcclient import XBMCClient, ACTION_EXECBUILTIN, ACTION_BUTTON

xClient = XBMCClient("Phone buttons are enabled")
xClient.connect()

if inXbmc:
    addon = xbmcaddon.Addon("service.oldphone.keypad")
    addonFolder = addon.getAddonInfo("path")
    xbmc.log("using folder: " + addonFolder)
    sys.path.append(os.path.realpath(os.path.join(addonFolder, "..", "service.oldphone.conversation")))
    logging.basicConfig(filename=os.path.join(addonFolder, "keypad.log"), level=logging.INFO)
    configFile = os.path.realpath(os.path.join(addonFolder, "keypad.config"))
    logging.info("in XBMC. Using config file " + configFile)
else:
    folder = os.path.dirname(os.path.realpath(__file__))
    sys.path.append(os.path.realpath(os.path.join(folder, "../..", "Conversation", "service")))

    logging.basicConfig(level=logging.INFO)