Jump to content
Flirc Forums

Force Flirc to work as Generic HID device instead of keyboard.


yawor

Recommended Posts

This is probably unsupported in any way by Jason so please don't report bugs in other threads when using this solution. If you have any problems with this setup it is better to post them here and I'll try to help if I have time to do so.

 

Hi,

 

This how-to is for users who want to build more advanced control schemes using their Flirc devices. It is mainly directed to Windows users because there is no way in Windows to capture input from a single keyboard, but can be done in Linux. But it should be also applicable in other OS-es when used with correct software.

 

The problem is that not everything can be done just by defining a single key combinations. There are applications like AutoHotKey (AHK) or EventGhost (EG) that can capture specific key combinations but there is a problem. Having many buttons on the mapped remote it is sometimes hard to find key combinations that are not used as OS or other apps shortcuts already. By capturing the specific key combination in AHK or EG user basically blocks this combination even on a normal keyboard connected to the PC (as there is no way in Windows to capture only input from one specific keyboard).

 

Here comes HID standard for the rescue. HID keyboards are just one of the many usages of this standard. Because of that the HID standard has been split into multiple usage tables. Standard keys on keyboards use table 7 and in Windows codes from this table are immediately captured by HID keyboard filter driver and are converted into key presses. On the other hand keys like multimedia keys are defined in usage table 12. Codes from this table are not captured by the Windows. Only a few of them are natively supported (like volume, mute, play, pause etc).

 

Flirc GUI and CLI util provide the ability to map only a few of the keys from table 12. Those keys when mapped are not recognized by AHK or EG when used with keyboard input plugins. This gave me an idea to do some experiments. I needed to find out how these multimedia keys are stored in the Flirc which can be checked by inspecting saved config file. After that I checked if I can assign any HID code from the table 12 and I was successful.

 

I've found out that there is a key code which acts as a marker for Flirc to send usage 12 instead o 7. When this marker is found then the actual HID key ID is stored as a modifier. It is possible to use flirc_util to map almost any code from table 12:

flirc_util.exe record_api 176 102

where 176 is decimal value of key ID (Play key in this case) and 102 is a marker that tells Flirc that this is key from table 12.

 

Table 12 has more than 256 keys defined but unfortunately Flirc can only hold a single byte value so there is still a restriction in the number of keys.

 

There are also holes in the list of keys in this table which I've used in my own config so I don't have any conflicts with other hardware and software. These are the usable values: 4-31, 34-47, 55-63, 73-95, 103-127, 159, 165-175. There are probably more but I've stopped looking other codes that are not mentioned by the standard. I think that other keys that are in the standard are also usable. Most of them are not natively supported by the Windows but I used these ranges in my case to be on the safe side. The way to record these keys is to change the first value to one in these ranges and record a button to them incrementally.

 

In my setup I've used EventGhost to capture HID events and map them to things I want them to do. It provides some nice features like programmable on screen menus and many plugins for specific apps like XBMC (it uses XBMC RPC API). To capture events from HID device a Generic HID plugin must be used. Unfortunately there is a small problem with this plugin and it sometimes sends multiple HID events on single button press (this is not the same problem as with repeated keys). I have a modifier Generic HID plugin that works very well with Flirc in this mode of operation. I can share it if there is a demand for it. I can also extend the how-to to some basic EG configuration.

 

I haven't used AHK but I know that there is also a way to capture HID events in it and use them to control things.

 

All the numbers I'm referring to are taken from this document http://www.freebsddiary.org/APC/usb_hid_usages.php

  • Like 3
Link to comment
Share on other sites

  • 5 weeks later...

Thanks for this; it looks like the way to get the functionality I'm looking for from the FLIRC.

 

I am confused about what usage tables you're referencing. What seems to be the most appropriate source of info (the USB HID Usage Table document here from usb.org) has simulation controls in table 7 and keyboard keys in table 12, as opposed to keyboard keys on 7 as you mentioned. Also, in your example, you use 176, referencing it as the play key. This falls inline with table 17 (Consumer Usage Page) in the above mentioned document.

Link to comment
Share on other sites

I'm sorry. I've forgotten to include link to the usage tables I've been referring to. I'll edit the post and add the link there too.

 

http://www.freebsddiary.org/APC/usb_hid_usages.php

I've based my description on the numbers in this document. I'm not an expert with all this USB stuff so I can't tell if these numbers are correct or not.

 

BTW simulation control in the document I've linked above is in table 2. I wonder why the numbers are different from the ones in the official USB doc.

Link to comment
Share on other sites

  • 2 months later...

Are you still on this?

I find this a viable workaround for the multiple keyboard problem (or keyboard and remote sending keystrokes) on windows.

I'm trying to use my HTPC in a dual monitor setup.

Primary monitor with keyboard control and always on focus and secondary with Kodi in fake fullscreen (borderless windowed) controlled via JSON-RPC (actually via tablet/phone app yatse).

I plan to have a better control of Kodi using a real remote this way:

Xsight Touch remote>Flirc>Generic HID Plugin(EG input)>XBMC2 plugin (JSON-RPC Mode)(EG output)>Kodi

Did you achieved success in this?

How?

I can understand the theory but i would like to see an implementation of this before buying Flirc.

Here in Spain with package tracking Flirc could cost +50 euros (+65 US$).

Can you please share your expertise? :)

Edited by sammarbella
Link to comment
Share on other sites

I'm using this setup (flirc with hid keys and EventGhost with generic hid plugin) for quite some time now and I don't see any outstanding issues with it. I don't know how well you'll be able to run htpc in dual monitor mode with both displays active at the same time. I think that xbmc/kodi exits full screen mode when you click something on second monitor.

I can share my modified generic hid plugin when I'm back at home in couple of days.

Link to comment
Share on other sites

Thanks for the quick reply!

Both display will be active but only the non Kodi monitor(s) will have always the focus.

Kodi doesn't need the focus to work properly and there are at least a couple of apps i know who are able to lock the movement of the mouse to a specific area/monitor avoiding accidental lost of focus (clicking on Kodi monitor).

Obviously to achieve that Kodi must be in fulscreen windowed mode not real fullscreen mode if not it will always get the focus for keyboard.

By modified generic HID you mean a profile of defined keys for EG?

What about the FLIRC config part?

Please share it when you come back home.

Link to comment
Share on other sites

By "modified Generic HID plugin" I mean that I've copied original Generic HID plugin code, changed its internal ID and name (added a suffix to its name) so both plugin versions can coexist in a single EventGhost install and changed the code so it works better with Flirc sending custom HID codes. The EventGhost differentiates between single events (short events) and enduring ones, which can have extended length. The original HID plugin for EG uses only short events so when you hold down the remote button you get a lot of short events. I've modified the code so HID plugin is generating an enduring event for as long as you keep the button pressed, so you only get a single event but it is active as long as you keep holding the button down. That way you can define repeats and long-press actions in the EventGhost without any problems.

 

You can download the plugin here: https://www.dropbox.com/s/j7ajh7rvoa2qpa9/MyHID.zip?dl=0

 

Go to the folder where you have EventGhost installed. You'll find plugins folder there. Unpack the downloaded zip to the plugins folder (it should create a MyHID folder). You can compare the __init__.py file with the original plugin code in the plugins\HID folder. There are only a few changes so it's easy to check that there is nothing malicious added in the code (even for non-programmers I think).

 

To use the plugin in EG you need to first restart EG for it to see new plugin. Then you add "Generic HID (mod)" plugin to Autostart folder in your EG config. You need to select Flirc from the device list in the plugin config window. There can be more than one device there so you need to do some testing which one works. You can also enter a prefix into Event prefix text input (I've set it to Flirc). I'm also using Remote event mapper plugin where I map Flirc.Button.X (where X is the HID code) events as Remote.YYYY (where YYYY is given button name like Play, Pause etc). That way I don't need to remember under which HID code I have a specific button mapped in Flirc. The rest of the EG config is very specific to my needs. Of course I use XBMC2 plugin to control Kodi using remote API and also I use Task Create/Switch Events plugin to enable/disable actions groups depending on the app in focus (you don't need that if you want to control Kodi out of focus).

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thank you very much for your explanation and for sharing your mod of generic HID plugin!

It covers FLIRC and EG config parts....What about your universal remote config?

Which device it will need to emulate in my Xsight Touch universal remote in order to comunicate with flirc?

I presume that it must be different than MCE/keyboard emulation remotes, any TV remote emulation will work?

Maybe Pronto hex codes?

This is the last piece of the puzzle. :)

Link to comment
Share on other sites

Basically you need to find a remote configuration which won't interfere with your other hardware (like TV etc) and will send a code for every button on the remote. Many devices don't need all the keys on the remote so universal remotes deactivate some of the buttons when they're not needed for specific device.

 

Second criteria for choosing remote config is IR signal protocol used by the device. There are many different protocols but I personally like to use a device with NEC1 protocol. For example (at least some) newer LG, Samsung and Panasonic devices use this protocol. Also try to set up the device as TV as they usually have all the remote keys active.

 

I'm using One-For-All URC-6440 remote and I've set a Samsung TV code on PVR device button for use with Flirc and all the keys are active and send unique signals. Of course I don't have a Samsung TV so I don't need to worry about Flirc interfering with my TV.

Link to comment
Share on other sites

When Flirc arrives here i will try with a samsung TV profile on my AR Xsight Touch (ARRX18G)(US)/One For All Xsight Touch (URC 8603)(worldwide):

http://www.oneforall.com/xsight-touch.html

Right now it's working well with a basic setup for a TV 60'LG PB690V (6900 in US) and a Onkyo TX-NR636 AV receiver and a macro to change to the HTPC HDMI input.

I just want to avoid the need of the flymouse/keyboard RF i must use right now to control Kodi in my HTPC.

I use the powerfull software RM-IR (RemoteMaster) to config this remote (and all One For All remotes i think) it can setup each key, macros and upgrades and many more things:

http://www.hifi-remote.com/wiki/index.php?title=JP1_-_Just_How_Easy_Is_It%3F_-_RM-IR_Version

P.S.: If you like this remote i bought it from ebay.com there are good deals for brand new ARRX18G remote (oem package)...way cheaper than buying the flirc from here!

Edited by sammarbella
Link to comment
Share on other sites

I know RemoteMaster :). I'm also the newest member of the RMIR developers team but I'm focusing on the SimpleSet remotes (like European URC-6440 or US OARUSB04G).

 

I like my URC-6440 as it has a fairly good set of buttons with nice layout and backlight. With recently finished Extender for this model this is one of the best OFA/EUI remotes to date and it's very cheap (I've paid for it about $20 in local electronics retail shop in my country).

Link to comment
Share on other sites

  • 4 weeks later...

I installed your modified HID plugin into EventGhost. In the plugin configuration, there are 2 flirc devices. I was thinking that with the plugin installed and with the correct flirc dfevice selected, I would be able to see the remote keys show up in eventghost.  I tried both flirc devices listed but I don't see anything show up in Eventghost. Am I missing a step?

Looking forward to using the plugin

Ian

Link to comment
Share on other sites

I installed your modified HID plugin into EventGhost. In the plugin configuration, there are 2 flirc devices. I was thinking that with the plugin installed and with the correct flirc dfevice selected, I would be able to see the remote keys show up in eventghost.  I tried both flirc devices listed but I don't see anything show up in Eventghost. Am I missing a step?

Looking forward to using the plugin

Ian

 

Did you record the keys the way I've described using flirc_util record_api? It is a required step, because you can't catch normal keyboard keys using this method. To do a quick test you can record one of the multimedia keys in the GUI - it should show up in EG if correct flirc device is selected in plugin's configuration.

Link to comment
Share on other sites

Is the GUI working normally and the problem is only with command line util? Are you sure you are using full file name of the exec file: flirc_util.exe, not just flirc_util? Some people are having a problem like you described when they try to execute command line commands which shortened exec name (without .exe). I've also experienced it but I don't have any problems when using full exec file name.

Link to comment
Share on other sites

I was not using the .exe. Let me try that. That is kind of odd behavior though.  I upgraded the firmware to 3.5  yesteday to se eif it would fix some minor issue. Per an other post, that has been painful as I have not been able to successfully record a complete set of codes sinc ete upgrade.

Ian 

 

Edit

Adding .exe to the commandline call works.

 

Where are recored codes saved? to the FLIRC itself? or to a config file somewhere

Edited by ijourneaux
Link to comment
Share on other sites

Everything is recorded and stored in the Flirc itself. You can use flirc_util.exe delete to delete keys you are unsure of. There is no easy way of displaying recorded keys when you are using my method. You can just save the config and figure out what is already recorded by checking its content in HEX editor. You just need to skip first 5 bytes and after that each mapping has 6 bytes - first 4 is hash of IR signal, then 1 byte modifier (in normal keyboard mode) or key code (in table 12 mode), then 1 byte key code (in normal keyboard code) or 0x66 for table 12 mode.

Link to comment
Share on other sites

Ok I just programmed the up/down and left/right buttons 66/67 68/69.

All 4 programmed seeming fine but when I test them. they are not reliably played back. Up returns 67 down returns 67. Left and Right only work some of the time.

 

I am just using an MCE remote Rosewill RRC-126. Perhaps there is a issue with this remote

 

Ian

Link to comment
Share on other sites

  • 7 months later...

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