ASPiK SDK
Loading...
Searching...
No Matches
AAXtoVSTGUIButtonState.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// ASPiK AAX Shell File: aaxtovstguibuttonstate.h
3//
17// -----------------------------------------------------------------------------
18#ifndef VolTestAAA_AAXtoVSTGUIButtonState_h
19#define VolTestAAA_AAXtoVSTGUIButtonState_h
20
21#include "AAX_CEffectGUI.h"
22#include "AAX_IACFEffectParameters.h"
23#include "AAX_IViewContainer.h"
24
25
26//==============================================================================
27// CAAXButtonState
28//==============================================================================
29
30static uint32_t SynthesizeModifiers(const VSTGUI::CButtonState& inButtonState, AAX_IViewContainer* inViewContainer)
31{
32 uint32_t aax_mods = 0;
33
34 if (inButtonState & VSTGUI::kAlt) { aax_mods |= AAX_eModifiers_Option; }
35 if (inButtonState & VSTGUI::kApple) { aax_mods |= AAX_eModifiers_Control; } // VSTGUI modifier definitions are flipped on Mac.
36 if (inButtonState & VSTGUI::kControl) { aax_mods |= AAX_eModifiers_Command; } // VSTGUI modifier definitions are flipped on Mac.
37 if (inButtonState & VSTGUI::kShift) { aax_mods |= AAX_eModifiers_Shift; }
38 if (inButtonState & VSTGUI::kRButton) { aax_mods |= AAX_eModifiers_SecondaryButton; }
39
40 // It is best practice to always query the host as
41 // well, since the host's key handler may have
42 // prevented some modifier key states from reaching
43 // the plug-in.
44 if (inViewContainer)
45 {
46 uint32_t aaxViewMods = 0;
47 inViewContainer->GetModifiers (&aaxViewMods);
48 aax_mods |= aaxViewMods;
49 }
50
51 return aax_mods;
52}
53
54static VSTGUI::CButtonState SynthesizeButtonState(const VSTGUI::CButtonState& inButtonState, uint32_t inModifiers)
55{
56 VSTGUI::CButtonState buttons(inButtonState);
57
58 if (AAX_eModifiers_Shift & inModifiers) { buttons |= VSTGUI::kShift; }
59 if (AAX_eModifiers_Control & inModifiers) { buttons |= VSTGUI::kApple; } // VSTGUI modifier definitions are flipped on Mac.
60 if (AAX_eModifiers_Option & inModifiers) { buttons |= VSTGUI::kAlt; }
61 if (AAX_eModifiers_Command & inModifiers) { buttons |= VSTGUI::kControl; } // VSTGUI modifier definitions are flipped on Mac.
62 if (AAX_eModifiers_SecondaryButton & inModifiers) { buttons |= VSTGUI::kRButton; }
63
64 return buttons;
65}
66
67//==============================================================================
68// CAAXButtonState
69// Helper class combining representations of the AAX modifier key mask and
70// the VSTGUI::CButtonState mask. Includes logic to fix missing modifier
71// key states that are removed by host filtering, e.g. by the host key hook.
73{
74public:
75 AAX_CVSTGUIButtonState(const VSTGUI::CButtonState& inButtonState, AAX_IViewContainer* inViewContainer)
76 : mModifiers(SynthesizeModifiers(inButtonState, inViewContainer))
77 , mButtonState(SynthesizeButtonState(inButtonState, mModifiers))
78 {
79 }
80
81 const VSTGUI::CButtonState& AsVST() const { return mButtonState; }
82 uint32_t AsAAX() const { return mModifiers; }
83
84private:
85 uint32_t mModifiers;
86 VSTGUI::CButtonState mButtonState;
87
88private:
89 AAX_CVSTGUIButtonState(); // Unimplemented
90};
91
92
93
94
95
96#endif
Definition: AAXtoVSTGUIButtonState.h:73