forked from adangert/JoustMania
-
Notifications
You must be signed in to change notification settings - Fork 0
/
win_pair.py
81 lines (73 loc) · 2.41 KB
/
win_pair.py
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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())