From b51c1c648146e49c25c4d6a2a6f5b9b66ea3190d Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Tue, 21 Jul 2015 23:42:32 +0200 Subject: Remove fake keypress event generation --- rcm-server-main.c | 45 --------------------------------------------- 1 file changed, 45 deletions(-) diff --git a/rcm-server-main.c b/rcm-server-main.c index 294510c..290ebdc 100644 --- a/rcm-server-main.c +++ b/rcm-server-main.c @@ -1071,45 +1071,6 @@ block_signals(void) return sigprocmask(SIG_BLOCK, &sigset, NULL); } -#include - -typedef uint64_t usec_t; -#define USEC_PER_SEC ((usec_t)1000000ULL) -#define NSEC_PER_USEC ((usec_t)1000ULL) - -static usec_t -now(clockid_t clk_id) -{ - struct timespec ts; - - clock_gettime(clk_id, &ts); - - return (usec_t)(ts.tv_sec * USEC_PER_SEC) + (usec_t)(ts.tv_nsec / NSEC_PER_USEC); -} - -static int -timeout_cb(sd_event_source *source, usec_t usec, void *userdata) -{ - struct manager *mgr = userdata; - static bool pressed = true; - unsigned timeout; - - sd_bus_emit_signal(mgr->bus, "/org/gnome/RemoteControlManager/rc0", - "org.gnome.RemoteControlManager.Device", - pressed ? "KeyPressed" : "KeyReleased", - "s", "KEY_OK"); - - if (pressed) - timeout = USEC_PER_SEC / 2; - else - timeout = USEC_PER_SEC * 3; - - sd_event_source_set_time(source, now(CLOCK_MONOTONIC) + timeout); - sd_event_source_set_enabled(source, SD_EVENT_ONESHOT); - pressed = !pressed; - return 0; -} - int main(int argc, char **argv) { @@ -1121,7 +1082,6 @@ main(int argc, char **argv) _cleanup_bus_slot_unref_ struct sd_bus_slot *objm_slot = NULL; _cleanup_event_source_unref_ sd_event_source *sigint_ev = NULL; _cleanup_event_source_unref_ sd_event_source *sigterm_ev = NULL; - _cleanup_event_source_unref_ sd_event_source *timeout_ev = NULL; mgr = zmalloc(sizeof(*mgr)); if (!mgr) { @@ -1190,11 +1150,6 @@ main(int argc, char **argv) sd_event_add_signal(mgr->event, &sigint_ev, SIGINT, NULL, NULL); sd_event_add_signal(mgr->event, &sigterm_ev, SIGTERM, NULL, NULL); - printf("Sending fake keypress events\n"); - sd_event_add_time(mgr->event, &timeout_ev, CLOCK_MONOTONIC, - now(CLOCK_MONOTONIC) + 3 * USEC_PER_SEC, - 0, timeout_cb, mgr); - r = sd_event_loop(mgr->event); if (r < 0) { fprintf(stderr, "Event loop failed: %s\n", strerror(-r)); -- cgit v1.2.3