31 #include "HotkeyHandler.h"
35 #include <hu/varadiistvan/xplcommon/Util.h>
37 #include <hu/varadiistvan/scpl/io/DataStream.h>
39 #include <XPLMDisplay.h>
45 using hu::varadiistvan::xplcommon::Util;
47 using hu::varadiistvan::scpl::io::DataStream;
51 HotkeyHandler::Hotkeys::Hotkeys(
size_t numHotkeys, DataStream& stream) :
52 numHotkeys(numHotkeys),
53 hotkeys(new uint16_t[numHotkeys]),
76 for(
size_t i = 0; i<numHotkeys; ++i) {
77 if (hotkeys[i]==code) {
89 uint8_t pressed1[numHotkeys];
91 for(
size_t i = 0; i<numHotkeys; ++i) {
92 pressed1[i] = __sync_val_compare_and_swap(pressed + i, 1, 0);
95 stream.writeU32(numHotkeys);
96 stream.write(pressed1,
sizeof(pressed1));
106 return hotkeyHandler->
handleKey(c, flags, virtualKey) ? 0 : 1;
138 if ( (flags&xplm_DownFlag)==0 )
return false;
140 uint16_t code =
static_cast<uint16_t
>(virtualKey);
144 bool handled =
false;
bool handleKey(uint16_t code)
void writePressed(hu::varadiistvan::scpl::io::DataStream &stream)
bool handleKey(char c, XPLMKeyFlags flags, char virtualKey)
static int keyCallback(char c, XPLMKeyFlags flags, char virtualKey, void *refCon)
void unregisterHotkeys(Hotkeys *hotkeys)
hu::varadiistvan::scpl::Mutex mutex
void registerHotkeys(Hotkeys *hotkeys)
static const uint16_t HOTKEY_MODIFIER_CONTROL
static const uint16_t HOTKEY_MODIFIER_SHIFT