diff options
author | Mattias Andrée <m@maandree.se> | 2025-02-19 19:53:53 +0100 |
---|---|---|
committer | Mattias Andrée <m@maandree.se> | 2025-02-19 19:55:30 +0100 |
commit | a40d93ab5a064f8f2f9696acd1b57ef3603cd2fe (patch) | |
tree | 288671ad6f1b0d8c57a00b18b04f21b827eab24d /libterminput_parse_decimal_mouse_tracking__.c | |
parent | minor readability improvement (diff) | |
download | libterminput-a40d93ab5a064f8f2f9696acd1b57ef3603cd2fe.tar.gz libterminput-a40d93ab5a064f8f2f9696acd1b57ef3603cd2fe.tar.bz2 libterminput-a40d93ab5a064f8f2f9696acd1b57ef3603cd2fe.tar.xz |
misc cleanup, fixes, and clarifications, and escape sequence
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to 'libterminput_parse_decimal_mouse_tracking__.c')
-rw-r--r-- | libterminput_parse_decimal_mouse_tracking__.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libterminput_parse_decimal_mouse_tracking__.c b/libterminput_parse_decimal_mouse_tracking__.c new file mode 100644 index 0000000..01b6040 --- /dev/null +++ b/libterminput_parse_decimal_mouse_tracking__.c @@ -0,0 +1,23 @@ +/* See LICENSE file for copyright and license details. */ +#include "common.h" + + +void +libterminput_parse_decimal_mouse_tracking__(union libterminput_input *input, unsigned long long int nums[3]) +{ + input->mouseevent.type = LIBTERMINPUT_MOUSEEVENT; + input->mouseevent.x = (size_t)nums[1] + (size_t)!nums[1]; + input->mouseevent.y = (size_t)nums[2] + (size_t)!nums[2]; + input->mouseevent.mods = (enum libterminput_mod)((nums[0] >> 2) & 7ULL); + if (nums[0] & 32) + input->mouseevent.event = LIBTERMINPUT_MOTION; + nums[0] = (nums[0] & 3ULL) | ((nums[0] >> 4) & ~3ULL); + if (nums[0] < 4) { + nums[0] = (nums[0] + 1) & 3; + if (!nums[0] && input->mouseevent.event == LIBTERMINPUT_PRESS) { + input->mouseevent.event = LIBTERMINPUT_RELEASE; + nums[0] = 1; + } + } + input->mouseevent.button = (enum libterminput_button)nums[0]; +} |