Skip to content

Commit

Permalink
Display HID devices in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
mauer committed Jul 2, 2024
1 parent 9b0db28 commit baf2860
Show file tree
Hide file tree
Showing 9 changed files with 4,315 additions and 76 deletions.
494 changes: 494 additions & 0 deletions external/fonts/IconsFontAwesome6Brands.h

Large diffs are not rendered by default.

3,553 changes: 3,553 additions & 0 deletions external/fonts/fa-brands-400.inc

Large diffs are not rendered by default.

Binary file added external/fonts/fa-brands-400.ttf
Binary file not shown.
1 change: 1 addition & 0 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ set(COMMON_SRC
${CMAKE_CURRENT_LIST_DIR}/text_logger.cpp
${CMAKE_CURRENT_LIST_DIR}/toml_utils.cpp
${CMAKE_CURRENT_LIST_DIR}/utils.cpp
hid_device_data.h
)

# Build static library
Expand Down
44 changes: 44 additions & 0 deletions src/common/hid_device_data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//---------------------------------------------------------------------------------------------------------------------
// XMidiCtrl - MIDI Controller plugin for X-Plane
//
// Copyright (c) 2021-2024 Marco Auer
//
// XMidiCtrl is free software: you can redistribute it and/or modify it under the terms of the
// GNU Affero General Public License as published by the Free Software Foundation, either version 3
// of the License, or (at your option) any later version.
//
// XMidiCtrl is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License along with XMidiCtrl.
// If not, see <https://www.gnu.org/licenses/>.
//---------------------------------------------------------------------------------------------------------------------

#ifndef XMC_HID_DEVICE_DATA_H
#define XMC_HID_DEVICE_DATA_H

// Standard
#include <string>

namespace xmidictrl {

//---------------------------------------------------------------------------------------------------------------------
// TYPES
//---------------------------------------------------------------------------------------------------------------------

struct hid_device_data {
std::string manufacturer_string;
std::string product_string;

unsigned short vendor_id;
unsigned short product_id;

wchar_t* serial_no;

int usb_interface_no;
};

} // Namespace xmidictrl

#endif // HID_DEVICE_DATA_H
16 changes: 16 additions & 0 deletions src/env-xplane/imgui_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
#include "IconsFontAwesome6.h"
#include "fa-solid-900.inc"

#include "IconsFontAwesome6Brands.h"
#include "fa-brands-400.inc"

// X-Plane SDK
#include <XPLMGraphics.h>

Expand Down Expand Up @@ -97,6 +100,19 @@ imgui_window::imgui_window(text_logger& in_log,
&config,
icon_ranges.Data))
in_log.warn("Error loading 'Font Awesome' for Dear ImGui");

// Brands
static ImVector<ImWchar> icon_ranges_brands;
ImFontGlyphRangesBuilder builder_brands;
builder_brands.AddText(ICON_FA_USB);
builder_brands.BuildRanges(&icon_ranges_brands);

if (!s_font->AddFontFromMemoryCompressedTTF(fa_brands_400_compressed_data,
fa_brands_400_compressed_size,
IMGUI_FONT_SIZE,
&config,
icon_ranges_brands.Data))
in_log.warn("Error loading 'Font Awesome Brands' for Dear ImGui");
}

// check if a font atlas was supplied
Expand Down
8 changes: 4 additions & 4 deletions src/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ if (WIN32)
target_link_libraries(${PROJECT_NAME} mingw_stdthreads)
endif()
if (MSVC)
target_link_libraries(${PROJECT_NAME} toml11 fmt::fmt-header-only rtmidi winmm xpsdk imgui)
target_link_libraries(${PROJECT_NAME} toml11 fmt::fmt-header-only rtmidi hidapi::hidapi winmm xpsdk imgui)
include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:${PROJECT_NAME}> "${PROJECT_SOURCE_DIR}/package/${PROJECT_NAME}/win_x64/$<TARGET_FILE_NAME:${PROJECT_NAME}>"
)
else()
target_link_libraries(${PROJECT_NAME} -s -static -static-libgcc -static-libstdc++ toml11 fmt::fmt-header-only rtmidi winmm xpsdk imgui)
target_link_libraries(${PROJECT_NAME} -s -static -static-libgcc -static-libstdc++ toml11 fmt::fmt-header-only rtmidi hidapi::hidapi winmm xpsdk imgui)
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/package/${PROJECT_NAME}/win_x64")
endif()
elseif (APPLE)
Expand All @@ -56,7 +56,7 @@ elseif (APPLE)
find_library(OpenGL_LIBRARY OpenGL REQUIRED)
# Link OS X core system libraries.
target_link_libraries(${PROJECT_NAME} ${CORE_FOUNDATION_LIBRARY} ${Cocoa_LIBRARY} ${Security_LIBRARY} ${GSS_LIBRARY} ${OpenGL_LIBRARY})
target_link_libraries(${PROJECT_NAME} toml11 fmt::fmt-header-only rtmidi xpsdk imgui)
target_link_libraries(${PROJECT_NAME} toml11 fmt::fmt-header-only rtmidi hidapi::hidapi xpsdk imgui)
target_link_options(${PROJECT_NAME} PRIVATE "-Wl,-no_weak_imports")

# Restrict set of symbols exported from the plugin to the ones required by XPLM:
Expand All @@ -65,7 +65,7 @@ elseif (APPLE)
elseif (UNIX)
message("Build for Linux Platform")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/package/${PROJECT_NAME}/lin_64")
target_link_libraries(${PROJECT_NAME} -static-libgcc -static-libstdc++ -fPIC toml11 fmt::fmt-header-only rtmidi xpsdk imgui)
target_link_libraries(${PROJECT_NAME} -static-libgcc -static-libstdc++ -fPIC toml11 fmt::fmt-header-only rtmidi hidapi::hidapi xpsdk imgui)
set_target_properties(${PROJECT_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/package/${PROJECT_NAME}/lin_x64")
endif ()

Expand Down
Loading

0 comments on commit baf2860

Please sign in to comment.