Skip to main content

Remote Control/KeyListener problem

5 replies [Last post]
bloomfield
Offline
Joined: 2008-01-28
Points: 0

Hello everybody,

i have a problem with the enter button. It works fine on PS3 and PowerDVD but not on some old Pioneer player.

I have a container with a close button on it. Even though the button is focused and the key listener is attached to it, it would not fire the keyPressed method:

int key = KeyEvent.getKeyCode();

if (KeyEvent.getSource() == closeButton & key == HRcEvent.VK_ENTER)
{
doSomething();
}

Nothing happens when i press enter.

The strange thing about it is:
when i put this code fragment into the keyReleased method, the enter button works.
But the desired behaviour is of course: triggering the action when pressing the button, not only when releasing it.
Does anybody have any idea what may be the problem?

thanks and cheers
Bloomield

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dbreitenfeld
Offline
Joined: 2007-03-18
Points: 0

Hi Bloomfield,

This is going to seem like a silly question and is probably just a typo but can you confirm the follow line

if (KeyEvent.getSource() == closeButton & key == HRcEvent.VK_ENTER)

is actually (notice the second & symbol)

if (KeyEvent.getSource() == closeButton && key == HRcEvent.VK_ENTER)

Also the use of == when comparing your source to the "closeButton". I would recommend using .equals like this:

if (closeButton.equals(KeyEvent.getSource()) && key == HRcEvent.VK_ENTER)

I placed closeButton first because I assume the closeButton will never be null, maybe the getSource could return null, not sure but this is the safe way to use .equals.

Hope this provides some help.

Denny B.
-------------------------------------------------------------------------------------------------------------
[i]NetBlender DoStudio Blu-ray Team - DSA - http://dostudio.netblender.com [/i]

bloomfield
Offline
Joined: 2008-01-28
Points: 0

Hey Denny,

thanks for your answer. I think you are right concerning the use of the == operator.
And using the && operator of course is better, too.
But the problem stays the same on the Pioneer player.
I tried many alternatives.

This doesn't work:
if (closeButton.equals(evt.getSource()) && keycode == HRcEvent.VK_ENTER)
{
doSomething();
}

while triggering an event from the closeButton with the i.e. VK_LEFT key works fine:

if (closeButton.equals(evt.getSource()) && keycode == HRcEvent.VK_LEFT)
{
doSomething();
}

any further ideas anyone?

Cheers bloomfield

dbreitenfeld
Offline
Joined: 2007-03-18
Points: 0

Hi Bloomfield,

Can you confirm the enter key works when it is attached to other buttons? Are you able to determine which side condition in the if statement is false? Like the source is never correct or the key is never correct? Do you have an on log screen logging feature?

Cheers,

Denny B.
-------------------------------------------------------------------------------------------------------------
[i]NetBlender DoStudio Blu-ray Team - DSA - http://dostudio.netblender.com [/i]

bloomfield
Offline
Joined: 2008-01-28
Points: 0

Hey Denny,

on the Pioneer player, i have the same problem with every other button, even with HTextButtons.

The exception is: When I add the Keylistener to the Hscene and not to a button, then an event is triggered by the enter key.
so the remote control is ok :-)

I also implemented an on screen log, but when pressing enter,i see that no event is triggered.
As already mentioned: my implementation works on PS3 etc. and it works on the Pioneer player when listening to i.e. VK_DOWN key.
An what confuses me too, it works in the keyReleased method.

cheers
bloomfield

dbreitenfeld
Offline
Joined: 2007-03-18
Points: 0

Hi Bloomfield,

That is very odd and sadly it sounds like a player implementation bug, as it seems your code and remote are just fine.

Unfortunately we have only done extensive testing by implementing a listener for org.dvb.event.UserEventListner and then manually keeping track of the focus and selection. We've also done extensive testing by implementing a listener for java.awt.event.KeyListener and once again manually keeping track of things. If you do not have a lot of work in changing your code to the above approach it might be an alternative route to go?

Maybe someone else here has had success or failure with the approach you are using?

Cheers,

Denny B.
-------------------------------------------------------------------------------------------------------------
[i]NetBlender DoStudio Blu-ray Team - DSA - http://dostudio.netblender.com [/i]