CKeyboardStat g_Keyboard;
-#define XBMC_NLK_CAPS 0x01
-#define XBMC_NLK_NUM 0x02
-
-/* Global keystate information */
-static uint8_t XBMC_KeyState[XBMCK_LAST];
-static XBMCMod XBMC_ModState;
-
-static uint8_t XBMC_NoLockKeys;
-
-struct _XBMC_KeyRepeat {
- int firsttime; /* if we check against the delay or repeat value */
- int delay; /* the delay before we start repeating */
- int interval; /* the delay between key repeat events */
- uint32_t timestamp; /* the time the first keydown event occurred */
-
- XBMC_Event evt; /* the event we are supposed to repeat */
-} XBMC_KeyRepeat;
-
-int XBMC_EnableKeyRepeat(int delay, int interval)
-{
- if ( (delay < 0) || (interval < 0) ) {
- return(-1);
- }
- XBMC_KeyRepeat.firsttime = 0;
- XBMC_KeyRepeat.delay = delay;
- XBMC_KeyRepeat.interval = interval;
- XBMC_KeyRepeat.timestamp = 0;
- return(0);
-}
-
struct XBMC_KeyMapping
{
int source;
CKeyboardStat::CKeyboardStat()
{
- /* Initialize the tables */
- XBMC_ModState = XBMCKMOD_NONE;
- memset(XBMC_KeyState, 0, sizeof(XBMC_KeyState));
-
- XBMC_EnableKeyRepeat(0, 0);
-
- XBMC_NoLockKeys = 0;
-
- Reset();
- m_lastKey = XBMCK_UNKNOWN;
+ memset(&m_lastKeysym, 0, sizeof(m_lastKeysym));
m_lastKeyTime = 0;
- m_keyHoldTime = 0;
+
+ // In Linux the codes (numbers) for multimedia keys differ depending on
+ // what driver is used and the evdev bool switches between the two.
m_bEvdev = true;
}
#endif
}
-void CKeyboardStat::Reset()
-{
- m_VKey = 0;
- m_wUnicode = '\0';
- m_cAscii = '\0';
- m_Modifiers = 0;
-
- ZeroMemory(&XBMC_KeyState, sizeof(XBMC_KeyState));
-}
-
-void CKeyboardStat::ResetState()
-{
- Reset();
- XBMC_ModState = XBMCKMOD_NONE;
-}
-
-int CKeyboardStat::HandleEvent(XBMC_Event& newEvent)
-{
- int repeatable;
- uint16_t modstate;
-
- /* Set up the keysym */
- XBMC_keysym *keysym = &newEvent.key.keysym;
- modstate = (uint16_t)XBMC_ModState;
-
- repeatable = 0;
-
- int state;
- if(newEvent.type == XBMC_KEYDOWN)
- state = XBMC_PRESSED;
- else if(newEvent.type == XBMC_KEYUP)
- state = XBMC_RELEASED;
- else
- return 0;
-
- if ( state == XBMC_PRESSED )
- {
- keysym->mod = (XBMCMod)modstate;
- switch (keysym->sym)
- {
- case XBMCK_UNKNOWN:
- break;
- case XBMCK_NUMLOCK:
- modstate ^= XBMCKMOD_NUM;
- if ( XBMC_NoLockKeys & XBMC_NLK_NUM )
- break;
- if ( ! (modstate&XBMCKMOD_NUM) )
- state = XBMC_RELEASED;
- keysym->mod = (XBMCMod)modstate;
- break;
- case XBMCK_CAPSLOCK:
- modstate ^= XBMCKMOD_CAPS;
- if ( XBMC_NoLockKeys & XBMC_NLK_CAPS )
- break;
- if ( ! (modstate&XBMCKMOD_CAPS) )
- state = XBMC_RELEASED;
- keysym->mod = (XBMCMod)modstate;
- break;
- case XBMCK_LCTRL:
- modstate |= XBMCKMOD_LCTRL;
- break;
- case XBMCK_RCTRL:
- modstate |= XBMCKMOD_RCTRL;
- break;
- case XBMCK_LSHIFT:
- modstate |= XBMCKMOD_LSHIFT;
- break;
- case XBMCK_RSHIFT:
- modstate |= XBMCKMOD_RSHIFT;
- break;
- case XBMCK_LALT:
- modstate |= XBMCKMOD_LALT;
- break;
- case XBMCK_RALT:
- modstate |= XBMCKMOD_RALT;
- break;
- case XBMCK_LMETA:
- modstate |= XBMCKMOD_LMETA;
- break;
- case XBMCK_RMETA:
- modstate |= XBMCKMOD_RMETA;
- break;
- case XBMCK_LSUPER:
- modstate |= XBMCKMOD_LSUPER;
- break;
- case XBMCK_RSUPER:
- modstate |= XBMCKMOD_RSUPER;
- break;
- case XBMCK_MODE:
- modstate |= XBMCKMOD_MODE;
- break;
- default:
- repeatable = 1;
- break;
- }
- }
- else
- {
- switch (keysym->sym)
- {
- case XBMCK_UNKNOWN:
- break;
- case XBMCK_NUMLOCK:
- if ( XBMC_NoLockKeys & XBMC_NLK_NUM )
- break;
- /* Only send keydown events */
- return(0);
- case XBMCK_CAPSLOCK:
- if ( XBMC_NoLockKeys & XBMC_NLK_CAPS )
- break;
- /* Only send keydown events */
- return(0);
- case XBMCK_LCTRL:
- modstate &= ~XBMCKMOD_LCTRL;
- break;
- case XBMCK_RCTRL:
- modstate &= ~XBMCKMOD_RCTRL;
- break;
- case XBMCK_LSHIFT:
- modstate &= ~XBMCKMOD_LSHIFT;
- break;
- case XBMCK_RSHIFT:
- modstate &= ~XBMCKMOD_RSHIFT;
- break;
- case XBMCK_LALT:
- modstate &= ~XBMCKMOD_LALT;
- break;
- case XBMCK_RALT:
- modstate &= ~XBMCKMOD_RALT;
- break;
- case XBMCK_LMETA:
- modstate &= ~XBMCKMOD_LMETA;
- break;
- case XBMCK_RMETA:
- modstate &= ~XBMCKMOD_RMETA;
- break;
- case XBMCK_LSUPER:
- modstate &= ~XBMCKMOD_LSUPER;
- break;
- case XBMCK_RSUPER:
- modstate &= ~XBMCKMOD_RSUPER;
- break;
- case XBMCK_MODE:
- modstate &= ~XBMCKMOD_MODE;
- break;
- default:
- break;
- }
- keysym->mod = (XBMCMod)modstate;
- }
-
- if(state == XBMC_RELEASED)
- if ( XBMC_KeyRepeat.timestamp &&
- XBMC_KeyRepeat.evt.key.keysym.sym == keysym->sym )
- {
- XBMC_KeyRepeat.timestamp = 0;
- }
-
- if ( keysym->sym != XBMCK_UNKNOWN )
- {
- /* Update internal keyboard state */
- XBMC_ModState = (XBMCMod)modstate;
- XBMC_KeyState[keysym->sym] = state;
- }
-
- newEvent.key.state = state;
- Update(newEvent);
-
- return 0;
-}
-
-void CKeyboardStat::Update(XBMC_Event& event)
-{
- if (event.type == XBMC_KEYDOWN)
- {
- unsigned int now = CTimeUtils::GetFrameTime();
- if (m_lastKey == event.key.keysym.sym)
- m_keyHoldTime += now - m_lastKeyTime;
- else
- m_keyHoldTime = 0;
- m_lastKey = event.key.keysym.sym;
- m_lastKeyTime = now;
-
- m_cAscii = 0;
- m_VKey = 0;
-
- m_wUnicode = event.key.keysym.unicode;
-
- m_Modifiers = 0;
- if (event.key.keysym.mod & XBMCKMOD_CTRL)
- m_Modifiers |= CKey::MODIFIER_CTRL;
- if (event.key.keysym.mod & XBMCKMOD_SHIFT)
- m_Modifiers |= CKey::MODIFIER_SHIFT;
- if (event.key.keysym.mod & XBMCKMOD_ALT)
- m_Modifiers |= CKey::MODIFIER_ALT;
- if (event.key.keysym.mod & XBMCKMOD_RALT)
- m_Modifiers |= CKey::MODIFIER_RALT;
- if (event.key.keysym.mod & XBMCKMOD_SUPER)
- m_Modifiers |= CKey::MODIFIER_SUPER;
-
- CLog::Log(LOGDEBUG, "SDLKeyboard: scancode: %d, sym: %d, unicode: %d, modifier: %x", event.key.keysym.scancode, event.key.keysym.sym, event.key.keysym.unicode, event.key.keysym.mod);
-
- if ((event.key.keysym.unicode >= 'A' && event.key.keysym.unicode <= 'Z') ||
- (event.key.keysym.unicode >= 'a' && event.key.keysym.unicode <= 'z'))
- {
- m_cAscii = (char)event.key.keysym.unicode;
- m_VKey = toupper(m_cAscii);
- }
- else if (event.key.keysym.unicode >= '0' && event.key.keysym.unicode <= '9')
- {
- m_cAscii = (char)event.key.keysym.unicode;
- m_VKey = 0x60 + m_cAscii - '0'; // xbox keyboard routine appears to return 0x60->69 (unverified). Ideally this "fixing"
- // should be done in xbox routine, not in the sdl/directinput routines.
- // we should just be using the unicode/ascii value in all routines (perhaps with some
- // headroom for modifier keys?)
- }
- else
- {
- // see comment above about the weird use of m_VKey here...
- if (event.key.keysym.unicode == ')') { m_VKey = 0x60; m_cAscii = ')'; }
- else if (event.key.keysym.unicode == '!') { m_VKey = 0x61; m_cAscii = '!'; }
- else if (event.key.keysym.unicode == '@') { m_VKey = 0x62; m_cAscii = '@'; }
- else if (event.key.keysym.unicode == '#') { m_VKey = 0x63; m_cAscii = '#'; }
- else if (event.key.keysym.unicode == '$') { m_VKey = 0x64; m_cAscii = '$'; }
- else if (event.key.keysym.unicode == '%') { m_VKey = 0x65; m_cAscii = '%'; }
- else if (event.key.keysym.unicode == '^') { m_VKey = 0x66; m_cAscii = '^'; }
- else if (event.key.keysym.unicode == '&') { m_VKey = 0x67; m_cAscii = '&'; }
- else if (event.key.keysym.unicode == '*') { m_VKey = 0x68; m_cAscii = '*'; }
- else if (event.key.keysym.unicode == '(') { m_VKey = 0x69; m_cAscii = '('; }
- else if (event.key.keysym.unicode == ':') { m_VKey = 0xba; m_cAscii = ':'; }
- else if (event.key.keysym.unicode == ';') { m_VKey = 0xba; m_cAscii = ';'; }
- else if (event.key.keysym.unicode == '=') { m_VKey = 0xbb; m_cAscii = '='; }
- else if (event.key.keysym.unicode == '+') { m_VKey = 0xbb; m_cAscii = '+'; }
- else if (event.key.keysym.unicode == '<') { m_VKey = 0xbc; m_cAscii = '<'; }
- else if (event.key.keysym.unicode == ',') { m_VKey = 0xbc; m_cAscii = ','; }
- else if (event.key.keysym.unicode == '-') { m_VKey = 0xbd; m_cAscii = '-'; }
- else if (event.key.keysym.unicode == '_') { m_VKey = 0xbd; m_cAscii = '_'; }
- else if (event.key.keysym.unicode == '>') { m_VKey = 0xbe; m_cAscii = '>'; }
- else if (event.key.keysym.unicode == '.') { m_VKey = 0xbe; m_cAscii = '.'; }
- else if (event.key.keysym.unicode == '?') { m_VKey = 0xbf; m_cAscii = '?'; } // 0xbf is OEM 2 Why is it assigned here?
- else if (event.key.keysym.unicode == '/') { m_VKey = 0xbf; m_cAscii = '/'; }
- else if (event.key.keysym.unicode == '~') { m_VKey = 0xc0; m_cAscii = '~'; }
- else if (event.key.keysym.unicode == '`') { m_VKey = 0xc0; m_cAscii = '`'; }
- else if (event.key.keysym.unicode == '{') { m_VKey = 0xeb; m_cAscii = '{'; }
- else if (event.key.keysym.unicode == '[') { m_VKey = 0xeb; m_cAscii = '['; } // 0xeb is not defined by MS. Why is it assigned here?
- else if (event.key.keysym.unicode == '|') { m_VKey = 0xec; m_cAscii = '|'; }
- else if (event.key.keysym.unicode == '\\') { m_VKey = 0xec; m_cAscii = '\\'; }
- else if (event.key.keysym.unicode == '}') { m_VKey = 0xed; m_cAscii = '}'; }
- else if (event.key.keysym.unicode == ']') { m_VKey = 0xed; m_cAscii = ']'; } // 0xed is not defined by MS. Why is it assigned here?
- else if (event.key.keysym.unicode == '"') { m_VKey = 0xee; m_cAscii = '"'; }
- else if (event.key.keysym.unicode == '\'') { m_VKey = 0xee; m_cAscii = '\''; }
-
- // For control key combinations, e.g. ctrl-P, the UNICODE gets set
- // to 1 for ctrl-A, 2 for ctrl-B etc. This mapping sets the UNICODE
- // back to 'a', 'b', etc.
- // It isn't clear to me if this applies to Linux and Mac as well as
- // Windows.
- if (m_Modifiers & CKey::MODIFIER_CTRL)
- {
- if (!m_VKey && !m_cAscii)
- LookupKeyMapping(&m_VKey, NULL, &m_wUnicode
- , event.key.keysym.sym
- , g_mapping_ctrlkeys
- , sizeof(g_mapping_ctrlkeys)/sizeof(g_mapping_ctrlkeys[0]));
- }
-
- /* Check for standard non printable keys */
- if (!m_VKey && !m_cAscii)
- LookupKeyMapping(&m_VKey, NULL, &m_wUnicode
- , event.key.keysym.sym
- , g_mapping_npc
- , sizeof(g_mapping_npc)/sizeof(g_mapping_npc[0]));
-
-
- if (!m_VKey && !m_cAscii)
- {
- /* Check for linux defined non printable keys */
- if(m_bEvdev)
- LookupKeyMapping(&m_VKey, NULL, NULL
- , event.key.keysym.scancode
- , g_mapping_evdev
- , sizeof(g_mapping_evdev)/sizeof(g_mapping_evdev[0]));
- else
- LookupKeyMapping(&m_VKey, NULL, NULL
- , event.key.keysym.scancode
- , g_mapping_ubuntu
- , sizeof(g_mapping_ubuntu)/sizeof(g_mapping_ubuntu[0]));
- }
-
- if (!m_VKey && !m_cAscii)
- {
- if (event.key.keysym.mod & XBMCKMOD_LSHIFT) m_VKey = 0xa0;
- else if (event.key.keysym.mod & XBMCKMOD_RSHIFT) m_VKey = 0xa1;
- else if (event.key.keysym.mod & XBMCKMOD_LALT) m_VKey = 0xa4;
- else if (event.key.keysym.mod & XBMCKMOD_RALT) m_VKey = 0xa5;
- else if (event.key.keysym.mod & XBMCKMOD_LCTRL) m_VKey = 0xa2;
- else if (event.key.keysym.mod & XBMCKMOD_RCTRL) m_VKey = 0xa3;
- else if (event.key.keysym.unicode > 32 && event.key.keysym.unicode < 128)
- // only TRUE ASCII! (Otherwise XBMC crashes! No unicode not even latin 1!)
- m_cAscii = (char)(event.key.keysym.unicode & 0xff);
- }
- }
- }
- else
- { // key up event
- Reset();
- m_lastKey = XBMCK_UNKNOWN;
- m_keyHoldTime = 0;
- }
-}
-
-// Set the supplied CKey from the current keyboard state.
-
-const CKey CKeyboardStat::GetKey()
-{
- return CKey(m_VKey, m_wUnicode, m_cAscii, m_Modifiers, m_keyHoldTime);
-}
-
-// New key handling code added in preparation for the major overhaul
-// of the keyboard handling
const CKey CKeyboardStat::ProcessKeyDown(XBMC_keysym& keysym)
{ uint8_t vkey;
wchar_t unicode;
bool CDVDSubtitleTagSami::Init()
{
m_tags = new CRegExp(true);
- if (!m_tags->RegComp("(<[^>]*>)"))
+ if (!m_tags->RegComp("(<[^>]*>|\\{[^\\}]*\\})"))
return false;
m_tagOptions = new CRegExp(true);
CStdString fullTag = m_tags->GetMatch(0);
fullTag.ToLower();
strUTF8.erase(pos, fullTag.length());
- if (fullTag == "<b>")
+ if (fullTag == "<b>" || fullTag == "{\\b1}")
{
m_flag[FLAG_BOLD] = true;
strUTF8.insert(pos, "[B]");
pos += 3;
}
- else if (fullTag == "</b>" && m_flag[FLAG_BOLD])
+ else if ((fullTag == "</b>" || fullTag == "{\\b0}") && m_flag[FLAG_BOLD])
{
m_flag[FLAG_BOLD] = false;
strUTF8.insert(pos, "[/B]");
pos += 4;
}
- else if (fullTag == "<i>")
+ else if (fullTag == "<i>" || fullTag == "{\\i1}")
{
m_flag[FLAG_ITALIC] = true;
strUTF8.insert(pos, "[I]");
pos += 3;
}
- else if (fullTag == "</i>" && m_flag[FLAG_ITALIC])
+ else if ((fullTag == "</i>" || fullTag == "{\\i0}") && m_flag[FLAG_ITALIC])
{
m_flag[FLAG_ITALIC] = false;
strUTF8.insert(pos, "[/I]");
pos += 4;
}
- else if (fullTag == "</font>" && m_flag[FLAG_COLOR])
+ else if ((fullTag == "</font>" || fullTag == "{\\c}") && m_flag[FLAG_COLOR])
{
m_flag[FLAG_COLOR] = false;
strUTF8.insert(pos, "[/COLOR]");
pos += 8;
}
+ else if (fullTag.Left(5) == "{\\c&h" || fullTag.Left(6) == "{\\1c&h")
+ {
+ m_flag[FLAG_COLOR] = true;
+ CStdString tempColorTag = "[COLOR FF";
+ CStdString tagOptionValue;
+ if (fullTag.Left(5) == "{\\c&h")
+ tagOptionValue = fullTag.substr(5,6);
+ else
+ tagOptionValue = fullTag.substr(6,6);
+ tempColorTag += tagOptionValue.substr(4,2);
+ tempColorTag += tagOptionValue.substr(2,2);
+ tempColorTag += tagOptionValue.substr(0,2);
+ tempColorTag += "]";
+ strUTF8.insert(pos, tempColorTag);
+ pos += tempColorTag.length();
+ }
else if (fullTag.Left(5) == "<font")
{
int pos2 = 5;