diff --git a/json_objects/osc_action_mapping.json b/json_objects/osc_action_mapping.json index 6b953ce..aeaa23f 100644 --- a/json_objects/osc_action_mapping.json +++ b/json_objects/osc_action_mapping.json @@ -1,4 +1,20 @@ { + "/shaderparam0": { + "DEFAULT": ["set_the_shader_param_0_layer_offset_0_continuous"], + "NAV_DETOUR": ["set_detour_mix_continuous"] + }, + "/shaderparam1": { + "DEFAULT": ["set_the_shader_param_1_layer_offset_0_continuous"], + "NAV_DETOUR": ["set_detour_speed_position_continuous"] + }, + "/shaderparam2": { + "DEFAULT": ["set_the_shader_param_2_layer_offset_0_continuous"], + "NAV_DETOUR": ["set_detour_start_continuous"] + }, + "/shaderparam3": { + "DEFAULT": ["set_the_shader_param_3_layer_offset_0_continuous"], + "NAV_DETOUR": ["set_detour_end_continuous"] + }, "a": { "NAV_BROWSER": ["move_browser_selection_up"], "DEFAULT": ["seek_back_on_player", "decrease_seek_time"], diff --git a/user_input/osc_input.py b/user_input/osc_input.py index 2d3be6f..7323d20 100644 --- a/user_input/osc_input.py +++ b/user_input/osc_input.py @@ -21,15 +21,19 @@ class OscInput(object): def setup_osc_server(self): server_parser = argparse.ArgumentParser() - server_parser.add_argument("--ip", default="0.0.0.0", help="the ip") + server_parser.add_argument("--ip", default="127.0.0.1", help="the ip") server_parser.add_argument("--port", type=int, default=5433, help="the port") server_args = server_parser.parse_args() this_dispatcher = dispatcher.Dispatcher() - this_dispatcher.map("/recurOsc", self.on_osc_input) + + this_dispatcher.map("/keyboard/*", self.on_osc_input) + this_dispatcher.map("/shaderparam0", self.on_param_osc_input) + this_dispatcher.map("/shaderparam1", self.on_param_osc_input) + this_dispatcher.map("/shaderparam2", self.on_param_osc_input) + this_dispatcher.map("/shaderparam3", self.on_param_osc_input) this_dispatcher.map("/shutdown", self.exit_osc_server) - this_dispatcher.map("/*", self.on_osc_message) server = osc_server.ThreadingOSCUDPServer((server_args.ip, server_args.port), this_dispatcher) server_thread = threading.Thread(target=server.serve_forever) @@ -39,39 +43,39 @@ class OscInput(object): def exit_osc_server(self, unused_addr, args): self.osc_server.shutdown() - def on_osc_message(self, addr, args): - #print("!!!!!!!!!!!!!!!!%s\t%s" %(addr,args)) - #print ("%s" %self.osc_mappings.keys()) - if addr in self.osc_mappings: - #'print("got a mapping for %s with value %s" % (addr,args)) - self.actions.call_method_name(self.osc_mappings[addr]['DEFAULT'][0], args) - def on_osc_input(self, addr, args): - #print("!!!!!!!!!!!!!!!!" + addr + ", " + args) + args = str(args) + print("!!!!!!!!!!!!!!!!" + args) + print("the address", addr) + key = addr[-1] numpad = list(string.ascii_lowercase[0:19]) - if args in numpad: - self.run_action_for_osc_channel(args) + if key in numpad: + self.run_action_for_osc_channel(key) else: print('{} is not in keypad map'.format(args)) - def run_action_for_osc_channel(self, channel, args = None): + def on_param_osc_input(self, addr, args): + print("the address", addr) + + self.run_action_for_osc_channel(addr, param_value=args) + + def run_action_for_osc_channel(self, channel, param_value=None): this_mapping = self.osc_mappings[channel] if self.data.control_mode in this_mapping: mode = self.data.control_mode elif 'DEFAULT' in this_mapping: mode = 'DEFAULT' - + if self.data.function_on and len(this_mapping[mode]) > 1: - print('the action being called is {}'.format(this_mapping[mode][1])) - #getattr(self.actions, this_mapping[mode][1])() - self.actions.call_method_name(this_mapping[mode][1], args) + method_name = this_mapping[mode][1] if self.data.settings['sampler']['FUNC_GATED']['value'] == 'off': self.data.function_on = False else: - print('the action being called is {}'.format(this_mapping[mode][0])) - #getattr(self.actions, this_mapping[mode][0])() - self.actions.call_method_name(this_mapping[mode][0], args) - - self.display.refresh_display() + method_name = this_mapping[mode][0] + + self.actions.call_method_name(method_name, param_value) + + if 'continuous' not in method_name: + self.display.refresh_display()