-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
#include <optional> | ||
|
||
/* SPDX-License-Identifier: GPL-3.0-or-later */ | ||
|
||
// clang-format off | ||
namespace examples | ||
{ | ||
struct Trigger | ||
{ | ||
static consteval auto name() { return "Trigger"; } | ||
static consteval auto c_name() { return "avnd_trigger"; } | ||
static constexpr auto author() { return "Jean-Michaël Celerier"; } | ||
static constexpr auto category() { return "Control/Mappings"; } | ||
static constexpr auto description() { return "Send an impulse upon triggering"; } | ||
static consteval auto uuid() { return "36427eb1-b5f4-4735-a383-6164cb9b2572"; } | ||
|
||
struct | ||
{ | ||
struct { static constexpr auto name() { return "Input"; } float value; } input; | ||
struct { static constexpr auto name() { return "Ceil"; } float value; enum widget { hslider }; struct range { float min = 0.f, max = 1.f, init = 0.5f;}; } ceil; | ||
} inputs; | ||
|
||
struct | ||
{ | ||
struct { std::optional<bool> value; } enter; | ||
struct { std::optional<bool> value; } leave; | ||
} outputs; | ||
|
||
bool state{}; | ||
void operator()() { | ||
if(inputs.input.value > inputs.ceil.value && !state) { | ||
outputs.enter.value= true; | ||
state = true; | ||
} | ||
else if(inputs.input.value < inputs.ceil.value && state) { | ||
outputs.leave.value = true; | ||
state = false; | ||
} | ||
} | ||
}; | ||
} | ||
// clang-format on |