From ee4fb92bd8de76d54ee8b06870cdf502e543b788 Mon Sep 17 00:00:00 2001
From: John Melton G0ORX <john.d.melton@googlemail.com>
Date: Tue, 8 Dec 2020 16:03:13 +0000
Subject: [PATCH] Add i2c controller switch actions

---
 i2c_controller.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/i2c_controller.c b/i2c_controller.c
index 9827f78..12a7c71 100644
--- a/i2c_controller.c
+++ b/i2c_controller.c
@@ -284,6 +284,42 @@ static void i2c_interrupt(int line) {
           //g_print("%s: INT_2\n",__FUNCTION__);
           __s32 i2status=i2c_smbus_read_byte_data(fd,REG_I2STATUS);
           //g_print("%s: i2status=%02X\n",__FUNCTION__,status&0xFF);
+	  if(i2status&GP1_NEG && encoder[i].gp1_enabled) {
+            SWITCH_ACTION *a=g_new(SWITCH_ACTION,1);
+            a->action=encoder[i].gp1_function;
+            a->state=PRESSED;
+            g_idle_add(switch_action,a);
+          }
+          if(i2status&GP1_POS && encoder[i].gp1_enabled) {
+            SWITCH_ACTION *a=g_new(SWITCH_ACTION,1);
+            a->action=encoder[i].gp1_function;
+            a->state=RELEASED;
+            g_idle_add(switch_action,a);
+          }
+          if(i2status&GP2_NEG && encoder[i].gp2_enabled) {
+            SWITCH_ACTION *a=g_new(SWITCH_ACTION,1);
+            a->action=encoder[i].gp2_function;
+            a->state=PRESSED;
+            g_idle_add(switch_action,a);
+          }
+          if(i2status&GP2_POS && encoder[i].gp2_enabled) {
+            SWITCH_ACTION *a=g_new(SWITCH_ACTION,1);
+            a->action=encoder[i].gp2_function;
+            a->state=RELEASED;
+            g_idle_add(switch_action,a);
+          }
+          if(i2status&GP3_NEG && encoder[i].gp3_enabled) {
+            SWITCH_ACTION *a=g_new(SWITCH_ACTION,1);
+            a->action=encoder[i].gp3_function;
+            a->state=PRESSED;
+            g_idle_add(switch_action,a);
+          }
+          if(i2status&GP3_POS && encoder[i].gp3_enabled) {
+            SWITCH_ACTION *a=g_new(SWITCH_ACTION,1);
+            a->action=encoder[i].gp3_function;
+            a->state=RELEASED;
+            g_idle_add(switch_action,a);
+          }
         }
       }
     }
-- 
2.45.2