Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions abs-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <string.h>
#include <ini.h>
#include <poll.h>
#include <errno.h>
#include <sched.h>
#include <sys/mman.h>
#include <sys/capability.h>
Expand Down Expand Up @@ -362,17 +363,15 @@ int main(int argc, char *argv[]) {
mlockall(MCL_CURRENT | MCL_FUTURE);

struct pollfd pfd = {.fd=fd, .events=POLLIN};
struct input_event ev_buf[64];



int x = 0, y = 0;
int x_old = -1, y_old = -1;
bool active;
bool active = false;
bool grabbed = false;

if (config.enable_tosu == true) {
tosu_init();
active = tosu_get_absolute_state();
}
else {
printf("Tosu integration is disabled.\n");
Expand All @@ -397,7 +396,23 @@ int main(int argc, char *argv[]) {
set_grab(fd, &grabbed, active);

if (active == true) {
if (poll(&pfd, 1, -1) <= 0)
int poll_rc = poll(&pfd, 1, -1);
if (poll_rc == -1) {
if (errno == EINTR) {
if (stop) break;
continue;
}
perror("poll");
break;
}
if (poll_rc == 0)
continue;

if (pfd.revents & (POLLERR | POLLHUP | POLLNVAL)) {
fprintf(stderr, "poll: fatal revents=0x%x\n", pfd.revents);
break;
}
if (!(pfd.revents & POLLIN))
continue;

struct input_event ev;
Expand Down
3 changes: 2 additions & 1 deletion tosuhandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <cjson/cJSON.h>

// ---------------- CONFIG ----------------
#define TOSU_URL "http://localhost:24050/json"
#define TOSU_URL "http://127.0.0.1:24050/json"
#define POLL_INTERVAL_MS 500
// ----------------------------------------

Expand Down Expand Up @@ -153,6 +153,7 @@ static void *poll_thread_func(void *arg) {
curl_easy_setopt(easy, CURLOPT_URL, TOSU_URL);
curl_easy_setopt(easy, CURLOPT_TIMEOUT_MS, 500);
curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(easy, CURLOPT_NOPROXY, "*");
curl_easy_setopt(easy, CURLOPT_WRITEFUNCTION, curl_write_cb);

while (running) {
Expand Down