NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 2 3 4 5 … 93 Next »
Remote control example code?

 
  • 0 Vote(s) - 0 Average
Remote control example code?
drmargarit
Offline

Member

Posts: 184
Threads: 49
Joined: Sep 2013
#1
2018-02-11, 02:19 AM
Are there any examples of how to capture remote control commands so I can build my own custom NextPVR client?
I am working with this bit of code but I get nothing when
Code:
public void RegisterRemote()
        {            
            RAWINPUTDEVICE[] rid = new RAWINPUTDEVICE[4];

            rid[0].usUsagePage = 0xFFBC;      // adds HID remote control
            rid[0].usUsage = 0x88;
            rid[0].dwFlags = 0;
            rid[0].hwndTarget = fForm.Handle;

            rid[1].usUsagePage = 0x0C;      // adds HID remote control
            rid[1].usUsage = 0x01;
            rid[1].dwFlags = RIDEV_INPUTSINK;
            rid[1].hwndTarget = fForm.Handle;

            rid[2].usUsagePage = 0x0C;      // adds HID remote control
            rid[2].usUsage = 0x80;
            rid[2].dwFlags = RIDEV_INPUTSINK;
            rid[2].hwndTarget = fForm.Handle;

            //rid[0].usUsagePage = 0x01;      // adds HID mouse with no legacy messages
            //rid[0].usUsage = 0x02;
            //rid[0].dwFlags = RIDEV_NOLEGACY;

            rid[3].usUsagePage = 0x01;      // adds HID keyboard with no legacy message
            rid[3].usUsage = 0x06;
            rid[3].dwFlags = RIDEV_NOLEGACY;
            uint theSize = (uint)Marshal.SizeOf(rid[0]);
            if (!RegisterRawInputDevices(rid, (uint)rid.Length, theSize))
                throw new ApplicationException("Failed to register raw input devices.");        
        }


It runs without error but I get nothing in the WndProc override when I press remote buttons.

Really frustrating.

Jim Margarit
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#2
2018-02-11, 06:19 AM
I think this was the original article I read on it:
https://msdn.microsoft.com/en-us/library/ms996387.aspx

Remember, it'll only work with MCE remote and receiver though, not just any remote.
drmargarit
Offline

Member

Posts: 184
Threads: 49
Joined: Sep 2013
#3
2018-02-11, 04:37 PM
sub Wrote:I think this was the original article I read on it:
https://msdn.microsoft.com/en-us/library/ms996387.aspx

Remember, it'll only work with MCE remote and receiver though, not just any remote.

Yes, that article is my primary source of info. It is outdated as it doesn't compile and actually has this line of code in it:
Code:
Marshal.FreeHGlobal(pRawInputDeviceList);Device, uint uiCommand, IntPtr
pData, ref uint pcbSize);

I'm thinking it is a cut and paste error or it that actually syntax that I'm not familiar with?

I'm using the same "Microsoft eHome Infrared transceiver" that I use with my NextPVR setup. GetRawDeviceInfo enumerates it as a IrDevice. That much of the code is working well.
Interestingly, the code I posted has one entry commented out.
Code:
//rid[0].usUsagePage = 0x01;      // adds HID mouse with no legacy messages
            //rid[0].usUsage = 0x02;
            //rid[0].dwFlags = RIDEV_NOLEGACY;

If I register this device, my main window stops responding to the mouse and keyboard. Those events are going somewhere but I don't know where.
I'm thinking that the hwndTarget is incorrect but I only have one window and that's the handle I pass.

My main interest was if any of the other clients have source code that uses the remote control code.

Thanks,

Jim
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#4
2018-02-11, 05:41 PM
I haven't looked at this code in maybe 10 years, but this is what I'm using this:

Code:
RAWINPUTDEVICE[] Rid = new RAWINPUTDEVICE[2];
                const int RIDEV_INPUTSINK = 0x00000100;
                const int RIDEV_NOLEGACY = 0x00000030;
                const int RIDEV_APPKEYS = 0x00000400;
                const int RIDEV_NOHOTKEYS = 0x00000200;


                Rid[0].usUsagePage = 0xFFBC; //adds most MCE remote buttons
                Rid[0].usUsage = 0x88;
                Rid[0].dwFlags = RIDEV_INPUTSINK | (0x03 & (RIDEV_NOLEGACY | RIDEV_APPKEYS | RIDEV_NOHOTKEYS));
                Rid[0].hwndTarget = parent.Handle;

                Rid[1].usUsagePage = 0x0C;   // adds MCE remote control - more info, details, guide buttons
                Rid[1].usUsage = 0x01;
                Rid[1].dwFlags = RIDEV_INPUTSINK | ((0x03 >> 8) & (RIDEV_NOLEGACY | RIDEV_APPKEYS | RIDEV_NOHOTKEYS));
                Rid[1].hwndTarget = parent.Handle;

                if (RegisterRawInputDevices(Rid, (uint)2, (uint)Marshal.SizeOf(Rid[0])) == false)
                {
                    Logger.Error("Error registering raw input devices");
                }
(Though I can see a weird shift in there that doesn't make a lot of sense)
drmargarit
Offline

Member

Posts: 184
Threads: 49
Joined: Sep 2013
#5
2018-04-21, 11:24 PM
Thanks for the code snippet. I write code in a virtual machine for portability between computers and to limit the carnage of rogue code. It bit me in the butt here. The VMware vm messes with RawInputDevices somehow and the code just doesn't work. I had to install Visual Studio on the host machine for this one project and it works fine now. I grieve for the wasted hours trying to fix this.

Jim
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Looking for C# UPnP Media Server code bgowland 5 7,555 2016-12-16, 08:25 PM
Last Post: mvallevand
  API help - remote control greg in kansas 0 2,621 2016-07-04, 03:54 PM
Last Post: greg in kansas
  ios app to control npvr ui idea jnbooker15 4 3,554 2015-09-21, 10:19 PM
Last Post: sub
  ios app to control npvr ui idea jnbooker15 0 2,432 2015-09-21, 06:39 PM
Last Post: jnbooker15
  TitanTv Remote Schedule For GBPVR UncleJohnsBand 51 33,387 2015-08-20, 05:11 PM
Last Post: sub
  Remote client logout timeout. mvallevand 2 2,504 2014-10-28, 12:55 AM
Last Post: mvallevand
  Kinect Voice (Gesture) Control topcat 5 3,516 2014-09-20, 12:03 PM
Last Post: topcat
  Version control / repository software for VS Express bgowland 2 2,377 2014-05-02, 09:57 PM
Last Post: bgowland
  Weird Code problem - serialisation (I'll spell it the proper way!!"0 psycik 22 6,041 2011-11-25, 03:16 AM
Last Post: whurlston
  sample video overlay plugin source code? reven 2 2,325 2011-10-03, 12:42 AM
Last Post: reven

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode