Drop obsolete powermate code from libs/surface
This commit is contained in:
parent
c72c7e6575
commit
55e07a7243
|
@ -1,21 +0,0 @@
|
|||
|
||||
This module works with the Griffin Powermate and allows some basic transport control.
|
||||
|
||||
It autodetects the Powermate on any input device of the form "/dev/input/event*". This means you must have the powermate module in your kernel. It works out-of-the-box with 64Studio and presumably lots of other modern distributions.
|
||||
|
||||
Turning the wheel left and right will act as a "Shuttle" wheel, adjusting playback speed up and down
|
||||
Pushing the knob will switch between play and stop
|
||||
Pushing the knob while turning will jump to the next or previous markers
|
||||
|
||||
|
||||
In order for the powermate to work, you have to have permission to open the input device for reading.
|
||||
In debian, I changed /etc/udev/rules.d/0_permissions.rules to have the line:
|
||||
KERNEL=="event[0-9]*", MODE="0666"
|
||||
but there are other ways to achieve this
|
||||
|
||||
|
||||
Feedback, tweaks, bug fixes and feature ideas are encouraged
|
||||
|
||||
-Ben Loftis, ben@benloftis.com
|
||||
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
#ifndef __i18n_h__
|
||||
#define __i18n_h__
|
||||
|
||||
#include "pbd/compose.h"
|
||||
#include "pbd/convert.h"
|
||||
#include "gettext.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#define _(Text) dgettext (PACKAGE,Text)
|
||||
#define N_(Text) gettext_noop (Text)
|
||||
#define X_(Text) Text
|
||||
#define I18N(Array) PBD::internationalize (PACKAGE, Array)
|
||||
|
||||
#endif // __i18n_h__
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
Ardour9pin interface file
|
||||
Ben Loftis
|
||||
Created: 05/18/06 11:07:56
|
||||
Copyright Harrison Audio, LLC, 2007
|
||||
*/
|
||||
|
||||
#include "powermate.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
ControlProtocol*
|
||||
new_powermate_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
|
||||
{
|
||||
PowermateControlProtocol* pcp = new PowermateControlProtocol (*s);
|
||||
|
||||
if (pcp->set_active (true)) {
|
||||
delete pcp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return pcp;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
delete_powermate_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
|
||||
{
|
||||
delete cp;
|
||||
}
|
||||
|
||||
bool
|
||||
probe_powermate_protocol (ControlProtocolDescriptor* /*descriptor*/)
|
||||
{
|
||||
return PowermateControlProtocol::probe ();
|
||||
}
|
||||
|
||||
static ControlProtocolDescriptor powermate_descriptor = {
|
||||
name : "powermate",
|
||||
id : "uri://ardour.org/ardour/powermate:0",
|
||||
ptr : 0,
|
||||
module : 0,
|
||||
mandatory : 0,
|
||||
supports_feedback : false,
|
||||
probe : probe_powermate_protocol,
|
||||
initialize : new_powermate_protocol,
|
||||
destroy : delete_powermate_protocol
|
||||
};
|
||||
|
||||
|
||||
extern "C" {
|
||||
ControlProtocolDescriptor*
|
||||
protocol_descriptor () {
|
||||
return &powermate_descriptor;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,258 +0,0 @@
|
|||
/*
|
||||
powermate.cc
|
||||
Ben Loftis
|
||||
Created: 03/26/07 20:07:56
|
||||
*/
|
||||
|
||||
|
||||
#include <linux/input.h>
|
||||
#include <cstring>
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <glibmm.h>
|
||||
|
||||
#include "pbd/pthread_utils.h"
|
||||
#include "pbd/xml++.h"
|
||||
#include "pbd/error.h"
|
||||
|
||||
#include "ardour/debug.h"
|
||||
|
||||
#include "powermate.h"
|
||||
#include "i18n.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
using namespace std;
|
||||
using namespace sigc;
|
||||
using namespace PBD;
|
||||
|
||||
#define NUM_VALID_PREFIXES 2
|
||||
|
||||
static const char *valid_prefix[NUM_VALID_PREFIXES] = {
|
||||
"Griffin PowerMate",
|
||||
"Griffin SoundKnob"
|
||||
};
|
||||
|
||||
#define NUM_EVENT_DEVICES 16
|
||||
|
||||
int open_powermate (const char *dev, int mode)
|
||||
{
|
||||
if (!Glib::file_test (dev, Glib::FILE_TEST_EXISTS)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fd = open(dev, mode);
|
||||
int i;
|
||||
char name[255];
|
||||
|
||||
if (fd < 0) {
|
||||
if (errno != EACCES) {
|
||||
error << string_compose ("Unable to open \"%1\": %2", dev, strerror(errno)) << endmsg;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* placate valgrind */
|
||||
name[0] = '\0';
|
||||
|
||||
if (ioctl (fd, EVIOCGNAME (sizeof(name)), name) < 0) {
|
||||
error << string_compose ("\"%1\": EVIOCGNAME failed: %2", dev, strerror(errno)) << endmsg;
|
||||
close (fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// it's the correct device if the prefix matches what we expect it to be:
|
||||
for (i = 0; i < NUM_VALID_PREFIXES; ++i) {
|
||||
if (!strncasecmp (name, valid_prefix[i], strlen (valid_prefix[i]))) {
|
||||
return fd;
|
||||
}
|
||||
}
|
||||
|
||||
close (fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int find_powermate(int mode)
|
||||
{
|
||||
char devname[256];
|
||||
int i, r;
|
||||
|
||||
for (i = 0; i < NUM_EVENT_DEVICES; i++) {
|
||||
sprintf (devname, "/dev/input/event%d", i);
|
||||
r = open_powermate (devname, mode);
|
||||
if (r >= 0) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
PowermateControlProtocol::PowermateControlProtocol (Session& s)
|
||||
: ControlProtocol (s, "powermate")
|
||||
{
|
||||
}
|
||||
|
||||
PowermateControlProtocol::~PowermateControlProtocol ()
|
||||
{
|
||||
set_active (false);
|
||||
}
|
||||
|
||||
bool
|
||||
PowermateControlProtocol::probe ()
|
||||
{
|
||||
int port = find_powermate( O_RDONLY );
|
||||
|
||||
if (port < 0) {
|
||||
if (errno == ENOENT) {
|
||||
DEBUG_TRACE (DEBUG::ControlProtocols, "Powermate device not found; perhaps you have no powermate connected");
|
||||
} else {
|
||||
DEBUG_TRACE (DEBUG::ControlProtocols, string_compose ("powermate: Opening of powermate failed - %1\n", strerror(errno)));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
close (port);
|
||||
return true;
|
||||
}
|
||||
|
||||
int
|
||||
PowermateControlProtocol::set_active (bool inActivate)
|
||||
{
|
||||
if (inActivate != _active) {
|
||||
|
||||
if (inActivate) {
|
||||
|
||||
mPort = find_powermate(O_RDONLY);
|
||||
|
||||
if ( mPort < 0 ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pthread_create_and_store ("Powermate", &mThread, SerialThreadEntry, this) == 0) {
|
||||
_active = true;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("Powermate Control Protocol activated\n");
|
||||
|
||||
} else {
|
||||
pthread_cancel (mThread);
|
||||
close (mPort);
|
||||
_active = false;
|
||||
printf("Powermate Control Protocol deactivated\n");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
XMLNode&
|
||||
PowermateControlProtocol::get_state ()
|
||||
{
|
||||
XMLNode* node = new XMLNode (X_("Protocol"));
|
||||
node->add_property (X_("name"), _name);
|
||||
return *node;
|
||||
}
|
||||
|
||||
int
|
||||
PowermateControlProtocol::set_state (const XMLNode& /*node*/, int /*version*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void*
|
||||
PowermateControlProtocol::SerialThreadEntry (void* arg)
|
||||
{
|
||||
static_cast<PowermateControlProtocol*>(arg)->register_thread ("Powermate");
|
||||
return static_cast<PowermateControlProtocol*>(arg)->SerialThread ();
|
||||
}
|
||||
|
||||
#define BUFFER_SIZE 32
|
||||
|
||||
bool held = false;
|
||||
bool skippingMarkers = false;
|
||||
|
||||
void
|
||||
PowermateControlProtocol::ProcessEvent(struct input_event *ev)
|
||||
{
|
||||
#ifdef VERBOSE
|
||||
fprintf(stderr, "type=0x%04x, code=0x%04x, value=%d\n",
|
||||
ev->type, ev->code, (int)ev->value);
|
||||
#endif
|
||||
|
||||
switch(ev->type){
|
||||
case EV_MSC:
|
||||
printf("The LED pulse settings were changed; code=0x%04x, value=0x%08x\n", ev->code, ev->value);
|
||||
break;
|
||||
case EV_REL:
|
||||
if(ev->code != REL_DIAL)
|
||||
fprintf(stderr, "Warning: unexpected rotation event; ev->code = 0x%04x\n", ev->code);
|
||||
else{
|
||||
if (held) {
|
||||
//click and hold to skip forward and back by markers
|
||||
skippingMarkers = true;;
|
||||
if (ev->value > 0)
|
||||
next_marker();
|
||||
else
|
||||
prev_marker();
|
||||
} else {
|
||||
//scale the range so that we can go from +/-8x within 180 degrees, with less precision at the higher speeds
|
||||
float speed = get_transport_speed();
|
||||
speed += (float)ev->value * 0.05;
|
||||
if (speed > 1.5 || speed < -1.5 )
|
||||
speed += ev->value;
|
||||
set_transport_speed( speed );
|
||||
}
|
||||
}
|
||||
break;
|
||||
case EV_KEY:
|
||||
if(ev->code != BTN_0)
|
||||
fprintf(stderr, "Warning: unexpected key event; ev->code = 0x%04x\n", ev->code);
|
||||
else
|
||||
if (ev->value)
|
||||
held = true;
|
||||
else {
|
||||
held = false;
|
||||
if (skippingMarkers) {
|
||||
skippingMarkers = false;
|
||||
} else {
|
||||
if (get_transport_speed() == 0.0) {
|
||||
set_transport_speed(1.0);
|
||||
} else {
|
||||
set_transport_speed(0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void*
|
||||
PowermateControlProtocol::SerialThread ()
|
||||
{
|
||||
struct input_event ibuffer[BUFFER_SIZE];
|
||||
int r, events, i;
|
||||
|
||||
while(1){
|
||||
r = read(mPort, ibuffer, sizeof(struct input_event) * BUFFER_SIZE);
|
||||
if( r > 0 ){
|
||||
events = r / sizeof(struct input_event);
|
||||
for(i=0; i<events; i++)
|
||||
ProcessEvent(&ibuffer[i]);
|
||||
}else{
|
||||
fprintf(stderr, "read() failed: %s\n", strerror(errno));
|
||||
return (void*) 0;
|
||||
}
|
||||
}
|
||||
|
||||
return (void*) 0;
|
||||
}
|
||||
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#ifndef ardour_powermate_h
|
||||
#define ardour_powermate_h
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "control_protocol/control_protocol.h"
|
||||
|
||||
class PowermateControlProtocol : public ARDOUR::ControlProtocol
|
||||
{
|
||||
public:
|
||||
PowermateControlProtocol (ARDOUR::Session&);
|
||||
virtual ~PowermateControlProtocol();
|
||||
|
||||
int set_active (bool yn);
|
||||
static bool probe ();
|
||||
|
||||
XMLNode& get_state ();
|
||||
int set_state (const XMLNode&, int version);
|
||||
|
||||
private:
|
||||
|
||||
static void* SerialThreadEntry (void* arg);
|
||||
void* SerialThread ();
|
||||
|
||||
void ProcessEvent(struct input_event *ev);
|
||||
|
||||
int mPort;
|
||||
pthread_t mThread;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
from waflib.extras import autowaf as autowaf
|
||||
import os
|
||||
|
||||
# Library version (UNIX style major, minor, micro)
|
||||
# major increment <=> incompatible changes
|
||||
# minor increment <=> compatible changes (additions)
|
||||
# micro increment <=> no interface changes
|
||||
LIBARDOUR_POWERMATE_LIB_VERSION = '4.1.0'
|
||||
|
||||
# Mandatory variables
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
def options(opt):
|
||||
autowaf.set_options(opt)
|
||||
|
||||
def configure(conf):
|
||||
autowaf.configure(conf)
|
||||
|
||||
def build(bld):
|
||||
obj = bld(features = 'cxx cxxshlib')
|
||||
obj.source = '''
|
||||
interface.cc
|
||||
powermate.cc
|
||||
'''
|
||||
obj.export_includes = ['.']
|
||||
obj.cxxflags = '-DPACKAGE="ardour_powermate"'
|
||||
obj.includes = ['.' ]
|
||||
obj.name = 'libpowermate'
|
||||
obj.target = 'powermate'
|
||||
obj.use = 'libardour libardour_cp'
|
||||
obj.vnum = LIBARDOUR_POWERMATE_LIB_VERSION
|
||||
obj.install_path = os.path.join(bld.env['LIBDIR'], 'ardour3', 'surfaces')
|
||||
|
||||
def shutdown():
|
||||
autowaf.shutdown()
|
|
@ -25,7 +25,6 @@ children = [
|
|||
'generic_midi',
|
||||
'mackie',
|
||||
'osc',
|
||||
'powermate',
|
||||
'tranzport',
|
||||
'wiimote'
|
||||
]
|
||||
|
@ -48,7 +47,6 @@ def configure(conf):
|
|||
#if Options.options.tranzport and conf.is_defined('HAVE_USB'):
|
||||
# conf.define('BUILD_TRANZPORT', 1)
|
||||
|
||||
conf.check_cc (header_name='linux/input.h', define_name='BUILD_POWERMATE',mandatory=False)
|
||||
autowaf.check_pkg (conf, 'liblo', mandatory=False, uselib_store="LO", atleast_version="0.24")
|
||||
|
||||
conf.check_cc (header_name='cwiid.h', define_name='HAVE_CWIID_H',mandatory=False)
|
||||
|
@ -68,8 +66,6 @@ def build(bld):
|
|||
bld.recurse('mackie')
|
||||
if bld.is_defined ('HAVE_LO'):
|
||||
bld.recurse('osc')
|
||||
if bld.is_defined('BUILD_POWERMATE'):
|
||||
bld.recurse('powermate')
|
||||
if bld.is_defined('BUILD_WIIMOTE'):
|
||||
bld.recurse('wiimote')
|
||||
if bld.is_defined('BUILD_TRANZPORT'):
|
||||
|
|
Loading…
Reference in New Issue