Mixer: Give better visual feedback in control OSC/MIDI learning mode.
This commit is contained in:
parent
5affbe4cef
commit
a2089421b1
|
@ -50,6 +50,9 @@
|
||||||
|
|
||||||
bool Controller_Module::learn_by_number = false;
|
bool Controller_Module::learn_by_number = false;
|
||||||
bool Controller_Module::_learn_mode = false;
|
bool Controller_Module::_learn_mode = false;
|
||||||
|
|
||||||
|
Controller_Module* Controller_Module::_learning_control = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -836,10 +839,27 @@ Controller_Module::draw ( void )
|
||||||
|
|
||||||
if ( learn_mode() )
|
if ( learn_mode() )
|
||||||
{
|
{
|
||||||
fl_rectf( x(),y(),w(),h(), fl_color_add_alpha( FL_MAGENTA, 50 ) );
|
fl_rectf( x(),y(),w(),h(),
|
||||||
|
fl_color_add_alpha(
|
||||||
|
this == _learning_control
|
||||||
|
? FL_RED
|
||||||
|
: FL_GREEN,
|
||||||
|
60 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller_Module::learning_callback ( void *userdata )
|
||||||
|
{
|
||||||
|
((Controller_Module*)userdata)->learning_callback();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller_Module::learning_callback ( void )
|
||||||
|
{
|
||||||
|
_learning_control = NULL;
|
||||||
|
this->redraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
Controller_Module::handle ( int m )
|
Controller_Module::handle ( int m )
|
||||||
{
|
{
|
||||||
|
@ -852,6 +872,10 @@ Controller_Module::handle ( int m )
|
||||||
{
|
{
|
||||||
tooltip( "Now learning control. Move the desired control on your controller" );
|
tooltip( "Now learning control. Move the desired control on your controller" );
|
||||||
|
|
||||||
|
_learning_control = this;
|
||||||
|
|
||||||
|
this->redraw();
|
||||||
|
|
||||||
//connect_to( &module->control_input[port] );
|
//connect_to( &module->control_input[port] );
|
||||||
Port *p = control_output[0].connected_port();
|
Port *p = control_output[0].connected_port();
|
||||||
|
|
||||||
|
@ -861,7 +885,7 @@ Controller_Module::handle ( int m )
|
||||||
|
|
||||||
DMESSAGE( "Will learn %s", path );
|
DMESSAGE( "Will learn %s", path );
|
||||||
|
|
||||||
mixer->osc_endpoint->learn( path );
|
mixer->osc_endpoint->learn( path, Controller_Module::learning_callback, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -47,9 +47,13 @@ class Controller_Module : public Module
|
||||||
void add_osc_peers_to_menu ( Fl_Menu_Button *m, const char *prefix );
|
void add_osc_peers_to_menu ( Fl_Menu_Button *m, const char *prefix );
|
||||||
void add_osc_connections_to_menu ( Fl_Menu_Button *m, const char *prefix );
|
void add_osc_connections_to_menu ( Fl_Menu_Button *m, const char *prefix );
|
||||||
|
|
||||||
|
static void learning_callback ( void *userdata );
|
||||||
|
void learning_callback ( void );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static bool _learn_mode;
|
static bool _learn_mode;
|
||||||
|
static Controller_Module *_learning_control;
|
||||||
|
|
||||||
static bool learn_by_number;
|
static bool learn_by_number;
|
||||||
static bool learn_mode ( void ) { return _learn_mode; }
|
static bool learn_mode ( void ) { return _learn_mode; }
|
||||||
|
|
|
@ -187,6 +187,7 @@ namespace OSC
|
||||||
Endpoint::Endpoint ( )
|
Endpoint::Endpoint ( )
|
||||||
{
|
{
|
||||||
_learning_path = NULL;
|
_learning_path = NULL;
|
||||||
|
_learning_callback = NULL;
|
||||||
_peer_signal_notification_callback = 0;
|
_peer_signal_notification_callback = 0;
|
||||||
_peer_signal_notification_userdata = 0;
|
_peer_signal_notification_userdata = 0;
|
||||||
_peer_scan_complete_callback = 0;
|
_peer_scan_complete_callback = 0;
|
||||||
|
@ -685,8 +686,13 @@ namespace OSC
|
||||||
DMESSAGE( "Learned translation \"%s\" -> \"%s\"", path, ep->_learning_path );
|
DMESSAGE( "Learned translation \"%s\" -> \"%s\"", path, ep->_learning_path );
|
||||||
|
|
||||||
free(ep->_learning_path);
|
free(ep->_learning_path);
|
||||||
|
|
||||||
|
ep->_learning_callback(ep->_learning_userdata);
|
||||||
|
|
||||||
|
ep->_learning_userdata = NULL;
|
||||||
|
ep->_learning_callback = NULL;
|
||||||
ep->_learning_path = NULL;
|
ep->_learning_path = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,13 +1072,16 @@ namespace OSC
|
||||||
|
|
||||||
/* prepare to learn a translation for /path/. The next unhandled message to come through will be mapped to /path/ */
|
/* prepare to learn a translation for /path/. The next unhandled message to come through will be mapped to /path/ */
|
||||||
void
|
void
|
||||||
Endpoint::learn ( const char *path )
|
Endpoint::learn ( const char *path, void (*callback)(void*), void *userdata )
|
||||||
{
|
{
|
||||||
if ( _learning_path )
|
if ( _learning_path )
|
||||||
free( _learning_path );
|
free( _learning_path );
|
||||||
|
|
||||||
_learning_path = NULL;
|
_learning_path = NULL;
|
||||||
|
|
||||||
|
_learning_callback = callback;
|
||||||
|
_learning_userdata = userdata;
|
||||||
|
|
||||||
if ( path )
|
if ( path )
|
||||||
_learning_path = strdup( path );
|
_learning_path = strdup( path );
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,6 +241,8 @@ namespace OSC
|
||||||
std::list<Method*> _methods;
|
std::list<Method*> _methods;
|
||||||
|
|
||||||
char *_learning_path;
|
char *_learning_path;
|
||||||
|
void (*_learning_callback)(void *);
|
||||||
|
void *_learning_userdata;
|
||||||
|
|
||||||
class TranslationDestination {
|
class TranslationDestination {
|
||||||
|
|
||||||
|
@ -305,7 +307,7 @@ namespace OSC
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void send_feedback ( const char *path, float v );
|
void send_feedback ( const char *path, float v );
|
||||||
void learn ( const char *path );
|
void learn ( const char *path, void (*callback)(void*), void *userdata );
|
||||||
|
|
||||||
lo_address address ( void )
|
lo_address address ( void )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue