NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 13 14 15 16 17 … 93 Next »
KeyMappings

 
  • 0 Vote(s) - 0 Average
KeyMappings
imilne
Offline

Posting Freak

Posts: 2,423
Threads: 135
Joined: Feb 2008
#1
2011-07-26, 05:21 PM
I have existing code that does something in response to CTRL+B being pressed:

Code:
public override bool OnKeyDown(KeyEventArgs e)
{
  if (e.Control && e.KeyCode == Keys.B)
  {
    // do something...

But I was wondering; should I actually be doing something with the KeyMappings.xml stuff and responding to that instead (ShowOSD in this case):

Code:
<Key code="{CTRL}B" command="ShowOSD"/>

Obviously it must be better because then the user can change their mappings and have my plugin respond to some other key.

Is there an API trick to it (or even a C# one), or do I need to parse the XML and work it all out manually?

Iain
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,724
Threads: 767
Joined: Nov 2003
#2
2011-07-26, 06:04 PM
I have a class that does this for me, but it's not in a module that is accessable to plugins.

In the attached patch I've made a slighty modified version of it in NUtility. Create an instance of the KeyCommandHelper object, passing in a path to your own keymappings.xml file (probably stored in with your plugin files), then for each key press you can do keyCommandHelper.GetCommand("General", theKeyEventArgs) and it'll return the command or null if unknown.

See my keymappings.xml for the format.
imilne
Offline

Posting Freak

Posts: 2,423
Threads: 135
Joined: Feb 2008
#3
2011-07-26, 06:57 PM
Works perfect, thanks.

Iain
johnsonx42
Offline

Posting Freak

Posts: 7,298
Threads: 189
Joined: Sep 2008
#4
2011-07-26, 07:22 PM
iain let me know if you plan to release a plugin that needs this functionality before the next NPVR release, and I'll include this update in the patch list.
server: NextPVR 5.0.7/Win10 2004/64-bit/AMD A6-7400k/hvr-2250 & hvr-1250/Winegard Flatwave antenna/Schedules Direct
main client: NextPVR 5.0.7 Desktop Client; LG 50UH5500 WebOS 3.0 TV
imilne
Offline

Posting Freak

Posts: 2,423
Threads: 135
Joined: Feb 2008
#5
2011-07-26, 07:27 PM
Nah, I highly doubt it, so don't worry about it. One for the back burner for the time being...

Iain
mvallevand
Offline

Posting Freak

Ontario Canada
Posts: 52,953
Threads: 956
Joined: May 2006
#6
2011-07-26, 10:00 PM
I think the proper codes for colours are actually now Alt R,G,B,Y but sub also allows Ctrl-B as a kind of legacy mode.

Martin
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Keymappings in NPVR scb147 2 1,745 2010-08-03, 04:10 PM
Last Post: scb147
  KeyMappings McBainUK 1 1,675 2010-02-13, 10:28 PM
Last Post: sub
  KeyMappings - PVRX2 - BaseButtonUIList psycik 1 1,284 2007-12-16, 04:06 PM
Last Post: sub

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode