def set_dpi(device_manager):
# Iterate over each device and set DPI
for device in device_manager.devices:
# If -d argument is set, only set those devices
if (args.device and device.name in args.device) or (not args.device):
if (device.type != "mouse"):
if args.verbose:
print("Device {} is not a mouse".format(device.name))
elif args.dpi == "print":
dpi = str(device.dpi)[1:-1].split(', ')
if args.poll == "print":
if dpi[0] == dpi[1]:
print('dpi:',dpi[0])
else:
print('dpi:',dpi[0], dpi[1])
else:
if dpi[0] == dpi[1]:
print(dpi[0])
else:
print(dpi[0], dpi[1])
else:
if args.verbose:
print("Setting DPI of device {} to {}".format(device.name,
args.dpi))
# Save used settings for this device to a file
util.write_settings_to_file(device, dpi=args.dpi)
# Actually set DPI
args.dpi = args.dpi.split(',')
if len(args.dpi) == 1:
args.dpi.append(int(args.dpi[0]))
device.dpi = (int(args.dpi[0]), int(args.dpi[1]))
def set_poll_rate(device_manager):
# Iterate over each device and set Polling Rate
for device in device_manager.devices:
# If -d argument is set, only set those devices
if (args.device and device.name in args.device) or (not args.device):
if device.has("poll_rate"):
if args.poll == "print":
if args.dpi == "print":
print('poll_rate:',device.poll_rate)
else:
print(device.poll_rate)
else:
if args.verbose:
print(
"Setting polling rate of device {} to {}".format(
device.name,
args.poll))
# Actually set Polling Rate
device.poll_rate = int(args.poll)
else:
print("Device does not support setting the polling rate")
Before:
After:
Revised Functions: