Browse Source

DevAPI: Add interface for drivers to define custom "Manage device" options

Luke Dashjr 12 years ago
parent
commit
a21e8b4533
2 changed files with 12 additions and 0 deletions
  1. 10 0
      miner.c
  2. 2 0
      miner.h

+ 10 - 0
miner.c

@@ -5962,7 +5962,10 @@ refresh:
 		wlogprint("[E]nable ");
 		wlogprint("[E]nable ");
 	if (cgpu->deven != DEV_DISABLED)
 	if (cgpu->deven != DEV_DISABLED)
 		wlogprint("[D]isable ");
 		wlogprint("[D]isable ");
+	if (drv->proc_tui_wlogprint_choices && likely(cgpu->status != LIFE_INIT))
+		drv->proc_tui_wlogprint_choices(cgpu);
 	wlogprint("\n");
 	wlogprint("\n");
+	wlogprint("Or press Enter when done\n");
 	if (msg)
 	if (msg)
 	{
 	{
 		wattron(logwin, A_BOLD);
 		wattron(logwin, A_BOLD);
@@ -6009,6 +6012,13 @@ refresh:
 			case '\x1b':  // ESC
 			case '\x1b':  // ESC
 			case '\n':
 			case '\n':
 				goto out;
 				goto out;
+			default:
+				if (drv->proc_tui_handle_choice && likely(cgpu->status != LIFE_INIT))
+				{
+					msg = drv->proc_tui_handle_choice(cgpu, input);
+					if (msg)
+						goto refresh;
+				}
 		}
 		}
 	}
 	}
 
 

+ 2 - 0
miner.h

@@ -297,6 +297,8 @@ struct device_drv {
 	bool (*identify_device)(struct cgpu_info *);  // e.g. to flash a led
 	bool (*identify_device)(struct cgpu_info *);  // e.g. to flash a led
 	char *(*set_device)(struct cgpu_info *, char *option, char *setting, char *replybuf);
 	char *(*set_device)(struct cgpu_info *, char *option, char *setting, char *replybuf);
 	void (*proc_wlogprint_status)(struct cgpu_info *);
 	void (*proc_wlogprint_status)(struct cgpu_info *);
+	void (*proc_tui_wlogprint_choices)(struct cgpu_info *);
+	const char *(*proc_tui_handle_choice)(struct cgpu_info *, int input);
 
 
 	// Thread-specific functions
 	// Thread-specific functions
 	bool (*thread_prepare)(struct thr_info *);
 	bool (*thread_prepare)(struct thr_info *);