Skip to content

Commit e005261

Browse files
committed
apps: daemon: Hook up the touchpad button
1 parent 8e5b3f8 commit e005261

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/apps/daemon/daemon.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <contacts/contact.hpp>
1111
#include <core/generic/application.hpp>
1212
#include <core/generic/config.hpp>
13+
#include <ipts/samples/button.hpp>
1314
#include <ipts/samples/stylus.hpp>
1415

1516
#include <spdlog/spdlog.h>
@@ -67,6 +68,14 @@ class Daemon : public core::Application {
6768
m_touch->update(contacts);
6869
}
6970

71+
void on_button(const ipts::samples::Button &button) override
72+
{
73+
if (!m_touch.has_value())
74+
return;
75+
76+
m_touch->update(button);
77+
}
78+
7079
void on_stylus(const ipts::samples::Stylus &stylus) override
7180
{
7281
if (!m_stylus.has_value())

src/apps/daemon/touch.hpp

+19
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <contacts/contact.hpp>
1111
#include <core/generic/config.hpp>
1212
#include <core/generic/device.hpp>
13+
#include <ipts/samples/button.hpp>
1314

1415
#include <gsl/gsl>
1516

@@ -86,13 +87,15 @@ class TouchDevice {
8687
m_uinput->set_keybit(BTN_TOUCH);
8788

8889
if (info.is_touchpad()) {
90+
m_uinput->set_keybit(BTN_LEFT);
8991
m_uinput->set_keybit(BTN_TOOL_FINGER);
9092
m_uinput->set_keybit(BTN_TOOL_DOUBLETAP);
9193
m_uinput->set_keybit(BTN_TOOL_TRIPLETAP);
9294
m_uinput->set_keybit(BTN_TOOL_QUADTAP);
9395
m_uinput->set_keybit(BTN_TOOL_QUINTTAP);
9496

9597
m_uinput->set_propbit(INPUT_PROP_POINTER);
98+
m_uinput->set_propbit(INPUT_PROP_BUTTONPAD);
9699

97100
m_overshoot = config.touchpad_overshoot;
98101
m_disable_on_palm = config.touchpad_disable_on_palm;
@@ -145,6 +148,21 @@ class TouchDevice {
145148
this->sync();
146149
}
147150

151+
/*!
152+
* Passes a sample of the touchpad button to the linux kernel.
153+
*
154+
* @param[in] button The state of the touchpad button (pressed / released).
155+
*/
156+
void update(const ipts::samples::Button &button)
157+
{
158+
// If the touch device is disabled ignore all inputs.
159+
if (!m_enabled)
160+
return;
161+
162+
m_uinput->emit(EV_KEY, BTN_LEFT, button.active ? 1 : 0);
163+
this->sync();
164+
}
165+
148166
/*!
149167
* Disables the touch device and lifts all contacts.
150168
*/
@@ -400,6 +418,7 @@ class TouchDevice {
400418
m_uinput->emit(EV_KEY, BTN_TOUCH, 0);
401419

402420
if (m_info.is_touchpad()) {
421+
m_uinput->emit(EV_KEY, BTN_LEFT, 0);
403422
m_uinput->emit(EV_KEY, BTN_TOOL_FINGER, 0);
404423
m_uinput->emit(EV_KEY, BTN_TOOL_DOUBLETAP, 0);
405424
m_uinput->emit(EV_KEY, BTN_TOOL_TRIPLETAP, 0);

0 commit comments

Comments
 (0)