#include <jogshuttle.h>
Collaboration diagram for JogShuttle:

Public Member Functions | |
| ~JogShuttle () | |
| Destructor. | |
| bool | start () |
| Start the GDK input handler if enabled. | |
| void | stop () |
| Stop the GDK input handler. | |
| void | registerCallback (void *user, JogShuttleCallback callback) |
| Register callback. | |
| void | deregisterCallback () |
| Deegister callback. | |
| media_ctrl_key * | getKeyset () |
Static Public Member Functions | |
| static JogShuttle & | getInstance () |
| Singleton getInstance method. | |
Protected Member Functions | |
| void | inputCallback (gint source, GdkInputCondition condition) |
| The GDK input callback function. | |
| JogShuttle () | |
| Constructor. | |
Private Member Functions | |
| void | jog (int dir) |
| Handle movement on the jog dial. | |
| void | shuttle (int angle) |
| Handle movement of the shuttle ring. | |
| void | button (struct media_ctrl_event *) |
| Handle key press. | |
| void | button_old (int code) |
Private Attributes | |
| JogShuttleCallback | _callback |
| Placeholder for callbacks. | |
| void * | _callbackdata |
| Any client supplied callbackdata is here. | |
| media_ctrl | _ctrl |
| int | input_ |
| gint | monitorTag_ |
| unsigned short | _modifier_code |
| media_ctrl_key * | _modifier |
Static Private Attributes | |
| static JogShuttle * | _instance = NULL |
| Singleton pattern. | |
Friends | |
| void | JogShuttle_inputCallback (gpointer data, gint source, GdkInputCondition condition) |
| A C wrappper for the GDK input handler callback. | |
This class is used by the kino core to interact with a JogShuttle device. (Also used by the preference dialog for configuration). It depends on the GDK input system, and uses the libmediactrl stuff to translate different (more or less broken) devices events into something that resembles the linux event system. It also keeps track of modifier keys, that is, up to two keys pressed in succesion.
Definition at line 49 of file jogshuttle.h.
|
|
Constructor.
Definition at line 126 of file jogshuttle.cc. References _ctrl, media_ctrl::device, and start(). Referenced by getInstance(). 00126 : 00127 _callback( NULL ), 00128 input_( -1 ), 00129 monitorTag_( -1 ), 00130 _modifier_code( 0 ) 00131 { 00132 _ctrl.device = NULL; 00133 start(); 00134 }
|
|
|
Destructor. Remove the callback function from the GDK input handler. Definition at line 140 of file jogshuttle.cc. References _ctrl, input_, media_ctrl_close(), and monitorTag_. 00141 {
00142 if ( input_ >= 0 )
00143 {
00144 gdk_input_remove( monitorTag_ );
00145 media_ctrl_close(&_ctrl);
00146 }
00147 }
|
|
|
Handle key press.
Definition at line 267 of file jogshuttle.cc. References _callback, _callbackdata, _modifier_code, media_ctrl_key::action, media_ctrl_event::code, Preferences::getInstance(), media_ctrl_event::index, KEY_RELEASE, processCommand(), and media_ctrl_event::value. Referenced by inputCallback(). 00268 {
00269 /* Figure out what codes to use */
00270 unsigned short first;
00271 unsigned short second;
00272
00273 /*
00274 Release may need to clear a modifier key
00275 */
00276 if ( ev->value == KEY_RELEASE && _modifier_code != 0 )
00277 {
00278 _modifier_code = 0;
00279 return;
00280 }
00281
00282 /* Do a callback or action based command */
00283 if ( _callback != NULL )
00284 {
00285 /* This is a key press - if there are no modifier, make sure that
00286 this is saved */
00287 if ( _modifier_code == 0 )
00288 _modifier_code = ev->index + 1;
00289
00290 if ( _modifier_code != ev->index + 1 )
00291 {
00292 first = _modifier_code - 1;
00293 second = ev->index + 1;
00294 }
00295 else
00296 {
00297 first = ev->index; /* Same as modifier */
00298 second = 0;
00299 }
00300 _callback( _callbackdata, first, second );
00301 }
00302 else
00303 {
00304 /* This is a key press - if there are no modifier, make sure that
00305 this is saved */
00306 if ( _modifier_code == 0 )
00307 _modifier_code = ev->code;
00308
00309 if ( _modifier_code != ev->code )
00310 {
00311 first = _modifier_code;
00312 second = ev->code;
00313 }
00314 else
00315 {
00316 first = ev->code; /* Same as modifier */
00317 second = 0;
00318 }
00319
00320 /* Get the action from the prefs */
00321 string action
00322 = Preferences::getInstance()._JogShuttleMappings[
00323 make_pair( first, second ) ]._action;
00324
00325 if ( "" != action )
00326 {
00327 gdk_threads_enter();
00328 processCommand( ( char * ) action.c_str() );
00329 gdk_threads_leave();
00330 }
00331 }
00332 return ;
00333
00334 }
|
|
|
|
|
|
Deegister callback. Deregister an interest in getting notification when buttons are pressed
Definition at line 206 of file jogshuttle.cc. References _callback. 00207 {
00208 if ( _callback == NULL )
00209 g_warning( "JogShuttle::deregisterCallback - not registered\n" );
00210 _callback = NULL;
00211 }
|
|
|
Singleton getInstance method. Standard pattern. Non-threadsafe, but first instance gets called from the commands.cc which should be OK. Definition at line 117 of file jogshuttle.cc. References _instance, and JogShuttle(). Referenced by kinoInitialise(), on_checkbutton_jogshuttle_toggled(), on_optionmenu_jogshuttle_action_clicked(), on_optionmenu_jogshuttle_firstsecond_button_clicked(), on_preferences_activate(), on_preferences_dialog_cancel_button_clicked(), on_preferences_dialog_destroy_event(), on_preferences_dialog_ok_button_clicked(), and startJogShuttle(). 00118 {
00119 if ( _instance == NULL )
00120 _instance = new JogShuttle();
00121 return *_instance;
00122 }
|
|
|
Definition at line 213 of file jogshuttle.cc. References _ctrl, media_ctrl::device, and media_ctrl_device::keys. 00214 {
00215 if ( _ctrl.device != NULL ) return _ctrl.device->keys;
00216 else return NULL;
00217 }
|
|
||||||||||||
|
The GDK input callback function. GDK calls this whenever input is received. It is hooked into the system during object construction. Definition at line 344 of file jogshuttle.cc. References _ctrl, button(), media_ctrl_event::code, jog(), MEDIA_CTRL_EVENT_JOG, MEDIA_CTRL_EVENT_KEY, MEDIA_CTRL_EVENT_NONE, MEDIA_CTRL_EVENT_SHUTTLE, media_ctrl_read_event(), shuttle(), stop(), media_ctrl_event::type, and media_ctrl_event::value. Referenced by JogShuttle_inputCallback(). 00345 {
00346 g_return_if_fail( this != NULL );
00347 // g_return_if_fail( input_ >= 0 );
00348 // g_return_if_fail( input_ == source );
00349 if ( condition != GDK_INPUT_READ )
00350 stop();
00351 g_return_if_fail( condition == GDK_INPUT_READ );
00352
00353 struct media_ctrl_event ev;
00354
00355 ev.type = MEDIA_CTRL_EVENT_NONE;
00356 media_ctrl_read_event(&_ctrl, &ev);
00357
00358
00359 /* We can get four "kinds" of events:
00360
00361 ev.type == MEDIA_CTRL_EVENT_NONE (0x00)
00362 An event that actually isnt one... Since we read every event
00363 from the input subsystem, we sometimes get double events
00364 (e.g. the shuttlepro reports its state approx. every second.)
00365 libmediactrl translates these events to none-events.
00366
00367
00368 ev.type == MEDIA_CTRL_EVENT_KEY (0x01)
00369 This is a button press. The whole event will be handled in the
00370 button method..
00371
00372 ev.type == MEDIA_CTRL_EVENT_JOG (0x02)
00373 This event is issued when ever the dial position changes.
00374 ev.value is the offset to the current jog position.
00375
00376
00377 - ev.code == EDIA_CTRL_EVENT_SHUTTLE (0x02)
00378 the outer wheel ev.value indicates the position, with positive
00379 values from 0x01 to 0x0f (inclusive) indicating clockwise twist,
00380 and negative values from -1 to -15 indicating counterclockwise
00381 twist. A 0 value is reported.
00382
00383
00384 */
00385
00386 if ( ev.type == MEDIA_CTRL_EVENT_NONE ) return;
00387 #if 0
00388 printf( "JogShuttle: %02x %02x %02d\n", ev.type, ev.code, ev.value );
00389 #endif
00390
00391
00392 if ( ev.type == MEDIA_CTRL_EVENT_JOG )
00393 {
00394 this->jog( CLAMP( ev.value, -1, 1 ) );
00395 }
00396 else if ( ev.type == MEDIA_CTRL_EVENT_SHUTTLE )
00397 {
00398 this->shuttle( ev.value );
00399 }
00400 else if ( ev.type == MEDIA_CTRL_EVENT_KEY )
00401 {
00402 this->button( &ev );
00403 }
00404 else
00405 {
00406 return;
00407 }
00408 }
|
|
|
Handle movement on the jog dial.
Definition at line 229 of file jogshuttle.cc. References videoBackBy(), and videoForwardBy(). Referenced by inputCallback(). 00230 {
00231 gdk_threads_enter();
00232 if ( offs < 0 )
00233 videoBackBy(offs);
00234 else
00235 videoForwardBy(offs);
00236 gdk_threads_leave();
00237 }
|
|
||||||||||||
|
Register callback. Register an interest in getting notification when buttons are pressed
Definition at line 192 of file jogshuttle.cc. References _callback, and _callbackdata. 00193 {
00194 if ( _callback )
00195 g_warning( "JogShuttle::registerCallback - already registered\n" );
00196 _callback = callback;
00197 _callbackdata = user;
00198 }
|
|
|
Handle movement of the shuttle ring.
Definition at line 243 of file jogshuttle.cc. References videoShuttle(). Referenced by inputCallback(). 00244 {
00245 /*if ( angle > 0 )
00246 angle--;
00247 if ( angle < 0 )
00248 angle++;
00249 */
00250 gdk_threads_enter();
00251 videoShuttle( angle );
00252 gdk_threads_leave();
00253 }
|
|
|
Start the GDK input handler if enabled.
Definition at line 154 of file jogshuttle.cc. References _ctrl, media_ctrl::device, Preferences::enableJogShuttle, media_ctrl::fd, Preferences::getInstance(), JogShuttle_inputCallback, media_ctrl_open(), monitorTag_, and stop(). Referenced by JogShuttle(). 00155 {
00156 Preferences & prefs = Preferences::getInstance();
00157
00158 if ( prefs.enableJogShuttle )
00159 {
00160 stop();
00161 media_ctrl_open( &_ctrl );
00162 if ( _ctrl.device )
00163 {
00164 monitorTag_ = gdk_input_add( _ctrl.fd, GDK_INPUT_READ,
00165 JogShuttle_inputCallback,
00166 ( gpointer ) this );
00167 return true;
00168 }
00169 }
00170 return false;
00171 }
|
|
|
Stop the GDK input handler.
Definition at line 175 of file jogshuttle.cc. References _ctrl, media_ctrl::device, media_ctrl_close(), and monitorTag_. Referenced by inputCallback(), and start(). 00176 {
00177 if ( monitorTag_ != -1 )
00178 {
00179 gdk_input_remove( monitorTag_ );
00180 monitorTag_ = -1;
00181 }
00182 if ( _ctrl.device )
00183 media_ctrl_close( &_ctrl );
00184 }
|
|
||||||||||||||||
|
A C wrappper for the GDK input handler callback.
Definition at line 99 of file jogshuttle.cc. Referenced by start(). 00100 {
00101 JogShuttle * js = static_cast<JogShuttle *>( data );
00102 g_return_if_fail( js != NULL );
00103 js->inputCallback( source, condition );
00104 }
|
|
|
Placeholder for callbacks.
Definition at line 55 of file jogshuttle.h. Referenced by button(), deregisterCallback(), and registerCallback(). |
|
|
Any client supplied callbackdata is here.
Definition at line 57 of file jogshuttle.h. Referenced by button(), and registerCallback(). |
|
|
Definition at line 80 of file jogshuttle.h. Referenced by getKeyset(), inputCallback(), JogShuttle(), start(), stop(), and ~JogShuttle(). |
|
|
Singleton pattern. It is accesible to other classes via the getInstance method. Definition at line 111 of file jogshuttle.cc. Referenced by getInstance(). |
|
|
Definition at line 87 of file jogshuttle.h. |
|
|
Definition at line 86 of file jogshuttle.h. Referenced by button(). |
|
|
Definition at line 81 of file jogshuttle.h. Referenced by ~JogShuttle(). |
|
|
Definition at line 82 of file jogshuttle.h. Referenced by start(), stop(), and ~JogShuttle(). |
1.4.2