Win HP hq-tre Remote RF - utility to use HID remote with Kodi
#1
Information 
Hi,

I have a HP remote RF with a dongle. The name of the remote is "HP HQ-TRE" and the dongle Model N° is RG-0983 , Assy No WUG1137.
After many work I can use it fully with Kodi. I can use the MCE button to launch Kodi too.

This same dongle is also used with mouse and keyboard, it comes from an old HP touchsmart. This dongle creates 3 entries in device manager :
  • 1 Keyboard -> receive numpad keys from the remote and directions
    • HID Keyboard Device
  • 1 mouse :
    • HID-compliant mouse
  • 1 Remote :
    • HID-compliant consumer control device
    • HID - Compliant system controller
    • HID-compliant device
    • HID-compliant device

Image


The difficulty on that remote is that some key comes from the HID keyboard and multimedia keys from an another HID device.
Most of the multimedias keys are not visible by softwares like ShowKey.exe , AutoScriptWriter , EventGhost or the extraordinary HIDMacros. Windows 10 doesn't have Windows Media Center so the eHome button doesn't work at all.

The solution that I found comes from AHKHID which is an AHK (autohotkey) implementation of the HID functions. It allows you to register HID devices and examine the data coming out.
I've made 2 scripts :
  • The first just return an ascii character when you press a multimedia button of the remote. So you have to affect each key to an action in KODI (use "Keymap Editor" plugin for that).
  • The second is more customized and comes with the "Keymap Editor" file configuration (gen.xml). So you have to run script at startup (a compiled exe version is given), install "Keymap Editor" plugin in Kodi and replace the file C:\Users\YourUserName\AppData\Roaming\Kodi\userdata\keymaps\gen.xml). and you will have the configuration described below :

Download these scripts Here

Image


It will be probably helpfull for others HID devices so I give the source code with it Wink
Hope you'll like it !



Source code of the ASCII mode (AutoHK) :

Code:
;========================================================
;Kodi Launcher By Schmurtz    11/10/2015
;========================================================

; --------------- Credits ---------------
;Written by EliteGamer360, Please give credit When you Copy and use my scripts for any other purpose.
;Copyright @ XBMCCUSTOMREGIS.SOURCEFORGE.NET

;http://www.autohotkey.net/~TheGood/AHKHID/AHKHID.ahk
;from: TheGood
;AHKHID.ahk is in C:\users\YourName\My Documents\AutoHotKey\Lib
; --------------- Credits ---------------


;win7 64bit/standard 32bit autohotkey.exe

;modif schmurtz to remove right clic in systray icon
Menu, Tray, NoStandard
Menu, Tray, Add, Exit, ByeScript
Menu, Tray, Default, Exit

;change tooltip text in systray
Menu, Tray, Tip, Kodi Launcher

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#SingleInstance, Force


#include AHKHID.ahk
;Set up the constants
AHKHID_UseConstants()

;Create GUI to receive messages
Gui, +LastFound
hGui := WinExist()

;Intercept WM_INPUT messages
WM_INPUT := 0xFF
OnMessage(WM_INPUT, "InputMsg")



;Register Remote Control with RIDEV_INPUTSINK (so that data is received even in the background)
r := AHKHID_Register(12, 1, hGui, RIDEV_INPUTSINK)
r := AHKHID_Register(65468, 136, hGui, RIDEV_INPUTSINK)
;r := AHKHID_Register(1, 6, hGui, RIDEV_INPUTSINK)
Return

InputMsg(wParam, lParam) {

    Local devh, iKey, sLabel, CurIndex

    Critical
  
    ;Get handle of device
    devh := AHKHID_GetInputInfo(lParam, II_DEVHANDLE)
    ;devt := AHKHID_GetInputInfo(lParam, II_DEVTYPE)
    ;MsgBox, % devh
    ;If (devh = 19210847 or devh = 7995485 or devh = 227481659) {

      
      
       ;CurIndex := AHKHID_GetDevIndex(devh)
       ;test := AHKHID_GetDevName(CurIndex)
       ;test := AHKHID_GetDevInfo(CurIndex, DI_HID_USAGEPAGE&)
       ;MsgBox, % test
      
       ; check code type, to display data in the right way
           r := AHKHID_GetInputInfo(lParam, II_DEVTYPE)
        
    If (r = RIM_TYPEKEYBOARD) {
    iKey := AHKHID_GetInputInfo(lParam, II_KBD_VKEY)
    }
    If (r = RIM_TYPEHID) {
    iKey := AHKHID_GetInputData(lParam, uData)
    iKey := NumGet(uData, 1, "UChar")
    }
    If (r = RIM_TYPEMOUSE) {
    iKey := AHKHID_GetInputData(lParam, uData)
    iKey := NumGet(uData, 1, "UChar")
    }
    

        ;Get data
        ;iKey := AHKHID_GetInputData(lParam, uData)
        ;MsgBox, % iKey
    
        ;Check for error
        If (iKey <> -1) {
         SendInput, {ASC %iKey%}
            }

;IfWinNotExist, Windows Media Center
;{
;}

        }
        
        
        ; ---------------------------------------- fonction ----------------------------------------
Kodi_Launcher() {
            ;Ctrl-Alt-Enter is the shortcut to start Kodi using the Big Green Start Button.
    IfWinNotExist Kodi.exe ;If Kodi is not running
    VarSetCapacity(si,44)
    DllCall("GetNativeSystemInfo", "uint", &si)
        if ErrorLevel {
        MsgBox Windows XP or later required.
        ExitApp
    }
        ARM := NumGet(si,0,"ushort")
        run % ARM=0 ? "C:\Program Files\Kodi\Kodi.exe" : ARM=9 ? "C:\Program Files (x86)\Kodi\Kodi.exe" : ARM=6 ? "IA64" : "Unknown System"

        f (ARM = 0)
        {
            32or64 := "32bit"
        }
        If (ARM = 9)
        {
            32or64 := "64bit"
        }
        If (ARM = 6)
        {
            32or64 := "Unknown System"
    }

    WinActivate ;Activate and Refocus Kodi.
    WinShow ;Bring Kodi to front.
    sleep, 1000
    WinGet, Style, Style, ahk_class Kodi
    
    if (Style & 0xC00000)  ;0xC00000 is WS_CAPTION, meaning window has a title bar.
    {
        ;Send {VKDC}  ;Maximize Kodi to fullscreen mode if its in a window mode.
        SendInput, !{Enter}
    }
    Return


        SetTitleMatchMode 2
        #IfWinActive Kodi ahk_class Kodi ; Kodi detection for Kodi/GSB Home Screen action.
        
        

        #IfWinActive ;



            
        
Return
}
        
ByeScript:

  ExitApp
        
        [quote][/quote]
Reply
#2
Hi schmurtz,

Thanks for your work here, I to have been searching for a suitable solution to getting the full use from my HID remote.
What I find interesting coming from Mediaportal is that there is no real support for HID remotes where as Media portal are focused mainly on HID remotes and are fazing out support for ehome remotes.
The biggest issue which I am yet to resolve is the record button, I see you have'nt appeared to map it either, Eventghost can read the record button but I am yet to commit to going down that route.
I take it you just gave up on mapping the record button?
Cheers
Mark
Reply
#3
Hi, no you can use all the button that you want with this script. It include the record button.
Best regards.
Reply

Logout Mark Read Team Forum Stats Members Help
HP hq-tre Remote RF - utility to use HID remote with Kodi0