Commit da48f73f authored by JP Dinger's avatar JP Dinger

Skins2: Factor out getModKey() and getKeyState() (both used twice), use...

Skins2: Factor out getModKey() and getKeyState() (both used twice), use var_SetVariant() instead of var_Set().
parent d79be0ff
...@@ -54,3 +54,13 @@ const string EvtKey::getAsString() const ...@@ -54,3 +54,13 @@ const string EvtKey::getAsString() const
return event; return event;
} }
int EvtKey::getModKey() const {
int i = getKey();
if( getMod() & kModAlt )
i |= KEY_MODIFIER_ALT;
if( getMod() & kModCtrl )
i |= KEY_MODIFIER_CTRL;
if( getMod() & kModShift )
i |= KEY_MODIFIER_SHIFT;
}
...@@ -44,6 +44,9 @@ public: ...@@ -44,6 +44,9 @@ public:
virtual const string getAsString() const; virtual const string getAsString() const;
int getKey() const { return m_key; } int getKey() const { return m_key; }
int getModKey() const;
ActionType_t getKeyState() const { return m_action; }
private: private:
/// The concerned key, stored according to the '#define's in vlc_keys.h /// The concerned key, stored according to the '#define's in vlc_keys.h
......
...@@ -218,7 +218,7 @@ void TopWindow::processEvent( EvtKey &rEvtKey ) ...@@ -218,7 +218,7 @@ void TopWindow::processEvent( EvtKey &rEvtKey )
} }
// Only do the action when the key is down // Only do the action when the key is down
if( rEvtKey.getAsString().find( "key:down") != string::npos ) if( rEvtKey.getKeyState() == EvtKey::kDown )
{ {
//XXX not to be hardcoded! //XXX not to be hardcoded!
// Ctrl-S = Change skin // Ctrl-S = Change skin
...@@ -240,31 +240,14 @@ void TopWindow::processEvent( EvtKey &rEvtKey ) ...@@ -240,31 +240,14 @@ void TopWindow::processEvent( EvtKey &rEvtKey )
return; return;
} }
vlc_value_t val; var_SetInteger( getIntf()->p_libvlc, "key-pressed",
// Set the key rEvtKey.getModKey() );
val.i_int = rEvtKey.getKey();
// Set the modifiers
if( rEvtKey.getMod() & EvtInput::kModAlt )
{
val.i_int |= KEY_MODIFIER_ALT;
}
if( rEvtKey.getMod() & EvtInput::kModCtrl )
{
val.i_int |= KEY_MODIFIER_CTRL;
}
if( rEvtKey.getMod() & EvtInput::kModShift )
{
val.i_int |= KEY_MODIFIER_SHIFT;
}
var_Set( getIntf()->p_libvlc, "key-pressed", val );
} }
// Always store the modifier, which can be needed for scroll events // Always store the modifier, which can be needed for scroll events
m_currModifier = rEvtKey.getMod(); m_currModifier = rEvtKey.getMod();
} }
void TopWindow::processEvent( EvtScroll &rEvtScroll ) void TopWindow::processEvent( EvtScroll &rEvtScroll )
{ {
// Raise the windows // Raise the windows
...@@ -289,20 +272,11 @@ void TopWindow::processEvent( EvtScroll &rEvtScroll ) ...@@ -289,20 +272,11 @@ void TopWindow::processEvent( EvtScroll &rEvtScroll )
} }
else else
{ {
// Treat the scroll event as a hotkey // Treat the scroll event as a hotkey plus current modifiers
vlc_value_t val; int i = (rEvtScroll.getDirection() == EvtScroll::kUp ?
if( rEvtScroll.getDirection() == EvtScroll::kUp ) KEY_MOUSEWHEELUP : KEY_MOUSEWHEELDOWN) | m_currModifier;
{
val.i_int = KEY_MOUSEWHEELUP;
}
else
{
val.i_int = KEY_MOUSEWHEELDOWN;
}
// Add the modifiers
val.i_int |= m_currModifier;
var_Set( getIntf()->p_libvlc, "key-pressed", val ); var_SetInteger( getIntf()->p_libvlc, "key-pressed", i );
} }
} }
......
...@@ -97,26 +97,8 @@ void VoutWindow::setFullscreen( bool b_fullscreen ) ...@@ -97,26 +97,8 @@ void VoutWindow::setFullscreen( bool b_fullscreen )
void VoutWindow::processEvent( EvtKey &rEvtKey ) void VoutWindow::processEvent( EvtKey &rEvtKey )
{ {
// Only do the action when the key is down // Only do the action when the key is down
if( rEvtKey.getAsString().find( "key:down") != string::npos ) if( rEvtKey.getKeyState() == EvtKey::kDown )
{ var_SetInteger( getIntf()->p_libvlc, "key-pressed",
vlc_value_t val; rEvtKey.getModKey() );
// Set the key
val.i_int = rEvtKey.getKey();
// Set the modifiers
if( rEvtKey.getMod() & EvtInput::kModAlt )
{
val.i_int |= KEY_MODIFIER_ALT;
}
if( rEvtKey.getMod() & EvtInput::kModCtrl )
{
val.i_int |= KEY_MODIFIER_CTRL;
}
if( rEvtKey.getMod() & EvtInput::kModShift )
{
val.i_int |= KEY_MODIFIER_SHIFT;
}
var_Set( getIntf()->p_libvlc, "key-pressed", val );
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment