Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

New way to get MCE Remote signals in EG (for Vista/Win7)

If you have a question or need help, this is the place to be.
Post Reply
User avatar
Melloware
Plugin Developer
Posts: 86
Joined: Mon May 12, 2008 6:18 pm

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by Melloware »

stottle wrote: To be clear, you still want an installer msi for the service (with the registry changes for #1 only - which doesn't require reboot), and a separate python script, not part of the msi, that does #2?
I am still interested in the MSI.
stottle wrote: BTW, I've got 64 bit working, I was going to post that when I saw this message.... So I will get that up as soon as I make these changes. Don't have the blaster working yet, though.
I am interested in testing out the 64 bit version!
-----------------------------------
Melloware Inc.
EventPhone iPhone Application
Intelliremote - HTPC Remote Application
-----------------------------------
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by Bitmonster »

Melloware wrote:
stottle wrote: To be clear, you still want an installer msi for the service (with the registry changes for #1 only - which doesn't require reboot), and a separate python script, not part of the msi, that does #2?
I am still interested in the MSI.
Why?
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by stottle »

Melloware wrote:
stottle wrote: To be clear, you still want an installer msi for the service (with the registry changes for #1 only - which doesn't require reboot), and a separate python script, not part of the msi, that does #2?
I am still interested in the MSI.
Ok, that's just not right! I just finish uploading a zip (see first post) with the 32 and 64 bit exe - without the installer - and now someone else wants an installer! Mello - you're timing is impeccable.

I've attached the 64 bit installer here. The msi in the original file is still valid for 32 bit Vista/Win7.

Brett
Attachments
AlternateMceIrInstaller.zip
64 bit installer for AlternateMceIrService.
(23.96 KiB) Downloaded 369 times
stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by stottle »

@Bitmonster -

Here's the python code to change the registry (this changes all five keys, not just ...da):

Code: Select all

HID_SUB_KEY = (
    "SYSTEM\\CurrentControlSet\\Services\\HidIr\\Remotes\\"
    "745a17a0-74d3-11d0-b6fe-00a0c90f57d"
)
    def SetHidState(self, disableHid):
        """
        Sets the HID registry values. Will raise WindowsError if not 
        successful.
        """
        noKeyCount = 0
        for a in ['a','b','c','d','e']:
            tmpkey = HID_SUB_KEY+a
            try:
                key = reg.OpenKey(
                    reg.HKEY_LOCAL_MACHINE, tmpkey, 0, reg.KEY_ALL_ACCESS
                )

                for i in xrange(4):
                    valueName = 'CodeSetNum%i' % i
                    if disableHid:
                        reg.DeleteValue(key, valueName)
                    else:
                        reg.SetValueEx(key, valueName, 0, reg.REG_DWORD, i + 1)
            except:
                noKeyCount = noKeyCount + 1
                continue            
        if noKeyCount == 5:
            raise

    def CheckHidState(self, disableHid):
        """
        Checks the HID registry values and calls self.ShowHidMessage
        if needed.
        """
        noKeyCount = 0
        for a in ['a','b','c','d','e']:
            tmpkey = HID_SUB_KEY+a
            try:
                key = reg.OpenKey(
                    reg.HKEY_LOCAL_MACHINE, tmpkey, 0, reg.KEY_READ
                )
            except WindowsError:
                noKeyCount = noKeyCount + 1
                continue
            
            needsChange = False
            for i in xrange(4):
                valueName = 'CodeSetNum%i' % i
                try:
                    dummyValue, dummyValueType = reg.QueryValueEx(key, valueName)
                    disabled = False
                except WindowsError:
                    disabled = True
                if disableHid != disabled:
                    needsChange = True
                    break
            reg.CloseKey(key)
        if noKeyCount == 5:
            raise self.Exceptions.DeviceNotFound
        if needsChange:
            wx.CallAfter(self.ShowHidMessage, disableHid)
Brett
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by Bitmonster »

Oops, haven't realized the answer came from Melloware. I was under the assumption it came from stottle. Now I can guess why you would like one. But for the EventGhost environment, it is simply more convenient for the users, if we can handle this through the plugin completely.

@stottle
Do we need two different Service.exe for 32bit and 64bit? Or was this an installer issue?
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by stottle »

The source code is the same, but it gets compiled into different binary executables for 32 vs 64 bit. The installer was also different, but even without the installer you need to run the version appropriate for the OS.

Brett
User avatar
Melloware
Plugin Developer
Posts: 86
Joined: Mon May 12, 2008 6:18 pm

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by Melloware »

stottle wrote:The source code is the same, but it gets compiled into different binary executables for 32 vs 64 bit. The installer was also different, but even without the installer you need to run the version appropriate for the OS.

Brett
I have tested the 64 bit version on Vista Ultimate 64 and it works great!
-----------------------------------
Melloware Inc.
EventPhone iPhone Application
Intelliremote - HTPC Remote Application
-----------------------------------
User avatar
jitterjames
Experienced User
Posts: 677
Joined: Thu Aug 13, 2009 4:36 pm
Location: Quebec, Canada
Contact:

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by jitterjames »

I would like to test this plugin as well. I have vista 32, vista 64, and win7 32 installed on different machines.

Having scanned this thread from the beginning I'm still not sure where to get the latest files. Also do I just need to install the plugin now or do I need to install the service separately?

Thanks for all your hard work guys. I sure hope you get the blaster thing figured out eventually.

Let me know if there is anything I can do to help with testing.

btw I have a mce remote made specifically for vista. It does work with the older plugin but the blaster doesn't work and it is generally a bit slow and quirky. I have only tested it on my vista 64 machine.
stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by stottle »

Right now, you need to install the Win7/Vista plugin as well as the service (either 32 or 64 bit, depending on the OS). Sorry its confusing at the moment, but Bitmonster seems to be close to having a modified plugin that will install the service automatically if necessary, making the process a lot simpler. I think he has everything he needs from me, so hopefully it will be out soon.

If you want to test before Bitmonster's release, grab the attached zip and uncompress it to your EG plugins folder. For this case, you can ignore the source code and the two exe's. Just run the appropriate msi (x86 for 32 bit, and x64 for 64 bit) and reboot, then load the plugin in EG and you will be up and running.

If that isn't clear, just post back here.

[edit] Thanks jitterjames, for the offer to help! [/edit]

Brett
Attachments
MceRemote_Vista.zip
Same files as previously posted, just all in one zip. Includes - plugin, 32/64 bit service exe's (for bitmonster) and 32/64 bit installers (for anyone that wants to test right away). Also has the source.
(89.26 KiB) Downloaded 351 times
User avatar
jitterjames
Experienced User
Posts: 677
Joined: Thu Aug 13, 2009 4:36 pm
Location: Quebec, Canada
Contact:

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by jitterjames »

that's clear. I'm going to give it a try on the x64 machine.

What I'm not clear on, is this: Does it matter if I am using a mce remote made for vista as opposed one made for xp?
User avatar
jitterjames
Experienced User
Posts: 677
Joined: Thu Aug 13, 2009 4:36 pm
Location: Quebec, Canada
Contact:

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by jitterjames »

hoo ya!

Seems to work extremely well. Every button on the mce remote is working, and it seems much quicker, though I should have tested the old setup immediately before updating for a better comparison.

It works great with my DVD remote as well. Of course the codes are all gobbledegook in this case. Is it possible to remap keycodes to friendlier eventnames with this plugin?

I don't know if I will be able to but I'd like to try to help with this, and especially with getting the blaster going.

I have only worked with c# so far not c++. Would I need the full VS2008 or can I use the Express version? If you could get me pointed in the right direction that would be great.

In the mean time I'll just poke through the code to see if I can make any sense of it.

cheers!

James

P.S. do you need me to test it on win7 32 bit?
User avatar
jitterjames
Experienced User
Posts: 677
Joined: Thu Aug 13, 2009 4:36 pm
Location: Quebec, Canada
Contact:

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by jitterjames »

OK I can ALMOST remap it, but it's not quite working.

I'm using this Python Script:

#remap keys for dvd remote
timeout = 0.1
eventRemap = eg.result.Map
eventRemap("SIRC20.49D16", "OpenCloseEject", timeout)
eventRemap("SIRC20.49D06", "Num7", timeout)


I can run the script with no errors.
When I press a button on the remote I get this in the log window:


MCE_Vista.OpenCloseEject
Exception in thread Thread-3:
Traceback (most recent call last):
File "threading.pyc", line 525, in __bootstrap_inner
File "threading.pyc", line 477, in run
File "C:\Program Files (x86)\EventGhost\eg\Classes\ResettableTimer.py", line 63, in ThreadLoop
ArgumentError: argument 2: <type 'exceptions.TypeError'>: wrong type


now here's the weird part. It works after that, but If I press a remapped key more than one time in a row it won't work. If I press another key then go back to the remapped key, then it will register correctly again.

I tried playing with different values for timeout but it doesn't seem to make a difference. Is timeout supposed to be an other type than a number? I tried putting 0.1 in quotes but it didn't change anything.

nevermind, I took a look at Classes\ResettableTimer.py and realized it was expecting milliseconds. Changed to 50 and it now works, though 50 is too small!

Should I just delete this post or will someone find it helpful?
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by Bitmonster »

@stottle
0.3.7.r1182 includes some stuff to experiment with the driver installing.

First add some code to the plugin, so we have two test buttons:

Code: Select all

    def Configure(self, dummy=True):
        from eg.WinApi.PipedProcess import ExecAsAdministrator
        from os.path import join, dirname
        import sys
        scriptPath = join(dirname(__file__.decode(sys.getfilesystemencoding())), "Install.py")
        panel = eg.ConfigPanel()
        installButton = panel.Button("Install Service")
        def OnInstallButton(event):
            ExecAsAdministrator(scriptPath, "Install")
        installButton.Bind(wx.EVT_BUTTON, OnInstallButton)
        uninstallButton = panel.Button("Uninstall Service")
        def OnUnInstallButton(event):
            ExecAsAdministrator(scriptPath, "Uninstall")
        uninstallButton.Bind(wx.EVT_BUTTON, OnUnInstallButton)
        panel.sizer.Add(installButton)
        panel.sizer.Add((10, 10))
        panel.sizer.Add(uninstallButton)
        while panel.Affirmed():
            panel.SetResult()
Quite clumsy, but works. The important function is ExecAsAdministrator() from eg.WinApi.PipedProcess.
The first argument is a Python file that should be executed in the elevated process. The second parameter is the name of the function that should be called inside the Python module. You can supply additional parameters that will be used to call the function, but we don't use it here. If such parameters are used, they must be "pickle-able".

Now we add a file "Install.py" to your plugin folder, with this content:

Code: Select all

import sys
from os.path import dirname, join
from eg.WinApi.Service import Service

def Install():
    service = Service(u"AlternateMceIrService")
    pluginDir =  dirname(__file__.decode(sys.getfilesystemencoding()))
    service.Install(join(pluginDir, "AlternateMceIrService_86.exe"))
    service.Start()
    print "Service successfully installed"


def Uninstall():
    service = Service(u"AlternateMceIrService")
    service.Stop()
    service.Uninstall()
    print "Service successfully uninstalled"
So once a button is pressed, the appropriate function will be called in this file.
"Service" from eg.WinApi.Service is the needed helper class for manipulating services. Its only instantiation parameter is the name of the service. It mainly has four methods:

Install(exePath):
To install a service. You have to supply the path to the executable to install

Start(), Stop(), Uninstall(): Should be easy to guess what they do.

So this code as is only works for 32-bit and will also throw exceptions quite easily. For example if you try to install the service, when it is already installed. But this is just a matter of some try/except blocks.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
User avatar
jitterjames
Experienced User
Posts: 677
Joined: Thu Aug 13, 2009 4:36 pm
Location: Quebec, Canada
Contact:

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by jitterjames »

wow. seems like a lot of work considering that the exe installed the service with a double click and no problems (on vista x64). I am impressed by your dilligence.

Once you get this working will you still need to reboot for the service to work?
stottle
Plugin Developer
Posts: 636
Joined: Sun Apr 26, 2009 10:59 pm

Re: New way to get MCE Remote signals in EG (for Vista/Win7)

Post by stottle »

Sorry its taken a bit to reply. I tried taking the family camping yesterday, got out a lake but had lot's of wind and rain. Then the wind collapsed the tent, breaking one of the poles. So we had to break camp and ended up trekking back home. It was a long and memorable day.

@Bitmonster -
That looks good, although I don't see it modifying the necessary registry values (both for eHome and so the event logging works). I've downloaded the new version, but haven't tried it yet, so sorry if that's in the code but not the post.

I also found this link on detecting the bitness of the OS. It works on Win7 64, with EG running in WoW64, I haven't tried on 32-bit yet. Here's the code snippet:

Code: Select all

from os import environ
os = 32
if environ.get("PROCESSOR_ARCHITECTURE") == "AMD64" or environ.get("PROCESSOR_ARCHITEW6432") == "AMD64":
    os = 64
@jitterjames -
I really like what Bitmonster is doing. You've read this thread on the forum, so you know about the separate installer for the service. A user who downloads EG won't necessarily know about this thread, so having the plugin install the service makes everything easier for the user.

I haven't found a way to avoid reboot, and I don't think Bitmonster has either. If anyone finds a way, please let us know!

Brett
Post Reply