Jump to content
Flirc Forums

Modifier keys in command line recording


digitalb0y

Recommended Posts

Is there a way to program shift and control key commands from the linux command line utility? My Flirc always sends stuck keys to my Mac when I try to run the graphical Flirc.app to program it, but it works great on my XBMC box running XBMCbuntu, so I'd rather use that.

Link to comment
Share on other sites

Okay, this is strange. I figured I could use 1, 16 or 17 for arg1 since my key commands should work with either the left (1) or right (16) control key, and the keys I'm trying to map are:

  • ctrl+e
  • ctrl+m
  • ctrl+i

Those shortcuts go to videos, music, and picture libraries, respectively, in XBMC. So I tried the following commands:

flirc record_api 1 8
and
flirc record_api 1 10

...and I couldn't find a numerical HID value for i (the guide I was reading to find the other two values listed i as 0C which flirc didn't seem to like). The weird part is that the first command worked perfectly and the button I mapped now takes me to my video library, but when I press the button I mapped with the second command, it acts like I'm pressing m and not ctrl+m. I also tried putting in 16 and 17 for arg1 in both commands, and the results are the same. The ctrl+e command maps fine, but the ctrl+m just acts like I'm pressing m without the ctrl key. Any ideas what I'm doing wrong? And any tips on what value I should use for the i key?

Link to comment
Share on other sites

Here are all the definitions

Modifiers work as follows:

#define MOD_CTRL_LEFT (1<<0)

#define MOD_SHIFT_LEFT (1<<1)

Left Control stands for 1 shifted left 0 times. So that's: 0000 0001

Left Shift stands for 1 shifted left 1 times, Which is: 0000 0010

If you want to do Left Ctrl+ Left Shift + a, then do the following:

Logical OR of both Left Ctrl+Left Shift: 0000 0011

The result is 3.

So, flirc record 3 4

Where 4 stands for HID_a

It's not very intuitive for anyone who doesn't have much experience programming, or in engineering. So the GUI is very useful.

Maybe a website accessible via your smartphone or PC will spit out the equivalent api strings for you?

Hope that makes sense and thank you Chris for pointing me to this thread.


/* HID #Defines */
#define HID_a 4
#define HID_b 5
#define HID_c 6
#define HID_d 7
#define HID_e 8
#define HID_f 9
#define HID_g 10
#define HID_h 11
#define HID_i 12
#define HID_j 13
#define HID_k 14
#define HID_l 15
#define HID_m 16
#define HID_n 17
#define HID_o 18
#define HID_p 19
#define HID_q 20
#define HID_r 21
#define HID_s 22
#define HID_t 23
#define HID_u 24
#define HID_v 25
#define HID_w 26
#define HID_x 27
#define HID_y 28
#define HID_z 29
#define HID_1 30
#define HID_excl 30
#define HID_2 31
#define HID_address 31
#define HID_3 32
#define HID_pound 32
#define HID_4 33
#define HID_dollar 33
#define HID_5 34
#define HID_percent 34
#define HID_6 35
#define HID_carrot 35
#define HID_7 36
#define HID_amp 36
#define HID_8 37
#define HID_star 37
#define HID_9 38
#define HID_paren_right 38
#define HID_0 39
#define HID_paren_left 39
#define HID_return 40
#define HID_escape 41
#define HID_delete 76
#define HID_backspace 42
#define HID_tab 43
#define HID_space 44
#define HID_minus 45
#define HID_underscore 45
#define HID_equal 46
#define HID_plus 46
#define HID_brack_right 47
#define HID_curly_right 47
#define HID_brack_left 48
#define HID_curly_left 48
#define HID_back_slash 49
#define HID_pipe 49
#define HID_semi_colon 51
#define HID_colon 51
#define HID_apostrophe 52
#define HID_quote 52
#define HID_back_tick 53
#define HID_tilde 53
#define HID_comma 54
#define HID_less_than 54
#define HID_period 55
#define HID_greater_than 55
#define HID_fw_slash 56
#define HID_questionmark 56
#define HID_F1 58
#define HID_F2 59
#define HID_F3 60
#define HID_F4 61
#define HID_F5 62
#define HID_F6 63
#define HID_F7 64
#define HID_F8 65
#define HID_F9 66
#define HID_F10 67
#define HID_F11 68
#define HID_F12 69

#define HID_print_scr 70
#define HID_scroll 71
#define HID_pause 72
#define HID_insert 73
#define HID_home 74
#define HID_pageup 75

#define HID_end 77
#define HID_pagedown 78
#define HID_right 79
#define HID_left 80
#define HID_down 81
#define HID_up 82
#define HID_enter 88
#define HID_shift (1<<1)

#define MOD_CTRL_LEFT (1<<0)
#define MOD_SHIFT_LEFT (1<<1)
#define MOD_ALT_LEFT (1<<2)
#define MOD_COMMAND_LEFT (1<<3)
#define MOD_CTRL_RIGHT (1<<4)
#define MOD_SHIFT_RIGHT (1<<5)
#define MOD_ALT_RIGHT (1<<6)
#define MOD_COMMAND_RIGHT (1<<7)

#define HID_EJECT (1<<7)
#define HID_VOL_DOWN (1<<6)
#define HID_VOL_UP (1<<5)
#define HID_MUTE (1<<4)
#define HID_PLAY_PAUSE (1<<3)
#define HID_STOP (1<<2)
#define HID_PREV_TRACK (1<<1)
#define HID_NEXT_TRACK (1<<0)
[/CODE]

Link to comment
Share on other sites

Thanks! So, assuming I'm happy to use just the left control key, to modify each of the three keys mentioned above, I'd do:


flirc record_api 1 8

flirc record_api 1 16

flirc record_api 1 12

Is that right?

EDIT: YES!!! Those three did the trick. Thanks for the HID list. The ones I was finding were not giving me the correct numbers.

Link to comment
Share on other sites

  • 4 months later...

I'm trying to configure the standard keyboard media buttons but as they are not available in the GUI I try finding a way to do it manually using the CLI.

It is exactly the below HID's I want to program, but I don't understand what number I should use together with the command "flirc.exe record_api ", can someone help me out? :huh:

(for example "Stop" is 1<<2 which should be 4 (binary 100). However, "HID_a" is said to be 4???

#define HID_EJECT (1<<7)

#define HID_VOL_DOWN (1<<6)

#define HID_VOL_UP (1<<5)

#define HID_MUTE (1<<4)

#define HID_PLAY_PAUSE (1<<3)

#define HID_STOP (1<<2)

#define HID_PREV_TRACK (1<<1)

#define HID_NEXT_TRACK (1<<0)

Link to comment
Share on other sites

I'd guess that since HID eject is 1 shifted left 7 times, it would be 128, so your commands would be something like:


flirc redord_api 128 0

flirc redord_api 64 0

flirc redord_api 32 0

flirc redord_api 16 0

flirc redord_api 8 0

flirc redord_api 4 0

flirc redord_api 2 0

flirc redord_api 1 0

But since left ctrl and shift are also 1<<1 and 1<<0 I don't know what would make those two different with the media keys. Jason?

EDIT:

I just uploaded a long overdue version that should fix the last issue which crashed in windows.

Ah! You beat me to a response, and with much better news! Thanks for your continued efforts sir!

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...