Cathwyler / MagicRemoteService

Use your LG Magic Remote as a Windows mouse and control your PC with the LG Magic Remote from your LG WebOS TV
GNU General Public License v3.0
48 stars 2 forks source link

Customising remote’s key actions #1

Closed paperboyo closed 1 year ago

paperboyo commented 1 year ago

Hi. Thank you for your work! I wonder if it would be possible to customise some of the keys sent to PC from the Magic Remote (even if only by modifying the code before running it on the PC)?

Let me describe my use case. I would like to be able to control Plex HTPC PC application using Magic Remote. My PC is connected to the LG TV via HDMI and they are on the same network. Sadly, Plex HTPC doesn’t work well with the PC mouse, but I would like to avoid yet another remote to control the PC. One option would be something like Flirc.

Your app does the scroll, direction keys, etc. Great! But I would love to be able to have eg. Pause on some of the colour buttons. So, basically, what Windows calls Media Keys, I suppose? I’m not a developer, but maybe I could follow what you did eg. here, if I could find codes for Windows Media Keys?

Sensible/possible? Not possible/stupid?

Cathwyler commented 1 year ago

Hi. Thank for your feedback. That's possible and that's a good idea because everyone would have probably some specific use. That's easy to do but the HMI part will take me a while. While waiting for a new version if you are able to compile the project with visual studio you can try modify /Resources/TV/MagicRemoteService/main.js

https://github.com/Cathwyler/MagicRemoteService/blob/420528555483091258738e2fcddc09c5d3d6094a/MagicRemoteService/Resources/TV/MagicRemoteService/main.js#L527-L633

Case 0x193 to 0x196 are the color key. refer to https://webostv.developer.lge.com/develop/guides/magic-remote. The Windows vk key you need are probably 0xB0 to 0xB3. You can remap in main.js each case 0x193 to 0x196 in keydown and keyup event with replacing

case 0x193: //Color key
    ...
    break;

with or add

case 0x193: //Color key
    SendKeyboardKey({ 
        usC: 0xB0, //VK Key
        bS: true //true in keydown event false in keyup event
    }); 

I forgot that you will need to add vk key case in https://github.com/Cathwyler/MagicRemoteService/blob/420528555483091258738e2fcddc09c5d3d6094a/MagicRemoteService/Service.cs#L1138-L1143

After compile you need to run and install it on TV.

paperboyo commented 1 year ago

Thanks! Customisation UI would indeed be ideal, but even if the mapping woul exist in a simple config file, that would help a lot (unless the compilation step would be still necessary, which may be too hard for some, like me: although I will try!).

Thanks again!

Cathwyler commented 1 year ago

You can now change Remote keybind from UI.