384 { |
298 { |
385 RDebug::Print(_L("CHidKeyboardDriver::Disconnected(%d)"), aReason); |
299 RDebug::Print(_L("CHidKeyboardDriver::Disconnected(%d)"), aReason); |
386 Stop(); |
300 Stop(); |
387 } |
301 } |
388 |
302 |
389 void CHidKeyboardDriver::UpdateXY(TInt aFieldIndex, const TDesC8& aReport) |
|
390 { |
|
391 // DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateModifiers()"))); |
|
392 |
|
393 // Translate the HID usage values into a boot protocol style |
|
394 // modifier bitmask: |
|
395 // |
|
396 TReportTranslator report(aReport, iMouseField[aFieldIndex]); |
|
397 |
|
398 TInt Xvalue = 0; |
|
399 TInt Yvalue = 0; |
|
400 |
|
401 TInt errX = report.GetValue(Xvalue, EGenericDesktopUsageX); |
|
402 TInt errY = report.GetValue(Yvalue, EGenericDesktopUsageY); |
|
403 |
|
404 DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateXY (%d,%d)"), Xvalue, Yvalue)); |
|
405 if ((Xvalue != 0) || (Yvalue != 0)) |
|
406 { |
|
407 MoveCursor(TPoint(Xvalue, Yvalue)); |
|
408 } |
|
409 } |
|
410 |
|
411 void CHidKeyboardDriver::UpdateWheel(TInt aFieldIndex, const TDesC8& aReport) |
|
412 { |
|
413 TReportTranslator report(aReport, iMouseField[aFieldIndex]); |
|
414 |
|
415 TInt Yvalue = 0; |
|
416 |
|
417 TInt errY = report.GetValue(Yvalue, EGenericDesktopUsageWheel); |
|
418 DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateWheel (%d)"), Yvalue)); |
|
419 TInt absValue(Abs(Yvalue)); |
|
420 if ((errY == KErrNone) && (absValue >= 1)) |
|
421 { |
|
422 TRawEvent rawEvent; |
|
423 for (TInt ii = 0; ii < absValue; ii++) |
|
424 { |
|
425 rawEvent.Set(TRawEvent::EKeyDown, |
|
426 (Yvalue > 0) ? EStdKeyUpArrow : EStdKeyDownArrow); |
|
427 UserSvr::AddEvent(rawEvent); |
|
428 rawEvent.Set(TRawEvent::EKeyUp, |
|
429 (Yvalue > 0) ? EStdKeyUpArrow : EStdKeyDownArrow); |
|
430 UserSvr::AddEvent(rawEvent); |
|
431 } |
|
432 } |
|
433 DBG(RDebug::Print(_L("[HID]\t new iModifiers = %02x"), iModifiers)); |
|
434 } |
|
435 |
|
436 void CHidKeyboardDriver::UpdateButtons(TInt aFieldIndex, |
|
437 const TDesC8& aReport) |
|
438 { |
|
439 DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons()"))); |
|
440 // Translate the HID usage values into a boot protocol style |
|
441 // modifier bitmask: |
|
442 // |
|
443 const TInt KButton1 = 1; |
|
444 const TInt KButton2 = 2; |
|
445 const TInt KButton3 = 3; |
|
446 |
|
447 TBool buttonPressed(EFalse); |
|
448 |
|
449 DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() %d, %d, %d"), |
|
450 iMouseField[aFieldIndex]->UsagePage(), |
|
451 iMouseField[aFieldIndex]->UsageMin(), |
|
452 iMouseField[aFieldIndex]->UsageMax())); |
|
453 (void) aFieldIndex; |
|
454 // Hack but works |
|
455 // We dont come here if the report is wrong? |
|
456 TInt buttonByte = aReport[1]; |
|
457 if (KButton1 == buttonByte) |
|
458 { |
|
459 DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() Button1"))); |
|
460 buttonPressed = ETrue; |
|
461 } |
|
462 |
|
463 if (KButton2 == buttonByte) |
|
464 { |
|
465 DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() Button2"))); |
|
466 if (!iButton2Down) |
|
467 { |
|
468 iButton2Down = ETrue; |
|
469 TRawEvent rawEvent; |
|
470 rawEvent.Set(TRawEvent::EKeyDown, EStdKeyApplication0); |
|
471 CursorRedraw(); |
|
472 UserSvr::AddEvent(rawEvent); |
|
473 } |
|
474 } |
|
475 else |
|
476 { |
|
477 if (iButton2Down) |
|
478 { |
|
479 iButton2Down = EFalse; |
|
480 TRawEvent rawEvent; |
|
481 rawEvent.Set(TRawEvent::EKeyUp, EStdKeyApplication0); |
|
482 CursorRedraw(); |
|
483 UserSvr::AddEvent(rawEvent); |
|
484 } |
|
485 } |
|
486 |
|
487 if (KButton3 == buttonByte) |
|
488 { |
|
489 DBG(RDebug::Print(_L("[HID]\tCHidMouseDriver::UpdateButtons() Button3"))); |
|
490 buttonPressed = ETrue; |
|
491 } |
|
492 |
|
493 if (buttonPressed) |
|
494 { |
|
495 if (!iButtonDown) |
|
496 { |
|
497 iButtonDown = ETrue; |
|
498 SendButtonEvent(ETrue);//Send Mouse Button Down |
|
499 } |
|
500 } |
|
501 else |
|
502 { |
|
503 if (iButtonDown) |
|
504 { |
|
505 iButtonDown = EFalse; |
|
506 SendButtonEvent(EFalse); //Send Mouse Button Up |
|
507 } |
|
508 } |
|
509 } |
|
510 //---------------------------------------------------------------------------- |
303 //---------------------------------------------------------------------------- |
511 // CHidKeyboardDriver::InterruptData |
304 // CHidKeyboardDriver::InterruptData |
512 //---------------------------------------------------------------------------- |
305 //---------------------------------------------------------------------------- |
513 // |
306 // |
514 void CHidKeyboardDriver::InterruptData(const TDesC8& aPayload) |
307 void CHidKeyboardDriver::InterruptData(const TDesC8& aPayload) |
1672 // EModifierRightFunc | EModifierFunc // 0x3000 (report bit 7) |
1429 // EModifierRightFunc | EModifierFunc // 0x3000 (report bit 7) |
1673 // }; |
1430 // }; |
1674 //---------------------------------------------------------------------------- |
1431 //---------------------------------------------------------------------------- |
1675 // |
1432 // |
1676 |
1433 |
1677 TBool CHidKeyboardDriver::HandleMultimediaKeys(TUint16 aScancodeKey, |
1434 TBool CHidKeyboardDriver::HandleKeyMapping(TDecodedKeyInfo& aKey, |
1678 TBool aIsKeyDown, TUint8 aHIDModifiers) |
1435 TBool aIsKeyDown, |
1679 { |
1436 TUint8 aHIDModifiers) |
1680 TBool ret = HandleMultimediaKeysForNokia(aScancodeKey, aIsKeyDown, |
1437 { |
1681 aHIDModifiers); |
1438 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleKeyMapping"))); |
1682 |
1439 |
1683 if (!ret) |
1440 TBool ret = EFalse; |
1684 { |
1441 |
1685 ret = HandleMultimediaKeysForStandard(aScancodeKey, aIsKeyDown, |
1442 switch (aKey.iScanCode) |
1686 aHIDModifiers); |
1443 { |
1687 } |
1444 case EStdKeyUpArrow: |
|
1445 { |
|
1446 ret = HandleKeyMappingUp(aKey, aIsKeyDown, aHIDModifiers); |
|
1447 break; |
|
1448 } |
|
1449 case EStdKeyDownArrow: |
|
1450 { |
|
1451 ret = HandleKeyMappingDown(aKey, aIsKeyDown, aHIDModifiers); |
|
1452 break; |
|
1453 } |
|
1454 case EStdKeyLeftArrow: |
|
1455 { |
|
1456 ret = HandleKeyMappingLeft(aKey, aIsKeyDown, aHIDModifiers); |
|
1457 break; |
|
1458 } |
|
1459 case EStdKeyRightArrow: |
|
1460 { |
|
1461 ret = HandleKeyMappingRight(aKey, aIsKeyDown, aHIDModifiers); |
|
1462 break; |
|
1463 } |
|
1464 case EStdKeyEscape: |
|
1465 // fall through |
|
1466 case EStdKeyF8: |
|
1467 // fall through |
|
1468 case EStdKeyApplication2: |
|
1469 // fall through |
|
1470 case EStdKeyApplication3: |
|
1471 // fall through |
|
1472 case EStdKeyF9: |
|
1473 // break; |
|
1474 case EStdKeyApplication4: |
|
1475 // fall through |
|
1476 case EStdKeyF7: |
|
1477 // fall through |
|
1478 case EStdKeyApplication5: |
|
1479 // fall through |
|
1480 case EStdKeyF12: |
|
1481 // fall through |
|
1482 case EStdKeyIncVolume: |
|
1483 // fall through |
|
1484 case EStdKeyF11: |
|
1485 // fall through |
|
1486 case EStdKeyDecVolume: |
|
1487 // fall through |
|
1488 case EStdKeyF10: |
|
1489 { |
|
1490 ret = HandleKeyMappingOther(aKey, aIsKeyDown, aHIDModifiers); |
|
1491 break; |
|
1492 } |
|
1493 default: |
|
1494 { |
|
1495 // no actions for these keys |
|
1496 break; |
|
1497 } |
|
1498 } |
|
1499 |
1688 return ret; |
1500 return ret; |
1689 } |
1501 } |
1690 |
1502 |
1691 void CHidKeyboardDriver::ResetBitmap(TBool aIsKeyDown, |
1503 // ---------------------------------------------------------------------- |
1692 TMmKeyDown aBitmapToReset) |
1504 // CHidKeyboardDriver::HandleKeyMappingUp |
1693 { |
1505 // Handle key mapping gor UP + MODIFIER |
1694 if (aIsKeyDown) |
1506 // ---------------------------------------------------------------------- |
1695 { |
1507 // |
1696 iMmKeyDown = (iMmKeyDown | aBitmapToReset); |
1508 TBool CHidKeyboardDriver::HandleKeyMappingUp(TDecodedKeyInfo& aKey, |
1697 } |
1509 TBool aIsKeyDown, |
1698 else |
1510 TUint8 aHIDModifiers) |
1699 { |
1511 { |
1700 iMmKeyDown = (iMmKeyDown & !aBitmapToReset); |
1512 TRACE_INFO((_L("[HID]\tCHidKeyboardDriver::HandleKeyMappingUp"))); |
1701 } |
1513 |
1702 } |
1514 TBool ret = EFalse; |
1703 |
|
1704 TBool CHidKeyboardDriver::HandleMultimediaKeysForNokia(TUint16 aScancodeKey, |
|
1705 TBool aIsKeyDown, TUint8 aHIDModifiers) |
|
1706 { |
|
1707 const TUint KHidModifierCtrl = 0x01; |
|
1708 const TUint KHidModifierCtrlRight = 0x10; |
|
1709 const TUint KHidModifierAlt = 0x04; |
|
1710 |
|
1711 // const TUint KHidModifierAltGr = 0x64; |
|
1712 TInt scancode = 0; |
1515 TInt scancode = 0; |
1713 TUint modifier = 0; |
1516 TUint modifier = 0; |
1714 TBool isMmKey = EFalse; |
1517 TBool isMmKey = EFalse; |
1715 |
1518 TMmKeyDown bitmapToReset = ENone; |
1716 TMmKeyDown bitmapToReset; |
1519 |
1717 |
1520 switch (aKey.iScanCode) |
1718 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: scancode 0x%08x, HIDmodifiers 0x%08x"), aScancodeKey, aHIDModifiers)); |
1521 { |
1719 |
|
1720 switch (aScancodeKey) |
|
1721 { |
|
1722 |
|
1723 // Mappings for Nokia SU-8W |
|
1724 // Key down events are stored into bitmap in order to detect if keys are released in reverse order, which caused jamming. |
|
1725 // For example: control key released before arrow key. |
|
1726 |
|
1727 case EStdKeyUpArrow: |
1522 case EStdKeyUpArrow: |
1728 { |
1523 { |
1729 if (aHIDModifiers & (KHidModifierCtrl | KHidModifierCtrlRight) |
1524 // Key up and send key was emulated |
1730 || iMmKeyDown & EVolUp) |
1525 if (!aIsKeyDown && |
1731 { |
1526 iNavKeyDown & ESend) |
1732 scancode = EStdKeyIncVolume; //Volume Up = Ctrl + ArrowUp |
1527 { |
1733 isMmKey = ETrue; |
1528 TRACE_INFO((_L("[HID]\tCTRL + UP >>> SEND KEY UP"))); |
1734 // Set or reset flag bit |
1529 |
1735 |
1530 aKey.iScanCode = EStdKeyYes; |
1736 bitmapToReset = EVolUp; |
1531 TTranslatedKey& key = aKey.iEvent[0]; |
1737 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Volume up %d"), aIsKeyDown)); |
1532 key.iIsRepeatingKey = aIsKeyDown; |
1738 } |
1533 key.iScanCode = EStdKeyYes; |
1739 break; |
1534 key.iUnicode = EKeyYes; |
1740 } |
1535 |
1741 |
1536 iNavKeyDown = (iNavKeyDown & !ESend); |
1742 case EStdKeyDownArrow: |
1537 } |
1743 { |
1538 |
1744 if (aHIDModifiers & (KHidModifierCtrl | KHidModifierCtrlRight) |
1539 //CTRL = Send key |
1745 || iMmKeyDown & EVolDown) |
1540 else if (aIsKeyDown && |
1746 { |
1541 aHIDModifiers & (KHidModifierCtrl | KHidModifierCtrlRight)) |
1747 scancode = EStdKeyDecVolume; //Volume Down = Ctrl + ArrowDown |
1542 { |
1748 isMmKey = ETrue; |
1543 TRACE_INFO((_L("[HID]\tCTRL + UP >>> SEND KEY DOWN"))); |
1749 bitmapToReset = EVolDown; |
1544 |
1750 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Volume down %d"), aIsKeyDown)); |
1545 aKey.iScanCode = EStdKeyYes; |
1751 } |
1546 aKey.iCount = 1; |
1752 break; |
1547 TTranslatedKey& key = aKey.iEvent[0]; |
1753 } |
1548 key.iIsRepeatingKey = aIsKeyDown; |
1754 |
1549 key.iScanCode = EStdKeyYes; |
1755 case EStdKeyRightArrow: |
1550 key.iUnicode = EKeyYes; |
1756 { |
1551 |
1757 if (aHIDModifiers & KHidModifierAlt || iMmKeyDown & EPlay) |
1552 iNavKeyDown = (iNavKeyDown | ESend); |
1758 { |
1553 } |
1759 scancode = EStdKeyApplication2; //Play = Alt + ArrowRight |
1554 |
1760 isMmKey = ETrue; |
1555 //ALT = Stop |
1761 bitmapToReset = EPlay; |
1556 else if (aHIDModifiers & (KHidModifierAlt | KHidModifierAltRight) || |
1762 |
1557 iMmKeyDown & EStop) |
1763 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Play %d"), aIsKeyDown)); |
1558 { |
1764 } |
1559 TRACE_INFO((_L("[HID]\tALT + UP >>> STOP"))); |
1765 else if (aHIDModifiers & (KHidModifierCtrl |
1560 |
1766 | KHidModifierCtrlRight) || iMmKeyDown & ENext) |
1561 scancode = EStdKeyApplication3; |
1767 { |
|
1768 scancode = EStdKeyApplication4; //Next = Ctrl + ArrowRight |
|
1769 isMmKey = ETrue; |
|
1770 bitmapToReset = ENext; |
|
1771 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Next %d"), aIsKeyDown)); |
|
1772 } |
|
1773 break; |
|
1774 } |
|
1775 |
|
1776 case EStdKeyLeftArrow: |
|
1777 { |
|
1778 if (aHIDModifiers & KHidModifierAlt || iMmKeyDown & EStop) |
|
1779 { |
|
1780 scancode = EStdKeyApplication3; //Stop = Alt + ArrowLeft |
|
1781 isMmKey = ETrue; |
1562 isMmKey = ETrue; |
1782 bitmapToReset = EStop; |
1563 bitmapToReset = EStop; |
1783 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Stop %d"), aIsKeyDown)); |
1564 } |
1784 } |
1565 |
1785 else if (aHIDModifiers & (KHidModifierCtrl |
1566 //SHIFT = Volume up |
1786 | KHidModifierCtrlRight) || iMmKeyDown & EPrev) |
1567 else if (aHIDModifiers & (KHidModifierShift | KHidModifierShiftRight) || |
1787 { |
1568 iMmKeyDown & EVolUp) |
1788 scancode = EStdKeyApplication5; //Prev = Ctrl + ArrowLeft |
1569 { |
|
1570 TRACE_INFO((_L("[HID]\tSHIFT + UP >>> VOLUME UP"))); |
|
1571 |
|
1572 scancode = EStdKeyIncVolume; |
1789 isMmKey = ETrue; |
1573 isMmKey = ETrue; |
1790 bitmapToReset = EPrev; |
1574 bitmapToReset = EVolUp; |
1791 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Prev %d"), aIsKeyDown)); |
1575 } |
1792 } |
1576 break; |
1793 break; |
1577 } |
1794 } |
|
1795 |
|
1796 default: |
1578 default: |
1797 break; |
1579 { |
|
1580 // no actions |
|
1581 break; |
|
1582 } |
1798 } |
1583 } |
1799 |
1584 |
1800 if (isMmKey) |
1585 if (isMmKey) |
1801 { |
1586 { |
1802 ResetBitmap(aIsKeyDown, bitmapToReset); |
1587 if (bitmapToReset) |
|
1588 { |
|
1589 ResetBitmap(aIsKeyDown, bitmapToReset); |
|
1590 } |
1803 SendRawEvent(scancode, aIsKeyDown, modifier); |
1591 SendRawEvent(scancode, aIsKeyDown, modifier); |
1804 } |
1592 ret = ETrue; |
1805 return isMmKey; |
1593 } |
1806 } |
1594 |
1807 |
1595 return ret; |
1808 TBool CHidKeyboardDriver::HandleMultimediaKeysForStandard( |
1596 } |
1809 TUint16 aScancodeKey, TBool aIsKeyDown, TUint8 aHIDModifiers) |
1597 |
1810 { |
1598 // ---------------------------------------------------------------------- |
|
1599 // CHidKeyboardDriver::HandleKeyMappingDown |
|
1600 // Handle key mapping gor DOWN + MODIFIER |
|
1601 // ---------------------------------------------------------------------- |
|
1602 // |
|
1603 TBool CHidKeyboardDriver::HandleKeyMappingDown(TDecodedKeyInfo& aKey, |
|
1604 TBool aIsKeyDown, |
|
1605 TUint8 aHIDModifiers) |
|
1606 { |
|
1607 TRACE_INFO((_L("[HID]\tCHidKeyboardDriver::HandleKeyMappingDown"))); |
|
1608 |
|
1609 TBool ret = EFalse; |
1811 TInt scancode = 0; |
1610 TInt scancode = 0; |
1812 TUint modifier = 0; |
1611 TUint modifier = 0; |
1813 TBool isMmKey = EFalse; |
1612 TBool isMmKey = EFalse; |
1814 |
1613 TMmKeyDown bitmapToReset = ENone; |
1815 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: scancode 0x%08x, HIDmodifiers 0x%08x"), aScancodeKey, aHIDModifiers)); |
1614 |
1816 //please complier... |
1615 switch (aKey.iScanCode) |
1817 (void) aHIDModifiers; |
1616 { |
1818 |
1617 case EStdKeyDownArrow: |
1819 switch (aScancodeKey) |
1618 { |
1820 { |
1619 // Key up and end key was emulated |
1821 // Mappings for standard keyboards |
1620 if (!aIsKeyDown && |
1822 |
1621 iNavKeyDown & EEnd) |
1823 case EStdKeyApplication2: //Play |
1622 { |
1824 { |
1623 TRACE_INFO((_L("[HID]\tCTRL + DOWN >>> END KEY UP"))); |
|
1624 |
|
1625 aKey.iScanCode = EStdKeyNo; |
|
1626 TTranslatedKey& key = aKey.iEvent[0]; |
|
1627 key.iIsRepeatingKey = aIsKeyDown; |
|
1628 key.iScanCode = EStdKeyNo; |
|
1629 key.iUnicode = EKeyNo; |
|
1630 |
|
1631 iNavKeyDown = (iNavKeyDown & !EEnd); |
|
1632 } |
|
1633 |
|
1634 //CTRL = End key |
|
1635 else if (aIsKeyDown && |
|
1636 aHIDModifiers & (KHidModifierCtrl | KHidModifierCtrlRight)) |
|
1637 { |
|
1638 TRACE_INFO((_L("[HID]\tCTRL + DOWN >>> END KEY DOWN"))); |
|
1639 |
|
1640 aKey.iScanCode = EStdKeyNo; |
|
1641 aKey.iCount = 1; |
|
1642 TTranslatedKey& key = aKey.iEvent[0]; |
|
1643 key.iIsRepeatingKey = aIsKeyDown; |
|
1644 key.iScanCode = EStdKeyNo; |
|
1645 key.iUnicode = EKeyNo; |
|
1646 |
|
1647 iNavKeyDown = (iNavKeyDown | EEnd); |
|
1648 } |
|
1649 |
|
1650 //ALT = Stop |
|
1651 else if (aHIDModifiers & (KHidModifierAlt | KHidModifierAltRight) || |
|
1652 iMmKeyDown & EPlay) |
|
1653 { |
|
1654 TRACE_INFO((_L("[HID]\tALT + DOWN >>> PLAY / PAUSE"))); |
|
1655 |
|
1656 scancode = EStdKeyApplication2; |
|
1657 isMmKey = ETrue; |
|
1658 bitmapToReset = EPlay; |
|
1659 } |
|
1660 |
|
1661 //SHIFT = Volume down |
|
1662 else if (aHIDModifiers & (KHidModifierShift | KHidModifierShiftRight) || |
|
1663 iMmKeyDown & EVolDown) |
|
1664 { |
|
1665 TRACE_INFO((_L("[HID]\tSHIFT + DOWN >>> VOLUME DOWN"))); |
|
1666 |
|
1667 scancode = EStdKeyDecVolume; |
|
1668 isMmKey = ETrue; |
|
1669 bitmapToReset = EVolDown; |
|
1670 } |
|
1671 break; |
|
1672 } |
|
1673 default: |
|
1674 { |
|
1675 // no actions |
|
1676 break; |
|
1677 } |
|
1678 } |
|
1679 |
|
1680 if (isMmKey) |
|
1681 { |
|
1682 if (bitmapToReset) |
|
1683 { |
|
1684 ResetBitmap(aIsKeyDown, bitmapToReset); |
|
1685 } |
|
1686 SendRawEvent(scancode, aIsKeyDown, modifier); |
|
1687 ret = ETrue; |
|
1688 } |
|
1689 |
|
1690 return ret; |
|
1691 } |
|
1692 |
|
1693 // ---------------------------------------------------------------------- |
|
1694 // CHidKeyboardDriver::HandleKeyMappingLeft |
|
1695 // Handle key mapping gor LEFT + MODIFIER |
|
1696 // ---------------------------------------------------------------------- |
|
1697 // |
|
1698 TBool CHidKeyboardDriver::HandleKeyMappingLeft(TDecodedKeyInfo& aKey, |
|
1699 TBool aIsKeyDown, |
|
1700 TUint8 aHIDModifiers) |
|
1701 { |
|
1702 TRACE_INFO((_L("[HID]\tCHidKeyboardDriver::HandleKeyMappingLeft"))); |
|
1703 |
|
1704 TBool ret = EFalse; |
|
1705 TInt scancode = 0; |
|
1706 TUint modifier = 0; |
|
1707 TBool isMmKey = EFalse; |
|
1708 TMmKeyDown bitmapToReset = ENone; |
|
1709 |
|
1710 switch (aKey.iScanCode) |
|
1711 { |
|
1712 case EStdKeyLeftArrow: |
|
1713 { |
|
1714 // Key up and LSK was simulated |
|
1715 if (!aIsKeyDown && |
|
1716 iNavKeyDown & ELsk) |
|
1717 { |
|
1718 TRACE_INFO((_L("[HID]\tCTRL + LEFT >>> LEFT SOFTKEY UP"))); |
|
1719 |
|
1720 aKey.iScanCode = EStdKeyDevice0; |
|
1721 TTranslatedKey& key = aKey.iEvent[0]; |
|
1722 key.iIsRepeatingKey = aIsKeyDown; |
|
1723 key.iScanCode = EStdKeyDevice0; |
|
1724 key.iUnicode = EKeyDevice0; |
|
1725 |
|
1726 iNavKeyDown = (iNavKeyDown & !ELsk); |
|
1727 } |
|
1728 |
|
1729 //CTRL = LSK |
|
1730 else if (aIsKeyDown && |
|
1731 aHIDModifiers & (KHidModifierCtrl | KHidModifierCtrlRight)) |
|
1732 { |
|
1733 TRACE_INFO((_L("[HID]\tCTRL + LEFT >>> LEFT SOFTKEY DOWN"))); |
|
1734 |
|
1735 aKey.iScanCode = EStdKeyDevice0; |
|
1736 aKey.iCount = 1; |
|
1737 TTranslatedKey& key = aKey.iEvent[0]; |
|
1738 key.iIsRepeatingKey = aIsKeyDown; |
|
1739 key.iScanCode = EStdKeyDevice0; |
|
1740 key.iUnicode = EKeyDevice0; |
|
1741 |
|
1742 iNavKeyDown = (iNavKeyDown | ELsk); |
|
1743 } |
|
1744 |
|
1745 //ALT (short) = Previous |
|
1746 //ALT (long) = Backwards |
|
1747 else if (aHIDModifiers & (KHidModifierAlt | KHidModifierAltRight) || |
|
1748 iMmKeyDown & EPrev) |
|
1749 { |
|
1750 TRACE_INFO((_L("[HID]\tALT + LEFT >>> PREVIOUS / REW"))); |
|
1751 |
|
1752 scancode = EStdKeyApplication5; |
|
1753 isMmKey = ETrue; |
|
1754 bitmapToReset = ENext; |
|
1755 } |
|
1756 |
|
1757 //SHIFT = Mute toggle |
|
1758 else if (aHIDModifiers & (KHidModifierShift | KHidModifierShiftRight) || |
|
1759 iMmKeyDown & EPlay) |
|
1760 { |
|
1761 TRACE_INFO((_L("[HID]\tSHIFT + LEFT >>> MUTE / UNMUTE"))); |
|
1762 |
|
1763 scancode = EStdKeyApplication2; |
|
1764 isMmKey = ETrue; |
|
1765 bitmapToReset = EPlay; |
|
1766 } |
|
1767 break; |
|
1768 } |
|
1769 default: |
|
1770 { |
|
1771 // no actions |
|
1772 break; |
|
1773 } |
|
1774 } |
|
1775 |
|
1776 if (isMmKey) |
|
1777 { |
|
1778 if (bitmapToReset) |
|
1779 { |
|
1780 ResetBitmap(aIsKeyDown, bitmapToReset); |
|
1781 } |
|
1782 SendRawEvent(scancode, aIsKeyDown, modifier); |
|
1783 ret = ETrue; |
|
1784 } |
|
1785 |
|
1786 return ret; |
|
1787 } |
|
1788 |
|
1789 // ---------------------------------------------------------------------- |
|
1790 // CHidKeyboardDriver::HandleKeyMappingRight |
|
1791 // Handle key mapping gor RIGHT + MODIFIER |
|
1792 // ---------------------------------------------------------------------- |
|
1793 // |
|
1794 TBool CHidKeyboardDriver::HandleKeyMappingRight(TDecodedKeyInfo& aKey, |
|
1795 TBool aIsKeyDown, |
|
1796 TUint8 aHIDModifiers) |
|
1797 { |
|
1798 TRACE_INFO((_L("[HID]\tCHidKeyboardDriver::HandleKeyMappingRight"))); |
|
1799 |
|
1800 TBool ret = EFalse; |
|
1801 TInt scancode = 0; |
|
1802 TUint modifier = 0; |
|
1803 TBool isMmKey = EFalse; |
|
1804 TMmKeyDown bitmapToReset = ENone; |
|
1805 |
|
1806 switch (aKey.iScanCode) |
|
1807 { |
|
1808 case EStdKeyRightArrow: |
|
1809 { |
|
1810 // Key up and RSK was simulated |
|
1811 if (!aIsKeyDown && |
|
1812 iNavKeyDown & ERsk) |
|
1813 { |
|
1814 TRACE_INFO((_L("[HID]\tCTRL + LEFT >>> RIGHT SOFTKEY UP"))); |
|
1815 |
|
1816 aKey.iScanCode = EStdKeyDevice1; |
|
1817 TTranslatedKey& key = aKey.iEvent[0]; |
|
1818 key.iIsRepeatingKey = aIsKeyDown; |
|
1819 key.iScanCode = EStdKeyDevice1; |
|
1820 key.iUnicode = EKeyDevice1; |
|
1821 |
|
1822 iNavKeyDown = (iNavKeyDown & !ERsk); |
|
1823 } |
|
1824 |
|
1825 //CTRL = RSK |
|
1826 else if (aIsKeyDown && |
|
1827 aHIDModifiers & (KHidModifierCtrl | KHidModifierCtrlRight)) |
|
1828 { |
|
1829 TRACE_INFO((_L("[HID]\tCTRL + RIGHT >>> RIGHT SOFTKEY DOWN"))); |
|
1830 |
|
1831 aKey.iScanCode = EStdKeyDevice1; |
|
1832 aKey.iCount = 1; |
|
1833 TTranslatedKey& key = aKey.iEvent[0]; |
|
1834 key.iIsRepeatingKey = aIsKeyDown; |
|
1835 key.iScanCode = EStdKeyDevice1; |
|
1836 key.iUnicode = EKeyDevice1; |
|
1837 |
|
1838 iNavKeyDown = (iNavKeyDown | ERsk); |
|
1839 } |
|
1840 |
|
1841 //ALT (short) = Next |
|
1842 //ALT (long) = Forward |
|
1843 else if (aHIDModifiers & (KHidModifierAlt | KHidModifierAltRight) || |
|
1844 iMmKeyDown & EPrev) |
|
1845 { |
|
1846 TRACE_INFO((_L("[HID]\tALT + RIGHT >>> NEXT / FF"))); |
|
1847 |
|
1848 scancode = EStdKeyApplication4; |
|
1849 isMmKey = ETrue; |
|
1850 bitmapToReset = EPrev; |
|
1851 } |
|
1852 |
|
1853 //SHIFT = Mute toggle (currently just toggle play / pause) |
|
1854 else if (aHIDModifiers & (KHidModifierShift | KHidModifierShiftRight) || |
|
1855 iMmKeyDown & EPlay) |
|
1856 { |
|
1857 TRACE_INFO((_L("[HID]\tSHIFT + RIGHT >>> MUTE / UNMUTE"))); |
|
1858 |
|
1859 scancode = EStdKeyApplication2; |
|
1860 isMmKey = ETrue; |
|
1861 bitmapToReset = EPlay; |
|
1862 } |
|
1863 break; |
|
1864 } |
|
1865 default: |
|
1866 { |
|
1867 // no actions |
|
1868 break; |
|
1869 } |
|
1870 } |
|
1871 |
|
1872 if (isMmKey) |
|
1873 { |
|
1874 if (bitmapToReset) |
|
1875 { |
|
1876 ResetBitmap(aIsKeyDown, bitmapToReset); |
|
1877 } |
|
1878 SendRawEvent(scancode, aIsKeyDown, modifier); |
|
1879 ret = ETrue; |
|
1880 } |
|
1881 |
|
1882 return ret; |
|
1883 } |
|
1884 |
|
1885 // ---------------------------------------------------------------------- |
|
1886 // CHidKeyboardDriver::HandleKeyMappingOther |
|
1887 // Handle key mapping gor OTHER + MODIFIER |
|
1888 // ---------------------------------------------------------------------- |
|
1889 // |
|
1890 TBool CHidKeyboardDriver::HandleKeyMappingOther(TDecodedKeyInfo& aKey, |
|
1891 TBool aIsKeyDown, |
|
1892 TUint8 /*aHIDModifiers*/) |
|
1893 { |
|
1894 TRACE_INFO((_L("[HID]\tCHidKeyboardDriver::HandleKeyMappingOther"))); |
|
1895 |
|
1896 TBool ret = EFalse; |
|
1897 TInt scancode = 0; |
|
1898 TUint modifier = 0; |
|
1899 TBool isMmKey = EFalse; |
|
1900 |
|
1901 switch (aKey.iScanCode) |
|
1902 { |
|
1903 case EStdKeyEscape: |
|
1904 { |
|
1905 // ESC is released and keys were locked, eat the key press |
|
1906 if (!aIsKeyDown && |
|
1907 iNavKeyDown & EEsc) |
|
1908 { |
|
1909 TRACE_INFO((_L("[HID]\tESC >>> DISBALE KEY LOCK UP"))); |
|
1910 |
|
1911 ret = ETrue; |
|
1912 iNavKeyDown = (iNavKeyDown & !EEsc); |
|
1913 } |
|
1914 |
|
1915 // ESC when keylock enabled >>> Disabled key lock |
|
1916 /* else if (aIsKeyDown && |
|
1917 iKeyLock.IsKeyLockEnabled()) |
|
1918 { |
|
1919 TRACE_INFO((_L("[HID]\tESC >>> DISBALE KEY LOCK DOWN"))); |
|
1920 |
|
1921 iKeyLock.DisableKeyLock(); |
|
1922 |
|
1923 ret = ETrue; |
|
1924 iNavKeyDown = (iNavKeyDown | EEsc); |
|
1925 } |
|
1926 */ |
|
1927 break; |
|
1928 } |
|
1929 case EStdKeyF8: |
|
1930 // fall through |
|
1931 case EStdKeyApplication2: |
|
1932 { |
|
1933 TRACE_INFO((_L("[HID]\tF8 / APPLICATION2 >>> PLAY / PAUSE"))); |
|
1934 |
|
1935 // PLAY / PAUSE |
|
1936 if (aKey.iScanCode != EStdKeyApplication2) |
|
1937 { |
|
1938 scancode = EStdKeyApplication2; |
|
1939 isMmKey = ETrue; |
|
1940 } |
|
1941 break; |
|
1942 } |
|
1943 case EStdKeyApplication3: |
|
1944 { |
|
1945 TRACE_INFO((_L("[HID]\tAPPLICATION3 >>> STOP"))); |
|
1946 |
|
1947 // STOP |
|
1948 scancode = EStdKeyApplication3; |
|
1949 isMmKey = ETrue; |
|
1950 break; |
|
1951 } |
|
1952 case EStdKeyF9: |
|
1953 // break; |
|
1954 case EStdKeyApplication4: |
|
1955 { |
|
1956 TRACE_INFO((_L("[HID]\tF9 / APPLICATION4 >>> NEXT / FF"))); |
|
1957 |
|
1958 // NEXT |
|
1959 scancode = EStdKeyApplication4; |
|
1960 isMmKey = ETrue; |
|
1961 break; |
|
1962 } |
|
1963 case EStdKeyF7: |
|
1964 // fall through |
|
1965 case EStdKeyApplication5: |
|
1966 { |
|
1967 TRACE_INFO((_L("[HID]\tF7 / APPLICATION5 >>> PREVIOUS / REW"))); |
|
1968 |
|
1969 // PREVIOUS |
|
1970 scancode = EStdKeyApplication5; |
|
1971 isMmKey = ETrue; |
|
1972 break; |
|
1973 } |
|
1974 case EStdKeyF12: |
|
1975 // fall through |
|
1976 case EStdKeyIncVolume: |
|
1977 { |
|
1978 TRACE_INFO((_L("[HID]\tF12 / INCVOLUME >>> VOLUME UP"))); |
|
1979 |
|
1980 // VOLUME UP |
|
1981 scancode = EStdKeyIncVolume; |
|
1982 isMmKey = ETrue; |
|
1983 break; |
|
1984 } |
|
1985 case EStdKeyF11: |
|
1986 // fall through |
|
1987 case EStdKeyDecVolume: |
|
1988 { |
|
1989 TRACE_INFO((_L("[HID]\tF11 / DECVOLUME >>> VOLUME DOWN"))); |
|
1990 |
|
1991 // VOLUME DOWN |
|
1992 scancode = EStdKeyDecVolume; |
|
1993 isMmKey = ETrue; |
|
1994 break; |
|
1995 } |
|
1996 case EStdKeyF10: |
|
1997 { |
|
1998 TRACE_INFO((_L("[HID]\tF10 >>> MUTE"))); |
|
1999 |
|
2000 // MUTE (currently just toggle play / pause) |
1825 scancode = EStdKeyApplication2; |
2001 scancode = EStdKeyApplication2; |
1826 isMmKey = ETrue; |
2002 isMmKey = ETrue; |
1827 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Play %d"), aIsKeyDown)); |
2003 break; |
1828 break; |
2004 } |
1829 } |
|
1830 |
|
1831 case EStdKeyApplication3: //Stop |
|
1832 { |
|
1833 scancode = EStdKeyApplication3; |
|
1834 isMmKey = ETrue; |
|
1835 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Stop %d"), aIsKeyDown)); |
|
1836 break; |
|
1837 } |
|
1838 |
|
1839 case EStdKeyApplication4: //Next |
|
1840 { |
|
1841 scancode = EStdKeyApplication4; |
|
1842 isMmKey = ETrue; |
|
1843 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Next %d"), aIsKeyDown)); |
|
1844 break; |
|
1845 } |
|
1846 |
|
1847 case EStdKeyApplication5: //Prev |
|
1848 { |
|
1849 scancode = EStdKeyApplication5; |
|
1850 isMmKey = ETrue; |
|
1851 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Prev %d"), aIsKeyDown)); |
|
1852 break; |
|
1853 } |
|
1854 |
|
1855 case EStdKeyIncVolume: //Volume up |
|
1856 { |
|
1857 scancode = EStdKeyIncVolume; |
|
1858 isMmKey = ETrue; |
|
1859 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Volume up %d"), aIsKeyDown)); |
|
1860 break; |
|
1861 } |
|
1862 |
|
1863 case EStdKeyDecVolume: //Volume down |
|
1864 { |
|
1865 scancode = EStdKeyDecVolume; |
|
1866 isMmKey = ETrue; |
|
1867 TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::HandleNokiaMultimediaKeys: Volume down %d"), aIsKeyDown)); |
|
1868 break; |
|
1869 } |
|
1870 |
|
1871 default: |
2005 default: |
1872 break; |
2006 { |
|
2007 break; |
|
2008 } |
1873 } |
2009 } |
1874 |
2010 |
1875 if (isMmKey) |
2011 if (isMmKey) |
1876 { |
2012 { |
1877 SendRawEvent(scancode, aIsKeyDown, modifier); |
2013 SendRawEvent(scancode, aIsKeyDown, modifier); |
1878 } |
2014 ret = ETrue; |
1879 return isMmKey; |
2015 } |
|
2016 |
|
2017 return ret; |
|
2018 } |
|
2019 |
|
2020 void CHidKeyboardDriver::ResetBitmap(TBool aIsKeyDown, |
|
2021 TMmKeyDown aBitmapToReset) |
|
2022 { |
|
2023 if (aIsKeyDown) |
|
2024 { |
|
2025 iMmKeyDown = (iMmKeyDown | aBitmapToReset); |
|
2026 } |
|
2027 else |
|
2028 { |
|
2029 iMmKeyDown = (iMmKeyDown & !aBitmapToReset); |
|
2030 } |
1880 } |
2031 } |
1881 |
2032 |
1882 // ---------------------------------------------------------------------- |
2033 // ---------------------------------------------------------------------- |
1883 // CHidKeyboardDriver::SendRawEvent |
2034 // CHidKeyboardDriver::SendRawEvent |
1884 // Send raw key event to window server |
2035 // Send raw key event to window server |