aboutsummaryrefslogtreecommitdiff
path: root/packages/sys-apps/razercfg/files/razercfg-0.17-freq.patch
blob: c6a2da4ac52e5754c008b1a2601fe62bed863ab4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
diff --git a/librazer/librazer.c b/librazer/librazer.c
index 766972d..ed74dcd 100644
--- a/librazer/librazer.c
+++ b/librazer/librazer.c
@@ -425,7 +425,34 @@ static bool mouse_apply_one_config(struct config_file *f,
 		}
 		goto error;
 	} else if (strcasecmp(item, "freq") == 0) {
-		//TODO
+		int profile, freq, i;
+		enum razer_mouse_freq *freqs;
+
+		err = parse_int_int_pair(value, &profile, &freq);
+		if (err == 1) {
+			prof = m->get_active_profile(m);
+			profile = prof->nr + 1;
+		} else if (err)
+			goto error;
+		if (profile < 1 || freq < 1)
+			goto error;
+		prof = find_prof(m, profile - 1);
+		if (!prof)
+			goto error;
+		nr = m->supported_freqs(m, &freqs);
+		if (nr <= 0)
+			goto error;
+		for (i = 0; i < nr; i++) {
+			if (freqs[i] != freq)
+				continue;
+			err = prof->set_freq(prof, freqs[i]);
+			razer_free_freq_list(freqs, nr);
+			if (err)
+				goto error;
+			goto ok;
+		}
+		razer_free_freq_list(freqs, nr);
+		goto error;
 	} else if (strcasecmp(item, "led") == 0) {
 		bool on;
 		struct razer_led *leds, *led;