aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/bfc/std_keyboard.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/bfc/std_keyboard.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/Wasabi/bfc/std_keyboard.cpp')
-rw-r--r--Src/Wasabi/bfc/std_keyboard.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/Src/Wasabi/bfc/std_keyboard.cpp b/Src/Wasabi/bfc/std_keyboard.cpp
new file mode 100644
index 00000000..aa5707dc
--- /dev/null
+++ b/Src/Wasabi/bfc/std_keyboard.cpp
@@ -0,0 +1,51 @@
+#include "precomp_wasabi_bfc.h"
+#include "std_keyboard.h"
+
+int Std::keyDown(int code)
+{
+#ifdef WIN32
+ return !!(GetKeyState(code) & 0x8000);
+#elif defined(LINUX)
+ if ( code == MK_RBUTTON || code == MK_LBUTTON ) {
+ Window t1, t2;
+ int rx, ry, wx, wy;
+ unsigned int buttons;
+
+ XQueryPointer( Linux::getDisplay(), Linux::RootWin(), &t1, &t2,
+ &rx, &ry, &wx, &wy, &buttons );
+
+ if ( code == MK_RBUTTON )
+ return buttons & Button3Mask;
+ else
+ return buttons & Button1Mask;
+ }
+
+ int code1 = XKeysymToKeycode( Linux::getDisplay(), code & 0xFFFF );
+ int code2 = XKeysymToKeycode( Linux::getDisplay(), (code>>16) & 0xFFFF );
+
+ char keys_return[32] = {0};
+ XQueryKeymap( Linux::getDisplay(), keys_return );
+
+ if ( code1 && code2 )
+ return (keys_return[ (code1 >> 3) & 31 ] & (1 << (code1 & 7))) ||
+ (keys_return[ (code2 >> 3) & 31 ] & (1 << (code2 & 7)));
+
+ return (keys_return[ (code1 >> 3) & 31 ] & (1 << (code1 & 7)));
+#else
+ return 0;
+#warning port me!
+#endif
+}
+
+// TODO: add async flag to be able to choose between GetKeyState/GetAsyncKeyState (win32) GetCurrentKeyModifiers/GetCurrentEventkeyModifiers (mac)
+bool Std::keyModifier(int code)
+{
+#ifdef WIN32
+ return !!(GetKeyState(code) & 0x8000);
+#elif defined(__APPLE__)
+ return GetCurrentKeyModifiers() & code;
+#elif defined(LINUX)
+#error port me
+#endif
+}
+