Sign up here and you can log into the forum!

catch key press

General WDTVExt forum

catch key press   

Postby KAD » Thu Jan 05, 2012 9:21 pm

it seems we're unable to catch certain key presses, is this correct?

after starting a plugin I found this thread
http://forum.wdlxtv.com/viewtopic.php?f=46&t=590&p=3915&hilit=catch+key+press#p3915

has this been resolved
it seems I'm unable to supress the underlying dmaosd function for the arrow keys on villa_home.xml

here's what I had come up with

Code: Select all
// OsdRemote Plugin WDTVExt plugin by KAD (2011)
//
//
/*
# meta-name="OsdRemote"
# meta-desc="WDTVExt OsdRemote"
# meta-author="KAD"
# meta-date="2012-01-10"
# meta-version="1.0.0"
# meta-type="wdtvext"
# meta-url="http://forum.wdlxtv.com"
# meta-filename="OsdRemote.plugin.js"
*/
traceln("OsdRemote: Start loading OsdRemote plugin");

function OsdRemotePlugin(path) {
   this.rootPath = path;
   
   this.debug = new Debug();
   this.debug.Enable = true;
   var dLevel = getConfigSetting("OSDREMOTE_DEBUG");
   this.debug.Level = (!dLevel || dLevel == "" || dLevel < 0) ? 0 : dLevel;
   this.debug.Lib = (this.debug.Level > 2) ? this.debug.Level - 2 : 0;
   this.debug.Prefix = "OsdRemote:";
}

OsdRemotePlugin.prototype = new Plugin();
OsdRemotePlugin.prototype.constructor = OsdRemotePlugin;

OsdRemotePlugin.prototype.onPageKey = function(page, key) {
   this.debug.Log("[onPageKey] page: " + page.markupFileName, 3);
   if (page.markupFileName == "villa_home.xml") {
      if (key == 34) { //UP
         res = executeCmd("irinject STOP", this.debug.Lib);
         return true
      }
      if (key == 35) { //DOWN
         res = executeCmd("irinject STOP", this.debug.Lib);
         return true
      }
      if (key == 32) {  //LEFT
         res = executeCmd("irinject UP", this.debug.Lib);
         return true
      }
      if (key == 33) { //RIGHT
         res = executeCmd("irinject DOWN", this.debug.Lib);
         return true
      }
   }
};

OsdRemotePlugin.instance = new OsdRemotePlugin(scriptPath);
Plugin.registerPlugin(OsdRemotePlugin.instance);
traceln("OsdRemote: End loading OsdRemote plugin");


plugin loads and functions with the exception that the underlying dmaosd function for the keys are still executed along with my irinject cmds

KAD
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
User avatar
KAD
Global Moderator
 
Posts: 4008
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: catch key press   

Postby dentex » Thu Jan 05, 2012 11:32 pm

Hi KAD,
my post will be of no use, but it's just to confirm this behavior.
On every if (key == XY) the underlying dmaosd function has already been called, and you're actually using this call to irinject something (but could be anything else).
This happens also in my TransmissionOsd plugin, when I'm on the osd keyboard I've done; basically it's like a submenu with a single item, so pushing UP, RIGHT or DOWN brings to nothing, and thus I can use the key pression on the remote to make what I want (that is to move within the keyboard). But when I press LEFT, it moves left on keyboard and together gets out of the menu and the keyboard itself...
We need a way to intercept the key pression BEFORE it's processed by the dmaosd; but how?

ciao!
User avatar
dentex
Supporter
 
Posts: 165
Joined: Fri Apr 15, 2011 4:57 am
Location: Italy

Re: catch key press   

Postby KAD » Thu Jan 05, 2012 11:39 pm

yeah for my purpose there's no submenu

another thought I had I could always use different keys
like
1 = left
2 = enter
3 = right

but I'd still prefer to over ride the existing arrow keys
basically I'm just trying to remap the main arrow keys

to function with a different osd layout

KAD
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
User avatar
KAD
Global Moderator
 
Posts: 4008
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: catch key press   

Postby mad_ady » Thu Jan 05, 2012 11:49 pm

It's good news then - if the underlying dmaosd process executes the remote ir code before your irinject, then you can revert by irinjecting the opposite IR code before your desired action. So, you'd be doing:
User presses left
DMAOSD executes Left
js code calls irinject Right; irinject YOUR_DESIRED_CODE

It's worth a try KAD, but I fear the page might interpret the irinject codes and you would end up in a loop.
User avatar
mad_ady
Developer
 
Posts: 2996
Joined: Fri Nov 05, 2010 9:08 am
Location: Bucharest, Romania

Re: catch key press   

Postby dentex » Thu Jan 05, 2012 11:57 pm

mad_ady wrote:... if the underlying dmaosd process executes the remote ir code before your irinject, then you can revert by irinjecting the opposite IR code before your desired action...


I was thinking the same thing, but maybe you'll end up with a "back and forth" behavior, because the actions are in sequence. It's worth a try anyway.

KAD wrote:another thought I had I could always use different keys, like
1 = left
2 = enter
3 = right

Thanks KAD, this solution can solve my problem! I don't mind using different keys to navigate the osd keyboard. And I already use the tv remote remapped with EIRI.
User avatar
dentex
Supporter
 
Posts: 165
Joined: Fri Apr 15, 2011 4:57 am
Location: Italy

Re: catch key press   

Postby dentex » Fri Jan 06, 2012 12:15 am

But, from the WIKI:
onPageKey

Things are starting to get interesting with this event now. This event is called everytime you press a key on the remote (or you use /tmp/ir_injection ;))


The part in brackets now is confusing me a bit.
User avatar
dentex
Supporter
 
Posts: 165
Joined: Fri Apr 15, 2011 4:57 am
Location: Italy

Re: catch key press   

Postby recliq » Fri Jan 06, 2012 3:42 am

It doesn't matter if you press a key on the remote or you use ir_injection it's both a key press for dmaosd.
ir_injection just simulates a keypress on remote, dmaosd doesn't know the difference.

If you want to catch a keypress in WDTVExt make your script return true from onPageKey(), note that this doesn't work for all keys. Some can be catched some not.
I told this pibos when he was still developing WDTVExt but he quit before putting out a newer version, so this bug is in all versions of WDTVExt.
­WDLXTV Project Maintainer
-:] If you like my contributions feel free to donate for a beer or a new flash drive. ...and always remember: RTFM! (README, FAQ, WIKI) [:-
User avatar
recliq
WDLXTV Team
 
Posts: 5021
Joined: Thu Apr 15, 2010 8:09 am
Location: Kiel, Germany

Re: catch key press   

Postby dentex » Fri Jan 06, 2012 3:54 am

recliq wrote:...ir_injection just simulates a keypress on remote, dmaosd doesn't know the difference...


Thanks, this clears the things up.
User avatar
dentex
Supporter
 
Posts: 165
Joined: Fri Apr 15, 2011 4:57 am
Location: Italy

Re: catch key press   

Postby KAD » Fri Jan 06, 2012 9:14 am

thanks for the idea's, I guess I've got a just a few more things to try tonight

we'll see how it goes

KAD
User avatar
KAD
Global Moderator
 
Posts: 4008
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Re: catch key press   

Postby KAD » Sat Jan 07, 2012 1:17 pm

another question, is it possible to issue system cmd's that will bring up a specific requested menu??

if possible, a massive WDTVext plugin to handle all menu navigation and placement could be written

KAD
If you like my work please consider a Donation. Donate
Please read the appropriate documentation before posting questions! READ ME FAQ WIKI
User avatar
KAD
Global Moderator
 
Posts: 4008
Joined: Mon Apr 12, 2010 4:59 pm
Location: Seattle, WA USA

Next

Return to WDTVExt discussion

Who is online

Users browsing this forum: No registered users and 1 guest