[mythtv-commits] Ticket #10053: MythUI KeyBinding reworked
noreply at mythtv.org
Wed Sep 21 16:47:34 UTC 2011
#10053: MythUI KeyBinding reworked
Reporter: Xavier Hervy <xavier.hervy@…> | Owner: stuartm
Type: Patch - Feature | Status: new
Priority: minor | Milestone: unknown
Component: MythTV - User Interface Library | Version: Unspecified
Severity: medium | Keywords: mythui lirc
Ticket locked: 0 |
This patch is an attempt to dissociate the key-bindings for the keyboard
from other inputs such as lirc, apple remote...
== Disclaimer ==
This is just a proof of concept and should probably '''NOT''' be apply to
any local source code.
I only attached this patch to avoid a ''Feature request without patch''
response and also to show that I am willing to work on this area.
This patch have been done somewhere between 0.24 and 0.24.1 then ported to
the HEAD. I did not try it on head, only build it.
== What is the problem with the current implementation ==
* It is difficult to create a remote configuration
1. Setup lirc and add all the remote control we plan to use in
2. Create a .lircrc file and map the button to key
3. Start mythfrontend to test the configuration
4. Go in mythcontrol to check what key is doing what
5. Change the .lircrc configuration accordingly
6. restart step 3 for all remote control until it does work properly
* It is even more difficult with more than on remote which haven't got the
same buttons i.e. some remote have previous/next and rwd/ffd, another one
only have previous/next but have the pause/play button separately ... you
get the picture
* If the user change the default key-binding, he take the risk to break
any client application which rely on the network control interface such
as mythmote ...
* Only 4 keys can be bind to an action
* The End user can not check in mythcontrol how a remote control have been
configured as only key are displayed (not the real name from lircd.conf).
== What this patch do ==
(I wrote this code 9 months ago so I am writing it down as I remember)
* Allow to use lirc without .lircrc
* if .lircrc is missing, the remote control can be configure with the
'''''real''''' name in mythcontrol
* any number of remote control (via lirc) can be configured independently
(as long as there not identical)
== How does it work ==
=== Main classes ===
I create a '''!MythInputManager''' singleton class which is responsible to
deal with the binding of keys and jumps for the keyboard.
'''!MythInputManager''' is also responsible to start any input such as
lirc, appleremote ... (in my patch this is done statically as I am not
very good with .pro files)
'''!MythInputInterface''' is a new abstract class which implement QT
Plugin facilities (declare "org.mythtv.!MythInputInterface/1.0");
The new abstract class '''!MythInputEvent''' represent an button press
event such a QKeyEvent, '''!MythLircEvent''' ...
Basically creating a new input interface is a matter of implementing few
* '''start():''' Start a service such as reading from a socket, ...
* '''stop():''' stop the service
* '''restart():''' ex: stop, reload a configuration file and start
* '''name():''' This is use when a binding need to be store in the
With a new input interface come an new implementation of the
'''!MythInputEvent''' class. A valid '''!MythInputEvent''' class need to
implement the following method:
* '''clone():''' to do a copy
* '''inputName:''' return the name of the input which produce the event,
except if the event have not been produce by any '''!MythInputInterface'''
such as '''!MythKeyboardEvent''' and '''!MythActionEvent'''
* '''remoteName:''' return the name of the remote control which produce
* '''buttonName():''' user friendly name of the button pressed
* '''buttonId():''' a unique id of the button press (unique for the
input/remote) during runtime, as this id is not persistently stored a
simple auto increment does work. This is use by '''!MythInputManager''' to
store the mapping in memory
* '''translateToActions(context,&actions):''' get the list of action an
input event is linked to for a particular event
* '''translateToJump():''' same but for a jump
* '''keyEvent():''' return a QKeyEvent, this is for backward compatibility
only and temporary. For Lirc, the QKeyEvent represent the configuration in
=== Additional changes ===
!MythUIType::keyPressEvent(QKeyEvent * e)
method have been replace by
!MythUIType::keyPressEvent(MythInputEvent * e)
bool MythMainWindow::TranslateKeyPress(const QString &context, QKeyEvent
*e, QStringList &actions, bool allowJumps = true)
have been replaced by
bool MythMainWindow::TranslateKeyPress(const QString &context,
MythInputEvent *e, QStringList &actions, bool allowJumps = true)
Every class which extends indirectly form MythUIType need to be converted
(done in the patch)
I also added to field in the database in the keybinding and jumpoint table
to hold the inputName and remoteName
=== Additionnal classes ===
* '''MythKeyboardEvent:''' encapsulate a QKeyEvent
* '''MythActionEvent:''' basic class which return the "buttonName" as a
list of action when translateToActions is invoke regardless the context.
This is usefull as in some part of the code a QKeyEvent is created to exit
a dialog (If my memory is corrected)
* '''!MythLircInput''' and '''!MythLircEvent'''
== Potential uses ==
Based on the this changes, the followings feature could be implemented
* Start a quick configuration setup when a new remote control is detected
which could setup the basic navigational buttons
* Display the current remote configuration in an help screen according to
the context the help screen have been displayed
* Quick implementation of new device without to have to build mythtv from
== Plan ==
This is the way I think I could implement every thing without disturbance:
1. Move all the code for key binding in !MythInputManager especially the
SQL statement which are currently in !MythMainWindow and in
keybindings.cpp in mythfrontend. Are they are tightly link together then
should not be apart
2. Implement a simple !MythInputInterface that can load '''dynamically'''
some !MythInputInterface implementation.
3. Change !AppleRemote, Lirc and other to implement this interface.
QKeyEvent would still be use at this stage
4. add !MythInputEvent class
5. Find a way to make keyPressEvent(QKeyEvent * ) and
keyPressEvent(!MythInputEvent *) works together
6. remove the need to create some QKeyEvent to trigger an action by
7. Change !MythControl to work with !MythInputEvent instead of QKeyEvent
8. Slowly remove the need for keyPressEvent(QKeyEvent * )
9. Take a rest and relax
Ticket URL: <http://code.mythtv.org/trac/ticket/10053>
MythTV Media Center
More information about the mythtv-commits