Remove NamedInts: Convert Task to enum
Refactor code related to task and task ID. Related #2273
This commit is contained in:
parent
b74e789715
commit
4c160d1723
|
@ -192,11 +192,11 @@ class ReprogrammableKey:
|
|||
- flags {List[str]} -- capabilities and desired software handling of the control
|
||||
"""
|
||||
|
||||
def __init__(self, device: Device, index, cid, tid, flags):
|
||||
def __init__(self, device: Device, index, cid, task_id, flags):
|
||||
self._device = device
|
||||
self.index = index
|
||||
self._cid = cid
|
||||
self._tid = tid
|
||||
self._tid = task_id
|
||||
self._flags = flags
|
||||
|
||||
@property
|
||||
|
@ -209,7 +209,10 @@ class ReprogrammableKey:
|
|||
while the name is the Control ID's native task. But this makes more sense
|
||||
than presenting details of controls vs tasks in the interface. The same
|
||||
convention applies to `mapped_to`, `remappable_to`, `remap` in `ReprogrammableKeyV4`."""
|
||||
task = str(special_keys.TASK[self._tid])
|
||||
try:
|
||||
task = str(special_keys.Task(self._tid))
|
||||
except ValueError:
|
||||
task = f"unknown:{self._tid:04X}"
|
||||
return NamedInt(self._cid, task)
|
||||
|
||||
@property
|
||||
|
@ -234,8 +237,8 @@ class ReprogrammableKeyV4(ReprogrammableKey):
|
|||
- mapping_flags {List[str]} -- mapping flags set on the control
|
||||
"""
|
||||
|
||||
def __init__(self, device: Device, index, cid, tid, flags, pos, group, gmask):
|
||||
ReprogrammableKey.__init__(self, device, index, cid, tid, flags)
|
||||
def __init__(self, device: Device, index, cid, task_id, flags, pos, group, gmask):
|
||||
ReprogrammableKey.__init__(self, device, index, cid, task_id, flags)
|
||||
self.pos = pos
|
||||
self.group = group
|
||||
self._gmask = gmask
|
||||
|
@ -251,7 +254,7 @@ class ReprogrammableKeyV4(ReprogrammableKey):
|
|||
if self._mapped_to is None:
|
||||
self._getCidReporting()
|
||||
self._device.keys._ensure_all_keys_queried()
|
||||
task = str(special_keys.TASK[self._device.keys.cid_to_tid[self._mapped_to]])
|
||||
task = str(special_keys.Task(self._device.keys.cid_to_tid[self._mapped_to]))
|
||||
return NamedInt(self._mapped_to, task)
|
||||
|
||||
@property
|
||||
|
@ -263,7 +266,11 @@ class ReprogrammableKeyV4(ReprogrammableKey):
|
|||
for g in self.group_mask:
|
||||
g = special_keys.CidGroup[str(g)]
|
||||
for tgt_cid in self._device.keys.group_cids[g]:
|
||||
tgt_task = str(special_keys.TASK[self._device.keys.cid_to_tid[tgt_cid]])
|
||||
cid = self._device.keys.cid_to_tid[tgt_cid]
|
||||
try:
|
||||
tgt_task = str(special_keys.Task(cid))
|
||||
except ValueError:
|
||||
tgt_task = f"unknown:{cid:04X}"
|
||||
tgt_task = NamedInt(tgt_cid, tgt_task)
|
||||
if tgt_task != self.default_task: # don't put itself in twice
|
||||
ret[tgt_task] = tgt_task
|
||||
|
@ -524,9 +531,9 @@ class KeysArrayV2(KeysArray):
|
|||
raise IndexError(index)
|
||||
keydata = self.device.feature_request(SupportedFeature.REPROG_CONTROLS, 0x10, index)
|
||||
if keydata:
|
||||
cid, tid, flags = struct.unpack("!HHB", keydata[:5])
|
||||
self.keys[index] = ReprogrammableKey(self.device, index, cid, tid, flags)
|
||||
self.cid_to_tid[cid] = tid
|
||||
cid, task_id, flags = struct.unpack("!HHB", keydata[:5])
|
||||
self.keys[index] = ReprogrammableKey(self.device, index, cid, task_id, flags)
|
||||
self.cid_to_tid[cid] = task_id
|
||||
elif logger.isEnabledFor(logging.WARNING):
|
||||
logger.warning(f"Key with index {index} was expected to exist but device doesn't report it.")
|
||||
|
||||
|
@ -540,10 +547,10 @@ class KeysArrayV4(KeysArrayV2):
|
|||
raise IndexError(index)
|
||||
keydata = self.device.feature_request(SupportedFeature.REPROG_CONTROLS_V4, 0x10, index)
|
||||
if keydata:
|
||||
cid, tid, flags1, pos, group, gmask, flags2 = struct.unpack("!HHBBBBB", keydata[:9])
|
||||
cid, task_id, flags1, pos, group, gmask, flags2 = struct.unpack("!HHBBBBB", keydata[:9])
|
||||
flags = flags1 | (flags2 << 8)
|
||||
self.keys[index] = ReprogrammableKeyV4(self.device, index, cid, tid, flags, pos, group, gmask)
|
||||
self.cid_to_tid[cid] = tid
|
||||
self.keys[index] = ReprogrammableKeyV4(self.device, index, cid, task_id, flags, pos, group, gmask)
|
||||
self.cid_to_tid[cid] = task_id
|
||||
if group != 0: # 0 = does not belong to a group
|
||||
self.group_cids[special_keys.CidGroup(group)].append(cid)
|
||||
elif logger.isEnabledFor(logging.WARNING):
|
||||
|
|
|
@ -323,255 +323,263 @@ CONTROL[0x1200] = "MR" # add in MR key - this is not really a Logitech Control
|
|||
|
||||
CONTROL._fallback = lambda x: f"unknown:{x:04X}"
|
||||
|
||||
# <tasks.xml awk -F\" '/<Task /{gsub(/ /, "_", $6); printf("\t%s=0x%04X,\n", $6, $4)}'
|
||||
TASK = NamedInts(
|
||||
Volume_Up=0x0001,
|
||||
Volume_Down=0x0002,
|
||||
Mute=0x0003,
|
||||
|
||||
class Task(IntEnum):
|
||||
"""
|
||||
<tasks.xml awk -F\" '/<Task /{gsub(/ /, "_", $6); printf("\t%s=0x%04X,\n", $6, $4)}'
|
||||
"""
|
||||
|
||||
VOLUME_UP = 0x0001
|
||||
VOLUME_DOWN = 0x0002
|
||||
MUTE = 0x0003
|
||||
# Multimedia tasks:
|
||||
Play__Pause=0x0004,
|
||||
Next=0x0005,
|
||||
Previous=0x0006,
|
||||
Stop=0x0007,
|
||||
Application_Switcher=0x0008,
|
||||
BurnMediaPlayer=0x0009,
|
||||
Calculator=0x000A,
|
||||
Calendar=0x000B,
|
||||
Close_Application=0x000C,
|
||||
Eject=0x000D,
|
||||
Email=0x000E,
|
||||
Help=0x000F,
|
||||
OffDocument=0x0010,
|
||||
OffSpreadsheet=0x0011,
|
||||
OffPowerpnt=0x0012,
|
||||
Undo=0x0013,
|
||||
Redo=0x0014,
|
||||
Print=0x0015,
|
||||
Save=0x0016,
|
||||
SmartKeySet=0x0017,
|
||||
Favorites=0x0018,
|
||||
GadgetsSet=0x0019,
|
||||
HomePage=0x001A,
|
||||
WindowsRestore=0x001B,
|
||||
WindowsMinimize=0x001C,
|
||||
Music=0x001D, # also known as MediaPlayer
|
||||
PLAY_PAUSE = 0x0004
|
||||
NEXT = 0x0005
|
||||
PREVIOUS = 0x0006
|
||||
STOP = 0x0007
|
||||
APPLICATION_SWITCHER = 0x0008
|
||||
BURN_MEDIA_PLAYER = 0x0009
|
||||
CALCULATOR = 0x000A
|
||||
CALENDAR = 0x000B
|
||||
CLOSE_APPLICATION = 0x000C
|
||||
EJECT = 0x000D
|
||||
EMAIL = 0x000E
|
||||
HELP = 0x000F
|
||||
OFF_DOCUMENT = 0x0010
|
||||
OFF_SPREADSHEET = 0x0011
|
||||
OFF_POWERPNT = 0x0012
|
||||
UNDO = 0x0013
|
||||
REDO = 0x0014
|
||||
PRINT = 0x0015
|
||||
SAVE = 0x0016
|
||||
SMART_KEY_SET = 0x0017
|
||||
FAVORITES = 0x0018
|
||||
GADGETS_SET = 0x0019
|
||||
HOME_PAGE = 0x001A
|
||||
WINDOWS_RESTORE = 0x001B
|
||||
WINDOWS_MINIMIZE = 0x001C
|
||||
MUSIC = 0x001D # also known as MediaPlayer
|
||||
# Both 0x001E and 0x001F are known as MediaCenterSet
|
||||
Media_Center_Logitech=0x001E,
|
||||
Media_Center_Microsoft=0x001F,
|
||||
UserMenu=0x0020,
|
||||
Messenger=0x0021,
|
||||
PersonalFolders=0x0022,
|
||||
MyMusic=0x0023,
|
||||
Webcam=0x0024,
|
||||
PicturesFolder=0x0025,
|
||||
MyVideos=0x0026,
|
||||
My_Computer=0x0027,
|
||||
PictureAppSet=0x0028,
|
||||
Search=0x0029, # also known as AdvSmartSearch
|
||||
RecordMediaPlayer=0x002A,
|
||||
BrowserRefresh=0x002B,
|
||||
RotateRight=0x002C,
|
||||
Search_Files=0x002D, # SearchForFiles
|
||||
MM_SHUFFLE=0x002E,
|
||||
Sleep=0x002F, # also known as StandBySet
|
||||
BrowserStop=0x0030,
|
||||
OneTouchSync=0x0031,
|
||||
ZoomSet=0x0032,
|
||||
ZoomBtnInSet2=0x0033,
|
||||
ZoomBtnInSet=0x0034,
|
||||
ZoomBtnOutSet2=0x0035,
|
||||
ZoomBtnOutSet=0x0036,
|
||||
ZoomBtnResetSet=0x0037,
|
||||
Left_Click=0x0038, # LeftClick
|
||||
Right_Click=0x0039, # RightClick
|
||||
Mouse_Middle_Button=0x003A, # from M510v2 was MiddleMouseButton
|
||||
Back=0x003B,
|
||||
Mouse_Back_Button=0x003C, # from M510v2 was BackEx
|
||||
BrowserForward=0x003D,
|
||||
Mouse_Forward_Button=0x003E, # from M510v2 was BrowserForwardEx
|
||||
Mouse_Scroll_Left_Button_=0x003F, # from M510v2 was HorzScrollLeftSet
|
||||
Mouse_Scroll_Right_Button=0x0040, # from M510v2 was HorzScrollRightSet
|
||||
QuickSwitch=0x0041,
|
||||
BatteryStatus=0x0042,
|
||||
Show_Desktop=0x0043, # ShowDesktop
|
||||
WindowsLock=0x0044,
|
||||
FileLauncher=0x0045,
|
||||
FolderLauncher=0x0046,
|
||||
GotoWebAddress=0x0047,
|
||||
GenericMouseButton=0x0048,
|
||||
KeystrokeAssignment=0x0049,
|
||||
LaunchProgram=0x004A,
|
||||
MinMaxWindow=0x004B,
|
||||
VOLUMEMUTE_NoOSD=0x004C,
|
||||
New=0x004D,
|
||||
Copy=0x004E,
|
||||
CruiseDown=0x004F,
|
||||
CruiseUp=0x0050,
|
||||
Cut=0x0051,
|
||||
Do_Nothing=0x0052,
|
||||
PageDown=0x0053,
|
||||
PageUp=0x0054,
|
||||
Paste=0x0055,
|
||||
SearchPicture=0x0056,
|
||||
Reply=0x0057,
|
||||
PhotoGallerySet=0x0058,
|
||||
MM_REWIND=0x0059,
|
||||
MM_FASTFORWARD=0x005A,
|
||||
Send=0x005B,
|
||||
ControlPanel=0x005C,
|
||||
UniversalScroll=0x005D,
|
||||
AutoScroll=0x005E,
|
||||
GenericButton=0x005F,
|
||||
MM_NEXT=0x0060,
|
||||
MM_PREVIOUS=0x0061,
|
||||
Do_Nothing_One=0x0062, # also known as Do_Nothing
|
||||
SnapLeft=0x0063,
|
||||
SnapRight=0x0064,
|
||||
WinMinRestore=0x0065,
|
||||
WinMaxRestore=0x0066,
|
||||
WinStretch=0x0067,
|
||||
SwitchMonitorLeft=0x0068,
|
||||
SwitchMonitorRight=0x0069,
|
||||
ShowPresentation=0x006A,
|
||||
ShowMobilityCenter=0x006B,
|
||||
HorzScrollNoRepeatSet=0x006C,
|
||||
TouchBackForwardHorzScroll=0x0077,
|
||||
MetroAppSwitch=0x0078,
|
||||
MetroAppBar=0x0079,
|
||||
MetroCharms=0x007A,
|
||||
Calculator_VKEY=0x007B, # also known as Calculator
|
||||
MetroSearch=0x007C,
|
||||
MetroStartScreen=0x0080,
|
||||
MetroShare=0x007D,
|
||||
MetroSettings=0x007E,
|
||||
MetroDevices=0x007F,
|
||||
MetroBackLeftHorz=0x0082,
|
||||
MetroForwRightHorz=0x0083,
|
||||
Win8_Back=0x0084, # also known as MetroCharms
|
||||
Win8_Forward=0x0085, # also known as AppSwitchBar
|
||||
Win8Charm_Appswitch_GifAnimation=0x0086,
|
||||
Win8BackHorzLeft=0x008B, # also known as Back
|
||||
Win8ForwardHorzRight=0x008C, # also known as BrowserForward
|
||||
MetroSearch2=0x0087,
|
||||
MetroShare2=0x0088,
|
||||
MetroSettings2=0x008A,
|
||||
MetroDevices2=0x0089,
|
||||
Win8MetroWin7Forward=0x008D, # also known as MetroStartScreen
|
||||
Win8ShowDesktopWin7Back=0x008E, # also known as ShowDesktop
|
||||
MetroApplicationSwitch=0x0090, # also known as MetroStartScreen
|
||||
ShowUI=0x0092,
|
||||
MEDIA_CENTER_LOGITECH = 0x001E
|
||||
MEDIA_CENTER_MICROSOFT = 0x001F
|
||||
USER_MENU = 0x0020
|
||||
MESSENGER = 0x0021
|
||||
PERSONAL_FOLDERS = 0x0022
|
||||
MY_MUSIC = 0x0023
|
||||
WEBCAM = 0x0024
|
||||
PICTURES_FOLDER = 0x0025
|
||||
MY_VIDEOS = 0x0026
|
||||
MY_COMPUTER = 0x0027
|
||||
PICTURE_APP_SET = 0x0028
|
||||
SEARCH = 0x0029 # also known as AdvSmartSearch
|
||||
RECORD_MEDIA_PLAYER = 0x002A
|
||||
BROWSER_REFRESH = 0x002B
|
||||
ROTATE_RIGHT = 0x002C
|
||||
SEARCH_FILES = 0x002D # SearchForFiles
|
||||
MM_SHUFFLE = 0x002E
|
||||
SLEEP = 0x002F # also known as StandBySet
|
||||
BROWSER_STOP = 0x0030
|
||||
ONE_TOUCH_SYNC = 0x0031
|
||||
ZOOM_SET = 0x0032
|
||||
ZOOM_BTN_IN_SET_2 = 0x0033
|
||||
ZOOM_BTN_IN_SET = 0x0034
|
||||
ZOOM_BTN_OUT_SET_2 = 0x0035
|
||||
ZOOM_BTN_OUT_SET = 0x0036
|
||||
ZOOM_BTN_RESET_SET = 0x0037
|
||||
LEFT_CLICK = 0x0038 # LeftClick
|
||||
RIGHT_CLICK = 0x0039 # RightClick
|
||||
MOUSE_MIDDLE_BUTTON = 0x003A # from M510v2 was MiddleMouseButton
|
||||
BACK = 0x003B
|
||||
MOUSE_BACK_BUTTON = 0x003C # from M510v2 was BackEx
|
||||
BROWSER_FORWARD = 0x003D
|
||||
MOUSE_FORWARD_BUTTON = 0x003E # from M510v2 was BrowserForwardEx
|
||||
MOUSE_SCROLL_LEFT_BUTTON = 0x003F # from M510v2 was HorzScrollLeftSet
|
||||
MOUSE_SCROLL_RIGHT_BUTTON = 0x0040 # from M510v2 was HorzScrollRightSet
|
||||
QUICK_SWITCH = 0x0041
|
||||
BATTERY_STATUS = 0x0042
|
||||
SHOW_DESKTOP = 0x0043 # ShowDesktop
|
||||
WINDOWS_LOCK = 0x0044
|
||||
FILE_LAUNCHER = 0x0045
|
||||
FOLDER_LAUNCHER = 0x0046
|
||||
GOTO_WEB_ADDRESS = 0x0047
|
||||
GENERIC_MOUSE_BUTTON = 0x0048
|
||||
KEYSTROKE_ASSIGNMENT = 0x0049
|
||||
LAUNCH_PROGRAM = 0x004A
|
||||
MIN_MAX_WINDOW = 0x004B
|
||||
VOLUME_MUTE_NO_OSD = 0x004C
|
||||
NEW = 0x004D
|
||||
COPY = 0x004E
|
||||
CRUISE_DOWN = 0x004F
|
||||
CRUISE_UP = 0x0050
|
||||
CUT = 0x0051
|
||||
DO_NOTHING = 0x0052
|
||||
PAGE_DOWN = 0x0053
|
||||
PAGE_UP = 0x0054
|
||||
PASTE = 0x0055
|
||||
SEARCH_PICTURE = 0x0056
|
||||
REPLY = 0x0057
|
||||
PHOTO_GALLERY_SET = 0x0058
|
||||
MM_REWIND = 0x0059
|
||||
MM_FASTFORWARD = 0x005A
|
||||
SEND = 0x005B
|
||||
CONTROL_PANEL = 0x005C
|
||||
UNIVERSAL_SCROLL = 0x005D
|
||||
AUTO_SCROLL = 0x005E
|
||||
GENERIC_BUTTON = 0x005F
|
||||
MM_NEXT = 0x0060
|
||||
MM_PREVIOUS = 0x0061
|
||||
DO_NOTHING_ONE = 0x0062 # also known as Do_Nothing
|
||||
SNAP_LEFT = 0x0063
|
||||
SNAP_RIGHT = 0x0064
|
||||
WIN_MIN_RESTORE = 0x0065
|
||||
WIN_MAX_RESTORE = 0x0066
|
||||
WIN_STRETCH = 0x0067
|
||||
SWITCH_MONITOR_LEFT = 0x0068
|
||||
SWITCH_MONITOR_RIGHT = 0x0069
|
||||
SHOW_PRESENTATION = 0x006A
|
||||
SHOW_MOBILITY_CENTER = 0x006B
|
||||
HORZ_SCROLL_NO_REPEAT_SET = 0x006C
|
||||
TOUCH_BACK_FORWARD_HORZ_SCROLL = 0x0077
|
||||
METRO_APP_SWITCH = 0x0078
|
||||
METRO_APP_BAR = 0x0079
|
||||
METRO_CHARMS = 0x007A
|
||||
CALCULATOR_VKEY = 0x007B # also known as Calculator
|
||||
METRO_SEARCH = 0x007C
|
||||
METRO_START_SCREEN = 0x0080
|
||||
METRO_SHARE = 0x007D
|
||||
METRO_SETTINGS = 0x007E
|
||||
METRO_DEVICES = 0x007F
|
||||
METRO_BACK_LEFT_HORZ = 0x0082
|
||||
METRO_FORW_RIGHT_HORZ = 0x0083
|
||||
WIN8_BACK = 0x0084 # also known as MetroCharms
|
||||
WIN8_FORWARD = 0x0085 # also known as AppSwitchBar
|
||||
WIN8_CHARM_APPSWITCH_GIF_ANIMATION = 0x0086
|
||||
WIN8_BACK_HORZ_LEFT = 0x008B # also known as Back
|
||||
WIN8_FORWARD_HORZ_RIGHT = 0x008C # also known as BrowserForward
|
||||
METRO_SEARCH_2 = 0x0087
|
||||
METROA_SHARE_2 = 0x0088
|
||||
METRO_SETTINGS_2 = 0x008A
|
||||
METRO_DEVICES_2 = 0x0089
|
||||
WIN8_METRO_WIN7_FORWARD = 0x008D # also known as MetroStartScreen
|
||||
WIN8_SHOW_DESKTOP_WIN7_BACK = 0x008E # also known as ShowDesktop
|
||||
METRO_APPLICATION_SWITCH = 0x0090 # also known as MetroStartScreen
|
||||
SHOW_UI = 0x0092
|
||||
# https://docs.google.com/document/d/1Dpx_nWRQAZox_zpZ8SNc9nOkSDE9svjkghOCbzopabc/edit
|
||||
# Extract to csv. Eliminate extra linefeeds and spaces. Turn / into __ and space into _
|
||||
# awk -F, '/0x/{gsub(" \\+ ","_",$2); gsub("_-","_Down",$2); gsub("_\\+","_Up",$2);
|
||||
# gsub("[()\"-]","",$2); gsub(" ","_",$2); printf("\t%s=0x%04X,\n", $2, $1)}' < tasks.csv > tasks.py
|
||||
Switch_Presentation__Switch_Screen=0x0093, # on K400 Plus
|
||||
Minimize_Window=0x0094,
|
||||
Maximize_Window=0x0095, # on K400 Plus
|
||||
MultiPlatform_App_Switch=0x0096,
|
||||
MultiPlatform_Home=0x0097,
|
||||
MultiPlatform_Menu=0x0098,
|
||||
MultiPlatform_Back=0x0099,
|
||||
Switch_Language=0x009A, # Mac_switch_language
|
||||
Screen_Capture=0x009B, # Mac_screen_Capture, on Craft Keyboard
|
||||
Gesture_Button=0x009C,
|
||||
Smart_Shift=0x009D,
|
||||
AppExpose=0x009E,
|
||||
Smart_Zoom=0x009F,
|
||||
Lookup=0x00A0,
|
||||
Microphone_on__off=0x00A1,
|
||||
Wifi_on__off=0x00A2,
|
||||
Brightness_Down=0x00A3,
|
||||
Brightness_Up=0x00A4,
|
||||
Display_Out=0x00A5,
|
||||
View_Open_Apps=0x00A6,
|
||||
View_All_Open_Apps=0x00A7,
|
||||
AppSwitch=0x00A8,
|
||||
Gesture_Button_Navigation=0x00A9, # Mouse_Thumb_Button on MX Master
|
||||
Fn_inversion=0x00AA,
|
||||
Multiplatform_Back=0x00AB,
|
||||
Multiplatform_Forward=0x00AC,
|
||||
Multiplatform_Gesture_Button=0x00AD,
|
||||
HostSwitch_Channel_1=0x00AE,
|
||||
HostSwitch_Channel_2=0x00AF,
|
||||
HostSwitch_Channel_3=0x00B0,
|
||||
Multiplatform_Search=0x00B1,
|
||||
Multiplatform_Home__Mission_Control=0x00B2,
|
||||
Multiplatform_Menu__Launchpad=0x00B3,
|
||||
Virtual_Gesture_Button=0x00B4,
|
||||
Cursor=0x00B5,
|
||||
Keyboard_Right_Arrow=0x00B6,
|
||||
SW_Custom_Highlight=0x00B7,
|
||||
Keyboard_Left_Arrow=0x00B8,
|
||||
TBD=0x00B9,
|
||||
Multiplatform_Language_Switch=0x00BA,
|
||||
SW_Custom_Highlight_2=0x00BB,
|
||||
Fast_Forward=0x00BC,
|
||||
Fast_Backward=0x00BD,
|
||||
Switch_Highlighting=0x00BE,
|
||||
Mission_Control__Task_View=0x00BF, # Switch_Workspace on Craft Keyboard
|
||||
Dashboard_Launchpad__Action_Center=0x00C0, # Application_Launcher on Craft Keyboard
|
||||
Backlight_Down=0x00C1, # Backlight_Down_FW_internal_function
|
||||
Backlight_Up=0x00C2, # Backlight_Up_FW_internal_function
|
||||
Right_Click__App_Contextual_Menu=0x00C3, # Context_Menu on Craft Keyboard
|
||||
DPI_Change=0x00C4,
|
||||
New_Tab=0x00C5,
|
||||
F2=0x00C6,
|
||||
F3=0x00C7,
|
||||
F4=0x00C8,
|
||||
F5=0x00C9,
|
||||
F6=0x00CA,
|
||||
F7=0x00CB,
|
||||
F8=0x00CC,
|
||||
F1=0x00CD,
|
||||
Laser_Button=0x00CE,
|
||||
Laser_Button_Long_Press=0x00CF,
|
||||
Start_Presentation=0x00D0,
|
||||
Blank_Screen=0x00D1,
|
||||
DPI_Switch=0x00D2, # AdjustDPI on MX Vertical
|
||||
Home__Show_Desktop=0x00D3,
|
||||
App_Switch__Dashboard=0x00D4,
|
||||
App_Switch=0x00D5,
|
||||
Fn_Inversion=0x00D6,
|
||||
LeftAndRightClick=0x00D7,
|
||||
Voice_Dictation=0x00D8,
|
||||
Emoji_Smiling_Face_With_Heart_Shaped_Eyes=0x00D9,
|
||||
Emoji_Loudly_Crying_Face=0x00DA,
|
||||
Emoji_Smiley=0x00DB,
|
||||
Emoji_Smiley_With_Tears=0x00DC,
|
||||
Open_Emoji_Panel=0x00DD,
|
||||
Multiplatform_App_Switch__Launchpad=0x00DE,
|
||||
Snipping_Tool=0x00DF,
|
||||
Grave_Accent=0x00E0,
|
||||
Standard_Tab_Key=0x00E1,
|
||||
Caps_Lock=0x00E2,
|
||||
Left_Shift=0x00E3,
|
||||
Left_Control=0x00E4,
|
||||
Left_Option__Start=0x00E5,
|
||||
Left_Command__Alt=0x00E6,
|
||||
Right_Command__Alt=0x00E7,
|
||||
Right_Option__Start=0x00E8,
|
||||
Right_Control=0x00E9,
|
||||
Right_Shift=0x0EA,
|
||||
Insert=0x00EB,
|
||||
Delete=0x00EC,
|
||||
Home=0x00ED,
|
||||
End=0x00EE,
|
||||
Page_Up=0x00EF,
|
||||
Page_Down=0x00F0,
|
||||
Mute_Microphone=0x00F1,
|
||||
Do_Not_Disturb=0x00F2,
|
||||
Backslash=0x00F3,
|
||||
Refresh=0x00F4,
|
||||
Close_Tab=0x00F5,
|
||||
Lang_Switch=0x00F6,
|
||||
Standard_Alphabetical_Key=0x00F7,
|
||||
Right_Option__Start__2=0x00F8,
|
||||
Left_Option=0x00F9,
|
||||
Right_Option=0x00FA,
|
||||
Left_Cmd=0x00FB,
|
||||
Right_Cmd=0x00FC,
|
||||
)
|
||||
TASK._fallback = lambda x: f"unknown:{x:04X}"
|
||||
SWITCH_PRESENTATION_SWITCH_SCREEN = 0x0093 # on K400 Plus
|
||||
MINIMIZE_WINDOW = 0x0094
|
||||
MAXIMIZE_WINDOW = 0x0095 # on K400 Plus
|
||||
MULTI_PLATFORM_APP_SWITCH = 0x0096
|
||||
MULTI_PLATFORM_HOME = 0x0097
|
||||
MULTI_PLATFORM_MENU = 0x0098
|
||||
MULTI_PLATFORM_BACK = 0x0099
|
||||
SWITCH_LANGUAGE = 0x009A # Mac_switch_language
|
||||
SCREEN_CAPTURE = 0x009B # Mac_screen_Capture, on Craft Keyboard
|
||||
GESTURE_BUTTON = 0x009C
|
||||
SMART_SHIFT = 0x009D
|
||||
APP_EXPOSE = 0x009E
|
||||
SMART_ZOOM = 0x009F
|
||||
LOOKUP = 0x00A0
|
||||
MICROPHEON_ON_OFF = 0x00A1
|
||||
WIFI_ON_OFF = 0x00A2
|
||||
BRIGHTNESS_DOWN = 0x00A3
|
||||
BRIGHTNESS_UP = 0x00A4
|
||||
DISPLAY_OUT = 0x00A5
|
||||
VIEW_OPEN_APPS = 0x00A6
|
||||
VIEW_ALL_OPEN_APPS = 0x00A7
|
||||
APP_SWITCH = 0x00A8
|
||||
GESTURE_BUTTON_NAVIGATION = 0x00A9 # Mouse_Thumb_Button on MX Master
|
||||
FN_INVERSION = 0x00AA
|
||||
MULTI_PLATFORM_BACK_2 = 0x00AB # Alternative
|
||||
MULTI_PLATFORM_FORWARD = 0x00AC
|
||||
MULTI_PLATFORM_Gesture_Button = 0x00AD
|
||||
HostSwitch_Channel_1 = 0x00AE
|
||||
HostSwitch_Channel_2 = 0x00AF
|
||||
HostSwitch_Channel_3 = 0x00B0
|
||||
MULTI_PLATFORM_SEARCH = 0x00B1
|
||||
MULTI_PLATFORM_HOME_MISSION_CONTROL = 0x00B2
|
||||
MULTI_PLATFORM_MENU_LAUNCHPAD = 0x00B3
|
||||
VIRTUAL_GESTURE_BUTTON = 0x00B4
|
||||
CURSOR = 0x00B5
|
||||
KEYBOARD_RIGHT_ARROW = 0x00B6
|
||||
SW_CUSTOM_HIGHLIGHT = 0x00B7
|
||||
KEYBOARD_LEFT_ARROW = 0x00B8
|
||||
TBD = 0x00B9
|
||||
MULTI_PLATFORM_Language_Switch = 0x00BA
|
||||
SW_CUSTOM_HIGHLIGHT_2 = 0x00BB
|
||||
FAST_FORWARD = 0x00BC
|
||||
FAST_BACKWARD = 0x00BD
|
||||
SWITCH_HIGHLIGHTING = 0x00BE
|
||||
MISSION_CONTROL_TASK_VIEW = 0x00BF # Switch_Workspace on Craft Keyboard
|
||||
DASHBOARD_LAUNCHPAD_ACTION_CENTER = 0x00C0 # Application_Launcher on Craft
|
||||
# Keyboard
|
||||
BACKLIGHT_DOWN = 0x00C1 # Backlight_Down_FW_internal_function
|
||||
BACKLIGHT_UP = 0x00C2 # Backlight_Up_FW_internal_function
|
||||
RIGHT_CLICK_APP_CONTEXT_MENU = 0x00C3 # Context_Menu on Craft Keyboard
|
||||
DPI_Change = 0x00C4
|
||||
NEW_TAB = 0x00C5
|
||||
F2 = 0x00C6
|
||||
F3 = 0x00C7
|
||||
F4 = 0x00C8
|
||||
F5 = 0x00C9
|
||||
F6 = 0x00CA
|
||||
F7 = 0x00CB
|
||||
F8 = 0x00CC
|
||||
F1 = 0x00CD
|
||||
LASER_BUTTON = 0x00CE
|
||||
LASER_BUTTON_LONG_PRESS = 0x00CF
|
||||
START_PRESENTATION = 0x00D0
|
||||
BLANK_SCREEN = 0x00D1
|
||||
DPI_Switch = 0x00D2 # AdjustDPI on MX Vertical
|
||||
HOME_SHOW_DESKTOP = 0x00D3
|
||||
APP_SWITCH_DASHBOARD = 0x00D4
|
||||
APP_SWITCH_2 = 0x00D5 # Alternative
|
||||
FN_INVERSION_2 = 0x00D6 # Alternative
|
||||
LEFT_AND_RIGHT_CLICK = 0x00D7
|
||||
VOICE_DICTATION = 0x00D8
|
||||
EMOJI_SMILING_FACE_WITH_HEART_SHAPED_EYES = 0x00D9
|
||||
EMOJI_LOUDLY_CRYING_FACE = 0x00DA
|
||||
EMOJI_SMILEY = 0x00DB
|
||||
EMOJI_SMILE_WITH_TEARS = 0x00DC
|
||||
OPEN_EMOJI_PANEL = 0x00DD
|
||||
MULTI_PLATFORM_APP_SWITCH_LAUNCHPAD = 0x00DE
|
||||
SNIPPING_TOOL = 0x00DF
|
||||
GRAVE_ACCENT = 0x00E0
|
||||
STANDARD_TAB_KEY = 0x00E1
|
||||
CAPS_LOCK = 0x00E2
|
||||
LEFT_SHIFT = 0x00E3
|
||||
LEFT_CONTROL = 0x00E4
|
||||
LEFT_OPTION_START = 0x00E5
|
||||
LEFT_COMMAND_ALT = 0x00E6
|
||||
RIGHT_COMMAND_ALT = 0x00E7
|
||||
RIGHT_OPTION_START = 0x00E8
|
||||
RIGHT_CONTROL = 0x00E9
|
||||
RIGHT_SHIFT = 0x0EA
|
||||
INSERT = 0x00EB
|
||||
DELETE = 0x00EC
|
||||
HOME = 0x00ED
|
||||
END = 0x00EE
|
||||
PAGE_UP_2 = 0x00EF # Alternative
|
||||
PAGE_DOWN_2 = 0x00F0 # Alternative
|
||||
MUTE_MICROPHONE = 0x00F1
|
||||
DO_NOT_DISTURB = 0x00F2
|
||||
BACKSLASH = 0x00F3
|
||||
REFRESH = 0x00F4
|
||||
CLOSE_TAB = 0x00F5
|
||||
LANG_SWITCH = 0x00F6
|
||||
STANDARD_ALPHABETICAL_KEY = 0x00F7
|
||||
RRIGH_OPTION_START_2 = 0x00F8
|
||||
LEFT_OPTION = 0x00F9
|
||||
RIGHT_OPTION = 0x00FA
|
||||
LEFT_CMD = 0x00FB
|
||||
RIGHT_CMD = 0x00FC
|
||||
|
||||
def __str__(self):
|
||||
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
|
||||
|
|
|
@ -215,7 +215,7 @@ def test_device_receiver(number, pairing_info, responses, handle, _name, codenam
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"number, info, responses, handle, unitId, modelId, tid, kind, firmware, serial, id, psl, rate",
|
||||
"number, info, responses, handle, unitId, modelId, task_id, kind, firmware, serial, id, psl, rate",
|
||||
zip(
|
||||
range(1, 7),
|
||||
[pi_CCCC, pi_2011, pi_4066, pi_1007, pi_407B, pi_DDDD],
|
||||
|
@ -239,7 +239,7 @@ def test_device_receiver(number, pairing_info, responses, handle, _name, codenam
|
|||
["1ms", "2ms", "4ms", "8ms", "1ms", "9ms"], # polling rate
|
||||
),
|
||||
)
|
||||
def test_device_ids(number, info, responses, handle, unitId, modelId, tid, kind, firmware, serial, id, psl, rate):
|
||||
def test_device_ids(number, info, responses, handle, unitId, modelId, task_id, kind, firmware, serial, id, psl, rate):
|
||||
low_level = LowLevelInterfaceFake(responses)
|
||||
low_level.request = partial(fake_hidpp.request, fake_hidpp.replace_number(responses, number))
|
||||
low_level.ping = partial(fake_hidpp.ping, fake_hidpp.replace_number(responses, number))
|
||||
|
@ -248,7 +248,7 @@ def test_device_ids(number, info, responses, handle, unitId, modelId, tid, kind,
|
|||
|
||||
assert test_device.unitId == unitId
|
||||
assert test_device.modelId == modelId
|
||||
assert test_device.tid_map == tid
|
||||
assert test_device.tid_map == task_id
|
||||
assert test_device.kind == kind
|
||||
assert test_device.firmware == firmware or len(test_device.firmware) > 0 and firmware is True
|
||||
assert test_device.id == id
|
||||
|
|
|
@ -154,19 +154,19 @@ def test_FeaturesArray_getitem(device, expected0, expected1, expected2, expected
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"device, index, cid, tid, flags, default_task, flag_names",
|
||||
"device, index, cid, task_id, flags, default_task, flag_names",
|
||||
[
|
||||
(device_standard, 2, 1, 1, 0x30, "Volume Up", ["reprogrammable", "divertable"]),
|
||||
(device_standard, 1, 2, 2, 0x20, "Volume Down", ["divertable"]),
|
||||
],
|
||||
)
|
||||
def test_ReprogrammableKey_key(device, index, cid, tid, flags, default_task, flag_names):
|
||||
key = hidpp20.ReprogrammableKey(device, index, cid, tid, flags)
|
||||
def test_reprogrammable_key_key(device, index, cid, task_id, flags, default_task, flag_names):
|
||||
key = hidpp20.ReprogrammableKey(device, index, cid, task_id, flags)
|
||||
|
||||
assert key._device == device
|
||||
assert key.index == index
|
||||
assert key._cid == cid
|
||||
assert key._tid == tid
|
||||
assert key._tid == task_id
|
||||
assert key._flags == flags
|
||||
assert key.key == special_keys.CONTROL[cid]
|
||||
assert key.default_task == common.NamedInt(cid, default_task)
|
||||
|
@ -174,7 +174,7 @@ def test_ReprogrammableKey_key(device, index, cid, tid, flags, default_task, fla
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"device, index, cid, tid, flags, pos, group, gmask, default_task, flag_names, group_names",
|
||||
"device, index, cid, task_id, flags, pos, group, gmask, default_task, flag_names, group_names",
|
||||
[
|
||||
(device_standard, 1, 0x51, 0x39, 0x60, 0, 1, 1, "Right Click", ["divertable", "persistently divertable"], ["g1"]),
|
||||
(device_standard, 2, 0x52, 0x3A, 0x11, 1, 2, 3, "Mouse Middle Button", ["mse", "reprogrammable"], ["g1", "g2"]),
|
||||
|
@ -193,13 +193,15 @@ def test_ReprogrammableKey_key(device, index, cid, tid, flags, default_task, fla
|
|||
),
|
||||
],
|
||||
)
|
||||
def test_reprogrammable_key_v4_key(device, index, cid, tid, flags, pos, group, gmask, default_task, flag_names, group_names):
|
||||
key = hidpp20.ReprogrammableKeyV4(device, index, cid, tid, flags, pos, group, gmask)
|
||||
def test_reprogrammable_key_v4_key(
|
||||
device, index, cid, task_id, flags, pos, group, gmask, default_task, flag_names, group_names
|
||||
):
|
||||
key = hidpp20.ReprogrammableKeyV4(device, index, cid, task_id, flags, pos, group, gmask)
|
||||
|
||||
assert key._device == device
|
||||
assert key.index == index
|
||||
assert key._cid == cid
|
||||
assert key._tid == tid
|
||||
assert key._tid == task_id
|
||||
assert key._flags == flags
|
||||
assert key.pos == pos
|
||||
assert key.group == group
|
||||
|
@ -220,7 +222,7 @@ def test_reprogrammable_key_v4_key(device, index, cid, tid, flags, pos, group, g
|
|||
],
|
||||
)
|
||||
# these fields need access all the key data, so start by setting up a device and its key data
|
||||
def test_ReprogrammableKeyV4_query(responses, index, mapped_to, remappable_to, mapping_flags):
|
||||
def test_reprogrammable_key_v4_query(responses, index, mapped_to, remappable_to, mapping_flags):
|
||||
device = fake_hidpp.Device(
|
||||
"KEY", responses=responses, feature=hidpp20_constants.SupportedFeature.REPROG_CONTROLS_V4, offset=5
|
||||
)
|
||||
|
@ -360,14 +362,14 @@ def test_KeysArrayV4_query_key(device, index, top, cid):
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"device, count, index, cid, tid, flags, pos, group, gmask",
|
||||
"device, count, index, cid, task_id, flags, pos, group, gmask",
|
||||
[
|
||||
(device_standard, 4, 0, 0x0011, 0x0012, 0xCDAB, 1, 2, 3),
|
||||
(device_standard, 6, 1, 0x0111, 0x0022, 0xCDAB, 1, 2, 3),
|
||||
(device_standard, 8, 3, 0x0311, 0x0032, 0xCDAB, 1, 2, 4),
|
||||
],
|
||||
)
|
||||
def test_KeysArrayV4__getitem(device, count, index, cid, tid, flags, pos, group, gmask):
|
||||
def test_KeysArrayV4__getitem(device, count, index, cid, task_id, flags, pos, group, gmask):
|
||||
keysarray = hidpp20.KeysArrayV4(device, count)
|
||||
|
||||
result = keysarray[index]
|
||||
|
@ -375,7 +377,7 @@ def test_KeysArrayV4__getitem(device, count, index, cid, tid, flags, pos, group,
|
|||
assert result._device == device
|
||||
assert result.index == index
|
||||
assert result._cid == cid
|
||||
assert result._tid == tid
|
||||
assert result._tid == task_id
|
||||
assert result._flags == flags
|
||||
assert result.pos == pos
|
||||
assert result.group == group
|
||||
|
@ -421,7 +423,7 @@ device_key = fake_hidpp.Device(
|
|||
(special_keys.CONTROL.Virtual_Gesture_Button, 7, common.NamedInt(0x51, "Right Click"), None),
|
||||
],
|
||||
)
|
||||
def test_KeysArrayV4_key(key, expected_index, expected_mapped_to, expected_remappable_to):
|
||||
def test_keys_array_v4_key(key, expected_index, expected_mapped_to, expected_remappable_to):
|
||||
device_key._keys = _hidpp20.get_keys(device_key)
|
||||
device_key._keys._ensure_all_keys_queried()
|
||||
|
||||
|
|
Loading…
Reference in New Issue