X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fwiimote%2Fwiimote.cc;h=59f0ea2c8686fe62feabf4a45c513b4eacd217ed;hb=54efcbaa35cec5e4cda663ceb31fa1ca12683c1b;hp=68f2125dcb5a6824768b26cf868eccba0a03cf1c;hpb=02092679808718c993e741f7328a33888ddc294c;p=ardour.git diff --git a/libs/surfaces/wiimote/wiimote.cc b/libs/surfaces/wiimote/wiimote.cc index 68f2125dcb..59f0ea2c86 100644 --- a/libs/surfaces/wiimote/wiimote.cc +++ b/libs/surfaces/wiimote/wiimote.cc @@ -24,7 +24,7 @@ #include "pbd/error.h" #include "ardour/debug.h" #include "ardour/session.h" -#include "i18n.h" +#include "pbd/i18n.h" #include "wiimote.h" @@ -65,7 +65,8 @@ WiimoteControlProtocol::set_active (bool yn) DEBUG_TRACE (DEBUG::WiimoteControl, string_compose ("WiimoteControlProtocol::set_active init with yn: '%1'\n", yn)); /* do nothing if the active state is not changing */ - if (yn == _active) { + + if (yn == active()) { return 0; } @@ -77,8 +78,7 @@ WiimoteControlProtocol::set_active (bool yn) result = stop (); } - /* remember new active state */ - _active = yn; + ControlProtocol::set_active (yn); DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::set_active done\n"); @@ -88,10 +88,9 @@ WiimoteControlProtocol::set_active (bool yn) XMLNode& WiimoteControlProtocol::get_state () { - XMLNode *node = new XMLNode ("Protocol"); - node->add_property (X_("name"), ARDOUR::ControlProtocol::_name); - node->add_property (X_("feedback"), "0"); - return *node; + XMLNode& node (ControlProtocol::get_state()); + node.set_property (X_("feedback"), "0"); + return node; } int @@ -165,7 +164,7 @@ WiimoteControlProtocol::thread_init () pthread_set_name (X_("wiimote")); // allow to make requests to the GUI and RT thread(s) - PBD::notify_gui_about_thread_creation (X_("gui"), pthread_self (), X_("wiimote"), 2048); + PBD::notify_event_loops_about_thread_creation (pthread_self (), X_("wiimote"), 2048); BasicUI::register_thread ("wiimote"); // connect a Wiimote @@ -209,11 +208,10 @@ WiimoteControlProtocol::connect_idle () { DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::connect_idle init\n"); - bool retry = true; + bool retry = false; if (connect_wiimote ()) { stop_wiimote_discovery (); - retry = false; } DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::connect_idle done\n"); @@ -229,30 +227,29 @@ WiimoteControlProtocol::connect_wiimote () return true; } - bool success = true; + bool success = false; // if we don't have a Wiimote yet, try to discover it; if that // fails, wait for a short period of time and try again - if (!wiimote) { + for (int i = 0; i < 5; ++i) { cerr << "Wiimote: Not discovered yet, press 1+2 to connect" << endl; bdaddr_t bdaddr = {{ 0, 0, 0, 0, 0, 0 }}; wiimote = cwiid_open (&bdaddr, 0); callback_thread_registered = false; - if (!wiimote) { - success = false; - } else { + if (wiimote) { // a Wiimote was discovered cerr << "Wiimote: Connected successfully" << endl; // attach the WiimoteControlProtocol object to the Wiimote handle if (cwiid_set_data (wiimote, this)) { cerr << "Wiimote: Failed to attach control protocol" << endl; - success = false; + } else { + success = true; + // clear the last button state to start processing events cleanly + button_state = 0; + break; } - - // clear the last button state to start processing events cleanly - button_state = 0; } } @@ -379,7 +376,7 @@ WiimoteControlProtocol::wiimote_callback (int mesg_count, union cwiid_mesg mesg[ // B + Home = add marker at playhead if (b & CWIID_BTN_HOME) { - access_action ("Editor/add-location-from-playhead"); + access_action ("Common/add-location-from-playhead"); } // B + minus = move playhead to the start @@ -409,12 +406,12 @@ WiimoteControlProtocol::wiimote_callback (int mesg_count, union cwiid_mesg mesg[ // left = move playhead back a bit if (b & CWIID_BTN_LEFT) { - access_action ("Editor/nudge-playhead-backward"); + access_action ("Common/nudge-playhead-backward"); } // right = move playhead forward a bit if (b & CWIID_BTN_RIGHT) { - access_action ("Editor/nudge-playhead-forward"); + access_action ("Common/nudge-playhead-forward"); } // up = select previous track @@ -450,7 +447,7 @@ wiimote_control_protocol_mesg_callback (cwiid_wiimote_t *wiimote, int mesg_count { DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::mesg_callback init\n"); - WiimoteControlProtocol *protocol = (WiimoteControlProtocol *)cwiid_get_data (wiimote); + WiimoteControlProtocol *protocol = reinterpret_cast (const_cast(cwiid_get_data (wiimote))); if (protocol) { protocol->wiimote_callback (mesg_count, mesg); @@ -458,3 +455,15 @@ wiimote_control_protocol_mesg_callback (cwiid_wiimote_t *wiimote, int mesg_count DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::mesg_callback done\n"); } + + +void* +WiimoteControlProtocol::request_factory (uint32_t num_requests) +{ + /* AbstractUI::request_buffer_factory() is a template method only + instantiated in this source module. To provide something visible for + use in the interface/descriptor, we have this static method that is + template-free. + */ + return request_buffer_factory (num_requests); +}