Jump to content
Flirc Forums

USB HID codes (keys and modifier keys) for flirc_util record_api x y


jonascj

Recommended Posts

tl;dr USB HID codes from here http://www.freebsddiary.org/APC/usb_hid_usages.php should be given to flirc_util record_api as decimal

Hi all

Just had to deal with flirc_util record_api on account of the GUI not recognizing the Flirc board as connected (http://forum.flirc.tv/index.php?/topic/2208-linux-x64-flirc_util-works-without-root-but-flirc-gui-always-say-disconnected/#comment-12182 ), and I thought I'd save the information I found in a topic with a descriptive title for future reference:

This is also a good resource: http://forum.flirc.tv/index.php?/topic/128-modifier-keys-in-command-line-recording/

flirc_util record_api x y where x is the modifier key and y is the HID key.

 

# Modifier keys

According to the documentation presented when running "flirc_util record_api" the modifier keys are specified by logically OR'ing these values together as binary (the de facto standard for specifying flags as a single parameter):

Key modifiers are defined in the IEEE HID Spec as follows:
LEFT  CONTROL          1    # 00000001 as binary
LEFT  SHIFT            2    # 00000010
LEFT  ALT              4    # 00000100
LEFT  CMD|WIN          8    # 00001000
RIGHT CONTROL          16   # 00010000
RIGHT SHIFT            32   # 00100000
RIGHT ALT              64   # 01000000
RIGHT CMD|WIN          128  # 10000000

OR'ing binary numbers is done by going through the two numbers bit by bit and comparing corresponding bits. If one of the two bits is 1 set the corresponding result bit to 1, otherwise set it to 0, e.g. 0101 OR 0010 = 0111.

For these specific binary numbers (1,2,4...128 as decimal) OR'ing is the same as ADDing, and since "flirc_util record_api" expects a decimal input we might as add them in decimal:

LEFT CTRL + LEFT SHFIT = 1 + 2 = 3
LEFT CTRL + LEFT ALT + LEFT SHIFT = 1 + 2 + 4 = 7

# HID keys

The HID key codes can be found here: http://www.freebsddiary.org/APC/usb_hid_usages.php

"flirc_util record_api" expects the code as decimal, but the freebsddiary.org page gives them in HEX, so get your hex-to-dec converter out.

For example, 'g and G' is specified as 0x0A which is 10 in decimal. So if you want to program the g/G keyboard key with "flirc_util record_api x y" you have to specify y as 10, not 0x0A or similar. Another example is DownArrow which is specified as 0x52 in hex which needs to be specified as 82 in decimal.

 

# Putting it together

If you want to program LEFT CTRL + LEFT SHIFT + UP ARROW you need 1+2=3 as modifier key and 0x52=82 as HID key:

flirc_util record_api 3 82

Another example is LEFT CTRL + LEFT SHIFT + LEFT ALT + S which would be 1+2+4=7 as modifier key and 0x16=22 as HID key:

flirc_util record_api 7 22

 

# Documentation from flirc_util

$ flirc_util record_api
Help for `record_api' command:
Send the raw HID value down to flirc to be linked with button recorded
usage:
  record_api 'arg1 arg2'   arg1 is key-modifier 
                           arg2 is HID key
example:
  flirc record_api 136 4   '136' represents right cmd + left cmd
                           '4' represents 'a' in HID

Key modifiers are defined in the IEEE HID Spec as follows:
LEFT  CONTROL          1
LEFT  SHIFT            2
LEFT  ALT              4
LEFT  CMD|WIN          8
RIGHT CONTROL          16
RIGHT SHIFT            32
RIGHT ALT              64
RIGHT CMD|WIN          128

To record Control + Shift, logically or 1 & 2 to make 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...