1
0
forked from drath/libratbag

tools: add 'rate get-all' to the resolutions

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2017-10-17 11:58:16 +10:00
committed by Benjamin Tissoires
parent bacdab2596
commit cb4be02a56
5 changed files with 39 additions and 0 deletions

View File

@@ -44,6 +44,14 @@
}
/* END OF custom typemap for handling ratbag_resolution_get_dpi_list */
/* custom typemap for handling ratbag_resolution_get_report_rate_list */
/* We re-use the ratbag_resolution_get_dpi_list typemap */
%typemap(in) (unsigned int *rates, size_t nrates) = (unsigned int *resolutions, size_t nres);
%typemap(argout) (unsigned int *rates, size_t nrates) = (unsigned int *resolutions, size_t nres);
%typemap(freearg) (unsigned int *rates, size_t nrates) = (unsigned int *resolutions, size_t nres);
/* END OF custom typemap for handling ratbag_resolution_get_report_rate_list */
/* Parse the header file to generate wrappers */
%include "libratbag.h"
%include "libratbag-enums.h"

View File

@@ -484,6 +484,13 @@ class RatbagdResolution(metaclass=MetaRatbag):
n = libratbag.ratbag_resolution_get_dpi_list(self._res, dpis)
return dpis[:n]
@property
def report_rates(self):
"""The list of supported report rates"""
rates = [0 for i in range(300)]
n = libratbag.ratbag_resolution_get_report_rate_list(self._res, rates)
return rates[:n]
@property
def is_active(self):
"""True if this is the currently active resolution, False

View File

@@ -112,6 +112,9 @@ resolution of the active profile if none are given.
.B rate get
Print the report rate in ms
.TP 8
.B rate get-all
Print the supported report rates in ms
.TP 8
.B rate set N
Set the report rate in N ms
.SH Button Commands

View File

@@ -450,6 +450,12 @@ def func_report_rate_get(r, args):
print(r.report_rate)
def func_report_rate_get_all(r, args):
r, p, d = find_resolution(r, args)
rates = r.report_rates
print(" ".join([str(x) for x in rates]))
def func_report_rate_set(r, args):
r, p, d = find_resolution(r, args)
r.report_rate = args.rate_n
@@ -915,6 +921,12 @@ active resolution of the active profile if none are given.""",
help_str: 'Show current report rate',
func: func_report_rate_get,
},
{
of_type: command,
name: 'get-all',
help_str: 'Show all available report rates',
func: func_report_rate_get_all,
},
{
of_type: command,
name: 'set',

View File

@@ -353,6 +353,15 @@ class TestRatbagCtlReportRate(TestRatbagCtl):
self.launch_fail_test(command + " 1 test_device")
self.launch_fail_test(command + " test_device X")
def test_rate_get_all(self):
rate_list = "500 1000"
command = "rate get-all"
r = self.launch_good_test(command + " test_device")
self.assertEqual(r, rate_list)
self.setProfile(1)
r = self.launch_good_test(command + " test_device")
self.assertEqual(r, rate_list)
def test_rate_set(self):
command = "rate set"
r = self.launch_good_test("rate get test_device")