]> git.sesse.net Git - kdenlive/blobdiff - src/lib/external/media_ctrl/mediactrl.c
mediactrl: update address of GPL foundation
[kdenlive] / src / lib / external / media_ctrl / mediactrl.c
index 3558d825008503efe976ebcfc4a023bf267e6a8b..3b32b50ee0fc0562754ed5efec5ae616d0744cf1 100644 (file)
 * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+* along with this program; if not, write to the
+* Free Software Foundation, Inc.,
+* 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/ioctl.h>
@@ -33,8 +35,8 @@
 #include "mediactrl.h"
 
 
-static char *_shuttle_name = "Shuttle";
-static char *_jog_name = "Jog";
+static char *_shuttle_name = (char*)"Shuttle";
+static char *_jog_name = (char*)"Jog";
 
 /*
        ShuttlePro keys
@@ -60,15 +62,6 @@ static struct  media_ctrl_key mc_shuttle_pro_keys[] = {
 /*
        ShuttleXPress keys
 */
-static struct  media_ctrl_key _mc_shuttle_xpress_keys[] = {
-    { 0x104, "Button B4", MEDIA_CTRL_B4 },
-    { 0x105, "Button B2", MEDIA_CTRL_B2 },
-    { 0x106, "Button B1", MEDIA_CTRL_B1 },
-    { 0x107, "Button B3", MEDIA_CTRL_B3 },
-    { 0x108, "Button B5", MEDIA_CTRL_B5 },
-    { 0, NULL, 0 }
-};
-
 static struct  media_ctrl_key mc_shuttle_xpress_keys[] = {
     { 0x104, "Button B1", MEDIA_CTRL_B1},
     { 0x105, "Button B2", MEDIA_CTRL_B2 },
@@ -171,6 +164,17 @@ struct  media_ctrl_key *media_ctrl_get_key(struct media_ctrl *ctrl, int code, in
        return NULL;
 }
 
+int media_ctrl_get_keys_count(struct media_ctrl *ctrl)
+{
+    int i = 0;
+    struct media_ctrl_key *keys = ctrl->device->keys;
+
+    while ( keys[i].key != 0 ) {
+        i++;
+    }
+
+    return i;
+}
 
 void translate_contour_hid_event(struct media_ctrl *ctrl, struct input_event *ev, struct media_ctrl_event *me) 
 {
@@ -190,8 +194,9 @@ void translate_contour_hid_event(struct media_ctrl *ctrl, struct input_event *ev
                        if ( cv == ctrl->lastshu ) return;
             ctrl->lastshu = cv;
 
+            /* TODO: review this change */
             if ( cv > 0 ) cv -= 1;
-            if ( cv < 0) cv += 1;
+            if ( cv < 0 ) cv += 1;
 
                        //printf("Shuttle: %d\n", cv);
                        me->type  = MEDIA_CTRL_EVENT_SHUTTLE;
@@ -281,15 +286,15 @@ void translate_compliant(struct media_ctrl *ctrl, struct input_event *ev, struct
 }
 
 struct media_ctrl_device supported_devices[] = {
-       { 0x0b33, 0x0030, "Contour ShuttlePRO v2", mc_shuttle_pro_keys, translate_contour_hid_event },
+       { 0x0b33, 0x0030, "Contour Design ShuttlePRO v2", mc_shuttle_pro_keys, translate_contour_hid_event },
        { 0x0b33, 0x0020, "Contour Design ShuttleXpress", mc_shuttle_xpress_keys, translate_contour_hid_event },
-       { 0x0b33, 0x0010, "Contour ShuttlePro", mc_shuttle_pro_keys, translate_contour_hid_event },
-       { 0x0b33, 0x0011, "Contour ShuttlePro", mc_shuttle_pro_keys, translate_contour_hid_event }, /* Hercules OEM */
-       { 0x05f3, 0x0240, "Contour ShuttlePro", mc_shuttle_pro_keys, translate_contour_hid_event },
+       { 0x0b33, 0x0010, "Contour Design ShuttlePro", mc_shuttle_pro_keys, translate_contour_hid_event },
+       { 0x0b33, 0x0011, "Contour Design ShuttlePro", mc_shuttle_pro_keys, translate_contour_hid_event }, /* Hercules OEM */
+       { 0x05f3, 0x0240, "Contour Design ShuttlePro", mc_shuttle_pro_keys, translate_contour_hid_event },
        { 0x0760, 0x0001, "JLCooper MCS3", mc_jlcooper_mcs3_keys, translate_compliant },
        { 0x077d, 0x0410, "Griffin PowerMate", mc_powermate_keys, translate_compliant },
        { 0x05f3, 0x0241, "X-Keys Editor", mc_x_keys, translate_contour_hid_event },
-       { 0, 0, 0 }
+       { 0, 0, 0, 0, 0 }
 };
 
 
@@ -315,7 +320,7 @@ void media_ctrl_read_event(struct media_ctrl *ctrl, struct media_ctrl_event *me)
        if (n != sizeof(ev)) {
                //printf("JogShuttle::inputCallback: read: (%d) %s\n", errno, strerror(errno));
                close(ctrl->fd);
-               ctrl->fd = 0;
+               ctrl->fd = -1;
                return;
        }