mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-08 07:33:53 +01:00
tools: ratbagctl: hook up report rate argparsing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
committed by
Benjamin Tissoires
parent
85f2ec3910
commit
7aed3640c4
@@ -301,6 +301,16 @@ def func_dpi_set(r, args):
|
||||
r.resolution = (args.dpi_n, args.dpi_n)
|
||||
|
||||
|
||||
def func_report_rate_get(r, args):
|
||||
r, p, d = find_resolution(r, args)
|
||||
print(r.report_rate)
|
||||
|
||||
|
||||
def func_report_rate_set(r, args):
|
||||
r, p, d = find_resolution(r, args)
|
||||
r.report_rate = args.rate_n
|
||||
|
||||
|
||||
def func_resolution_get(r, args):
|
||||
r, p, d = find_resolution(r, args)
|
||||
print_resolution(d, p, r, 0)
|
||||
@@ -508,6 +518,10 @@ parser_def = [
|
||||
of_type: link,
|
||||
dest: 'dpi',
|
||||
},
|
||||
{
|
||||
of_type: link,
|
||||
dest: 'rate',
|
||||
},
|
||||
{
|
||||
of_type: link,
|
||||
dest: 'button',
|
||||
@@ -570,6 +584,10 @@ parser_def = [
|
||||
of_type: link,
|
||||
dest: 'dpi',
|
||||
},
|
||||
{
|
||||
of_type: link,
|
||||
dest: 'rate',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -602,6 +620,35 @@ parser_def = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
of_type: switch,
|
||||
name: 'rate',
|
||||
help_str: 'Access report rate information',
|
||||
tag: 'rate',
|
||||
switch: [
|
||||
{
|
||||
of_type: command,
|
||||
name: 'get',
|
||||
help_str: 'Show current report rate',
|
||||
func: func_report_rate_get,
|
||||
},
|
||||
{
|
||||
of_type: command,
|
||||
name: 'set',
|
||||
help_str: 'Set the report rate to N',
|
||||
pos_args: [
|
||||
{
|
||||
of_type: argument,
|
||||
name: 'rate_n',
|
||||
metavar: 'N',
|
||||
help_str: 'The report rate to set as current',
|
||||
arg_type: int,
|
||||
},
|
||||
],
|
||||
func: func_report_rate_set,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
of_type: switch,
|
||||
name: 'button',
|
||||
|
||||
@@ -276,6 +276,43 @@ class TestRatbgagCtlDPI(TestRatbagCtl):
|
||||
self.launch_fail_test("Profile 1 Resolution 1 Resolution 2 DPI get test_device")
|
||||
|
||||
|
||||
class TestRatbgagCtlReportRate(TestRatbagCtl):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestRatbgagCtlReportRate, cls).setUpClass()
|
||||
cls.setProfile(0)
|
||||
|
||||
def test_rate_get(self):
|
||||
command = "rate get"
|
||||
r = self.launch_good_test(command + " test_device")
|
||||
self.assertEqual(int(r), 1000)
|
||||
self.launch_fail_test(command)
|
||||
self.launch_fail_test(command + " 1 test_device")
|
||||
self.launch_fail_test(command + " test_device X")
|
||||
|
||||
def test_rate_set(self):
|
||||
command = "rate set"
|
||||
r = self.launch_good_test("rate get test_device")
|
||||
res = int(r) + 500
|
||||
r = self.launch_good_test(command + " {} test_device".format(res))
|
||||
self.assertEqual(r, '')
|
||||
r = self.launch_good_test("rate get test_device")
|
||||
self.assertEqual(int(r), res)
|
||||
self.launch_fail_test(command)
|
||||
self.launch_fail_test(command + " X test_device")
|
||||
self.launch_fail_test(command + " 100 test_device X")
|
||||
|
||||
def test_prefix_rate(self):
|
||||
r = self.launch_good_test("Profile 1 rate get test_device")
|
||||
self.assertEqual(int(r), 2000)
|
||||
r = self.launch_good_test("Profile 1 Resolution 1 rate get test_device")
|
||||
self.assertEqual(int(r), 2000)
|
||||
r = self.launch_good_test("Resolution 2 rate get test_device")
|
||||
self.assertEqual(int(r), 1000)
|
||||
self.launch_fail_test("Profile 1 Profile 1 rate get test_device")
|
||||
self.launch_fail_test("Profile 1 Resolution 1 Resolution 2 rate get test_device")
|
||||
|
||||
|
||||
class TestRatbgagCtlButton(TestRatbagCtl):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
Reference in New Issue
Block a user