Merge pull request #351 from mchehab/mx_anywhere2-v5

Mx anywhere2 v5
This commit is contained in:
Peter Wu 2017-09-21 00:16:15 +01:00 committed by GitHub
commit e3d658ea10
5 changed files with 99 additions and 1 deletions

View File

@ -283,7 +283,8 @@ _D('Anywhere Mouse MX', codename='Anywhere MX', protocol=1.0, wpid='1017',
)
_D('Anywhere Mouse MX 2', codename='Anywhere MX 2', protocol=4.5, wpid='404A',
settings=[
_FS.smooth_scroll(),
_FS.hires_smooth_invert(),
_FS.hires_smooth_resolution(),
],
)
_D('Performance Mouse MX', codename='Performance MX', protocol=1.0, wpid='101A',

View File

@ -477,3 +477,30 @@ def get_mouse_pointer_info(device):
'suggest_os_ballistics': suggest_os_ballistics,
'suggest_vertical_orientation': suggest_vertical_orientation
}
def get_hires_wheel(device):
caps = feature_request(device, FEATURE.HIRES_WHEEL, 0x00)
mode = feature_request(device, FEATURE.HIRES_WHEEL, 0x10)
ratchet = feature_request(device, FEATURE.HIRES_WHEEL, 0x030)
if caps and mode and ratchet:
# Parse caps
multi, flags = _unpack('!BB', caps[:2])
has_invert = (flags & 0x08) != 0
has_ratchet = (flags & 0x04) != 0
# Parse mode
wheel_mode, reserved = _unpack('!BB', mode[:2])
target = (wheel_mode & 0x01) != 0
res = (wheel_mode & 0x02) != 0
inv = (wheel_mode & 0x04) != 0
# Parse Ratchet switch
ratchet_mode, reserved = _unpack('!BB', ratchet[:2])
ratchet = (ratchet_mode & 0x01) != 0
return multi, has_invert, has_ratchet, inv, res, target, ratchet

View File

@ -275,4 +275,22 @@ def _process_feature_notification(device, status, n, feature):
_log.warn("%s: unknown TOUCH MOUSE %s", device, n)
return True
if feature == _F.HIRES_WHEEL:
if (n.address == 0x00):
if _log.isEnabledFor(_INFO):
flags, delta_v = _unpack('>bh', n.data[:3])
high_res = (flags & 0x10) != 0
periods = flags & 0x0f
_log.info("%s: WHEEL: res: %d periods: %d delta V:%-3d", device, high_res, periods, delta_v)
return True
elif (n.address == 0x10):
if _log.isEnabledFor(_INFO):
flags = ord(n.data[:1])
ratchet = flags & 0x01
_log.info("%s: WHEEL: ratchet: %d", device, ratchet)
return True
else:
_log.warn("%s: unknown WHEEL %s", device, n)
return True
_log.warn("%s: unrecognized %s for feature %s (index %02X)", device, n, feature, n.sub_id)

View File

@ -118,6 +118,10 @@ def feature_range(name, feature, min_value, max_value,
_SMOOTH_SCROLL = ('smooth-scroll', _("Smooth Scrolling"),
_("High-sensitivity mode for vertical scroll with the wheel."))
_HIRES_INV = ('hires-smooth-invert', _("High Resolution Wheel Invert"),
_("High-sensitivity wheel invert mode for vertical scroll."))
_HIRES_RES = ('hires-smooth-resolution', _("Wheel Resolution"),
_("High-sensitivity mode for vertical scroll with the wheel."))
_SIDE_SCROLL = ('side-scroll', _("Side Scrolling"),
_("When disabled, pushing the wheel sideways sends custom button events\n"
"instead of the standard side-scrolling events."))
@ -184,6 +188,21 @@ def _feature_lowres_smooth_scroll():
return feature_toggle(_SMOOTH_SCROLL[0], _F.LOWRES_WHEEL,
label=_SMOOTH_SCROLL[1], description=_SMOOTH_SCROLL[2],
device_kind=_DK.mouse)
def _feature_hires_smooth_invert():
return feature_toggle(_HIRES_INV[0], _F.HIRES_WHEEL,
read_function_id=0x10,
write_function_id=0x20,
true_value=0x04, mask=0x04,
label=_HIRES_INV[1], description=_HIRES_INV[2],
device_kind=_DK.mouse)
def _feature_hires_smooth_resolution():
return feature_toggle(_HIRES_RES[0], _F.HIRES_WHEEL,
read_function_id=0x10,
write_function_id=0x20,
true_value=0x02, mask=0x02,
label=_HIRES_RES[1], description=_HIRES_RES[2],
device_kind=_DK.mouse)
def _feature_smart_shift():
_MIN_SMART_SHIFT_VALUE = 0
@ -275,6 +294,8 @@ _SETTINGS_LIST = namedtuple('_SETTINGS_LIST', [
'new_fn_swap',
'smooth_scroll',
'lowres_smooth_scroll',
'hires_smooth_invert',
'hires_smooth_resolution',
'side_scroll',
'dpi',
'pointer_speed',
@ -289,6 +310,8 @@ RegisterSettings = _SETTINGS_LIST(
new_fn_swap=None,
smooth_scroll=_register_smooth_scroll,
lowres_smooth_scroll=None,
hires_smooth_invert=None,
hires_smooth_resolution=None,
side_scroll=_register_side_scroll,
dpi=_register_dpi,
pointer_speed=None,
@ -301,6 +324,8 @@ FeatureSettings = _SETTINGS_LIST(
new_fn_swap=_feature_new_fn_swap,
smooth_scroll=_feature_smooth_scroll,
lowres_smooth_scroll=_feature_lowres_smooth_scroll,
hires_smooth_invert=_feature_hires_smooth_invert,
hires_smooth_resolution=_feature_hires_smooth_resolution,
side_scroll=None,
dpi=_feature_adjustable_dpi,
pointer_speed=_feature_pointer_speed,
@ -342,6 +367,8 @@ def check_feature_settings(device, already_known):
check_feature(_SMOOTH_SCROLL[0], _F.HI_RES_SCROLLING)
check_feature(_SMOOTH_SCROLL[0], _F.LOWRES_WHEEL)
check_feature(_HIRES_INV[0], _F.HIRES_WHEEL, "hires_smooth_invert")
check_feature(_HIRES_RES[0], _F.HIRES_WHEEL, "hires_smooth_resolution")
check_feature(_FN_SWAP[0], _F.FN_INVERSION)
check_feature(_FN_SWAP[0], _F.NEW_FN_INVERSION, 'new_fn_swap')
check_feature(_DPI[0], _F.ADJUSTABLE_DPI)

View File

@ -93,6 +93,31 @@ def _print_device(dev):
flags = 0 if flags is None else ord(flags[1:2])
flags = _hidpp20.FEATURE_FLAG.flag_names(flags)
print (' %2d: %-22s {%04X} %s' % (index, feature, feature, ', '.join(flags)))
if feature == _hidpp20.FEATURE.HIRES_WHEEL:
wheel = _hidpp20.get_hires_wheel(dev)
if wheel:
multi, has_invert, has_switch, inv, res, target, ratchet = wheel
print(" Multiplier: %s" % multi)
if has_invert:
print(" Has invert")
if inv:
print(" Inverse wheel motion")
else:
print(" Normal wheel motion")
if has_switch:
print(" Has ratchet switch")
if ratchet:
print(" Normal wheel mode")
else:
print(" Free wheel mode")
if res:
print(" High resolution mode")
else:
print(" Low resolution mode")
if target:
print(" HID++ notification")
else:
print(" HID notification")
if dev.online and dev.keys:
print (' Has %d reprogrammable keys:' % len(dev.keys))