Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
3.6KB

  1. //-----------------------------------------------------------------------------
  2. // Project : SDK Core
  3. //
  4. // Category : SDK Core Interfaces
  5. // Filename : pluginterfaces/base/keycodes.h
  6. // Created by : Steinberg, 01/2004
  7. // Description : Key Code Definitions
  8. //
  9. //-----------------------------------------------------------------------------
  10. // This file is part of a Steinberg SDK. It is subject to the license terms
  11. // in the LICENSE file found in the top-level directory of this distribution
  12. // and at www.steinberg.net/sdklicenses.
  13. // No part of the SDK, including this file, may be copied, modified, propagated,
  14. // or distributed except according to the terms contained in the LICENSE file.
  15. //-----------------------------------------------------------------------------
  16. #pragma once
  17. #include "pluginterfaces/base/ftypes.h"
  18. namespace Steinberg {
  19. //------------------------------------------------------------------------------
  20. /** Virtual Key Codes.
  21. OS-independent enumeration of virtual keycodes.
  22. */
  23. //------------------------------------------------------------------------------
  24. enum VirtualKeyCodes
  25. {
  26. KEY_BACK = 1,
  27. KEY_TAB,
  28. KEY_CLEAR,
  29. KEY_RETURN,
  30. KEY_PAUSE,
  31. KEY_ESCAPE,
  32. KEY_SPACE,
  33. KEY_NEXT,
  34. KEY_END,
  35. KEY_HOME,
  36. KEY_LEFT,
  37. KEY_UP,
  38. KEY_RIGHT,
  39. KEY_DOWN,
  40. KEY_PAGEUP,
  41. KEY_PAGEDOWN,
  42. KEY_SELECT,
  43. KEY_PRINT,
  44. KEY_ENTER,
  45. KEY_SNAPSHOT,
  46. KEY_INSERT,
  47. KEY_DELETE,
  48. KEY_HELP,
  49. KEY_NUMPAD0,
  50. KEY_NUMPAD1,
  51. KEY_NUMPAD2,
  52. KEY_NUMPAD3,
  53. KEY_NUMPAD4,
  54. KEY_NUMPAD5,
  55. KEY_NUMPAD6,
  56. KEY_NUMPAD7,
  57. KEY_NUMPAD8,
  58. KEY_NUMPAD9,
  59. KEY_MULTIPLY,
  60. KEY_ADD,
  61. KEY_SEPARATOR,
  62. KEY_SUBTRACT,
  63. KEY_DECIMAL,
  64. KEY_DIVIDE,
  65. KEY_F1,
  66. KEY_F2,
  67. KEY_F3,
  68. KEY_F4,
  69. KEY_F5,
  70. KEY_F6,
  71. KEY_F7,
  72. KEY_F8,
  73. KEY_F9,
  74. KEY_F10,
  75. KEY_F11,
  76. KEY_F12,
  77. KEY_NUMLOCK,
  78. KEY_SCROLL,
  79. KEY_SHIFT,
  80. KEY_CONTROL,
  81. KEY_ALT,
  82. KEY_EQUALS, // only occurs on a Mac
  83. KEY_CONTEXTMENU, // Windows only
  84. // multimedia keys
  85. KEY_MEDIA_PLAY,
  86. KEY_MEDIA_STOP,
  87. KEY_MEDIA_PREV,
  88. KEY_MEDIA_NEXT,
  89. KEY_VOLUME_UP,
  90. KEY_VOLUME_DOWN,
  91. KEY_F13,
  92. KEY_F14,
  93. KEY_F15,
  94. KEY_F16,
  95. KEY_F17,
  96. KEY_F18,
  97. KEY_F19,
  98. VKEY_FIRST_CODE = KEY_BACK,
  99. VKEY_LAST_CODE = KEY_F19,
  100. VKEY_FIRST_ASCII = 128
  101. /*
  102. KEY_0 - KEY_9 are the same as ASCII '0' - '9' (0x30 - 0x39) + FIRST_ASCII
  103. KEY_A - KEY_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A) + FIRST_ASCII
  104. */
  105. };
  106. //------------------------------------------------------------------------------
  107. inline tchar VirtualKeyCodeToChar (uint8 vKey)
  108. {
  109. if (vKey >= VKEY_FIRST_ASCII)
  110. return (tchar)(vKey - VKEY_FIRST_ASCII + 0x30);
  111. else if (vKey == KEY_SPACE)
  112. return ' ';
  113. return 0;
  114. }
  115. //------------------------------------------------------------------------------
  116. inline uint8 CharToVirtualKeyCode (tchar character)
  117. {
  118. if ((character >= 0x30 && character <= 0x39) || (character >= 0x41 && character <= 0x5A))
  119. return (uint8)(character - 0x30 + VKEY_FIRST_ASCII);
  120. if (character == ' ')
  121. return (uint8)KEY_SPACE;
  122. return 0;
  123. }
  124. //------------------------------------------------------------------------------
  125. enum KeyModifier
  126. {
  127. kShiftKey = 1 << 0, ///< same on both PC and Mac
  128. kAlternateKey = 1 << 1, ///< same on both PC and Mac
  129. kCommandKey = 1 << 2, ///< windows ctrl key; mac cmd key (apple button)
  130. kControlKey = 1 << 3 ///< windows: not assigned, mac: ctrl key
  131. };
  132. //------------------------------------------------------------------------
  133. struct KeyCode
  134. {
  135. tchar character;
  136. uint8 virt;
  137. uint8 modifier;
  138. explicit KeyCode (tchar character = 0, uint8 virt = 0, uint8 modifier = 0)
  139. : character (character), virt (virt), modifier (modifier)
  140. {
  141. }
  142. };
  143. //------------------------------------------------------------------------
  144. } // namespace Steinberg