MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / getModifierMask

Function getModifierMask

Src/FrmViewer.cpp:436–479  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434
435#if ! (defined(Q_OS_WIN) || defined(Q_OS_APPLE) || defined(Q_OS_ANDROID) || defined(Q_OS_APPLE) || defined(Q_OS_MACOS))
436unsigned int getModifierMask(unsigned int keysym)
437{
438 XkbDescPtr xkb;
439 unsigned int mask, keycode;
440 XkbAction *act;
441
442 mask = 0;
443 Display *dpy = XOpenDisplay(0);
444 xkb = XkbGetMap(dpy, XkbAllComponentsMask, XkbUseCoreKbd);
445 if (xkb == nullptr)
446 return 0;
447
448 for (keycode = xkb->min_key_code; keycode <= xkb->max_key_code; keycode++) {
449 unsigned int state_out;
450 KeySym ks;
451
452 XkbTranslateKeyCode(xkb, keycode, 0, &state_out, &ks);
453 if (ks == NoSymbol)
454 continue;
455
456 if (ks == keysym)
457 break;
458 }
459
460 // KeySym not mapped?
461 if (keycode > xkb->max_key_code)
462 goto out;
463
464 act = XkbKeyAction(xkb, keycode, 0);
465 if (act == nullptr)
466 goto out;
467 if (act->type != XkbSA_LockMods)
468 goto out;
469
470 if (act->mods.flags & XkbSA_UseModMapMods)
471 mask = xkb->map->modmap[keycode];
472 else
473 mask = act->mods.mask;
474
475out:
476 XkbFreeKeyboard(xkb, XkbAllComponentsMask, True);
477
478 return mask;
479}
480#endif
481
482void CFrmViewer::slotUpdateLedState(unsigned int state)

Callers 1

slotUpdateLedStateMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected