key flags: Move to module of use
The key flags are solely used in hiddpp20 module, thus put them into the module. Related #2273
This commit is contained in:
parent
5a9725ee17
commit
267b0a723d
|
@ -42,6 +42,7 @@ from .common import BatteryLevelApproximation
|
||||||
from .common import BatteryStatus
|
from .common import BatteryStatus
|
||||||
from .common import FirmwareKind
|
from .common import FirmwareKind
|
||||||
from .common import NamedInt
|
from .common import NamedInt
|
||||||
|
from .common import NamedInts
|
||||||
from .hidpp20_constants import CHARGE_STATUS
|
from .hidpp20_constants import CHARGE_STATUS
|
||||||
from .hidpp20_constants import DEVICE_KIND
|
from .hidpp20_constants import DEVICE_KIND
|
||||||
from .hidpp20_constants import ChargeLevel
|
from .hidpp20_constants import ChargeLevel
|
||||||
|
@ -79,6 +80,24 @@ class Device(Protocol):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
# Capabilities and desired software handling for a control
|
||||||
|
# Ref: https://drive.google.com/file/d/10imcbmoxTJ1N510poGdsviEhoFfB_Ua4/view
|
||||||
|
# We treat bytes 4 and 8 of `getCidInfo` as a single bitfield
|
||||||
|
KEY_FLAG = NamedInts(
|
||||||
|
analytics_key_events=0x400,
|
||||||
|
force_raw_XY=0x200,
|
||||||
|
raw_XY=0x100,
|
||||||
|
virtual=0x80,
|
||||||
|
persistently_divertable=0x40,
|
||||||
|
divertable=0x20,
|
||||||
|
reprogrammable=0x10,
|
||||||
|
FN_sensitive=0x08,
|
||||||
|
nonstandard=0x04,
|
||||||
|
is_FN=0x02,
|
||||||
|
mse=0x01,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class FeaturesArray(dict):
|
class FeaturesArray(dict):
|
||||||
def __init__(self, device):
|
def __init__(self, device):
|
||||||
assert device is not None
|
assert device is not None
|
||||||
|
@ -217,7 +236,7 @@ class ReprogrammableKey:
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def flags(self) -> List[str]:
|
def flags(self) -> List[str]:
|
||||||
return special_keys.KEY_FLAG.flag_names(self._flags)
|
return KEY_FLAG.flag_names(self._flags)
|
||||||
|
|
||||||
|
|
||||||
class ReprogrammableKeyV4(ReprogrammableKey):
|
class ReprogrammableKeyV4(ReprogrammableKey):
|
||||||
|
@ -354,11 +373,11 @@ class ReprogrammableKeyV4(ReprogrammableKey):
|
||||||
|
|
||||||
# The capability required to set a given reporting flag.
|
# The capability required to set a given reporting flag.
|
||||||
FLAG_TO_CAPABILITY = {
|
FLAG_TO_CAPABILITY = {
|
||||||
special_keys.MAPPING_FLAG.diverted: special_keys.KEY_FLAG.divertable,
|
special_keys.MAPPING_FLAG.diverted: KEY_FLAG.divertable,
|
||||||
special_keys.MAPPING_FLAG.persistently_diverted: special_keys.KEY_FLAG.persistently_divertable,
|
special_keys.MAPPING_FLAG.persistently_diverted: KEY_FLAG.persistently_divertable,
|
||||||
special_keys.MAPPING_FLAG.analytics_key_events_reporting: special_keys.KEY_FLAG.analytics_key_events,
|
special_keys.MAPPING_FLAG.analytics_key_events_reporting: KEY_FLAG.analytics_key_events,
|
||||||
special_keys.MAPPING_FLAG.force_raw_XY_diverted: special_keys.KEY_FLAG.force_raw_XY,
|
special_keys.MAPPING_FLAG.force_raw_XY_diverted: KEY_FLAG.force_raw_XY,
|
||||||
special_keys.MAPPING_FLAG.raw_XY_diverted: special_keys.KEY_FLAG.raw_XY,
|
special_keys.MAPPING_FLAG.raw_XY_diverted: KEY_FLAG.raw_XY,
|
||||||
}
|
}
|
||||||
|
|
||||||
bfield = 0
|
bfield = 0
|
||||||
|
|
|
@ -580,22 +580,6 @@ class Task(IntEnum):
|
||||||
return self.name.replace("_", " ").title()
|
return self.name.replace("_", " ").title()
|
||||||
|
|
||||||
|
|
||||||
# Capabilities and desired software handling for a control
|
|
||||||
# Ref: https://drive.google.com/file/d/10imcbmoxTJ1N510poGdsviEhoFfB_Ua4/view
|
|
||||||
# We treat bytes 4 and 8 of `getCidInfo` as a single bitfield
|
|
||||||
KEY_FLAG = NamedInts(
|
|
||||||
analytics_key_events=0x400,
|
|
||||||
force_raw_XY=0x200,
|
|
||||||
raw_XY=0x100,
|
|
||||||
virtual=0x80,
|
|
||||||
persistently_divertable=0x40,
|
|
||||||
divertable=0x20,
|
|
||||||
reprogrammable=0x10,
|
|
||||||
FN_sensitive=0x08,
|
|
||||||
nonstandard=0x04,
|
|
||||||
is_FN=0x02,
|
|
||||||
mse=0x01,
|
|
||||||
)
|
|
||||||
# Flags describing the reporting method of a control
|
# Flags describing the reporting method of a control
|
||||||
# We treat bytes 2 and 5 of `get/setCidReporting` as a single bitfield
|
# We treat bytes 2 and 5 of `get/setCidReporting` as a single bitfield
|
||||||
MAPPING_FLAG = NamedInts(
|
MAPPING_FLAG = NamedInts(
|
||||||
|
|
Loading…
Reference in New Issue