Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (73 sloc) 2.41 KB
import psmove
import os
from sys import platform
print(platform)
if platform == "linux" or platform == "linux2":
import jm_dbus
elif "win" in platform:
import win_jm_dbus as jm_dbus
class Pair():
"""
Manage paring move controllers to the server
"""
def __init__(self):
"""Use DBus to find bluetooth controllers"""
pass
# self.hci_dict = jm_dbus.get_hci_dict()
#
# devices = self.hci_dict.values()
# self.bt_devices = {}
# for device in devices:
# self.bt_devices[device] = []
#
# self.pre_existing_devices()
def pre_existing_devices(self):
"""
Enumerate known devices
For each device on each adapter, add the device's address to it's adapter's
list of known devices
"""
pass
# for hci, addr in self.hci_dict.items():
# proxy = jm_dbus.get_adapter_proxy(hci)
# devices = jm_dbus.get_node_child_names(proxy)
#
# self.bt_devices[addr] = jm_dbus.get_attached_addresses(hci)
def update_adapters(self):
"""
Rescan for bluetooth adapters that may not have existed on program launch
"""
pass
# self.hci_dict = jm_dbus.get_hci_dict()
#
# for addr in self.hci_dict.values():
# if addr not in self.bt_devices.keys():
# self.bt_devices[addr] = []
#
# self.pre_existing_devices()
def check_if_not_paired(self, addr):
pass
# for devs in self.bt_devices.keys():
# if addr in self.bt_devices[devs]:
# return False
# return True
def get_lowest_bt_device(self):
pass
# num = 9999999
# print(self.bt_devices)
# for dev in self.bt_devices.keys():
# if len(self.bt_devices[dev]) < num:
# num = len(self.bt_devices[dev])
#
# for dev in self.bt_devices.keys():
# if len(self.bt_devices[dev]) == num:
# return dev
# return ''
def pair_move(self, move):
result = move.pair()
return result
# if move and move.get_serial():
# if move.connection_type == psmove.Conn_USB:
# self.pre_existing_devices()
# if self.check_if_not_paired(move.get_serial().upper()):
# move.pair_custom(self.get_lowest_bt_device())
You can’t perform that action at this time.