PlayStation 3 Bluetooth Remote

Questions and comments specific to a particular plugin should go here.

Re: PlayStation 3 Bluetooth Remote

Postby magao » Sun Nov 09, 2008 12:48 pm

Out of date - see below

I've been playing around today and ended up modifying the PS3 remote plugin to generate "repeat" events for long and mixed presses (separate events for long and mixed). This allows simple scrolling through lists, etc. I've also worked out how to make the PS3 remote work without any extra intervention after resuming from standby. If I could wake from standby using the remote I wouldn't need anything else, but my bluetooth adaptor doesn't allow it ...

The "repeat" event codes look like:

Code: Select all
HID.Up.L#
HID.Up.M#

HID.Down.L#
HID.Down.M#


By default, I've configured the repeat interval to be 0.00 (no repeat). Any positive non-zero value means that the appropriate "repeat" event will be generated at that interval after the "long press" event is generated until the key is released. For example, if the "long press" wait is 0.50 seconds, and the "repeat" interval is 0.06 seconds, you will get events like:

Code: Select all
0.50 HID.Up.L
0.56 HID.Up.L#
0.62 HID.Up.L#
0.68 HID.Up.L#
...
0.?? HID.Release


I think I'd like to add the interval as payload i.e. instead produce:

Code: Select all
0.50 HID.Up.L
0.56 HID.Up.L# [0.06]
0.62 HID.Up.L# [0.12]
0.68 HID.Up.L# [0.18]
...
0.?? HID.Release


I've found in my testing that 0.06 seems optimal for scrolling through lists. If I have it any faster on my machine, events get queued up and you can't guarantee that you can stop appropriately. Testing is needed on other machines.

BTW, I haven't quite done things correctly here - I'm actually doing fixed delay rather than fixed time i.e. the sequence is actually:

Code: Select all
Wait for long press timeout
Trigger long press event
Wait for repeat interval
Trigger long press repeat event
Wait for repeat interval
Trigger long press repeat event


What I should be doing is:

Code: Select all
Get event time
Calculate when the long press should time out
Wait for remainder of long press timeout
Trigger long press event
Calculate when the repeat interval should time out
Wait for remainder of repeat interval
Trigger long press repeat event
Calculate when the repeat interval should time out
Wait for remainder of repeat interval
Trigger long press repeat event


I also had to do some extra work to ensure that if a button is being held down when the PC goes into standby (e.g. configured Standby on HID.Zarbi.L) that it doesn't continue to spew unusable events when the PC wakes up (stopping the timer threads in various situations).

I've attached my modified version (I've labelled it 2.02 to distinguish it) plus an example configuration file demonstrating how I'm using it. The plugin is backwards-compatible with version 2.0.1 (I've added a parameter with a default value of 0.0 to __start__).

The configuration file also demonstrates how to ensure that the PS3 remote is usable when waking from standby (or a reboot). My bluetooth adaptor is from a Logitech MX900, which doesn't automatically use HCI mode, so I force it to HCI when EventGhost starts or the PC wakes up (other dongles may not need this step). Then when the various devices are discovered I disable and re-enable the PS3 remote plugin - once this has been done, pressing any button on the remote will connect to the PC and generate events.
Last edited by magao on Tue Nov 11, 2008 5:57 am, edited 1 time in total.
magao
 
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

Re: PlayStation 3 Bluetooth Remote - 3.0.0

Postby magao » Mon Nov 10, 2008 5:05 am

Out of date - see below

OK - major update - big enough that I've bumped it to 3.0.0.

1. The PS3 remote is now put into low-power (SNIFF) mode when the "Hibernate" event is generated. It's also put into SNIFF mode when suspending, and when EventGhost is first started up. It is taken out of SNIFF mode when any button press is registered (also if possible when resuming, but in practice it needs a button press anyway). I use eg.Bind to detect these events. I've added a message to the log when entering/exiting low-power mode. You can tell you're in low-power mode because it will take a couple of seconds for the first button press to be registered (and I've found that can't be a long press for some reason).

2. The plugin automatically handles re-detecting the PS3 remote after resuming, so the workaround (System.DeviceAttached) is no longer needed. I do the same thing internally (using eg.Bind).

3. I've fixed the interval issue I mentioned in the previous post, and added the time since the long timeout as the payload of the "repeat" events.

I've had to do some pretty hacky things to get the first two working (e.g. enumerating keys in the registry to find the Bluetooth device address). I don't know if there's a better way to do some of it. The code also needs a major cleanup.
Last edited by magao on Tue Nov 11, 2008 5:58 am, edited 1 time in total.
magao
 
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

Re: PlayStation 3 Bluetooth Remote

Postby Thierry » Mon Nov 10, 2008 6:15 am

This is a great update. Thanks. Should be added in the next beta of eventghost.
Thierry
Plugin Developer
 
Posts: 13
Joined: Sun Nov 25, 2007 9:50 pm

Re: PlayStation 3 Bluetooth Remote

Postby Bitmonster » Mon Nov 10, 2008 7:11 am

@ magao

It looks like ypu missed the concept of TriggerEnduringEvent()/EndLastEvent().
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
User avatar
Bitmonster
Site Admin
 
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: PlayStation 3 Bluetooth Remote

Postby magao » Mon Nov 10, 2008 7:50 am

I've got the basic concept, but not quite sure how to use them yet. I only started using my PS3 remote and EventGhost yesterday - my PS3 was badly hurt by the 2.50 firmware (not fixed by 2.52) to the point that it's basically useless as a media player now. My brother recently gave up on his MX900 mouse, which meant I had a Bluetooth dongle available. And I'm currently on leave. Someone was obviously telling me to do some HTPC experimentation, so I grabbed my laptop and started hacking away. Never done any bluetooth programming before. I've got a lovely mixture of hacks, cargo-cult programming and other nasties in there ;)

Since I've got something working, I thought it was worthwhile handing over. Hopefully someone can take what I've got, and produce a good version that has the same (or more) capabilities.

BTW, the PS3 remote plugin is already using enduring events for "normal" button presses (and in fact, that's one of the things I had to deal with for repeating events and suspending). The repeating events aren't meant to be enduring.
magao
 
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

Re: PlayStation 3 Bluetooth Remote

Postby Bitmonster » Mon Nov 10, 2008 8:03 am

Take a look at the action "Autorepeat current macro" and "Jump if long press" with the Keyboard plugin for example and I guess you realize the problem quite soon. EG works in a down/up event manner and repeating or other timed things are done by the user through adding special actions.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
User avatar
Bitmonster
Site Admin
 
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: PlayStation 3 Bluetooth Remote

Postby magao » Mon Nov 10, 2008 8:14 am

That's what I first tried, but couldn't get it to work - I think there needs to be more documentation around the "Autorepeat current macro". Leastwise, I couldn't work it out in the first half hour, at which point I started looking at code ...

I'd happily rip out the "repeating" events if someone were to add an example of achieving the same effect using the original capabilities of the PS3 remote ;)
magao
 
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

Re: PlayStation 3 Bluetooth Remote

Postby Bitmonster » Mon Nov 10, 2008 8:16 am

You don't seem to be one of the patient folks. :)
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
User avatar
Bitmonster
Site Admin
 
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: PlayStation 3 Bluetooth Remote

Postby Bitmonster » Mon Nov 10, 2008 8:26 am

magao wrote:I'd happily rip out the "repeating" events if someone were to add an example of achieving the same effect using the original capabilities of the PS3 remote ;)

Just make a macro with some action (like toggle mute) and add a autorepeat action to the macro.
Or use this macro and press and hold the green triangle:
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1542">
    <Macro Name="Repeat test" Expanded="True">
        <Event Name="X10.DVDMenu" />
        <Action>
            EventGhost.PythonScript(u'try:\n    eg.globals.i += 1\nexcept:\n    eg.globals.i = 0')
        </Action>
        <Action>
            EventGhost.ShowOSD(u"I have repeated {i} times.", u'0;-29;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (255, 255, 255), (0, 0, 0), 0, (15, 15), 0, 3.0, True)
        </Action>
        <Action>
            EventGhost.AutoRepeat(0.59999999999999998, 0.29999999999999999, 0.0, 3.0)
        </Action>
    </Macro>
</EventGhost>
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
User avatar
Bitmonster
Site Admin
 
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: PlayStation 3 Bluetooth Remote

Postby magao » Mon Nov 10, 2008 7:36 pm

Hmm - I'm sure I tried that. Maybe I tried using the .L event rather than the enduring event - at the time I think I thought that the .L was the enduring event. If I can get it to work I'll rip out the repeating stuff and repost.

BTW the "half hour" bit was slightly tongue-in-cheek - it was probably more like a couple of hours, but it appears my Google-fu failed me.
magao
 
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

Re: PlayStation 3 Bluetooth Remote - 3.0.1

Postby magao » Tue Nov 11, 2008 6:03 am

Updated to 3.0.1 - ripped out the "repeat" events. Thanks for the pointer I needed - with that it became obvious. This version will continue to work with xml files from 2.0.2 and 3.0.0 despite removing the "repeat" config option - I've left a dummy parameter in.

<edit>I should note that the low-power mode will only work if you are using the Widcomm bluetooth stack - it will not work with the default MS stack.</edit>

magao wrote:OK - major update - big enough that I've bumped it to 3.0.0.

1. The PS3 remote is now put into low-power (SNIFF) mode when the "Hibernate" event is generated. It's also put into SNIFF mode when suspending, and when EventGhost is first started up. It is taken out of SNIFF mode when any button press is registered (also if possible when resuming, but in practice it needs a button press anyway). I use eg.Bind to detect these events. I've added a message to the log when entering/exiting low-power mode. You can tell you're in low-power mode because it will take a couple of seconds for the first button press to be registered (and I've found that can't be a long press for some reason).

2. The plugin automatically handles re-detecting the PS3 remote after resuming, so the workaround (System.DeviceAttached) is no longer needed. I do the same thing internally (using eg.Bind).


As I said, I'm sure there are things which should be done in a better way in the code, but I don't know enough to do it better at this stage.
Attachments
PS3-3.0.1.zip
(11.56 KiB) Downloaded 499 times
Last edited by magao on Tue Nov 11, 2008 9:42 am, edited 1 time in total.
magao
 
Posts: 21
Joined: Sun Nov 09, 2008 11:06 am

Re: PlayStation 3 Bluetooth Remote

Postby djdafreund » Tue Nov 11, 2008 8:05 am

Hey, thanks a bunch for these nice additions. Going to test it now.
djdafreund
 
Posts: 6
Joined: Sat Oct 18, 2008 3:55 am

Re: PlayStation 3 Bluetooth Remote

Postby Bitmonster » Tue Nov 11, 2008 10:51 am

I assume some more could be ripped from this plugin. :)
"Trigger enduring events" could be set to true for all cases and "use raw data" will never be useful I guess. "Event prefix" is also looks superfluous, as a simple "PS3." prefix will do it. These settings seem to be unnecessary inherited from the HID plugin.

"Short press" and "Long press" really should go away, as they don't fit into the concept of EG's event processing. "Release event" is also unnecessary. Using the proper "remote key as name" if known, could also be used in all cases I guess.

Oh, and it would be fine, if the device list could only show PS3 remote instances if possible. Might be a bit confusing to the user if all HID devices are shown there.

So actually not much more then the "sleep" and "hibernate" settings are needed.

Does the remote generate a dedicated zone event if the zone button is pressed? Or does the plugin only see a zone change when the next button is pressed?
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
User avatar
Bitmonster
Site Admin
 
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: PlayStation 3 Bluetooth Remote

Postby Thierry » Wed Nov 12, 2008 12:52 am

Bitmonster wrote:I assume some more could be ripped from this plugin. :)
"Trigger enduring events" could be set to true for all cases and "use raw data" will never be useful I guess. "Event prefix" is also looks superfluous, as a simple "PS3." prefix will do it. These settings seem to be unnecessary inherited from the HID plugin.


100% agree.

Bitmonster wrote:"Short press" and "Long press" really should go away, as they don't fit into the concept of EG's event processing. "Release event" is also unnecessary. Using the proper "remote key as name" if known, could also be used in all cases I guess.


Short, Long, Mixte are really usefull to increase the number of command possible to trigger with this remote. It's very usefull to do something with a short press on a button and an other with a long press and it's very complicated to do this inside the .XML itself by the use of the timer box (and it's works very badly)

It should be better if this kind of things was available inside EG itself, ie if there is a simple way inside EG to do something different depends if it's short press, long bress, double click or mixte click but it's not the case (or I miss it ?) so ...

"remote key" are used as far as they are known (from remote itself or paper sheet documentation inside the box)

Bitmonster wrote:Oh, and it would be fine, if the device list could only show PS3 remote instances if possible. Might be a bit confusing to the user if all HID devices are shown there.

So actually not much more then the "sleep" and "hibernate" settings are needed.


Same than Short, Long and so on. It's usefull to do something when the remote is not used during a long time and difficult to do inside EG .xml file ...

Bitmonster wrote:Does the remote generate a dedicated zone event if the zone button is pressed? Or does the plugin only see a zone change when the next button is pressed?


The remote don't generate a zone event. same than the other, it's avoid to made a big "OR" inside .xml file ...

I fully understand I add many calculated/simulated events inside the plugin and it's not the right place to add this kind of things but this event are usefull, simplify .xml a lot, and I think should be added inside EG itself.

EG include an easy way to do an "Autorepeat" function why not include an easy way to detect "Short click" "Long click" "Double click" "Mixte click" "no click since xxx seconds" and so on ???

Regards,

Thierry.
Thierry
Plugin Developer
 
Posts: 13
Joined: Sun Nov 25, 2007 9:50 pm

Re: PlayStation 3 Bluetooth Remote

Postby djdafreund » Wed Nov 12, 2008 2:57 am

I agree about keeping short press and long press. I am personally taking advantage of this functionality. Example, i use my red/green/blue/yellow buttons normal press as shortcuts for videos/music/weather/favorite's, and long press i have them configured for updatevideoDB/updatemusicDB/, and also play controls play, but longplay it's adds it in the cue list. Very usefull indeed. PS button normal press starts up XBMC, long press brings up shutdown menu.
djdafreund
 
Posts: 6
Joined: Sat Oct 18, 2008 3:55 am

PreviousNext

Return to Plugin Support

Who is online

Users browsing this forum: No registered users and 3 guests