From 9d373452843619e3e53f197579a84f6ec171ed98 Mon Sep 17 00:00:00 2001
From: John Melton - G0ORX <john.d.melton@googlemail.com>
Date: Wed, 11 Aug 2021 06:38:41 +0100
Subject: [PATCH] fix LOCALCW problem with CWL and CWR being added twice to
 line monitoring

---
 gpio.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/gpio.c b/gpio.c
index 5505c5b..e5afe7e 100644
--- a/gpio.c
+++ b/gpio.c
@@ -1029,14 +1029,9 @@ int gpio_init() {
     if((ret=setup_line(chip,CWL_BUTTON,CW_ACTIVE_LOW==1))<0) {
       goto err;
     }
-    monitor_lines[lines]=CWL_BUTTON;
-    lines++;
     if((ret=setup_line(chip,CWR_BUTTON,CW_ACTIVE_LOW==1))<0) {
       goto err;
     }
-    monitor_lines[lines]=CWR_BUTTON;
-    lines++;
-
   }
   if (ENABLE_GPIO_SIDETONE) {
 //
@@ -1093,7 +1088,11 @@ void gpio_close() {
 void gpio_cw_sidetone_set(int level) {
   int rc;
   if (ENABLE_GPIO_SIDETONE) {
+#ifdef OLD_GPIOD
+    if((rc=gpiod_ctxless_set_value(gpio_device,SIDETONE_GPIO,level,FALSE,consumer,NULL,NULL))<0) {
+#else
     if((rc=gpiod_ctxless_set_value_ext(gpio_device,SIDETONE_GPIO,level,FALSE,consumer,NULL,NULL,0))<0) {
+#endif
       g_print("%s: err=%d\n",__FUNCTION__,rc);
     }
   }
-- 
2.45.2