platform specific api usage
Basile B. via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Aug 13 11:44:54 PDT 2016
On Saturday, 13 August 2016 at 08:11:50 UTC, Brons wrote:
> Hi,
>
> Im trying to make a application to have global system hotkeys,
> and key emulation.
> Ive found:
> https://github.com/dlang/druntime/tree/master/src/core/sys/
> https://github.com/madadam/X11.d/tree/master/X11
> https://github.com/smjgordon/bindings
>
> It looks like druntime is based off smjgordon. But i cant find
> any documentation on using any of them.
>
> Id like it to work on windows and linux.
> Any ideas on where to get started on this?
You must start with something like this:
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
version(Windows)
{
import core.sys.windows.winuser;
enum WIN = true;
}
else
{
import x11.keysymdef;
enum WIN = false;
}
enum VK // virtual keys
{
left = WIN ? VK_LEFT : XK_Left,
right = WIN ? VK_RIGHT : XK_Right,
// etc...
}
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
Hotkeys are then a story of bit masking and bit sets.
For each specific platform you'll have to translate the incoming
events to form something like a struct made of a bitset of key
modifiers (alt|ctrl|shift) and a char.
example with x11:
-
https://github.com/BBasile/kheops/blob/master/src/kheops/control.d#L2166
-
https://github.com/buggins/dlangui/blob/master/src/dlangui/platforms/x11/x11app.d#L811
example with win:
-
https://github.com/buggins/dlangui/blob/master/src/dlangui/platforms/windows/winapp.d#L787
-
https://github.com/Devisualization/window/blob/master/platforms/win32/devisualization/window/window.d#L548
More information about the Digitalmars-d-learn
mailing list