2013-01-07 13:28:09 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2009-2013 Paul Davis
|
|
|
|
Authors: Sampo Savolainen, Jannis Pohlmann
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
2008-12-12 09:43:24 -05:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
#include "pbd/compose.h"
|
|
|
|
#include "pbd/error.h"
|
|
|
|
#include "ardour/debug.h"
|
2009-10-29 20:21:40 -04:00
|
|
|
#include "ardour/session.h"
|
2008-12-12 09:43:24 -05:00
|
|
|
#include "i18n.h"
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
#include "wiimote.h"
|
2008-12-12 09:43:24 -05:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
2013-01-07 13:28:09 -05:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
#include "pbd/abstract_ui.cc" // instantiate template
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
void wiimote_control_protocol_mesg_callback (cwiid_wiimote_t *wiimote, int mesg_count, union cwiid_mesg mesg[], timespec *t);
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
WiimoteControlProtocol::WiimoteControlProtocol (Session& session)
|
|
|
|
: ControlProtocol (session, X_("Wiimote"))
|
|
|
|
, AbstractUI<WiimoteControlUIRequest> ("wiimote")
|
|
|
|
, wiimote (0)
|
|
|
|
, idle_source (0)
|
|
|
|
, button_state (0)
|
|
|
|
, callback_thread_registered (false)
|
|
|
|
{
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
WiimoteControlProtocol::~WiimoteControlProtocol ()
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
2013-01-07 13:28:09 -05:00
|
|
|
stop ();
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
bool
|
|
|
|
WiimoteControlProtocol::probe ()
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
2013-01-07 13:28:09 -05:00
|
|
|
return true;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
int
|
|
|
|
WiimoteControlProtocol::set_active (bool yn)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, string_compose ("WiimoteControlProtocol::set_active init with yn: '%1'\n", yn));
|
|
|
|
|
|
|
|
/* do nothing if the active state is not changing */
|
2013-12-21 15:30:34 -05:00
|
|
|
|
|
|
|
if (yn == active()) {
|
2013-01-07 13:28:09 -05:00
|
|
|
return 0;
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2009-12-04 14:24:09 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
if (yn) {
|
|
|
|
/* activate Wiimote control surface */
|
|
|
|
result = start ();
|
|
|
|
} else {
|
|
|
|
/* deactivate Wiimote control surface */
|
|
|
|
result = stop ();
|
|
|
|
}
|
|
|
|
|
2013-12-21 15:30:34 -05:00
|
|
|
ControlProtocol::set_active (yn);
|
2013-01-07 13:28:09 -05:00
|
|
|
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::set_active done\n");
|
|
|
|
|
|
|
|
return result;
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
XMLNode&
|
|
|
|
WiimoteControlProtocol::get_state ()
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
2013-12-21 15:30:34 -05:00
|
|
|
XMLNode& node (ControlProtocol::get_state());
|
|
|
|
node.add_property (X_("feedback"), "0");
|
|
|
|
return node;
|
2013-01-07 13:28:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
WiimoteControlProtocol::set_state (const XMLNode&, int)
|
|
|
|
{
|
|
|
|
return 0;
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-07 13:28:09 -05:00
|
|
|
WiimoteControlProtocol::do_request (WiimoteControlUIRequest* req)
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
2013-01-07 13:28:09 -05:00
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::do_request init\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
if (req->type == CallSlot) {
|
|
|
|
call_slot (MISSING_INVALIDATOR, req->the_slot);
|
|
|
|
} else if (req->type == Quit) {
|
|
|
|
stop ();
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::do_request done\n");
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
int
|
|
|
|
WiimoteControlProtocol::start ()
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::start init\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// update LEDs whenever the transport or recording state changes
|
|
|
|
session->TransportStateChange.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&WiimoteControlProtocol::update_led_state, this), this);
|
|
|
|
session->RecordStateChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&WiimoteControlProtocol::update_led_state, this), this);
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// start the Wiimote control UI; it will run in its own thread context
|
|
|
|
BaseUI::run ();
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::start done\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
int
|
|
|
|
WiimoteControlProtocol::stop ()
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::stop init\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// stop wiimote discovery, just in case
|
|
|
|
stop_wiimote_discovery ();
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// close and reset the wiimote handle
|
|
|
|
if (wiimote) {
|
|
|
|
cwiid_close (wiimote);
|
|
|
|
wiimote = 0;
|
|
|
|
callback_thread_registered = false;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// stop the Wiimote control UI
|
|
|
|
BaseUI::quit ();
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// no longer update the LEDs
|
|
|
|
session_connections.drop_connections ();
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::stop done\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
void
|
|
|
|
WiimoteControlProtocol::thread_init ()
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::thread_init init\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
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);
|
|
|
|
BasicUI::register_thread ("wiimote");
|
|
|
|
|
|
|
|
// connect a Wiimote
|
|
|
|
start_wiimote_discovery ();
|
|
|
|
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::thread_init done\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-01-07 13:28:09 -05:00
|
|
|
WiimoteControlProtocol::start_wiimote_discovery ()
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
2013-01-07 13:28:09 -05:00
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::start_wiimote_discovery init\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// connect to the Wiimote using an idle source
|
|
|
|
Glib::RefPtr<Glib::IdleSource> source = Glib::IdleSource::create ();
|
|
|
|
source->connect (sigc::mem_fun (*this, &WiimoteControlProtocol::connect_idle));
|
|
|
|
source->attach (_main_loop->get_context ());
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// grab a reference on the underlying idle source to keep it around
|
|
|
|
idle_source = source->gobj ();
|
|
|
|
g_source_ref (idle_source);
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::start_wiimote_discovery done\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WiimoteControlProtocol::stop_wiimote_discovery ()
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::stop_wiimote_discovery init\n");
|
|
|
|
|
|
|
|
if (idle_source) {
|
|
|
|
g_source_unref (idle_source);
|
|
|
|
idle_source = 0;
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::stop_wiimote_discovery done\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
bool
|
|
|
|
WiimoteControlProtocol::connect_idle ()
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
2013-01-07 13:28:09 -05:00
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::connect_idle init\n");
|
2009-12-04 14:24:09 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
bool retry = true;
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
if (connect_wiimote ()) {
|
|
|
|
stop_wiimote_discovery ();
|
|
|
|
retry = false;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::connect_idle done\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
return retry;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
bool
|
|
|
|
WiimoteControlProtocol::connect_wiimote ()
|
|
|
|
{
|
|
|
|
// abort the discovery and do nothing else if we already have a Wiimote
|
|
|
|
if (wiimote) {
|
|
|
|
return true;
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
bool success = true;
|
|
|
|
|
|
|
|
// 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) {
|
|
|
|
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 {
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// clear the last button state to start processing events cleanly
|
|
|
|
button_state = 0;
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2013-01-07 13:28:09 -05:00
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// enable message based communication with the Wiimote
|
|
|
|
if (success && cwiid_enable (wiimote, CWIID_FLAG_MESG_IFC)) {
|
|
|
|
cerr << "Wiimote: Failed to enable message based communication" << endl;
|
|
|
|
success = false;
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// enable button events to be received from the Wiimote
|
|
|
|
if (success && cwiid_command (wiimote, CWIID_CMD_RPT_MODE, CWIID_RPT_BTN)) {
|
|
|
|
cerr << "Wiimote: Failed to enable button events" << endl;
|
|
|
|
success = false;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// receive an event for every single button pressed, not just when
|
|
|
|
// a different button was pressed than before
|
|
|
|
if (success && cwiid_enable (wiimote, CWIID_FLAG_REPEAT_BTN)) {
|
|
|
|
cerr << "Wiimote: Failed to enable repeated button events" << endl;
|
|
|
|
success = false;
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
2013-01-07 13:28:09 -05:00
|
|
|
|
|
|
|
// be notified of new input events
|
|
|
|
if (success && cwiid_set_mesg_callback (wiimote, wiimote_control_protocol_mesg_callback)) {
|
|
|
|
}
|
|
|
|
|
|
|
|
// reset Wiimote handle if the configuration failed
|
|
|
|
if (!success && wiimote) {
|
|
|
|
cwiid_close (wiimote);
|
|
|
|
wiimote = 0;
|
|
|
|
callback_thread_registered = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WiimoteControlProtocol::update_led_state ()
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::update_led_state init\n");
|
|
|
|
|
|
|
|
uint8_t state = 0;
|
|
|
|
|
|
|
|
// do nothing if we do not have a Wiimote
|
|
|
|
if (!wiimote) {
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::update_led_state no wiimote connected\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// enable LED1 if Ardour is playing
|
|
|
|
if (session->transport_rolling ()) {
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::update_led_state playing, activate LED1\n");
|
|
|
|
state |= CWIID_LED1_ON;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// enable LED4 if Ardour is recording
|
|
|
|
if (session->actively_recording ()) {
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::update_led_state recording, activate LED4\n");
|
|
|
|
state |= CWIID_LED4_ON;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// apply the LED state
|
|
|
|
cwiid_set_led (wiimote, state);
|
|
|
|
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::update_led_state done\n");
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
void
|
|
|
|
WiimoteControlProtocol::wiimote_callback (int mesg_count, union cwiid_mesg mesg[])
|
|
|
|
{
|
|
|
|
// register the cwiid callback thread if that hasn't happened yet
|
|
|
|
if (!callback_thread_registered) {
|
|
|
|
BasicUI::register_thread ("wiimote callback");
|
|
|
|
callback_thread_registered = true;
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
for (int i = 0; i < mesg_count; i++) {
|
|
|
|
// restart Wiimote discovery when receiving errors
|
|
|
|
if (mesg[i].type == CWIID_MESG_ERROR) {
|
|
|
|
cerr << "Wiimote: disconnected" << endl;
|
|
|
|
cwiid_close (wiimote);
|
|
|
|
wiimote = 0;
|
|
|
|
callback_thread_registered = false;
|
|
|
|
start_wiimote_discovery ();
|
|
|
|
return;
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// skip non-button events
|
|
|
|
if (mesg[i].type != CWIID_MESG_BTN) {
|
|
|
|
continue;
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// drop buttons from the event that were already pressed before
|
|
|
|
uint16_t b = mesg[i].btn_mesg.buttons & ~button_state;
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// remember new button state
|
|
|
|
button_state = mesg[i].btn_mesg.buttons;
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
if (button_state & CWIID_BTN_B) {
|
|
|
|
// B + A = abort recording and jump back
|
|
|
|
if (b & CWIID_BTN_A) {
|
|
|
|
access_action ("Transport/ToggleRollForgetCapture");
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// B + left = move playhead to previous region boundary
|
|
|
|
if (b & CWIID_BTN_LEFT) {
|
|
|
|
access_action ("Editor/playhead-to-previous-region-boundary");
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// B + right = move playhead to next region boundary
|
|
|
|
if (b & CWIID_BTN_RIGHT) {
|
|
|
|
access_action ("Editor/playhead-to-next-region-boundary");
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// B + up = move playhead to next marker
|
|
|
|
if (b & CWIID_BTN_UP) {
|
|
|
|
next_marker ();
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// B + down = move playhead to prev marker
|
|
|
|
if (b & CWIID_BTN_DOWN) {
|
|
|
|
prev_marker ();
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// B + Home = add marker at playhead
|
|
|
|
if (b & CWIID_BTN_HOME) {
|
|
|
|
access_action ("Editor/add-location-from-playhead");
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
// B + minus = move playhead to the start
|
|
|
|
if (b & CWIID_BTN_MINUS) {
|
|
|
|
access_action ("Transport/GotoStart");
|
|
|
|
}
|
|
|
|
|
|
|
|
// B + plus = move playhead to the end
|
|
|
|
if (b & CWIID_BTN_PLUS) {
|
|
|
|
access_action ("Transport/GotoEnd");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// A = toggle playback
|
|
|
|
if (b & CWIID_BTN_A) {
|
|
|
|
access_action ("Transport/ToggleRoll");
|
|
|
|
}
|
|
|
|
|
|
|
|
// 1 = toggle recording on the current track
|
|
|
|
if (b & CWIID_BTN_1) {
|
|
|
|
access_action ("Editor/track-record-enable-toggle");
|
|
|
|
}
|
|
|
|
|
|
|
|
// 2 = enable recording in general
|
|
|
|
if (b & CWIID_BTN_2) {
|
|
|
|
rec_enable_toggle ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// left = move playhead back a bit
|
|
|
|
if (b & CWIID_BTN_LEFT) {
|
|
|
|
access_action ("Editor/nudge-playhead-backward");
|
|
|
|
}
|
|
|
|
|
|
|
|
// right = move playhead forward a bit
|
|
|
|
if (b & CWIID_BTN_RIGHT) {
|
|
|
|
access_action ("Editor/nudge-playhead-forward");
|
|
|
|
}
|
|
|
|
|
|
|
|
// up = select previous track
|
|
|
|
if (b & CWIID_BTN_UP) {
|
|
|
|
access_action ("Editor/select-prev-route");
|
|
|
|
}
|
|
|
|
|
|
|
|
// down = select next track
|
|
|
|
if (b & CWIID_BTN_DOWN) {
|
|
|
|
access_action ("Editor/select-next-route");
|
|
|
|
}
|
|
|
|
|
|
|
|
// + = zoom in
|
|
|
|
if (b & CWIID_BTN_PLUS) {
|
|
|
|
access_action ("Editor/temporal-zoom-in");
|
|
|
|
}
|
|
|
|
|
|
|
|
// - = zoom out
|
|
|
|
if (b & CWIID_BTN_MINUS) {
|
|
|
|
access_action ("Editor/temporal-zoom-out");
|
|
|
|
}
|
|
|
|
|
|
|
|
// home = no-op
|
|
|
|
if (b & CWIID_BTN_HOME) {
|
|
|
|
access_action ("Editor/playhead-to-edit");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:28:09 -05:00
|
|
|
void
|
|
|
|
wiimote_control_protocol_mesg_callback (cwiid_wiimote_t *wiimote, int mesg_count, union cwiid_mesg mesg[], timespec *)
|
2008-12-12 09:43:24 -05:00
|
|
|
{
|
2013-01-07 13:28:09 -05:00
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::mesg_callback init\n");
|
|
|
|
|
|
|
|
WiimoteControlProtocol *protocol = (WiimoteControlProtocol *)cwiid_get_data (wiimote);
|
|
|
|
|
|
|
|
if (protocol) {
|
|
|
|
protocol->wiimote_callback (mesg_count, mesg);
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUG_TRACE (DEBUG::WiimoteControl, "WiimoteControlProtocol::mesg_callback done\n");
|
2008-12-12 09:43:24 -05:00
|
|
|
}
|