00001 /* 00002 * mediactrl.c -- Jog Shuttle device support 00003 * Copyright (C) 2001-2007 Dan Dennedy <dan@dennedy.org> 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software Foundation, 00017 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 #ifndef _MEDIA_CTRL_H 00020 #define _MEDIA_CTRL_H 00021 00022 00023 // just to make the code more readable 00024 #define KEY_RELEASE 0x00 00025 #define KEY_PRESS 0x01 00026 00027 // not used yet 00028 #define MEDIA_ST_ACTIVE 0x02 00029 #define MEDIA_ST_INACTIVE 0x01 00030 00031 // media ctrl event types 00032 #define MEDIA_CTRL_EVENT_NONE 0x00 00033 #define MEDIA_CTRL_EVENT_KEY 0x01 00034 #define MEDIA_CTRL_EVENT_JOG 0x02 00035 #define MEDIA_CTRL_EVENT_SHUTTLE 0x03 00036 #define MEDIA_CTRL_EVENT_STICK 0x04 00037 00038 // the disconnect event - not used yet 00039 #define MEDIA_CTRL_DISCONNECT 0x01 00040 00041 #define MEDIA_CTRL_SHIFT 0x01 00042 00043 #define MEDIA_CTRL_PLAY 0x10 00044 #define MEDIA_CTRL_PLAY_FWD 0x10 00045 #define MEDIA_CTRL_REVERSE 0x11 00046 #define MEDIA_CTRL_PLAY_REV 0x11 00047 #define MEDIA_CTRL_STOP 0x12 00048 #define MEDIA_CTRL_PAUSE 0x13 00049 #define MEDIA_CTRL_NEXT 0x14 00050 #define MEDIA_CTRL_PREV 0x15 00051 #define MEDIA_CTRL_RECORD 0x16 00052 #define MEDIA_CTRL_FAST_FORWARD 0x17 00053 #define MEDIA_CTRL_REWIND 0x18 00054 00055 #define MEDIA_CTRL_STICK_LEFT 0x20 00056 #define MEDIA_CTRL_STICK_RIGHT 0x21 00057 #define MEDIA_CTRL_STICK_UP 0x22 00058 #define MEDIA_CTRL_STICK_DOWN 0x23 00059 00060 /* function keys, usually at top of device */ 00061 #define MEDIA_CTRL_F1 0x100 00062 #define MEDIA_CTRL_F2 0x101 00063 #define MEDIA_CTRL_F3 0x102 00064 #define MEDIA_CTRL_F4 0x103 00065 #define MEDIA_CTRL_F5 0x104 00066 #define MEDIA_CTRL_F6 0x105 00067 #define MEDIA_CTRL_F7 0x106 00068 #define MEDIA_CTRL_F8 0x107 00069 #define MEDIA_CTRL_F9 0x108 00070 #define MEDIA_CTRL_F10 0x109 00071 #define MEDIA_CTRL_F11 0x10a 00072 #define MEDIA_CTRL_F12 0x10b 00073 #define MEDIA_CTRL_F13 0x10c 00074 #define MEDIA_CTRL_F14 0x10d 00075 #define MEDIA_CTRL_F15 0x10e 00076 #define MEDIA_CTRL_F16 0x10f 00077 00078 #define MEDIA_CTRL_B1 0x110 00079 #define MEDIA_CTRL_B2 0x111 00080 #define MEDIA_CTRL_B3 0x112 00081 #define MEDIA_CTRL_B4 0x113 00082 #define MEDIA_CTRL_B5 0x114 00083 #define MEDIA_CTRL_B6 0x115 00084 #define MEDIA_CTRL_B7 0x116 00085 #define MEDIA_CTRL_B8 0x117 00086 #define MEDIA_CTRL_B9 0x118 00087 #define MEDIA_CTRL_B10 0x119 00088 #define MEDIA_CTRL_B11 0x11a 00089 #define MEDIA_CTRL_B12 0x11b 00090 #define MEDIA_CTRL_B13 0x11c 00091 #define MEDIA_CTRL_B14 0x11d 00092 #define MEDIA_CTRL_B15 0x11e 00093 #define MEDIA_CTRL_B16 0x11f 00094 00095 #ifdef __cplusplus 00096 extern "C" { 00097 #endif 00098 00099 struct media_ctrl_device; 00100 00101 struct media_ctrl_key { 00102 int key; // internal keycode - do not use 00103 const char *name; 00104 int code; // eventcode 00105 int action; 00106 }; 00107 00108 struct media_ctrl_event { 00109 struct timeval time; 00110 unsigned short type; 00111 unsigned short code; 00112 char *name; 00113 int value; 00114 unsigned short index; 00115 }; 00116 00117 struct media_ctrl { 00118 00119 int fd; 00120 int eventno; 00121 00122 int status; 00123 00124 struct media_ctrl_device *device; 00125 00126 long jogpos; 00127 int shuttlepos; 00128 00129 int lastval; 00130 int lastshu; 00131 00132 int jogrel; // accumulate relative values if events come too fast 00133 unsigned long last_jog_time; // last jog event 00134 00135 }; 00136 00137 struct media_ctrl_device { 00138 int vendor; 00139 int product; 00140 const char *name; 00141 struct media_ctrl_key *keys; 00142 void (*translate)(struct media_ctrl *ctrl, struct input_event *ev, struct media_ctrl_event *me); 00143 }; 00144 00145 void media_ctrl_open(struct media_ctrl *); 00146 void media_ctrl_close(struct media_ctrl *); 00147 void media_ctrl_read_event(struct media_ctrl *, struct media_ctrl_event *); 00148 00149 struct media_ctrl_key *media_ctrl_get_keys(struct media_ctrl *); 00150 00151 #ifdef __cplusplus 00152 } 00153 #endif 00154 00155 #endif
1.4.2