13 roslib.load_manifest(
"jsk_teleop_joy")
26 devices = pygame.midi.get_count()
27 print(
"===========================================")
28 print(
"First, we choose device name:")
29 for d
in range(devices):
30 info = pygame.midi.get_device_info(d)
32 print(
" [%d] %s (%s)" % (d, info[1],
"input"))
34 print(
" [%d] %s (%s)" % (d, info[1],
"output"))
35 val = raw_input(
"Please select the device by number[%d-%d]:" % (0, d))
37 parsed_number = int(val)
38 if parsed_number >= 0
and parsed_number <= d:
39 name = pygame.midi.get_device_info(parsed_number)[1]
40 G_DEVICE_INFO[
"device_name"] = name
42 print(
"device_name: %s" % (name))
45 raise ParseException(
"please input number bewtween %d to %d" % (0, d))
47 raise ParseException(
"please input number")
51 print(
"===========================================")
52 print(
"Please move ALL the inputs")
53 print(
"===========================================")
54 print(
"The order you move them will be mapped into Joy/axes.")
55 print(
"If you want to finish analog mapping, please type 'q'")
58 ready = select.select([sys.stdin], [], [], 0.1)[0]
60 line = sys.stdin.readline()
61 if line.startswith(
"q"):
62 print(
"We installed %d analog inputs" % (len(analog_configs)))
63 G_DEVICE_INFO[
"analogs"] = analog_configs
65 while controller.poll():
66 data = controller.read(1)
69 (command, index, val) =
MIDIParse(elem_set)
70 if (command, index)
not in analog_configs:
71 print(
"(%d, %d) installing into %d" % (command, index, len(analog_configs)))
72 analog_configs.append((command, index))
73 except MIDIException
as e:
74 print(
"(%d, %d, %d) is not supported" % (elem_set[0][0], elem_set[0][1], elem_set[0][2]))
82 except ParseException
as e:
86 controller = pygame.midi.Input(device_num)
88 f = open(
'/tmp/midi.yaml',
'w')
89 f.write(yaml.dump(G_DEVICE_INFO))
91 print(
"writing the configuration to /tmp/midi.yaml")
93 if __name__ ==
"__main__":
def configAnalogInputs(controller)