Decouple controls from tasks (programmable keys)
They are treated differently in the HID++ 2.0 specification. Observations seem to confirm this difference. For instance, a part of solaar-cli's output: 0: unknown:0022 => Home FN sensitive, is FN, reprogrammable 1: Mail => Mail FN sensitive, is FN, reprogrammable 2: unknown:003E => Search FN sensitive, is FN, reprogrammable
This commit is contained in:
parent
093cca9d21
commit
6e36e33b22
|
@ -25,6 +25,7 @@ from .common import (FirmwareInfo as _FirmwareInfo,
|
||||||
ReprogrammableKeyInfo as _ReprogrammableKeyInfo,
|
ReprogrammableKeyInfo as _ReprogrammableKeyInfo,
|
||||||
KwException as _KwException,
|
KwException as _KwException,
|
||||||
NamedInts as _NamedInts)
|
NamedInts as _NamedInts)
|
||||||
|
from . import special_keys
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
@ -82,30 +83,6 @@ BATTERY_STATUS = _NamedInts(
|
||||||
invalid_battery=0x05,
|
invalid_battery=0x05,
|
||||||
thermal_error=0x06)
|
thermal_error=0x06)
|
||||||
|
|
||||||
KEY = _NamedInts(
|
|
||||||
Volume_Up=0x0001,
|
|
||||||
Volume_Down=0x0002,
|
|
||||||
Mute=0x0003,
|
|
||||||
Play__Pause=0x0004,
|
|
||||||
Next=0x0005,
|
|
||||||
Previous=0x0006,
|
|
||||||
Stop=0x0007,
|
|
||||||
Application_Switcher=0x0008,
|
|
||||||
Calculator=0x000A,
|
|
||||||
Mail=0x000E,
|
|
||||||
Home=0x001A,
|
|
||||||
Music=0x001D,
|
|
||||||
Search=0x0029,
|
|
||||||
Sleep=0x002F)
|
|
||||||
KEY._fallback = lambda x: 'unknown:%04X' % x
|
|
||||||
|
|
||||||
KEY_FLAG = _NamedInts(
|
|
||||||
reprogrammable=0x10,
|
|
||||||
FN_sensitive=0x08,
|
|
||||||
nonstandard=0x04,
|
|
||||||
is_FN=0x02,
|
|
||||||
mse=0x01)
|
|
||||||
|
|
||||||
ERROR = _NamedInts(
|
ERROR = _NamedInts(
|
||||||
unknown=0x01,
|
unknown=0x01,
|
||||||
invalid_argument=0x02,
|
invalid_argument=0x02,
|
||||||
|
@ -285,7 +262,9 @@ class KeysArray(object):
|
||||||
keydata = feature_request(self.device, FEATURE.REPROGRAMMABLE_KEYS, 0x10, index)
|
keydata = feature_request(self.device, FEATURE.REPROGRAMMABLE_KEYS, 0x10, index)
|
||||||
if keydata:
|
if keydata:
|
||||||
key, key_task, flags = _unpack('!HHB', keydata[:5])
|
key, key_task, flags = _unpack('!HHB', keydata[:5])
|
||||||
self.keys[index] = _ReprogrammableKeyInfo(index, KEY[key], KEY[key_task], flags)
|
ctrl_id_text = special_keys.CONTROL[key]
|
||||||
|
ctrl_task_text = special_keys.TASK[key_task]
|
||||||
|
self.keys[index] = _ReprogrammableKeyInfo(index, ctrl_id_text, ctrl_task_text, flags)
|
||||||
|
|
||||||
return self.keys[index]
|
return self.keys[index]
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
#
|
||||||
|
# Reprogrammable keys information
|
||||||
|
#
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
from .common import NamedInts as _NamedInts
|
||||||
|
|
||||||
|
CONTROL = _NamedInts(
|
||||||
|
Volume_Up=0x0001,
|
||||||
|
Volume_Down=0x0002,
|
||||||
|
Mute=0x0003,
|
||||||
|
Play__Pause=0x0004,
|
||||||
|
Next=0x0005,
|
||||||
|
Previous=0x0006,
|
||||||
|
Stop=0x0007,
|
||||||
|
Application_Switcher=0x0008,
|
||||||
|
Calculator=0x000A,
|
||||||
|
Mail=0x000E,
|
||||||
|
Home=0x001A,
|
||||||
|
Music=0x001D,
|
||||||
|
Search=0x0029,
|
||||||
|
Sleep=0x002F,
|
||||||
|
)
|
||||||
|
CONTROL._fallback = lambda x: 'unknown:%04X' % x
|
||||||
|
|
||||||
|
TASK = _NamedInts(
|
||||||
|
Volume_Up=0x0001,
|
||||||
|
Volume_Down=0x0002,
|
||||||
|
Mute=0x0003,
|
||||||
|
Play__Pause=0x0004,
|
||||||
|
Next=0x0005,
|
||||||
|
Previous=0x0006,
|
||||||
|
Stop=0x0007,
|
||||||
|
Application_Switcher=0x0008,
|
||||||
|
Calculator=0x000A,
|
||||||
|
Mail=0x000E,
|
||||||
|
Home=0x001A,
|
||||||
|
Music=0x001D,
|
||||||
|
Search=0x0029,
|
||||||
|
Sleep=0x002F,
|
||||||
|
)
|
||||||
|
TASK._fallback = lambda x: 'unknown:%04X' % x
|
||||||
|
|
||||||
|
KEY_FLAG = _NamedInts(
|
||||||
|
reprogrammable=0x10,
|
||||||
|
FN_sensitive=0x08,
|
||||||
|
nonstandard=0x04,
|
||||||
|
is_FN=0x02,
|
||||||
|
mse=0x01
|
||||||
|
)
|
|
@ -132,7 +132,7 @@ def _print_device(dev, verbose=False):
|
||||||
if dev.power_switch_location:
|
if dev.power_switch_location:
|
||||||
print (" The power switch is located on the", dev.power_switch_location)
|
print (" The power switch is located on the", dev.power_switch_location)
|
||||||
|
|
||||||
from logitech.unifying_receiver import hidpp10, hidpp20
|
from logitech.unifying_receiver import hidpp10, hidpp20, special_keys
|
||||||
if p > 0:
|
if p > 0:
|
||||||
if dev.features:
|
if dev.features:
|
||||||
print (" Supports %d HID++ 2.0 features:" % len(dev.features))
|
print (" Supports %d HID++ 2.0 features:" % len(dev.features))
|
||||||
|
@ -146,7 +146,7 @@ def _print_device(dev, verbose=False):
|
||||||
if dev.keys:
|
if dev.keys:
|
||||||
print (" Has %d reprogrammable keys:" % len(dev.keys))
|
print (" Has %d reprogrammable keys:" % len(dev.keys))
|
||||||
for k in dev.keys:
|
for k in dev.keys:
|
||||||
flags = hidpp20.KEY_FLAG.flag_names(k.flags)
|
flags = special_keys.KEY_FLAG.flag_names(k.flags)
|
||||||
print (" %2d: %-20s => %-20s %s" % (k.index, k.key, k.task, ', '.join(flags)))
|
print (" %2d: %-20s => %-20s %s" % (k.index, k.key, k.task, ', '.join(flags)))
|
||||||
|
|
||||||
if p > 0:
|
if p > 0:
|
||||||
|
|
Loading…
Reference in New Issue