enough with umpteen "i18n.h" files. Consolidate on pbd/i18n.h
[ardour.git] / libs / surfaces / faderport / faderport_interface.cc
1 /*
2     Copyright (C) 2012 Paul Davis
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <pbd/failed_constructor.h>
21
22 #include "control_protocol/control_protocol.h"
23 #include "faderport.h"
24
25 using namespace ARDOUR;
26 using namespace ArdourSurface;
27
28 static ControlProtocol*
29 new_faderport_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
30 {
31         FaderPort* fp;
32
33         try {
34                 fp =  new FaderPort (*s);
35         } catch (failed_constructor& err) {
36                 return 0;
37         }
38
39         if (fp->set_active (true)) {
40                 delete fp;
41                 return 0;
42         }
43
44         return fp;
45 }
46
47 static void
48 delete_faderport_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
49 {
50         delete cp;
51 }
52
53 static bool
54 probe_faderport_midi_protocol (ControlProtocolDescriptor* /*descriptor*/)
55 {
56         return FaderPort::probe ();
57 }
58
59 static void*
60 faderport_request_buffer_factory (uint32_t num_requests)
61 {
62         return FaderPort::request_factory (num_requests);
63 }
64
65 static ControlProtocolDescriptor faderport_midi_descriptor = {
66         /*name :              */   "PreSonus FaderPort",
67         /*id :                */   "uri://ardour.org/surfaces/faderport:0",
68         /*ptr :               */   0,
69         /*module :            */   0,
70         /*mandatory :         */   0,
71         /*supports_feedback : */   true,
72         /*probe :             */   probe_faderport_midi_protocol,
73         /*initialize :        */   new_faderport_midi_protocol,
74         /*destroy :           */   delete_faderport_midi_protocol,
75         /*request_buffer_factory */ faderport_request_buffer_factory
76 };
77
78 extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &faderport_midi_descriptor; }
79