浏览代码

win-capture: Always allow conf. of game capture hotkey

Even if the hotkey is not enabled, always allow configuration of the
hotkey.  Fixes a bug where the hotkey configuration settings would not
save if the settings were changed.

Annoyingly this means that the hotkey will still be shown to the user,
possibly confusing the user as to whether they can use it, but for the
time being it's better than having their hotkey configuration removed
each time they change the mode.
jp9000 9 年之前
父节点
当前提交
06b42f4f27
共有 1 个文件被更改,包括 11 次插入17 次删除
  1. 11 17
      plugins/win-capture/game-capture.c

+ 11 - 17
plugins/win-capture/game-capture.c

@@ -376,8 +376,9 @@ static inline bool capture_needs_reset(struct game_capture_config *cfg1,
 static bool hotkey_start(void *data, obs_hotkey_pair_id id,
 static bool hotkey_start(void *data, obs_hotkey_pair_id id,
 		obs_hotkey_t *hotkey, bool pressed)
 		obs_hotkey_t *hotkey, bool pressed)
 {
 {
-	if (pressed) {
-		struct game_capture *gc = data;
+	struct game_capture *gc = data;
+
+	if (pressed && gc->config.mode == CAPTURE_MODE_HOTKEY) {
 		info("Activate hotkey pressed");
 		info("Activate hotkey pressed");
 		os_atomic_set_long(&gc->hotkey_window,
 		os_atomic_set_long(&gc->hotkey_window,
 				(long)GetForegroundWindow());
 				(long)GetForegroundWindow());
@@ -391,8 +392,9 @@ static bool hotkey_start(void *data, obs_hotkey_pair_id id,
 static bool hotkey_stop(void *data, obs_hotkey_pair_id id,
 static bool hotkey_stop(void *data, obs_hotkey_pair_id id,
 		obs_hotkey_t *hotkey, bool pressed)
 		obs_hotkey_t *hotkey, bool pressed)
 {
 {
-	if (pressed) {
-		struct game_capture *gc = data;
+	struct game_capture *gc = data;
+
+	if (pressed && gc->config.mode == CAPTURE_MODE_HOTKEY) {
 		info("Deactivate hotkey pressed");
 		info("Deactivate hotkey pressed");
 		os_atomic_set_bool(&gc->deactivate_hook, true);
 		os_atomic_set_bool(&gc->deactivate_hook, true);
 	}
 	}
@@ -424,19 +426,6 @@ static void game_capture_update(void *data, obs_data_t *settings)
 	gc->retry_interval = DEFAULT_RETRY_INTERVAL;
 	gc->retry_interval = DEFAULT_RETRY_INTERVAL;
 	gc->wait_for_target_startup = false;
 	gc->wait_for_target_startup = false;
 
 
-	if (cfg.mode == CAPTURE_MODE_HOTKEY) {
-		if (!gc->hotkey_pair) {
-			gc->hotkey_pair = obs_hotkey_pair_register_source(
-					gc->source,
-					HOTKEY_START, TEXT_HOTKEY_START,
-					HOTKEY_STOP,  TEXT_HOTKEY_STOP,
-					hotkey_start, hotkey_stop, gc, gc);
-		}
-	} else if (gc->hotkey_pair) {
-		obs_hotkey_pair_unregister(gc->hotkey_pair);
-		gc->hotkey_pair = 0;
-	}
-
 	dstr_free(&gc->title);
 	dstr_free(&gc->title);
 	dstr_free(&gc->class);
 	dstr_free(&gc->class);
 	dstr_free(&gc->executable);
 	dstr_free(&gc->executable);
@@ -463,6 +452,11 @@ static void *game_capture_create(obs_data_t *settings, obs_source_t *source)
 	gc->source = source;
 	gc->source = source;
 	gc->initial_config = true;
 	gc->initial_config = true;
 	gc->retry_interval = DEFAULT_RETRY_INTERVAL;
 	gc->retry_interval = DEFAULT_RETRY_INTERVAL;
+	gc->hotkey_pair = obs_hotkey_pair_register_source(
+			gc->source,
+			HOTKEY_START, TEXT_HOTKEY_START,
+			HOTKEY_STOP,  TEXT_HOTKEY_STOP,
+			hotkey_start, hotkey_stop, gc, gc);
 
 
 	game_capture_update(gc, settings);
 	game_capture_update(gc, settings);
 	return gc;
 	return gc;