| 3614 | |
| 3615 | |
| 3616 | modLR_type KeyToModifiersLR(vk_type aVK, sc_type aSC, bool *pIsNeutral) |
| 3617 | // Convert the given virtual key / scan code to its equivalent bitwise modLR value. |
| 3618 | // Callers rely upon the fact that we convert a neutral key such as VK_SHIFT into MOD_LSHIFT, |
| 3619 | // not the bitwise combo of MOD_LSHIFT|MOD_RSHIFT. |
| 3620 | // v1.0.43: VK_SHIFT should yield MOD_RSHIFT if the caller explicitly passed the right vs. left scan code. |
| 3621 | // The SendPlay method relies on this to properly release AltGr, such as after "SendPlay @" in German. |
| 3622 | // Other things may also rely on it because it is more correct. |
| 3623 | { |
| 3624 | bool placeholder; |
| 3625 | bool &is_neutral = pIsNeutral ? *pIsNeutral : placeholder; // Simplifies other things below. |
| 3626 | is_neutral = false; // Set default for output parameter for caller. |
| 3627 | |
| 3628 | if (!(aVK || aSC)) |
| 3629 | return 0; |
| 3630 | |
| 3631 | if (aVK) // Have vk take precedence over any non-zero sc. |
| 3632 | switch(aVK) |
| 3633 | { |
| 3634 | case VK_SHIFT: |
| 3635 | if (aSC == SC_RSHIFT) |
| 3636 | return MOD_RSHIFT; |
| 3637 | //else aSC is omitted (0) or SC_LSHIFT. Either way, most callers would probably want that considered "neutral". |
| 3638 | is_neutral = true; |
| 3639 | return MOD_LSHIFT; |
| 3640 | case VK_LSHIFT: return MOD_LSHIFT; |
| 3641 | case VK_RSHIFT: return MOD_RSHIFT; |
| 3642 | |
| 3643 | case VK_CONTROL: |
| 3644 | if (aSC == SC_RCONTROL) |
| 3645 | return MOD_RCONTROL; |
| 3646 | //else aSC is omitted (0) or SC_LCONTROL. Either way, most callers would probably want that considered "neutral". |
| 3647 | is_neutral = true; |
| 3648 | return MOD_LCONTROL; |
| 3649 | case VK_LCONTROL: return MOD_LCONTROL; |
| 3650 | case VK_RCONTROL: return MOD_RCONTROL; |
| 3651 | |
| 3652 | case VK_MENU: |
| 3653 | if (aSC == SC_RALT) |
| 3654 | return MOD_RALT; |
| 3655 | //else aSC is omitted (0) or SC_LALT. Either way, most callers would probably want that considered "neutral". |
| 3656 | is_neutral = true; |
| 3657 | return MOD_LALT; |
| 3658 | case VK_LMENU: return MOD_LALT; |
| 3659 | case VK_RMENU: return MOD_RALT; |
| 3660 | |
| 3661 | case VK_LWIN: return MOD_LWIN; |
| 3662 | case VK_RWIN: return MOD_RWIN; |
| 3663 | |
| 3664 | default: |
| 3665 | return 0; |
| 3666 | } |
| 3667 | |
| 3668 | // If above didn't return, rely on the scan code instead, which is now known to be non-zero. |
| 3669 | switch(aSC) |
| 3670 | { |
| 3671 | case SC_LSHIFT: return MOD_LSHIFT; |
| 3672 | case SC_RSHIFT: return MOD_RSHIFT; |
| 3673 | case SC_LCONTROL: return MOD_LCONTROL; |
no outgoing calls
no test coverage detected