Skip to content

Commit

Permalink
apps: daemon: Hook up the touchpad button
Browse files Browse the repository at this point in the history
  • Loading branch information
StollD committed Apr 20, 2024
1 parent 4ed9f2f commit 57ab8f8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/apps/daemon/daemon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <contacts/contact.hpp>
#include <core/generic/application.hpp>
#include <core/generic/config.hpp>
#include <ipts/samples/button.hpp>
#include <ipts/samples/stylus.hpp>

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

void on_button(const ipts::samples::Button &button) override
{
if (!m_touch.has_value())
return;

m_touch->update(button);
}

void on_stylus(const ipts::samples::Stylus &stylus) override
{
if (!m_stylus.has_value())
Expand Down
19 changes: 19 additions & 0 deletions src/apps/daemon/touch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <contacts/contact.hpp>
#include <core/generic/config.hpp>
#include <core/generic/device.hpp>
#include <ipts/samples/button.hpp>

#include <gsl/gsl>

Expand Down Expand Up @@ -86,13 +87,15 @@ class TouchDevice {
m_uinput->set_keybit(BTN_TOUCH);

if (info.is_touchpad()) {
m_uinput->set_keybit(BTN_LEFT);
m_uinput->set_keybit(BTN_TOOL_FINGER);
m_uinput->set_keybit(BTN_TOOL_DOUBLETAP);
m_uinput->set_keybit(BTN_TOOL_TRIPLETAP);
m_uinput->set_keybit(BTN_TOOL_QUADTAP);
m_uinput->set_keybit(BTN_TOOL_QUINTTAP);

m_uinput->set_propbit(INPUT_PROP_POINTER);
m_uinput->set_propbit(INPUT_PROP_BUTTONPAD);

m_overshoot = config.touchpad_overshoot;
m_disable_on_palm = config.touchpad_disable_on_palm;
Expand Down Expand Up @@ -145,6 +148,21 @@ class TouchDevice {
this->sync();
}

/*!
* Passes a sample of the touchpad button to the linux kernel.
*
* @param[in] button The state of the touchpad button (pressed / released).
*/
void update(const ipts::samples::Button &button)
{
// If the touch device is disabled ignore all inputs.
if (!m_enabled)
return;

m_uinput->emit(EV_KEY, BTN_LEFT, button.active ? 1 : 0);
this->sync();
}

/*!
* Disables the touch device and lifts all contacts.
*/
Expand Down Expand Up @@ -400,6 +418,7 @@ class TouchDevice {
m_uinput->emit(EV_KEY, BTN_TOUCH, 0);

if (m_info.is_touchpad()) {
m_uinput->emit(EV_KEY, BTN_LEFT, 0);
m_uinput->emit(EV_KEY, BTN_TOOL_FINGER, 0);
m_uinput->emit(EV_KEY, BTN_TOOL_DOUBLETAP, 0);
m_uinput->emit(EV_KEY, BTN_TOOL_TRIPLETAP, 0);
Expand Down

0 comments on commit 57ab8f8

Please sign in to comment.