Compare commits
9 Commits
master
...
c9df603a8a
| Author | SHA1 | Date | |
|---|---|---|---|
|
c9df603a8a
|
|||
|
e1141617c2
|
|||
|
271120d45c
|
|||
|
94797f4a94
|
|||
|
49d38e2210
|
|||
|
9c787b0e72
|
|||
|
b8a1412738
|
|||
| b236c2fb35 | |||
| ba735340dc |
@@ -0,0 +1,13 @@
|
|||||||
|
FROM docker.io/fedora:44 as BUILDER
|
||||||
|
|
||||||
|
RUN dnf install --assumeyes --setopt install_weak_deps=False \
|
||||||
|
gcc make just \
|
||||||
|
libinput-devel
|
||||||
|
|
||||||
|
FROM BUILDER as PACKER
|
||||||
|
|
||||||
|
RUN dnf install \
|
||||||
|
--assumeyes \
|
||||||
|
--setopt install_weak_deps=False \
|
||||||
|
rpmdevtools
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
image TARGET='PACKER':
|
||||||
|
podman build --target {{ TARGET }} -t lisgd:{{ lowercase(TARGET) }} .
|
||||||
|
|
||||||
|
build: (image 'BUILDER')
|
||||||
|
podman run --interactive --tty --rm --name lisgd-builder \
|
||||||
|
--volume ./:/work:z --workdir /work \
|
||||||
|
lisgd:builder \
|
||||||
|
make lisgd
|
||||||
+2
-10
@@ -19,14 +19,6 @@ char *device = "/dev/input/event1";
|
|||||||
|
|
||||||
Gesture gestures[] = {
|
Gesture gestures[] = {
|
||||||
/* nfingers gesturetype command */
|
/* nfingers gesturetype command */
|
||||||
{ 1, SwipeLR, "xdotool key --clearmodifiers Alt+Shift+e" },
|
{ 4, SwipeLR, "swaymsg workspace prev_on_output" },
|
||||||
{ 1, SwipeRL, "xdotool key --clearmodifiers Alt+Shift+r" },
|
{ 4, SwipeRL, "swaymsg workspace next_on_output" },
|
||||||
{ 1, SwipeDLUR, "sxmo_vol.sh up" },
|
|
||||||
{ 1, SwipeURDL, "sxmo_vol.sh down" },
|
|
||||||
{ 1, SwipeDRUL, "sxmo_brightness.sh up" },
|
|
||||||
{ 1, SwipeULDR, "sxmo_brightness.sh down" },
|
|
||||||
{ 2, SwipeLR, "xdotool key --clearmodifiers Alt+e" },
|
|
||||||
{ 2, SwipeRL, "xdotool key --clearmodifiers Alt+r" },
|
|
||||||
{ 2, SwipeDU, "pidof svkbd-sxmo || svkbd-sxmo &" },
|
|
||||||
{ 2, SwipeUD, "pkill -9 svkbd-sxmo" },
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <libinput.h>
|
#include <libinput.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
#include <sys/signalfd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -39,10 +40,12 @@ typedef struct {
|
|||||||
|
|
||||||
/* Globals */
|
/* Globals */
|
||||||
Gesture *gestsarr;
|
Gesture *gestsarr;
|
||||||
|
Gesture *originalgestures;
|
||||||
int gestsarrlen;
|
int gestsarrlen;
|
||||||
Swipe pendingswipe;
|
Swipe pendingswipe;
|
||||||
double xstart[MAXSLOTS], xend[MAXSLOTS], ystart[MAXSLOTS], yend[MAXSLOTS];
|
double xstart[MAXSLOTS], xend[MAXSLOTS], ystart[MAXSLOTS], yend[MAXSLOTS];
|
||||||
unsigned nfdown = 0, nfpendingswipe = 0;
|
unsigned nfdown = 0, nfpendingswipe = 0;
|
||||||
|
unsigned orientationdirty = 0;
|
||||||
struct timespec timedown;
|
struct timespec timedown;
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -141,6 +144,22 @@ swipereorient(Swipe swipe, int orientation) {
|
|||||||
return swipe;
|
return swipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
reorientgestures(int orientation) {
|
||||||
|
for (int i = 0; i < gestsarrlen; i++)
|
||||||
|
gestsarr[i].swipe = swipereorient(originalgestures[i].swipe, orientation);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
changeorientation(int _signal, siginfo_t *info, void *_none) {
|
||||||
|
int new_orientation = (info->si_value).sival_int;
|
||||||
|
|
||||||
|
if (orientation != new_orientation) {
|
||||||
|
orientation = new_orientation;
|
||||||
|
orientationdirty = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
touchdown(struct libinput_event *e)
|
touchdown(struct libinput_event *e)
|
||||||
{
|
{
|
||||||
@@ -212,6 +231,25 @@ touchup(struct libinput_event *e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
sigusr1fd() {
|
||||||
|
sigset_t mask;
|
||||||
|
int sfd;
|
||||||
|
|
||||||
|
sigemptyset(&mask);
|
||||||
|
sigaddset(&mask, SIGUSR1);
|
||||||
|
if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1) {
|
||||||
|
die("Can't block SIGUSR1.");
|
||||||
|
}
|
||||||
|
|
||||||
|
sfd = signalfd(-1, &mask, 0);
|
||||||
|
if (sfd == -1) {
|
||||||
|
die("Can't open signalfd on SIGUSR1.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return sfd;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
run()
|
run()
|
||||||
{
|
{
|
||||||
@@ -221,7 +259,12 @@ run()
|
|||||||
struct libinput_event_touch *tevent;
|
struct libinput_event_touch *tevent;
|
||||||
struct libinput_device *d;
|
struct libinput_device *d;
|
||||||
int selectresult;
|
int selectresult;
|
||||||
|
|
||||||
fd_set fdset;
|
fd_set fdset;
|
||||||
|
int li_fd;
|
||||||
|
int sig_fd;
|
||||||
|
int sfdrsize;
|
||||||
|
struct signalfd_siginfo sfdinfo;
|
||||||
|
|
||||||
const static struct libinput_interface interface = {
|
const static struct libinput_interface interface = {
|
||||||
.open_restricted = libinputopenrestricted,
|
.open_restricted = libinputopenrestricted,
|
||||||
@@ -246,21 +289,37 @@ run()
|
|||||||
ystart[i] = NOMOTION;
|
ystart[i] = NOMOTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
FD_ZERO(&fdset);
|
sig_fd = sigusr1fd();
|
||||||
FD_SET(libinput_get_fd(li), &fdset);
|
li_fd = libinput_get_fd(li);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
FD_ZERO(&fdset);
|
||||||
|
FD_SET(sig_fd, &fdset);
|
||||||
|
FD_SET(li_fd, &fdset);
|
||||||
selectresult = select(FD_SETSIZE, &fdset, NULL, NULL, NULL);
|
selectresult = select(FD_SETSIZE, &fdset, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (selectresult == -1) {
|
if (selectresult == -1) {
|
||||||
die("Can't select on device node?");
|
die("Can't select on device node?");
|
||||||
} else {
|
}
|
||||||
libinput_dispatch(li);
|
else {
|
||||||
while ((event = libinput_get_event(li)) != NULL) {
|
if (FD_ISSET(sig_fd, &fdset)) {
|
||||||
switch(libinput_event_get_type(event)) {
|
sfdrsize = read(sig_fd, &sfdinfo, sizeof(struct signalfd_siginfo));
|
||||||
case LIBINPUT_EVENT_TOUCH_DOWN: touchdown(event); break;
|
|
||||||
case LIBINPUT_EVENT_TOUCH_UP: touchup(event); break;
|
if (sfdrsize != sizeof(struct signalfd_siginfo)) {
|
||||||
case LIBINPUT_EVENT_TOUCH_MOTION: touchmotion(event); break;
|
die("Couldn't read reorient signal.");
|
||||||
|
}
|
||||||
|
reorientgestures(sfdinfo.ssi_int);
|
||||||
|
}
|
||||||
|
if (FD_ISSET(li_fd, &fdset)) {
|
||||||
|
libinput_dispatch(li);
|
||||||
|
while ((event = libinput_get_event(li)) != NULL) {
|
||||||
|
switch(libinput_event_get_type(event)) {
|
||||||
|
case LIBINPUT_EVENT_TOUCH_DOWN: touchdown(event); break;
|
||||||
|
case LIBINPUT_EVENT_TOUCH_UP: touchup(event); break;
|
||||||
|
case LIBINPUT_EVENT_TOUCH_MOTION: touchmotion(event); break;
|
||||||
|
}
|
||||||
|
libinput_event_destroy(event);
|
||||||
}
|
}
|
||||||
libinput_event_destroy(event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,9 +388,12 @@ main(int argc, char *argv[])
|
|||||||
memcpy(gestsarr, gestures, sizeof(gestures));
|
memcpy(gestsarr, gestures, sizeof(gestures));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modify gestures swipes based on orientation provided
|
// Save original gestures for runtime orientation change
|
||||||
for (i = 0; i < gestsarrlen; i++)
|
originalgestures = malloc(sizeof(Gesture) * gestsarrlen);
|
||||||
gestsarr[i].swipe = swipereorient(gestsarr[i].swipe, orientation);
|
memcpy(originalgestures, gestsarr, sizeof(Gesture) * gestsarrlen);
|
||||||
|
|
||||||
|
// Modify gestures swipes based on orientation provided
|
||||||
|
reorientgestures(orientation);
|
||||||
|
|
||||||
run();
|
run();
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user