summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Makefile5
-rw-r--r--UI.cpp21
-rw-r--r--UI.h4
-rw-r--r--debian/control2
4 files changed, 27 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 8580c77..f48b8b2 100644
--- a/Makefile
+++ b/Makefile
@@ -17,12 +17,12 @@ SRCS= \
ClockClick.cpp \
InternalClick.cpp \
BPMDetect.cpp \
+ Touchpad.cpp
HEADERS=$(SRCS:.cpp=.h)
OBJS=$(SRCS:.cpp=.o)
-CXXLIBS=$(shell pkg-config --libs alsa) -lreichwein -lfmt -lasound
CXX=clang++
ifeq ($(CXXFLAGS),)
@@ -32,6 +32,9 @@ endif
CXXFLAGS+=-std=c++20 -Wall -Wpedantic
# workaround for Debian dh_dwz:
CXXFLAGS+=-gdwarf-4
+CXXFLAGS+=-I/usr/include/libevdev-1.0
+
+CXXLIBS=$(shell pkg-config --libs alsa) -lreichwein -lfmt -lasound -levdev
$(TARGET): $(OBJS)
$(CXX) $^ -o $@ $(CXXLIBS)
diff --git a/UI.cpp b/UI.cpp
index 5d304b0..2dab410 100644
--- a/UI.cpp
+++ b/UI.cpp
@@ -61,16 +61,16 @@ UI::UI(Config& config):
m_active_sensing_timestamp{},
m_midi_timestamp{},
m_note_bpm{},
- m_clock_bpm{}
+ m_clock_bpm{},
+ m_touchpad{}
{
}
bool UI::key_available() {
struct pollfd fds{};
- int ret;
fds.fd = 0; // stdin
fds.events = POLLIN;
- ret = poll(&fds, 1, 0);
+ int ret = poll(&fds, 1, 0);
if (ret == 0)
return false;
else if (ret == 1)
@@ -179,6 +179,7 @@ void UI::draw()
void UI::handle_input()
{
+ // handle console key
if (key_available()) {
char c;
std::cin >> c;
@@ -206,6 +207,20 @@ void UI::handle_input()
log_cout << fmt::format("Unknown key: {}", c) << std::endl;
}
}
+
+ // handle touchpad
+ if (m_touchpad.is_valid() && m_touchpad.event_available()) {
+ input_event ev = m_touchpad.get_event();
+
+ if (m_touchpad.event_is_button1(ev)) {
+ m_config.set_mode((m_config.get_mode() + 1) % 3);
+ } else if (m_touchpad.event_is_button2(ev)) {
+ if (!m_midi_monitor.empty()) {
+ m_config.set_midi_channel(m_midi_monitor.front().first);
+ m_config.set_midi_note(m_midi_monitor.front().second);
+ }
+ }
+ }
}
void UI::count_main_loops()
diff --git a/UI.h b/UI.h
index e8b1031..b1dd7dd 100644
--- a/UI.h
+++ b/UI.h
@@ -8,6 +8,8 @@
#include <boost/signals2.hpp>
+#include "Touchpad.h"
+
using clock_type = std::chrono::high_resolution_clock;
struct IntervalCounter
@@ -62,5 +64,7 @@ private:
int m_note_bpm;
int m_clock_bpm;
+
+ Touchpad m_touchpad;
};
diff --git a/debian/control b/debian/control
index dd6e5f8..32b713a 100644
--- a/debian/control
+++ b/debian/control
@@ -2,7 +2,7 @@ Source: click
Section: sound
Priority: optional
Maintainer: Roland Reichwein <mail@reichwein.it>
-Build-Depends: debhelper, clang, libc++-dev, libreichwein-dev, libasound2-dev, libfmt-dev, libboost-all-dev
+Build-Depends: debhelper, clang, libc++-dev, libreichwein-dev, libasound2-dev, libfmt-dev, libboost-all-dev, libevdev-dev
Standards-Version: 4.5.0
Homepage: http://www.reichwein.it/click/