From 148cb04452d65a9b146014f4901f34d8ac98fc24 Mon Sep 17 00:00:00 2001
From: John Melton G0ORX <john.d.melton@googlemail.com>
Date: Tue, 8 Dec 2020 14:20:27 +0000
Subject: [PATCH] Fixup switch selectiosn for NO Controller

---
 gpio.c        |  4 ++--
 new_menu.c    |  6 ++++++
 switch_menu.c | 12 ++++++------
 3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/gpio.c b/gpio.c
index bd8ba54..ca48856 100644
--- a/gpio.c
+++ b/gpio.c
@@ -286,7 +286,7 @@ SWITCH switches_controller2_v2[MAX_SWITCHES]={
   {FALSE,FALSE,0,CTUN}
   };
 
-SWITCH *switches=switches_no_controller;
+SWITCH *switches=switches_controller1[0];
 
 static int running=0;
 
@@ -642,7 +642,7 @@ void gpio_set_defaults(int ctrlr) {
   switch(ctrlr) {
     case NO_CONTROLLER:
       encoders=encoders_no_controller;
-      switches=switches_no_controller;
+      switches=switches_controller1[0];
       break;
     case CONTROLLER1:
       encoders=encoders_controller1;
diff --git a/new_menu.c b/new_menu.c
index 0374e8b..98fe564 100644
--- a/new_menu.c
+++ b/new_menu.c
@@ -593,6 +593,12 @@ void new_menu()
 #ifdef GPIO
     switch(controller) {
       case NO_CONTROLLER:
+	{
+        GtkWidget *switches_b=gtk_button_new_with_label("Switches");
+        g_signal_connect (switches_b, "button-press-event", G_CALLBACK(switch_cb), NULL);
+        gtk_grid_attach(GTK_GRID(grid),switches_b,(i%5),i/5,1,1);
+        i++;
+        }
         break;
       case CONTROLLER1:
       case CONTROLLER2_V1:
diff --git a/switch_menu.c b/switch_menu.c
index 02e740b..4148779 100644
--- a/switch_menu.c
+++ b/switch_menu.c
@@ -136,7 +136,7 @@ void switch_menu(GtkWidget *parent) {
 
   function=0;
 
-  if(controller==CONTROLLER1) {
+  if(controller==NO_CONTROLLER || controller==CONTROLLER1) {
     notebook=gtk_notebook_new();
   }
  
@@ -155,8 +155,8 @@ next_function_set:
   gint max_switches=MAX_SWITCHES;
   switch(controller) {
     case NO_CONTROLLER:
-      max_switches=0;
-      temp_switches=switches_no_controller;
+      max_switches=8;
+      temp_switches=switches_controller1[function];
       break;
     case CONTROLLER1:
       max_switches=8;
@@ -178,7 +178,7 @@ next_function_set:
   col++;
 
   widget=gtk_label_new(NULL);
-  gtk_label_set_markup(GTK_LABEL(widget),"<b>Function</b>");
+  gtk_label_set_markup(GTK_LABEL(widget),"<b>Action</b>");
   gtk_grid_attach(GTK_GRID(grid),widget,col,row,1,1);
 
   row++;
@@ -191,7 +191,7 @@ next_function_set:
     gtk_grid_attach(GTK_GRID(grid),widget,col,row,1,1);
     col++;
 
-    if(controller==CONTROLLER1 && (i==0 || i==(max_switches-1))) {
+    if((controller==NO_CONTROLLER || controller==CONTROLLER1) && (i==0 || i==(max_switches-1))) {
       widget=gtk_label_new(NULL);
       g_sprintf(label,"<b>%s</b>",sw_string[temp_switches[i].switch_function]);
       gtk_label_set_markup (GTK_LABEL(widget), label);
@@ -205,7 +205,7 @@ next_function_set:
     col=0;
   }
 
-  if(controller==CONTROLLER1) {
+  if(controller==NO_CONTROLLER || controller==CONTROLLER1) {
     g_sprintf(label,"Function %d",function);
     gtk_notebook_append_page(GTK_NOTEBOOK(notebook),grid,gtk_label_new(label));
     function++;
-- 
2.45.2