C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 08-15-2008, 08:53 AM   #1
Registered User
 
Join Date: Aug 2007
Posts: 40
Howto make own application for remote control handling

What I want to do is to make a program which is controlled by a remote control.
Now I have a remote control that came with my tv card, and I would like to use that one. TV card is conceptronic ctvfmi2 for pci slot.
There is a process running that handles what has to be done if a button has been pressed on the remote. That is P3XRCtl.exe. (I'm just mentioning this in case someone has experience with it)
Now I don't know how it's actually working, if someone knows I would love to know too
But the way I see it, it should be something like this. When P3XRCtl starts, it lets the driver or windows or whatever know that he is the one handling the remote control actions. The processID is stored and everytime hardware/driver/windows notices a button was pressed, it will send a custom windows message to the process with the processsID they have stored. The wndproc of P3XRCtl can then determine which button was pressed and take action.
So to figure out the buttons I could put this in the wndproc:
Code:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message >= WM_USER)
	{
		wstringstream lala;
		lala << message;
		MessageBox(hWnd,lala.str().c_str(),_T("Title"),0);
	}
}
Or something else, in any way let me know the code for the button that I have just pressed.
In a second stadium I could then just so a switch where the cases are those custom messages.

I want to know if this could work, and if I'm correct how to let the drivers/hardware/windows know which app to send the messages to. Perhaps even have to track what P3XRCtl is doing when it's starting.
And if I'm wrong, some other way I could achieve this. I've been googline for it but I can't seem to find anything relative.

I hope someone can help me on this one ^^
s-men is offline   Reply With Quote
Old 08-15-2008, 09:45 AM   #2
Registered User
 
Codeplug's Avatar
 
Join Date: Mar 2003
Posts: 3,844
My first attempt would be try the techniques discussed here: http://www.codeguru.com/cpp/w-p/syst...icle.php/c5655
http://msdn.microsoft.com/en-us/libr...75(VS.85).aspx

gg
Codeplug is offline   Reply With Quote
Old 08-15-2008, 10:47 AM   #3
Registered User
 
Join Date: Mar 2005
Location: Mountaintop, Pa
Posts: 1,054
Possibly WinLirc ????
BobS0327 is offline   Reply With Quote
Old 08-15-2008, 12:16 PM   #4
Registered User
 
Join Date: Aug 2007
Posts: 40
WM_APPCOMMAND doesn't seem to work.
And winlirc works with IR eyes connected to a com port, while mine is connected to a port on the tv card.
I should have to know what P3XRCtl is doing, without going into assembly code or anything cause that's way over my head.
s-men is offline   Reply With Quote
Old 08-15-2008, 01:31 PM   #5
Registered User
 
Codeplug's Avatar
 
Join Date: Mar 2003
Posts: 3,844
Can your controller control anything other than the software provided by the manufacturer? Like Windows Media Player or IE etc... Does it claim to be MediaCenter compatible?

gg
Codeplug is offline   Reply With Quote
Old 08-15-2008, 01:42 PM   #6
Registered User
 
Join Date: Aug 2007
Posts: 40
They don't make any claims about the remote.
When I press power it starts honestechTV and while that is running I control that. When honestechTV isn't running, I can use the numbers to move my mouse, do left and right clicks, and turn off the pc.
I would just have to intercept the messages from the buttons and to my own thing with it, and if possible prevent the normal program from getting the mesages at all. Or else I would have to pretend to be that program so I would get the messages anyway without the normal exe for handling the remote even running.
s-men is offline   Reply With Quote
Old 08-15-2008, 02:48 PM   #7
Registered User
 
Join Date: Aug 2007
Posts: 40
hmmm I think i've got an idea. I could just replace the honestechTV exe with my exe. The remote control handler will execute my exe and then think that he is sending the remote button commands to the real program while it's actually mine, this just might work, time to try it out ^^

edit: damn, he runs my exe, but thinks that it isn't open. I guess I have to send him a message stating that it's the real deal. I'll have to use windows hooks to see what he is getting at the time honestechTV is starting.

Last edited by s-men; 08-15-2008 at 02:59 PM. Reason: tested it out
s-men is offline   Reply With Quote
Old 08-15-2008, 03:15 PM   #8
Registered User
 
Codeplug's Avatar
 
Join Date: Mar 2003
Posts: 3,844
That's making a lot of assumptions about how it actually works. Their code could be talking directly to the driver for all you know.

Since it does cause the mouse to move and click - you *should* be able to see injected mouse actions with a WH_MOUSE_LL mouse hook - which you could even intercept and handle yourself. WH_MOUSE_LL doesn't require a DLL - just a call to SetWindowsHookEx and a message pump in the same thread. See MSDN for SetWindowsHookEx, WH_MOUSE_L and LowLevelMouseProc.

gg
Codeplug is offline   Reply With Quote
Old 08-15-2008, 05:13 PM   #9
Registered User
 
Join Date: Mar 2005
Location: Mountaintop, Pa
Posts: 1,054
Quote:
But the way I see it, it should be something like this. When P3XRCtl starts, it lets the driver or windows or whatever know that he is the one handling the remote control actions. The processID is stored and everytime hardware/driver/windows notices a button was pressed, it will send a custom windows message to the process with the processsID they have stored. The wndproc of P3XRCtl can then determine which button was pressed and take action.
You certainly do have a creative imagination. IR transmitters and receivers use the Phillips RC5 protocol. Build youself an inexpensive IR receiver, write the software to drive the hardware to process the RC5 messages and you will accomplish your task.
BobS0327 is offline   Reply With Quote
Old 08-15-2008, 05:18 PM   #10
Registered User
 
Join Date: Aug 2007
Posts: 40
I don't think it's talking to the driver directly, because without that P3XRCtl, you can't use the remote control at all.
I would like to see all the messages but just the ones from P3XRCtl, but I don't know how to do that. I can get the messages of ALL the threads, or I suppose just the ones for the app I'm making if I use GetCurrentThreadID.
The buttons that control the mouse are only half of the buttons and I'd rather use them all, but if I can't get the other other ones, it'll be enough, but I'm going to try my best of getting them all first.

edit @ BobS0327: I'm not very good at building things
s-men is offline   Reply With Quote
Old 08-15-2008, 06:01 PM   #11
Registered User
 
Codeplug's Avatar
 
Join Date: Mar 2003
Posts: 3,844
>> without that P3XRCtl, you can't use the remote control at all
That's evidence that P3XRCtl talks directly to the driver. The driver is receiving data from the IR/RF dongle (or whatever). From there, a user mode application or service would communicate with the driver and do something with it.

gg
Codeplug is offline   Reply With Quote
Old 08-15-2008, 06:17 PM   #12
Registered User
 
Join Date: Aug 2007
Posts: 40
So the app I make should just talk to P3XRCtl since he is already getting the signals from the IR eye and sending them to honestechTV if it's active. So I have to make P3XRCtl think that my app is honestechTV right? HonestechTV isn't getting the IR signals directly since if I kill the P3XRCtl when honestechTV is running, the pressing on buttons does nothing untill I start P3XRCtl again.
Btw, using WH_MOUSE_LL works in vista but in xp I get an "ERROR_HOOK_NEEDS_HMOD 1428 0x594", so I'm going to need to work with a dll in xp (that's what my interpretation of that error is).
s-men is offline   Reply With Quote
Old 08-15-2008, 06:32 PM   #13
Registered User
 
Join Date: Mar 2005
Location: Mountaintop, Pa
Posts: 1,054
$39.95 infrared receiver with Windows software development kit.
BobS0327 is offline   Reply With Quote
Old 08-15-2008, 07:34 PM   #14
Registered User
 
Codeplug's Avatar
 
Join Date: Mar 2003
Posts: 3,844
Just forget about "talking" to P3XRCtl, or "pretending" to be the TV app.

*If you're lucky*, P3XRCtl may find and post messages to a specific window created by the TV application. If so, you may be able to inject a DLL into the TV app and hook the window procedure of the window that receives remote-button presses.

Use this to "spy" on a window messages of the TV app: http://www.windows-spy.com/

gg
Codeplug is offline   Reply With Quote
Old 08-15-2008, 08:55 PM   #15
Registered User
 
Join Date: Aug 2007
Posts: 40
oh very nice little tool, thanks to that tool I have found the windows message I was looking for. WM_USER + 2000 is the one stating a button was pressed on the remote, and wParam tells which button it was.
I could hook all threads with WH_CALLWNDPROC and as long as it's not that one I can just pass them on, but I wonder if I don't do CallNextHookEx if it will prevent the message from reaching the normal app.
I'm also wondering about performance of checking the messages of all the threads. Is there anyway to get a threadID of another process? (I've seen it in an application today that it would show me the threadID's of everything, but I would need to be able to request it myself in realtime).

Anyway thanks for all the help and pointers in the right direction, I have a feeling I'm close to doing it

edit: hooray it's working! but only if honestechTV is running, I can do my thing with it, and honestech does his thing with it afterwards (which I don't want so that is next to fix).
Weird thing happend, wh_callwndproc worked like a charm on vista, but on xp it worked, it called the proc, but the only calls that were "intercepted" were calls from itself, while in vista I got it from all threads. Anyway, switched to wh_getmessage and that is working just fine now.

edit2: more hooray, the following line fooled honestechTV, I get the message and he disgards it after my edit
Code:
(reinterpret_cast<MSG*>(lParam))->wParam = 0; //edit wparam so that honestechtv "thinks" that it was an invalid button
The only thing left is to only monitor 1 thread instead of all, so if someone could tell me how to get the threadID it's gonna be perfect.
In any way I would like to say thank you very much Codeplug, if you ever are in Bruges - Belgium, I'll buy you a beer

Last edited by s-men; 08-15-2008 at 11:27 PM.
s-men is offline   Reply With Quote
Reply

Tags
driver, hardware, windows

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can i make a normal application jobbie C++ Programming 18 01-22-2006 05:59 PM
Relativly new to c++, how do I make application interfaces? Frantic- C++ Programming 20 12-09-2004 07:52 PM
howto make a static library? mart_man00 C Programming 2 07-19-2003 11:10 PM
Tab Controls - API -KEN- Windows Programming 7 06-02-2002 09:44 AM
How do you make a 'Slider' control? Okiesmokie Windows Programming 4 04-26-2002 03:49 PM


All times are GMT -6. The time now is 01:26 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22