From: Jonathan Denose <jdenose@google.com>
To: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <bentiss@kernel.org>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
Henrik Rydberg <rydberg@bitmath.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, Angela Czubak <aczubak@google.com>,
"Sean O'Brien" <seobrien@google.com>,
Jonathan Denose <jdenose@google.com>
Subject: [PATCH v3 09/11] Input: MT - add INPUT_MT_TOTAL_FORCE flags
Date: Mon, 18 Aug 2025 23:08:50 +0000 [thread overview]
Message-ID: <20250818-support-forcepads-v3-9-e4f9ab0add84@google.com> (raw)
In-Reply-To: <20250818-support-forcepads-v3-0-e4f9ab0add84@google.com>
From: Angela Czubak <aczubak@google.com>
Add a flag to generate ABS_PRESSURE as sum of ABS_MT_PRESSURE across
all slots.
This flag should be set if one knows a device reports true force and would
like to report total force to the userspace.
Signed-off-by: Angela Czubak <aczubak@google.com>
Co-developed-by: Jonathan Denose <jdenose@google.com>
Signed-off-by: Jonathan Denose <jdenose@google.com>
---
drivers/input/input-mt.c | 14 ++++++++++----
include/linux/input/mt.h | 1 +
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/drivers/input/input-mt.c b/drivers/input/input-mt.c
index 337006dd9dcf72ef2eeb8580e4dd83babf8100be..09f518897d4a71a4a7625367dc2c652ee6035d98 100644
--- a/drivers/input/input-mt.c
+++ b/drivers/input/input-mt.c
@@ -198,6 +198,7 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
struct input_mt *mt = dev->mt;
struct input_mt_slot *oldest;
int oldid, count, i;
+ int p, reported_p = 0;
if (!mt)
return;
@@ -216,6 +217,13 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
oldest = ps;
oldid = id;
}
+ if (test_bit(ABS_MT_PRESSURE, dev->absbit)) {
+ p = input_mt_get_value(ps, ABS_MT_PRESSURE);
+ if (mt->flags & INPUT_MT_TOTAL_FORCE)
+ reported_p += p;
+ else if (oldid == id)
+ reported_p = p;
+ }
count++;
}
@@ -245,10 +253,8 @@ void input_mt_report_pointer_emulation(struct input_dev *dev, bool use_count)
input_event(dev, EV_ABS, ABS_X, x);
input_event(dev, EV_ABS, ABS_Y, y);
- if (test_bit(ABS_MT_PRESSURE, dev->absbit)) {
- int p = input_mt_get_value(oldest, ABS_MT_PRESSURE);
- input_event(dev, EV_ABS, ABS_PRESSURE, p);
- }
+ if (test_bit(ABS_MT_PRESSURE, dev->absbit))
+ input_event(dev, EV_ABS, ABS_PRESSURE, reported_p);
} else {
if (test_bit(ABS_MT_PRESSURE, dev->absbit))
input_event(dev, EV_ABS, ABS_PRESSURE, 0);
diff --git a/include/linux/input/mt.h b/include/linux/input/mt.h
index 2cf89a538b18bbc7c99c8705c2d22bdc95065238..d30286298a00a356bc9db954ae362f034cdd359b 100644
--- a/include/linux/input/mt.h
+++ b/include/linux/input/mt.h
@@ -17,6 +17,7 @@
#define INPUT_MT_DROP_UNUSED 0x0004 /* drop contacts not seen in frame */
#define INPUT_MT_TRACK 0x0008 /* use in-kernel tracking */
#define INPUT_MT_SEMI_MT 0x0010 /* semi-mt device, finger count handled manually */
+#define INPUT_MT_TOTAL_FORCE 0x0020 /* calculate total force from slots pressure */
/**
* struct input_mt_slot - represents the state of an input MT slot
--
2.51.0.rc1.193.gad69d77794-goog
next prev parent reply other threads:[~2025-08-18 23:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-18 23:08 [PATCH v3 00/11] HID: Implement haptic touchpad support Jonathan Denose
2025-08-18 23:08 ` [PATCH v3 01/11] HID: add haptics page defines Jonathan Denose
2025-08-18 23:08 ` [PATCH v3 02/11] Input: add FF_HAPTIC effect type Jonathan Denose
2025-08-18 23:08 ` [PATCH v3 03/11] Input: add INPUT_PROP_HAPTIC_TOUCHPAD Jonathan Denose
2025-08-19 4:19 ` Randy Dunlap
2025-08-18 23:08 ` [PATCH v3 04/11] HID: haptic: introduce hid_haptic_device Jonathan Denose
2025-08-18 23:08 ` [PATCH v3 05/11] HID: input: allow mapping of haptic output Jonathan Denose
2025-08-18 23:08 ` [PATCH v3 06/11] HID: haptic: initialize haptic device Jonathan Denose
2025-08-18 23:08 ` [PATCH v3 07/11] HID: input: calculate resolution for pressure Jonathan Denose
2025-08-18 23:08 ` [PATCH v3 08/11] HID: haptic: add functions handling events Jonathan Denose
2025-08-18 23:08 ` Jonathan Denose [this message]
2025-08-18 23:08 ` [PATCH v3 10/11] HID: haptic: add hid_haptic_switch_mode Jonathan Denose
2025-08-18 23:08 ` [PATCH v3 11/11] HID: multitouch: add haptic multitouch support Jonathan Denose
2025-09-02 21:30 ` [PATCH v3 00/11] HID: Implement haptic touchpad support Jonathan Denose
2025-09-04 10:02 ` Benjamin Tissoires
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250818-support-forcepads-v3-9-e4f9ab0add84@google.com \
--to=jdenose@google.com \
--cc=aczubak@google.com \
--cc=bentiss@kernel.org \
--cc=corbet@lwn.net \
--cc=dmitry.torokhov@gmail.com \
--cc=jikos@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rydberg@bitmath.org \
--cc=seobrien@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).