Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: MythTV: Dev

Shift key ignored in shortcuts

 

 

MythTV dev RSS feed   Index | Next | Previous | View Threaded


olly at roomaroo

Oct 27, 2008, 10:00 AM

Post #1 of 6 (1070 views)
Permalink
Shift key ignored in shortcuts

I'm trying to set up a new remote control at the moment. It's
recognised as a keyboard and most of the buttons send key combinations
- e.g. Stop sends Ctrl+Shift+S, Play sends Ctrl+Shift+P.

The problem is, any key combination containing Shift is ignored. Ctrl
or Alt are fine. I looked in the code and found this in
libs/libmythui/mythmainwindow.cpp:


// Make keynum in QKeyEvent be equivalent to what's in QKeySequence
int MythMainWindowPrivate::TranslateKeyNum(QKeyEvent* e)
{
int keynum = e->key();

if (keynum != Qt::Key_Escape && (keynum < Qt::Key_Shift || keynum >
Qt::Key_ScrollLock))
{
Qt::ButtonState modifiers;
// if modifiers have been pressed, rebuild keynum
if ((modifiers = e->state()) != 0)
{
int modnum = (((modifiers & Qt::ShiftButton) &&
keynum > 0x7f) ? Qt::SHIFT : 0) |
((modifiers & Qt::ControlButton) ? Qt::CTRL : 0) |
((modifiers & Qt::MetaButton) ? Qt::META : 0) |
((modifiers & Qt::AltButton) ? Qt::ALT : 0);
modnum &= ~Qt::UNICODE_ACCEL;
return (keynum |= modnum);
}
}

return keynum;
}

So, if the keycode is less than 0x7f the shift modifier is ignored.
According to the docs at [1] all the ASCII characters are in the range
0x20 to 0x7e, so that > 0x7f excludes pretty much any key you'd want
to use in a shortcut!

Does anyone know the logic behind this? If no-one comes up with any
good justifications I'll raise a bug.

Olly


[1] http://doc.trolltech.com/4.3/qt.html#Key-enum
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


mtdean at thirdcontact

Oct 27, 2008, 10:20 AM

Post #2 of 6 (1038 views)
Permalink
Re: Shift key ignored in shortcuts [In reply to]

On 10/27/2008 01:00 PM, Oliver Maunder wrote:
> I'm trying to set up a new remote control at the moment. It's
> recognised as a keyboard and most of the buttons send key combinations
> - e.g. Stop sends Ctrl+Shift+S, Play sends Ctrl+Shift+P.
>
> The problem is, any key combination containing Shift is ignored. Ctrl
> or Alt are fine. I looked in the code and found this in
> libs/libmythui/mythmainwindow.cpp:
>
>
> // Make keynum in QKeyEvent be equivalent to what's in QKeySequence
> int MythMainWindowPrivate::TranslateKeyNum(QKeyEvent* e)
> {
> int keynum = e->key();
>
> if (keynum != Qt::Key_Escape && (keynum < Qt::Key_Shift || keynum >
> Qt::Key_ScrollLock))
> {
> Qt::ButtonState modifiers;
> // if modifiers have been pressed, rebuild keynum
> if ((modifiers = e->state()) != 0)
> {
> int modnum = (((modifiers & Qt::ShiftButton) &&
> keynum > 0x7f) ? Qt::SHIFT : 0) |
> ((modifiers & Qt::ControlButton) ? Qt::CTRL : 0) |
> ((modifiers & Qt::MetaButton) ? Qt::META : 0) |
> ((modifiers & Qt::AltButton) ? Qt::ALT : 0);
> modnum &= ~Qt::UNICODE_ACCEL;
> return (keynum |= modnum);
> }
> }
>
> return keynum;
> }
>
> So, if the keycode is less than 0x7f the shift modifier is ignored.
> According to the docs at [1] all the ASCII characters are in the range
> 0x20 to 0x7e, so that > 0x7f excludes pretty much any key you'd want
> to use in a shortcut!
>
> Does anyone know the logic behind this? If no-one comes up with any
> good justifications I'll raise a bug.

TTBOMK, the keybindings and jumppoints in Myth have always been "case
insensitive," meaning that Ctrl+s is equivalent to Ctrl+S (which is
Ctrl+Shift+s).

Mike
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


olly at roomaroo

Oct 27, 2008, 10:48 AM

Post #3 of 6 (1037 views)
Permalink
Re: Shift key ignored in shortcuts [In reply to]

> TTBOMK, the keybindings and jumppoints in Myth have always been "case
> insensitive," meaning that Ctrl+s is equivalent to Ctrl+S (which is
> Ctrl+Shift+s).
>

I understood that it was case insensitive in that the function will
always get "Shift+S" rather than either "S" or "s". The Qt:Key
enumeration doesn't have separate entries for capital and lower case
characters. There is only one Qt::Key_S.

Olly
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


david at istwok

Oct 27, 2008, 11:21 AM

Post #4 of 6 (1040 views)
Permalink
Re: Shift key ignored in shortcuts [In reply to]

On Mon, Oct 27, 2008 at 05:00:05PM +0000, Oliver Maunder wrote:
> I'm trying to set up a new remote control at the moment. It's
> recognised as a keyboard and most of the buttons send key combinations
> - e.g. Stop sends Ctrl+Shift+S, Play sends Ctrl+Shift+P.
>
> The problem is, any key combination containing Shift is ignored. Ctrl
> or Alt are fine. I looked in the code and found this in
> libs/libmythui/mythmainwindow.cpp:

The code has been that way as long as I can remember. Isaac might be
the only one who knows why shift was handled specially. FWIW, I
considered getting a remote control like you have awhile back and
changed the code in question to treat shift like the other modifier
keys. There were no ill effects as far as could tell.

David
--
David Engel
david [at] istwok
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


ijr at case

Oct 27, 2008, 11:24 AM

Post #5 of 6 (1041 views)
Permalink
Re: Shift key ignored in shortcuts [In reply to]

On Monday 27 October 2008 2:21:54 pm David Engel wrote:
> On Mon, Oct 27, 2008 at 05:00:05PM +0000, Oliver Maunder wrote:
> > I'm trying to set up a new remote control at the moment. It's
> > recognised as a keyboard and most of the buttons send key combinations
> > - e.g. Stop sends Ctrl+Shift+S, Play sends Ctrl+Shift+P.
> >
> > The problem is, any key combination containing Shift is ignored. Ctrl
> > or Alt are fine. I looked in the code and found this in
> > libs/libmythui/mythmainwindow.cpp:
>
> The code has been that way as long as I can remember. Isaac might be
> the only one who knows why shift was handled specially. FWIW, I
> considered getting a remote control like you have awhile back and
> changed the code in question to treat shift like the other modifier
> keys. There were no ill effects as far as could tell.

Basically, it's just there for case insensitivity when using a regular
keyboard.

Isaac

_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev


olly at roomaroo

Oct 27, 2008, 11:33 AM

Post #6 of 6 (1040 views)
Permalink
Re: Shift key ignored in shortcuts [In reply to]

> On Monday 27 October 2008 2:21:54 pm David Engel wrote:
>> The code has been that way as long as I can remember. Isaac might be
>> the only one who knows why shift was handled specially. FWIW, I
>> considered getting a remote control like you have awhile back and
>> changed the code in question to treat shift like the other modifier
>> keys. There were no ill effects as far as could tell.

I'm just building a modified version myself. I can't imagine there'll
be any problems.

On Mon, Oct 27, 2008 at 6:24 PM, Isaac Richards <ijr [at] case> wrote:
> Basically, it's just there for case insensitivity when using a regular
> keyboard.

FWIW I get the same behaviour using regular keyboards - not just with
the remote. I'm surprised the issue hasn't come up before, although I
guess if you've got a normal 105-key keyboard at your disposal you
don't need to mess around with modifiers.

Olly
_______________________________________________
mythtv-dev mailing list
mythtv-dev [at] mythtv
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev

MythTV dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.