#include <stdlib.h>#include <stdio.h>#include <sys/ioctl.h>#include <sys/types.h>#include <sys/stat.h>#include <sys/time.h>#include <asm/types.h>#include <fcntl.h>#include <unistd.h>#include <stdint.h>#include <string.h>#include <errno.h>#include <linux/input.h>#include "mediactrl.h"Include dependency graph for mediactrl.c:

Go to the source code of this file.
|
|
Definition at line 375 of file mediactrl.c. References media_ctrl::eventno, media_ctrl::fd, and probe_device(). Referenced by media_ctrl_open(). 00376 {
00377 char buf[256];
00378 int fd, i;
00379
00380 for ( i = 0; i < 32; i++ ) {
00381 sprintf(buf, "/dev/input/event%d", i);
00382 fd = open( buf, O_RDONLY );
00383 if ( fd < 0 ) {
00384 perror(buf);
00385 } else {
00386 mc->fd = fd;
00387 mc->eventno = i;
00388 if( probe_device(mc) ) {
00389 return;
00390 } else {
00391 close(fd);
00392 mc->fd = -1;
00393 }
00394 }
00395 }
00396 return;
00397 }
|
|
|
Definition at line 400 of file mediactrl.c. References media_ctrl::fd. Referenced by JogShuttle::stop(), and JogShuttle::~JogShuttle(). 00401 {
00402 if (mc->fd > 0)
00403 close( mc->fd );
00404 memset( mc, 0, sizeof( struct media_ctrl ) );
00405 }
|
|
|
Definition at line 368 of file mediactrl.c. 00369 {
00370 // TBD
00371 }
|
|
||||||||||||||||
|
Definition at line 147 of file mediactrl.c. References media_ctrl::device, media_ctrl_key::key, and media_ctrl_device::keys. Referenced by translate_compliant(), and translate_contour_hid_event(). 00148 {
00149 int i = 0;
00150 struct media_ctrl_key *keys = ctrl->device->keys;
00151
00152 while ( keys[i].key != 0 ) {
00153 if (keys[i].key == code) {
00154 if (index != NULL)
00155 *index = i;
00156 return &keys[i];
00157 }
00158 i++;
00159 }
00160
00161 return NULL;
00162 }
|
|
|
Definition at line 408 of file mediactrl.c. References find_first_device(). Referenced by JogShuttle::start(). 00409 {
00410 find_first_device(mc);
00411 }
|
|
||||||||||||
|
Definition at line 289 of file mediactrl.c. References MEDIA_CTRL_EVENT_JOG, MEDIA_CTRL_EVENT_NONE, media_ctrl_event::type, and media_ctrl_event::value. Referenced by JogShuttle::inputCallback(). 00290 {
00291 ssize_t n;
00292 struct input_event ev;
00293
00294 // struct media_ctrl_event me;
00295
00296 if ( ctrl->fd > 0 ) {
00297 n = read(ctrl->fd, &ev, sizeof(ev));
00298 } else {
00299 return;
00300 }
00301
00302 if (n != sizeof(ev)) {
00303 //printf("JogShuttle::inputCallback: read: (%d) %s\n", errno, strerror(errno));
00304 close(ctrl->fd);
00305 ctrl->fd = 0;
00306 return;
00307 }
00308
00309 if ( ctrl->device && ctrl->device->translate)
00310 ctrl->device->translate(ctrl, &ev, me);
00311 else
00312 me->type = 0;
00313
00314 if ( me->type == MEDIA_CTRL_EVENT_JOG ) {
00315 struct timeval timev;
00316 gettimeofday(&timev, NULL);
00317 unsigned long now = (unsigned long)timev.tv_usec + (1000000*(unsigned long)timev.tv_sec);
00318 if ( now < ctrl->last_jog_time + 40000 ) {
00319 //printf("*** Fast Jog %02d %05d ***\n", me->value, now - ctrl->last_jog_time);
00320 ctrl->jogrel = me->value;
00321 me->type = MEDIA_CTRL_EVENT_NONE;
00322 } else {
00323 me->value += ctrl->jogrel;
00324 ctrl->jogrel = 0;
00325 ctrl->last_jog_time = now;
00326 // printf("*** Jog %02d ***\n", me->value);
00327 }
00328 }
00329
00330 return;
00331
00332 }
|
|
||||||||||||||||
|
Definition at line 283 of file mediactrl.c.
|
|
|
Definition at line 335 of file mediactrl.c. References media_ctrl::device, media_ctrl::fd, media_ctrl::jogpos, media_ctrl::last_jog_time, and media_ctrl::lastval. Referenced by find_first_device(). 00336 {
00337 short devinfo[4];
00338 int i = 0;
00339
00340 if ( ioctl(mc->fd, EVIOCGID, &devinfo) ) {
00341 perror("evdev ioctl");
00342 return 0;
00343 }
00344
00345 do {
00346 if ( supported_devices[i].vendor == devinfo[1]
00347 && supported_devices[i].product == devinfo[2] ) {
00348
00349 mc->device = &supported_devices[i];
00350 //printf("Success on /dev/input/event%d: %s\n", mc->eventno, mc->device->name);
00351 // mc->fd = fd;
00352 // mc->translate = mc->device.translate_function;
00353 // mc = malloc(sizeof(struct media_ctrl));
00354 mc->jogpos = 0;
00355 mc->lastval = -1;
00356 mc->last_jog_time = 0;
00357 return 1;
00358 } else {
00359 //mc->device = NULL;
00360 }
00361
00362 } while ( supported_devices[++i].vendor != 0 );
00363
00364 return 0;
00365 }
|
|
||||||||||||||||
|
Definition at line 226 of file mediactrl.c. References _jog_name, _shuttle_name, media_ctrl_key::code, media_ctrl_event::code, media_ctrl_event::index, media_ctrl_key::key, MEDIA_CTRL_EVENT_JOG, MEDIA_CTRL_EVENT_KEY, MEDIA_CTRL_EVENT_SHUTTLE, media_ctrl_get_key(), media_ctrl_key::name, media_ctrl_event::name, media_ctrl_event::type, and media_ctrl_event::value. 00227 {
00228 me->type = 0;
00229
00230 // printf("Translate %02x %02x\n", ev->type, ev->code );
00231
00232 if (ev->type == EV_REL) {
00233 if (ev->code == REL_DIAL) {
00234
00235 me->type = MEDIA_CTRL_EVENT_JOG;
00236 me->value = (signed int)ev->value;
00237 me->name = _jog_name;
00238
00239 ctrl->jogpos += me->value;
00240 //printf("Jog: %06ld (%d)\n", ctrl->jogpos, me->value);
00241 }
00242 return;
00243 } else if (ev->type == EV_ABS) {
00244 // printf("ABS\n" );
00245 if ( ev->code == 0x1c || ev->code == ABS_THROTTLE ) {
00246 //printf("ABS_MISC\n" );
00247 me->type = MEDIA_CTRL_EVENT_SHUTTLE;
00248 me->value = (signed int)ev->value;
00249 me->name = _shuttle_name;
00250
00251 ctrl->shuttlepos = me->value;
00252 //printf("Shuttle: %06d (%d)\n", ctrl->shuttlepos, me->value);
00253 }
00254 } else if (ev->type == EV_KEY) {
00255 int index;
00256 struct media_ctrl_key *key = media_ctrl_get_key(ctrl, ev->code, &index);
00257 if ( key == NULL ) return;
00258
00259 me->type = MEDIA_CTRL_EVENT_KEY;
00260 me->code = key->code;
00261 me->value = ev->value;
00262 me->name = ( char* )key->name;
00263 me->index = index;
00264
00265 //printf("Key: %04x %02x: %s\n", ev->code, ev->value, key->name);
00266
00267 }
00268 }
|
|
||||||||||||||||
|
Definition at line 165 of file mediactrl.c. References _jog_name, _shuttle_name, media_ctrl_key::code, media_ctrl_event::code, media_ctrl_event::index, media_ctrl_key::key, MEDIA_CTRL_EVENT_JOG, MEDIA_CTRL_EVENT_KEY, MEDIA_CTRL_EVENT_SHUTTLE, media_ctrl_get_key(), media_ctrl_key::name, media_ctrl_event::name, media_ctrl_event::type, and media_ctrl_event::value. 00166 {
00167
00168 int lv, cv;
00169
00170 me->type = 0;
00171
00172 if (ev->type == EV_REL) {
00173 /* First check the outer dial */
00174 if (ev->code == REL_WHEEL) {
00175
00176 cv = (signed int)ev->value;
00177 if (cv == 1 || cv == -1 ) cv = 0;
00178
00179
00180 if ( cv == ctrl->lastshu ) return;
00181 ctrl->lastshu = cv;
00182
00183 //printf("Shuttle: %d\n", cv);
00184 me->type = MEDIA_CTRL_EVENT_SHUTTLE;
00185 me->value = cv*2;
00186 me->name = _shuttle_name;
00187
00188 } else if (ev->code == REL_DIAL) {
00189
00190 if ( ctrl->lastval == -1 ) ctrl->lastval = ev->value;
00191 lv = ctrl->lastval;
00192 cv = ev->value;
00193
00194 if ( lv == cv ) return;
00195
00196 ctrl->lastval = cv;
00197
00198 if (cv < 10 && lv > 0xF0) cv +=0x100;
00199 if (lv < 10 && cv > 0xF0) lv +=0x100;
00200
00201 me->type = MEDIA_CTRL_EVENT_JOG;
00202 me->value = cv-lv;
00203 me->name = _jog_name;
00204
00205 ctrl->jogpos += me->value;
00206 //printf("Jog: %06ld (%d)\n", ctrl->jogpos, me->value);
00207 }
00208 return;
00209 } else if (ev->type == EV_KEY) {
00210 int index;
00211 struct media_ctrl_key *key = media_ctrl_get_key(ctrl, ev->code, &index);
00212 if ( key == NULL ) return;
00213
00214 me->type = MEDIA_CTRL_EVENT_KEY;
00215 me->code = key->code;
00216 me->value = ev->value;
00217 me->name = ( char* )key->name;
00218 me->index = index;
00219
00220 //printf("Key: %04x %02x: %s\n", ev->code, ev->value, key->name);
00221
00222 }
00223
00224 }
|
|
|
Definition at line 37 of file mediactrl.c. Referenced by translate_compliant(), and translate_contour_hid_event(). |
|
|
Definition at line 36 of file mediactrl.c. Referenced by translate_compliant(), and translate_contour_hid_event(). |
|
|
Initial value: {
{ 0x107, "F1", MEDIA_CTRL_F1 },
{ 0x101, "F2", MEDIA_CTRL_F2 },
{ 0x105, "F3", MEDIA_CTRL_F3 },
{ 0x102, "F4", MEDIA_CTRL_F4 },
{ 0x103, "F5", MEDIA_CTRL_F5 },
{ 0x104, "F6", MEDIA_CTRL_F6 },
{ 0x10d, "W1", MEDIA_CTRL_B6 },
{ 0x10e, "W2", MEDIA_CTRL_B4 },
{ 0x100, "W3", MEDIA_CTRL_B2 },
{ 0x106, "W4", MEDIA_CTRL_B1 },
{ 0x110, "W5", MEDIA_CTRL_B3 },
{ 0x111, "W6", MEDIA_CTRL_B5 },
{ 0x115, "W7", MEDIA_CTRL_B7 },
{ 0x116, "STICK_LEFT", MEDIA_CTRL_STICK_LEFT },
{ 0x113, "STICK_RIGHT", MEDIA_CTRL_STICK_RIGHT },
{ 0x114, "STICK_UP", MEDIA_CTRL_STICK_UP },
{ 0x112, "STICK_DOWN", MEDIA_CTRL_STICK_DOWN },
{ 0x10f, "Rewind", MEDIA_CTRL_REWIND },
{ 0x108, "Fast Forward", MEDIA_CTRL_FAST_FORWARD },
{ 0x109, "Stop", MEDIA_CTRL_STOP },
{ 0x10a, "Play", MEDIA_CTRL_PLAY },
{ 0x10b, "Record", MEDIA_CTRL_RECORD },
{ 0, NULL, 0 }
}
Definition at line 76 of file mediactrl.c. |
|
|
Initial value: {
{ BTN_0, "Button", MEDIA_CTRL_B1 },
{ 0, NULL, 0 }
}
Definition at line 106 of file mediactrl.c. |
|
|
Initial value: {
{ 0x100, "Button 1", MEDIA_CTRL_F1 },
{ 0x101, "Button 2", MEDIA_CTRL_F2 },
{ 0x102, "Button 3", MEDIA_CTRL_F3 },
{ 0x103, "Button 4", MEDIA_CTRL_F4 },
{ 0x104, "Button 5", MEDIA_CTRL_B4 },
{ 0x105, "Button 6", MEDIA_CTRL_B2 },
{ 0x106, "Button 7", MEDIA_CTRL_B1 },
{ 0x107, "Button 8", MEDIA_CTRL_B3 },
{ 0x108, "Button 9", MEDIA_CTRL_B5 },
{ 0x109, "Button 10", MEDIA_CTRL_B6 },
{ 0x10a, "Button 11", MEDIA_CTRL_B7 },
{ 0x10b, "Button 12", MEDIA_CTRL_B8 },
{ 0x10c, "Button 13", MEDIA_CTRL_B9 },
{ 0, NULL, 0 }
}
Definition at line 42 of file mediactrl.c. |
|
|
Initial value: {
{ 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 }
}
Definition at line 63 of file mediactrl.c. |
|
|
Definition at line 115 of file mediactrl.c. |
|
|
Initial value: {
{ 0x0b33, 0x0030, "Contour ShuttlePRO v2", mc_shuttle_pro_keys, translate_contour_hid_event },
{ 0x0b33, 0x0020, "Contour 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 },
{ 0x05f3, 0x0240, "Contour 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 }
}
Definition at line 270 of file mediactrl.c. |
1.4.2