| 1 |
# SPDX-License-Identifier: GPL-2.0-or-later |
| 2 |
|
| 3 |
from openrazer_daemon.dbus_services import endpoint |
| 4 |
|
| 5 |
|
| 6 |
@endpoint('razer.device.scroll', 'setScrollMode', in_sig='y') |
| 7 |
def set_scroll_mode(self, mode): |
| 8 |
""" |
| 9 |
Set the device's scroll mode |
| 10 |
|
| 11 |
:param mode: The mode to set (0 = tactile, 1 = free spin) |
| 12 |
:type mode: int |
| 13 |
""" |
| 14 |
self.logger.debug("DBus call set_scroll_mode") |
| 15 |
|
| 16 |
if mode not in (0, 1): |
| 17 |
raise ValueError("mode has to be 0 or 1") |
| 18 |
|
| 19 |
driver_path = self.get_driver_path('scroll_mode') |
| 20 |
|
| 21 |
with open(driver_path, 'w') as driver_file: |
| 22 |
driver_file.write(str(int(mode))) |
| 23 |
|
| 24 |
|
| 25 |
@endpoint('razer.device.scroll', 'getScrollMode', out_sig='y') |
| 26 |
def get_scroll_mode(self): |
| 27 |
""" |
| 28 |
Get the device's current scroll mode |
| 29 |
|
| 30 |
:return: The device's current scroll mode (0 = tactile, 1 = free spin) |
| 31 |
:rtype: int |
| 32 |
""" |
| 33 |
self.logger.debug("DBus call get_scroll_mode") |
| 34 |
|
| 35 |
driver_path = self.get_driver_path('scroll_mode') |
| 36 |
|
| 37 |
with open(driver_path, 'r') as driver_file: |
| 38 |
return int(driver_file.read().strip()) |
| 39 |
|
| 40 |
|
| 41 |
@endpoint('razer.device.scroll', 'setScrollAcceleration', in_sig='b') |
| 42 |
def set_scroll_acceleration(self, enabled): |
| 43 |
""" |
| 44 |
Set the device's scroll acceleration state |
| 45 |
|
| 46 |
:param enabled: true to enable acceleration, false to disable it |
| 47 |
:type enabled: bool |
| 48 |
""" |
| 49 |
self.logger.debug("DBus call set_scroll_acceleration") |
| 50 |
|
| 51 |
driver_path = self.get_driver_path('scroll_acceleration') |
| 52 |
|
| 53 |
with open(driver_path, 'w') as driver_file: |
| 54 |
driver_file.write(str(int(enabled))) |
| 55 |
|
| 56 |
|
| 57 |
@endpoint('razer.device.scroll', 'getScrollAcceleration', out_sig='b') |
| 58 |
def get_scroll_acceleration(self): |
| 59 |
""" |
| 60 |
Get the device's scroll acceleration state |
| 61 |
|
| 62 |
:return: true if acceleration enabled, false otherwise |
| 63 |
:rtype: bool |
| 64 |
""" |
| 65 |
self.logger.debug("DBus call get_scroll_acceleration") |
| 66 |
|
| 67 |
driver_path = self.get_driver_path('scroll_acceleration') |
| 68 |
|
| 69 |
with open(driver_path, 'r') as driver_file: |
| 70 |
return bool(int(driver_file.read().strip())) |
| 71 |
|
| 72 |
|
| 73 |
@endpoint('razer.device.scroll', 'setScrollSmartReel', in_sig='b') |
| 74 |
def set_scroll_smart_reel(self, enabled): |
| 75 |
""" |
| 76 |
Set the device's "smart reel" state |
| 77 |
|
| 78 |
:param enabled: true to enable smart reel, false to disable it |
| 79 |
:type enabled: bool |
| 80 |
""" |
| 81 |
self.logger.debug("DBus call set_scroll_smart_reel") |
| 82 |
|
| 83 |
driver_path = self.get_driver_path('scroll_smart_reel') |
| 84 |
|
| 85 |
with open(driver_path, 'w') as driver_file: |
| 86 |
driver_file.write(str(int(enabled))) |
| 87 |
|
| 88 |
|
| 89 |
@endpoint('razer.device.scroll', 'getScrollSmartReel', out_sig='b') |
| 90 |
def get_scroll_smart_reel(self): |
| 91 |
""" |
| 92 |
Get the device's "smart reel" state |
| 93 |
|
| 94 |
:return: true if smart reel enabled, false otherwise |
| 95 |
:rtype: bool |
| 96 |
""" |
| 97 |
self.logger.debug("DBus call get_scroll_smart_reel") |
| 98 |
|
| 99 |
driver_path = self.get_driver_path('scroll_smart_reel') |
| 100 |
|
| 101 |
with open(driver_path, 'r') as driver_file: |
| 102 |
return bool(int(driver_file.read().strip())) |