Skip to content

Commit

Permalink
Various improvements and refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Auer committed Oct 27, 2024
1 parent 5aa387b commit 4317c69
Show file tree
Hide file tree
Showing 34 changed files with 1,339 additions and 1,115 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
+ Internal refactoring
+ Added HIDAPI as external library and started preparations for HID support
+ Added new parameter values_wrap to enable/disable value wrapping
+ The command mapping will now be executed as soon as "Data 2" is equal or higher than the specified *data_2_on*
parameter. This allows the use of pad controllers like the Akai LPD8. Many thanks to GitHub user *delgod* for
contributing this feature.

-----------------------------------------------------------------------------------------------------------------------

Expand Down
17 changes: 9 additions & 8 deletions docs/inbound_mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The following parameter is required for each mapping.
| Parameter | Description |
|-----------|----------------------------------------|
| ch | MIDI Channel (Default Value = 11) |
| type | Specifies the mapping type (see below) |
| type | Specifies the mapping type (see below) |

One of the following parameters is required, depending on the MIDI message type.

Expand All @@ -33,13 +33,14 @@ One of the following parameters is required, depending on the MIDI message type.

The following mapping types are supported:

| Mapping Type | Name | Description and usage |
|:------------:|:---------:|----------------------------------------------------------------------------------|
| cmd | Command | Executes a X-Plane command |
| pnp | Push&pull | Simulates a Push & pull button, which can execute two different commands |
| drf | Dataref | Toggles a given Dataref between two values |
| enc | Encoder | Executes different commands for up/down or modifies a given dataref |
| sld | Slider | Executes up to three different commands, depending on the location of the slider |
| Mapping Type | Name | Description and usage |
|:------------:|:------------:|-----------------------------------------------------------------------------------------------------------------------|
| cmd | Command | Executes a X-Plane command |
| pnp | Push & pull | *Obsolete: use Short & Long instead!*<br><br>Simulates a Push & pull button, which can execute two different commands |
| snl | Short & long | Allows to define different datarefs and/or commands for short and long button presses |
| drf | Dataref | Toggles a given Dataref between two values |
| enc | Encoder | Executes different commands for up/down or modifies a given dataref |
| sld | Slider | Executes up to three different commands, depending on the location of the slider |

## Multi-Map

Expand Down
12 changes: 6 additions & 6 deletions docs/inbound_mapping_command_by_value.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

## Description

Executes an X-Plane command when a button is pressed. The command will be executed as long as the button is being
pressed down. This behaviour is useful to map the CLR button of the G530, as pressing the button for a longer time
returns to the map screen.
Executes an X-Plane command based on the current value of a specified dataref. The command will be executed as long as
the button is being pressed down. This behaviour is useful to map the CLR button of the G530, as pressing the button
for a longer time returns to the map screen.

## Required Parameters

| Parameter | Description |
|-----------|--------------------------------------------|
| command | Defines the X-Plane command to be executed |
| Parameter | Description |
|-----------|-------------------------------------------------------------------------|
| dataref | Defines dataref in X-Plane which should be used for the command mapping |

## Optional Parameters

Expand Down
4 changes: 3 additions & 1 deletion docs/inbound_mapping_pushnpull.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Inbound Mapping Type: Push&pull
# Inbound Mapping Type: Push & pull

*Obsolete: use [Short & Long](inbound_mapping_short_and_long.md) instead!*

## Description

Expand Down
22 changes: 22 additions & 0 deletions docs/inbound_mapping_short_and_long.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Inbound Mapping Type: Short & long

## Description

This mapping simulates a push and pull button, as found in Airbus aircraft. A short button press will execute the push
command, while a longer button press (~1 sec) will execute the pull command.

## Required Parameters

| Parameter | Description |
|---------------|------------------------------------------------------|
| command_short | Defines the command to be executed for a push action |
| command_long | Defines the command to be executed for a pull action |

## Examples

```
{ ch = 11, cc = 14, type = "snl", command_push = "AirbusFBW/PushAltitude", command_pull = "AirbusFBW/PullAltitude" }
```
*If the button for Channel 11 and Control Change 14 is pressed and immediately released the command
'AirbusFBW/PushAltitude' will be executed. If the button is pressed for a longer time (~one second) then command
'AirbusFBW/PullAltitude' will be executed.*
7 changes: 1 addition & 6 deletions src/common/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ namespace xmidictrl {
// CONSTANTS
//---------------------------------------------------------------------------------------------------------------------

// Spacer 2
#define UI_SPACER_2 " "

// Spacer 3
#define UI_SPACER_3 " "

// MIDI unsigned int none
const char MIDI_NONE(-1);

Expand Down Expand Up @@ -98,6 +92,7 @@ const char* const CFG_MAPTYPE_CONSTANT = "con";
const char* const CFG_MAPTYPE_DATAREF = "drf";
const char* const CFG_MAPTYPE_ENCODER = "enc";
const char* const CFG_MAPTYPE_PUSH_PULL = "pnp";
const char* const CFG_MAPTYPE_SHORT_AND_LONG = "snl";
const char* const CFG_MAPTYPE_SLIDER = "sld";


Expand Down
1 change: 0 additions & 1 deletion src/common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class utils {
public:
static bool create_directory(text_logger& in_log, const std::filesystem::path& in_path);

// TODO: Move to cpp file
static std::string ltrim(std::string_view in_str) {
return std::regex_replace(in_str.data(), std::regex("^\\s+"), std::string());
}
Expand Down
12 changes: 7 additions & 5 deletions src/device/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,26 @@ set(DEV_SRC
${CMAKE_CURRENT_LIST_DIR}/device_list.cpp
${CMAKE_CURRENT_LIST_DIR}/midi_device.cpp
${CMAKE_CURRENT_LIST_DIR}/virtual_device.cpp

${CMAKE_CURRENT_LIST_DIR}/map_init/map_init.cpp
${CMAKE_CURRENT_LIST_DIR}/map_init/map_init_list.cpp

${CMAKE_CURRENT_LIST_DIR}/map_in/label.cpp
${CMAKE_CURRENT_LIST_DIR}/map_in/map_in.cpp
${CMAKE_CURRENT_LIST_DIR}/map_in/map_in_cbv.cpp
${CMAKE_CURRENT_LIST_DIR}/map_in/map_in_cmd.cpp
${CMAKE_CURRENT_LIST_DIR}/map_in/map_in_drf.cpp
${CMAKE_CURRENT_LIST_DIR}/map_in/map_in_enc.cpp
${CMAKE_CURRENT_LIST_DIR}/map_in/map_in_label.cpp
${CMAKE_CURRENT_LIST_DIR}/map_in/map_in_list.cpp
${CMAKE_CURRENT_LIST_DIR}/map_in/map_in_pnp.cpp
${CMAKE_CURRENT_LIST_DIR}/map_in/map_in_snl.cpp
${CMAKE_CURRENT_LIST_DIR}/map_in/map_in_sld.cpp
${CMAKE_CURRENT_LIST_DIR}/map_init/map_init.cpp
${CMAKE_CURRENT_LIST_DIR}/map_init/map_init_list.cpp

${CMAKE_CURRENT_LIST_DIR}/map_out/map_out.cpp
${CMAKE_CURRENT_LIST_DIR}/map_out/map_out_con.cpp
${CMAKE_CURRENT_LIST_DIR}/map_out/map_out_drf.cpp
${CMAKE_CURRENT_LIST_DIR}/map_out/map_out_list.cpp
${CMAKE_CURRENT_LIST_DIR}/map_out/map_out_sld.cpp
)
)

# Build static library
add_library(${XMIDICTRL_LIB_DEV} STATIC ${DEV_SRC})
Expand Down
2 changes: 2 additions & 0 deletions src/device/conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ std::string conversions::map_in_type_to_str(map_in_type in_type)
return "Encoder";
case map_in_type::push_pull:
return "Push&Pull";
case map_in_type::short_and_long:
return "Short & long";
case map_in_type::slider:
return "Slider";
case map_in_type::none:
Expand Down
Loading

0 comments on commit 4317c69

Please sign in to comment.