diff --git a/include/midi_control_listener.h b/include/midi_control_listener.h index c54a87e63..059824929 100644 --- a/include/midi_control_listener.h +++ b/include/midi_control_listener.h @@ -30,9 +30,9 @@ #include "midi_event_processor.h" #include "midi_port.h" #include "note.h" -#include -#include -#include +#include +#include +#include class QDomDocument; diff --git a/include/setup_dialog_mcl.h b/include/setup_dialog_mcl.h index ff6629afe..81505ed0c 100644 --- a/include/setup_dialog_mcl.h +++ b/include/setup_dialog_mcl.h @@ -50,10 +50,10 @@ private: bool m_keysActive; // true: configure key, false: configure controller - groupBox * m_actionKey_gb; - groupBox * m_actionController_gb; - QComboBox * m_actionsKey_box; - QComboBox * m_actionsController_box; + groupBox * m_actionKeyGroupBox; + groupBox * m_actionControllerGroupBox; + QComboBox * m_actionsKeyBox; + QComboBox * m_actionsControllerBox; lcdSpinBoxModel * m_controllerSbModel; } ; diff --git a/src/core/engine.cpp b/src/core/engine.cpp index e6c354cb1..eb5405419 100644 --- a/src/core/engine.cpp +++ b/src/core/engine.cpp @@ -25,7 +25,7 @@ */ #include -#include +#include #include "engine.h" #include "automation_editor.h" diff --git a/src/core/midi/midi_control_listener.cpp b/src/core/midi/midi_control_listener.cpp index 3a47a70db..9573b565b 100644 --- a/src/core/midi/midi_control_listener.cpp +++ b/src/core/midi/midi_control_listener.cpp @@ -24,11 +24,10 @@ */ -#include -#include -#include -#include -#include +#include +#include +#include +#include #include "midi_control_listener.h" #include "mixer.h" @@ -39,7 +38,7 @@ #include "song.h" #include "config_mgr.h" -const QString MidiControlListener::configClass = "midicontrollistener"; +const QString MidiControlListener::configClass = "MidiControlListener"; QDomElement MidiControlListener::s_configTree; const MidiControlListener::ActionNameMap MidiControlListener::actionNames[] = @@ -54,7 +53,7 @@ const MidiControlListener::ActionNameMap MidiControlListener::actionNames[] = MidiControlListener::MidiControlListener() : - m_port( "unnamed_midi_controller", + m_port( "UnnamedMidiController", engine::getMixer()->getMidiClient(), this, NULL, midiPort::Input ), m_controlKeyCount( 0 ), @@ -87,62 +86,64 @@ void MidiControlListener::processInEvent( const midiEvent & _me, // pre-check whether this MIDI packet suits our configuration switch( _me.m_type ) { - case MidiNoteOn: - case MidiNoteOff: - case MidiControlChange: - // ignore commands for other channels - if( m_channel != -1 && m_channel != _me.channel() ) + case MidiNoteOn: + case MidiNoteOff: + case MidiControlChange: + // ignore commands for other channels + if( m_channel != -1 && m_channel != _me.channel() ) + { + return; + } + break; + + default: + // ignore commands other than note on/off and control change return; - break; - - default: - // ignore commands other than note on/off and control change - return; } // check MIDI packet type and act upon - switch( _me.m_type ) + switch( _me.m_type ) { - case MidiNoteOn: - if( m_actionMapKeys.contains( _me.key() ) ) - { - if( m_actionMapKeys.value( _me.key(), ActionNone ) == ActionControl ) + case MidiNoteOn: + if( m_actionMapKeys.contains( _me.key() ) ) { - if( _me.velocity() > 0 ) + if( m_actionMapKeys.value( _me.key(), ActionNone ) == ActionControl ) { - m_controlKeyCount++; - } - else - { - m_controlKeyCount--; - if( m_controlKeyCount < 0 ) + if( _me.velocity() > 0 ) { - m_controlKeyCount = 0; + m_controlKeyCount++; + } + else + { + m_controlKeyCount--; + if( m_controlKeyCount < 0 ) + { + m_controlKeyCount = 0; + } } } + else if( _me.velocity() > 0 && + ( !m_useControlKey || m_controlKeyCount > 0) ) + { + act( m_actionMapKeys.value( _me.key(), ActionNone ) ); + } } - else if( _me.velocity() > 0 && - ( !m_useControlKey || m_controlKeyCount > 0) ) + break; + + case MidiNoteOff: + break; + + case MidiControlChange: + // controller changed to a value other than zero + if( _me.m_data.m_param[1] > 0 ) { - act( m_actionMapKeys.value( _me.key(), ActionNone ) ); + act( m_actionMapControllers.value( _me.m_data.m_param[0], ActionNone ) ); } - } - break; - - case MidiNoteOff: - break; - - case MidiControlChange: - // controller changed to a value other than zero - if( _me.m_data.m_param[1] > 0 ) - { - act( m_actionMapControllers.value( _me.m_data.m_param[0], ActionNone ) ); - } - break; - - default: - // nop - break; + break; + + default: + // nop + break; } } @@ -153,15 +154,16 @@ void MidiControlListener::act( EventAction _action ) { switch( _action ) { - case ActionNone: - case ActionControl: - break; - case ActionPlay: - engine::getSong()->play(); - break; - case ActionStop: - engine::getSong()->stop(); - break; + case ActionNone: + break; + case ActionControl: + break; + case ActionPlay: + engine::getSong()->play(); + break; + case ActionStop: + engine::getSong()->stop(); + break; } } @@ -222,8 +224,8 @@ void MidiControlListener::saveConfiguration( QDomDocument & doc ) confRoot.appendChild( actionNode ); } - QDomElement lmms_config = doc.documentElement(); - lmms_config.appendChild( confRoot ); + QDomElement lmmsConfig = doc.documentElement(); + lmmsConfig.appendChild( confRoot ); } diff --git a/src/gui/setup_dialog_mcl.cpp b/src/gui/setup_dialog_mcl.cpp index b15bf6b64..9bca9a73d 100644 --- a/src/gui/setup_dialog_mcl.cpp +++ b/src/gui/setup_dialog_mcl.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include "embed.h" #include "group_box.h" @@ -46,25 +46,25 @@ setupDialogMCL::setupDialogMCL( setupDialog * _parent ) : resize( 270, 330 ); QWidget * buttons = new QWidget( this ); - QHBoxLayout * btn_layout = new QHBoxLayout( buttons ); - btn_layout->setSpacing( 0 ); - btn_layout->setMargin( 0 ); - QPushButton * ok_btn = new QPushButton( embed::getIconPixmap( "apply" ), + QHBoxLayout * buttonLayout = new QHBoxLayout( buttons ); + buttonLayout->setSpacing( 0 ); + buttonLayout->setMargin( 0 ); + QPushButton * okButton = new QPushButton( embed::getIconPixmap( "apply" ), tr( "OK" ), buttons ); - connect( ok_btn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( okButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); - QPushButton * cancel_btn = new QPushButton( embed::getIconPixmap( + QPushButton * cancelButton = new QPushButton( embed::getIconPixmap( "cancel" ), tr( "Cancel" ), buttons ); - connect( cancel_btn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( cancelButton, SIGNAL( clicked() ), this, SLOT( reject() ) ); - btn_layout->addStretch(); - btn_layout->addSpacing( 10 ); - btn_layout->addWidget( ok_btn ); - btn_layout->addSpacing( 10 ); - btn_layout->addWidget( cancel_btn ); - btn_layout->addSpacing( 10 ); + buttonLayout->addStretch(); + buttonLayout->addSpacing( 10 ); + buttonLayout->addWidget( okButton ); + buttonLayout->addSpacing( 10 ); + buttonLayout->addWidget( cancelButton ); + buttonLayout->addSpacing( 10 ); QWidget * settings = new QWidget( this ); settings->setGeometry( 10, 10, 280, 100 ); @@ -79,56 +79,56 @@ setupDialogMCL::setupDialogMCL( setupDialog * _parent ) : vlayout->addStretch(); - m_actionKey_gb = new groupBox( tr( "MIDI KEYBOARD" ), + m_actionKeyGroupBox = new groupBox( tr( "MIDI KEYBOARD" ), settings ); - m_actionKey_gb->setFixedHeight( 160 ); - m_actionKey_gb->ledButton()->setChecked( m_keysActive ); - connect( m_actionKey_gb->ledButton(), SIGNAL( clicked() ), + m_actionKeyGroupBox->setFixedHeight( 160 ); + m_actionKeyGroupBox->ledButton()->setChecked( m_keysActive ); + connect( m_actionKeyGroupBox->ledButton(), SIGNAL( clicked() ), this, SLOT( clickedKeyBox( ) ) ); - m_actionController_gb = new groupBox( tr( "MIDI CONTROLLER" ), + m_actionControllerGroupBox = new groupBox( tr( "MIDI CONTROLLER" ), settings ); - m_actionController_gb->setFixedHeight( 100 ); - m_actionController_gb->ledButton()->setChecked( ! m_keysActive ); - connect( m_actionController_gb->ledButton(), SIGNAL( clicked() ), + m_actionControllerGroupBox->setFixedHeight( 100 ); + m_actionControllerGroupBox->ledButton()->setChecked( ! m_keysActive ); + connect( m_actionControllerGroupBox->ledButton(), SIGNAL( clicked() ), this, SLOT( clickedControllerBox( ) ) ); - QVBoxLayout * settings_vl = new QVBoxLayout( settings ); - settings_vl->setSpacing( 0 ); - settings_vl->setMargin( 0 ); - settings_vl->addWidget( m_actionController_gb ); - settings_vl->addSpacing( 10 ); - settings_vl->addWidget( m_actionKey_gb ); - settings_vl->addSpacing( 10 ); - settings_vl->addStretch(); + QVBoxLayout * settingsLayout = new QVBoxLayout( settings ); + settingsLayout->setSpacing( 0 ); + settingsLayout->setMargin( 0 ); + settingsLayout->addWidget( m_actionControllerGroupBox ); + settingsLayout->addSpacing( 10 ); + settingsLayout->addWidget( m_actionKeyGroupBox ); + settingsLayout->addSpacing( 10 ); + settingsLayout->addStretch(); - m_actionsKey_box = new QComboBox( m_actionKey_gb ); - m_actionsKey_box->setGeometry( 10, 20, 150, 22 ); + m_actionsKeyBox = new QComboBox( m_actionKeyGroupBox ); + m_actionsKeyBox->setGeometry( 10, 20, 150, 22 ); for( int i = 0; i < MidiControlListener::numActions; ++i ) { MidiControlListener::ActionNameMap action = MidiControlListener::action2ActionNameMap( (MidiControlListener::EventAction) i ); if( action.name != "" ) { - m_actionsKey_box->addItem( action.name ); + m_actionsKeyBox->addItem( action.name ); } } - QWidget * pianoWidget = new QWidget( m_actionKey_gb ); + QWidget * pianoWidget = new QWidget( m_actionKeyGroupBox ); pianoWidget->move( 10, 60 ); - PianoView * piano_view = new PianoView( pianoWidget ); - piano_view->setFixedSize( 250, 84 ); + PianoView * pianoViewWidget = new PianoView( pianoWidget ); + pianoViewWidget->setFixedSize( 250, 84 ); - m_actionsController_box = new QComboBox( m_actionController_gb ); - m_actionsController_box->setGeometry( 10, 30, 150, 22 ); + m_actionsControllerBox = new QComboBox( m_actionControllerGroupBox ); + m_actionsControllerBox->setGeometry( 10, 30, 150, 22 ); for( int i = 0; i < MidiControlListener::numActions; ++i ) { MidiControlListener::ActionNameMap action = MidiControlListener::action2ActionNameMap( (MidiControlListener::EventAction) i ); if( action.name != "" && action.action != MidiControlListener::ActionControl ) { - m_actionsController_box->addItem( action.name ); + m_actionsControllerBox->addItem( action.name ); } } @@ -136,7 +136,7 @@ setupDialogMCL::setupDialogMCL( setupDialog * _parent ) : m_controllerSbModel->setRange( 0, 127 ); m_controllerSbModel->setStep( 1 ); m_controllerSbModel->setValue( 63 ); - lcdSpinBox * controllerSb = new lcdSpinBox( 3, m_actionController_gb ); + lcdSpinBox * controllerSb = new lcdSpinBox( 3, m_actionControllerGroupBox ); controllerSb->setModel( m_controllerSbModel ); controllerSb->setLabel( tr( "CONTROLLER" ) ); controllerSb->move( 20, 60 ); @@ -160,7 +160,7 @@ void setupDialogMCL::accept( void ) { MidiControlListener::ActionNameMap action = MidiControlListener::actionName2ActionNameMap( - m_actionsKey_box->currentText() ); + m_actionsKeyBox->currentText() ); m_parent->mclAddKeyAction( 40, action.action ); } @@ -168,7 +168,7 @@ void setupDialogMCL::accept( void ) { MidiControlListener::ActionNameMap action = MidiControlListener::actionName2ActionNameMap( - m_actionsController_box->currentText() ); + m_actionsControllerBox->currentText() ); m_parent->mclAddControllerAction( m_controllerSbModel->value(), action.action ); @@ -182,8 +182,8 @@ void setupDialogMCL::accept( void ) void setupDialogMCL::clickedKeyBox( void ) { m_keysActive = true; - m_actionKey_gb->ledButton()->setChecked( true ); - m_actionController_gb->ledButton()->setChecked( false ); + m_actionKeyGroupBox->ledButton()->setChecked( true ); + m_actionControllerGroupBox->ledButton()->setChecked( false ); } @@ -192,8 +192,8 @@ void setupDialogMCL::clickedKeyBox( void ) void setupDialogMCL::clickedControllerBox( void ) { m_keysActive = false; - m_actionKey_gb->ledButton()->setChecked( false ); - m_actionController_gb->ledButton()->setChecked( true ); + m_actionKeyGroupBox->ledButton()->setChecked( false ); + m_actionControllerGroupBox->ledButton()->setChecked( true ); }