Skip to content

Commit

Permalink
Merge branch 'release/1.3.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rsjaffe committed Jul 15, 2016
2 parents fbc2890 + 0316548 commit 50409cd
Show file tree
Hide file tree
Showing 25 changed files with 966 additions and 58 deletions.
4 changes: 2 additions & 2 deletions Builds/MacOSX/Info-App.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.3.0.0</string>
<string>1.3.0.1</string>
<key>CFBundleVersion</key>
<string>1.3.0.0</string>
<string>1.3.0.1</string>
<key>NSHumanReadableCopyright</key>
<string></string>
<key>NSHighResolutionCapable</key>
Expand Down
8 changes: 4 additions & 4 deletions Builds/MacOSX/MIDI2LR.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2450,8 +2450,8 @@
"_NDEBUG=1",
"NDEBUG=1",
"JUCER_XCODE_MAC_F6D2F4CF=1",
"JUCE_APP_VERSION=1.3.0.0",
"JUCE_APP_VERSION_HEX=0x1030000", );
"JUCE_APP_VERSION=1.3.0.1",
"JUCE_APP_VERSION_HEX=0x1030001", );
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "$(inherited)");
Expand All @@ -2476,8 +2476,8 @@
"_NDEBUG=1",
"NDEBUG=1",
"JUCER_XCODE_MAC_F6D2F4CF=1",
"JUCE_APP_VERSION=1.3.0.0",
"JUCE_APP_VERSION_HEX=0x1030000", );
"JUCE_APP_VERSION=1.3.0.1",
"JUCE_APP_VERSION_HEX=0x1030001", );
GCC_SYMBOLS_PRIVATE_EXTERN = YES;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = ("../../JuceLibraryCode", "../../JuceLibraryCode/modules", "$(inherited)");
Expand Down
4 changes: 2 additions & 2 deletions Builds/VisualStudio2015/MIDI2LR.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<Optimization>Disabled</Optimization>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<AdditionalIncludeDirectories>..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.3.0.0;JUCE_APP_VERSION_HEX=0x1030000;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;DEBUG;_DEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.3.0.1;JUCE_APP_VERSION_HEX=0x1030001;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
Expand Down Expand Up @@ -97,7 +97,7 @@
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>..\..\JuceLibraryCode;..\..\JuceLibraryCode\modules;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.3.0.0;JUCE_APP_VERSION_HEX=0x1030000;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_WINDOWS;NDEBUG;JUCER_VS2015_78A5022=1;JUCE_APP_VERSION=1.3.0.1;JUCE_APP_VERSION_HEX=0x1030001;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader/>
Expand Down
6 changes: 3 additions & 3 deletions Builds/VisualStudio2015/resources.rc
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
#include <windows.h>

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,3,0,0
FILEVERSION 1,3,0,1
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileDescription", "MIDI2LR\0"
VALUE "FileVersion", "1.3.0.0\0"
VALUE "FileVersion", "1.3.0.1\0"
VALUE "ProductName", "MIDI2LR\0"
VALUE "ProductVersion", "1.3.0.0\0"
VALUE "ProductVersion", "1.3.0.1\0"
END
END

Expand Down
4 changes: 2 additions & 2 deletions JuceLibraryCode/JuceHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
namespace ProjectInfo
{
const char* const projectName = "MIDI2LR";
const char* const versionString = "1.3.0.0";
const int versionNumber = 0x1030000;
const char* const versionString = "1.3.0.1";
const int versionNumber = 0x1030001;
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion MIDI2LR.jucer
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<JUCERPROJECT id="jqaeel" name="MIDI2LR" projectType="guiapp" version="1.3.0.0"
<JUCERPROJECT id="jqaeel" name="MIDI2LR" projectType="guiapp" version="1.3.0.1"
bundleIdentifier="com.rsjaffe.MIDI2LR" includeBinaryInAppConfig="1"
jucerVersion="4.2.3" companyWebsite="http://rsjaffe.github.io/MIDI2LR/"
companyEmail="rsjaffe@gmail.com">
Expand Down
2 changes: 1 addition & 1 deletion Source/CommandMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CommandMenu final: public TextButton,
const std::vector<String> menus_;
const std::vector<std::vector<String>> menu_entries_;
MIDI_Message message_;
size_t selected_item_{std::numeric_limits<unsigned int>::max()};
size_t selected_item_{std::numeric_limits<size_t>::max()};
std::shared_ptr<CommandMap> command_map_{nullptr};
};

Expand Down
2 changes: 1 addition & 1 deletion Source/CommandTableModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ void CommandTableModel::addRow(int midi_channel, int midi_data, bool is_cc) {
}

void CommandTableModel::removeRow(int row) {
commands_.erase(commands_.begin() + row);
if (command_map_) {
command_map_->removeMessage(commands_[row]);
}
commands_.erase(commands_.cbegin() + row);
}

void CommandTableModel::removeAllRows() {
Expand Down
2 changes: 1 addition & 1 deletion Source/LRPlugin/MIDI2LR.lrplugin/Info.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ return {
},
--]]
},
VERSION = { major=1, minor=3, revision=0, build=0}
VERSION = { major=1, minor=3, revision=0, build=1}
}
8 changes: 5 additions & 3 deletions Source/MIDIProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,19 @@ void MIDIProcessor::addMIDICommandListener(MIDICommandListener* listener) {
listeners_.push_back(listener);
}

void MIDIProcessor::rescanDevices() {
void MIDIProcessor::RescanDevices() {
for (auto const& dev : devices_)
dev->stop();
devices_.clear(true);
devices_.clear();

InitDevices_();
}

void MIDIProcessor::InitDevices_() {
for (auto idx = 0; idx < MidiInput::getDevices().size(); idx++) {
if (devices_.set(idx, MidiInput::openDevice(idx, this))) {
auto dev = MidiInput::openDevice(idx, this);
if (dev != nullptr) {
devices_.emplace_back(dev);
devices_[idx]->start();
DBG(devices_[idx]->getName());
}
Expand Down
4 changes: 2 additions & 2 deletions Source/MIDIProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MIDIProcessor final: private MidiInputCallback {
void addMIDICommandListener(MIDICommandListener*);

// re-enumerates MIDI IN devices
void rescanDevices();
void RescanDevices();

private:
// overridden from MidiInputCallback
Expand All @@ -52,7 +52,7 @@ class MIDIProcessor final: private MidiInputCallback {
void InitDevices_();

NRPN_Filter nrpn_filter_;
OwnedArray<MidiInput> devices_;
std::vector<std::unique_ptr<MidiInput>> devices_;
std::vector<MIDICommandListener *> listeners_;
};

Expand Down
10 changes: 5 additions & 5 deletions Source/MIDISender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void MIDISender::Init(void) {

void MIDISender::sendCC(int midi_channel, int controller, int value) const {
if (controller < 128) { // regular message
for (auto dev : output_devices)
for (auto& dev : output_devices_)
dev->sendMessageNow(MidiMessage::controllerEvent(midi_channel, controller,
value));
}
Expand All @@ -39,7 +39,7 @@ void MIDISender::sendCC(int midi_channel, int controller, int value) const {
const auto parameterMSB = (controller >> 7) & 0x7F;
const auto valueLSB = value & 0x7f;
const auto valueMSB = (value >> 7) & 0x7F;
for (auto dev : output_devices) {
for (auto& dev : output_devices_) {
dev->sendMessageNow(MidiMessage::controllerEvent(midi_channel, 99, parameterMSB));
dev->sendMessageNow(MidiMessage::controllerEvent(midi_channel, 98, parameterLSB));
dev->sendMessageNow(MidiMessage::controllerEvent(midi_channel, 6, valueMSB));
Expand All @@ -48,15 +48,15 @@ void MIDISender::sendCC(int midi_channel, int controller, int value) const {
}
}

void MIDISender::rescanDevices() {
output_devices.clear(true);
void MIDISender::RescanDevices() {
output_devices_.clear();
InitDevices_();
}

void MIDISender::InitDevices_() {
for (auto idx = 0; idx < MidiOutput::getDevices().size(); idx++) {
auto dev = MidiOutput::openDevice(idx);
if (dev != nullptr)
output_devices.set(idx, dev);
output_devices_.emplace_back(dev);
}
}
4 changes: 2 additions & 2 deletions Source/MIDISender.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class MIDISender {
void sendCC(int midi_channel, int controller, int value) const;

// re-enumerates MIDI OUT devices
void rescanDevices();
void RescanDevices();

private:
void InitDevices_();
OwnedArray<MidiOutput> output_devices;
std::vector<std::unique_ptr<MidiOutput>> output_devices_;
};

#endif // MIDISENDER_H_INCLUDED
12 changes: 6 additions & 6 deletions Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void MainContentComponent::Init(std::shared_ptr<CommandMap>& command_map,
midi_processor->addMIDICommandListener(this);
}

if (auto ptr = lr_ipc_out_.lock()) {
if (const auto ptr = lr_ipc_out_.lock()) {
// Add ourselves as a listener for LR_IPC_OUT events
ptr->addListener(this);
}
Expand Down Expand Up @@ -218,14 +218,14 @@ void MainContentComponent::buttonClicked(Button* button) {
// Re-enumerate MIDI IN and OUT devices

if (midi_processor_) {
midi_processor_->rescanDevices();
midi_processor_->RescanDevices();
}

if (midi_sender_) {
midi_sender_->rescanDevices();
midi_sender_->RescanDevices();
}
// Send new CC parameters to MIDI Out devices
if (auto ptr = lr_ipc_in_.lock()) {
if (const auto ptr = lr_ipc_in_.lock()) {
ptr->refreshMIDIOutput();
}
}
Expand Down Expand Up @@ -288,7 +288,7 @@ void MainContentComponent::buttonClicked(Button* button) {
const auto new_profile = browser.getSelectedFile(0);
const auto command = String{"ChangedToFullPath "} +new_profile.getFullPathName() + "\n";

if (auto ptr = lr_ipc_out_.lock()) {
if (const auto ptr = lr_ipc_out_.lock()) {
ptr->sendCommand(command);
}
profile_name_label_.setText(new_profile.getFileName(),
Expand Down Expand Up @@ -322,7 +322,7 @@ void MainContentComponent::profileChanged(XmlElement* xml_element, const String&
// _systemTrayComponent.showInfoBubble(filename, "Profile loaded");

// Send new CC parameters to MIDI Out devices
if (auto ptr = lr_ipc_in_.lock()) {
if (const auto ptr = lr_ipc_in_.lock()) {
ptr->refreshMIDIOutput();
}
}
Expand Down
15 changes: 8 additions & 7 deletions Source/ProfileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void ProfileManager::Init(std::weak_ptr<LR_IPC_OUT>&& out,
command_map_ = commandMap;
lr_ipc_out_ = std::move(out);

if (auto ptr = lr_ipc_out_.lock()) {
if (const auto ptr = lr_ipc_out_.lock()) {
// add ourselves as a listener to LR_IPC_OUT so that we can send plugin
// settings on connection
ptr->addListener(this);
Expand All @@ -57,18 +57,18 @@ void ProfileManager::setProfileDirectory(const File& directory) {
current_profile_index_ = 0;
profiles_.clear();
for (const auto file : file_array)
profiles_.add(file.getFileName());
profiles_.emplace_back(file.getFileName());

if (profiles_.size() > 0)
switchToProfile(profiles_[0]);
}

const StringArray& ProfileManager::getMenuItems() const noexcept {
const std::vector<juce::String>& ProfileManager::getMenuItems() const noexcept {
return profiles_;
}

void ProfileManager::switchToProfile(int profile_index) {
if (profile_index >= 0 && profile_index < profiles_.size()) {
if (profile_index >= 0 && profile_index < static_cast<int>(profiles_.size())) {
switchToProfile(profiles_[profile_index]);
current_profile_index_ = profile_index;
}
Expand All @@ -82,7 +82,7 @@ void ProfileManager::switchToProfile(const String& profile) {
for (auto listener : listeners_)
listener->profileChanged(xml_element.get(), profile);

if (auto ptr = lr_ipc_out_.lock()) {
if (const auto ptr = lr_ipc_out_.lock()) {
auto command = String{"ChangedToDirectory "} +
File::addTrailingSeparator(profile_location_.getFullPathName()) +
String{"\n"};
Expand All @@ -95,7 +95,8 @@ void ProfileManager::switchToProfile(const String& profile) {

void ProfileManager::switchToNextProfile() {
current_profile_index_++;
if (current_profile_index_ == profiles_.size()) current_profile_index_ = 0;
if (current_profile_index_ == static_cast<int>(profiles_.size()))
current_profile_index_ = 0;

switchToProfile(current_profile_index_);
}
Expand Down Expand Up @@ -150,7 +151,7 @@ void ProfileManager::connected() {
const auto command = String{"ChangedToDirectory "} +
File::addTrailingSeparator(profile_location_.getFullPathName()) +
String{"\n"};
if (auto ptr = lr_ipc_out_.lock()) {
if (const auto ptr = lr_ipc_out_.lock()) {
ptr->sendCommand(command);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/ProfileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class ProfileManager final: public MIDICommandListener,
void setProfileDirectory(const File& dir);

// returns an array of profile names
const StringArray& getMenuItems() const noexcept;
const std::vector<juce::String>& getMenuItems() const noexcept;

// switches to a profile defined by an index
void switchToProfile(int profileIdx);
Expand Down Expand Up @@ -89,7 +89,7 @@ class ProfileManager final: public MIDICommandListener,
std::shared_ptr<CommandMap> command_map_{nullptr};
std::vector<ProfileChangeListener *> listeners_;
std::weak_ptr<LR_IPC_OUT> lr_ipc_out_;
StringArray profiles_;
std::vector<juce::String> profiles_;
SWITCH_STATE switch_state_;
};

Expand Down
18 changes: 11 additions & 7 deletions Source/SendKeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ MIDI2LR. If not, see <http://www.gnu.org/licenses/>.
#endif
namespace {
#ifdef _WIN32
bool IsForegroundProcess() {
return (GetCurrentProcessId() ==
GetWindowThreadProcessId(GetForegroundWindow(), NULL));
}

wchar_t MBtoWChar(const std::string& key) {
wchar_t full_character;
const auto return_value = MultiByteToWideChar(CP_UTF8, 0, key.data(),
Expand All @@ -51,18 +56,17 @@ namespace {

HKL GetLanguageAndFGApp(std::string program_name) {
const auto hLRWnd = FindWindow(NULL, program_name.c_str());
HKL language_id;
// Bring Lightroom to foreground if it isn't already there
if (hLRWnd) {
SetForegroundWindow(hLRWnd);
// Bring Lightroom to foreground if MIDI2LR is in foreground
if (IsForegroundProcess())
SetForegroundWindow(hLRWnd);
// get language that LR is using (if hLrWnd is found)
const auto thread_id = GetWindowThreadProcessId(hLRWnd, NULL);
language_id = GetKeyboardLayout(thread_id);
return GetKeyboardLayout(thread_id);
}
else { // use keyboard of MIDI2LR application
language_id = GetKeyboardLayout(0);
return GetKeyboardLayout(0);
}
return language_id;
}
#else
std::wstring utf8_to_utf16(const std::string& utf8) {
Expand Down Expand Up @@ -246,7 +250,7 @@ void SendKeys::SendKeyDownUp(const std::string& key, const bool alt_opt,

// construct input event.
INPUT ip;
constexpr auto size_ip = sizeof(INPUT);
constexpr auto size_ip = sizeof(ip);
ip.type = INPUT_KEYBOARD;
//ki: wVk, wScan, dwFlags, time, dwExtraInfo
ip.ki = {0,0,0,0,0};
Expand Down
Loading

0 comments on commit 50409cd

Please sign in to comment.