void add(Option newval)  { add(AddDataType(BRIDGE_DATATYPE_OPTION),  AddValue(newval.get())); }
 // utility
 void add(KeyCode newval) { add(AddDataType(BRIDGE_DATATYPE_KEYCODE), AddValue(newval.get())); }
Beispiel #3
0
    void
    FilterUnion::initialize(const unsigned int* vec, size_t length)
    {
      type_ = BRIDGE_FILTERTYPE_NONE;

      // ------------------------------------------------------------
      // check parameters.
      //
      if (! vec || length == 0) {
        IOLOG_ERROR("FilterUnion::initialize invalid parameter.\n");
        goto error;
      }

      // ------------------------------------------------------------
      // initialize values.
      //
      type_ = vec[0];

      switch (type_) {
        case BRIDGE_FILTERTYPE_APPLICATION_NOT:
        case BRIDGE_FILTERTYPE_APPLICATION_ONLY:
          p_.applicationFilter = new ApplicationFilter(type_);
          if (p_.applicationFilter) {
            for (size_t i = 1; i < length; ++i) {
              (p_.applicationFilter)->add(AddValue(vec[i]));
            }
          }
          break;

        case BRIDGE_FILTERTYPE_CONFIG_NOT:
        case BRIDGE_FILTERTYPE_CONFIG_ONLY:
          p_.configFilter = new ConfigFilter(type_);
          if (p_.configFilter) {
            for (size_t i = 1; i < length; ++i) {
              (p_.configFilter)->add(AddValue(vec[i]));
            }
          }
          break;

        case BRIDGE_FILTERTYPE_DEVICE_NOT:
        case BRIDGE_FILTERTYPE_DEVICE_ONLY:
          p_.deviceFilter = new DeviceFilter(type_);
          if (p_.deviceFilter) {
            for (size_t i = 1; i < length - 2; i += 3) {
              (p_.deviceFilter)->add(DeviceVendor(vec[i]),
                                     DeviceProduct(vec[i + 1]),
                                     DeviceLocation(vec[i + 2]));
            }
            if ((length - 1) % 3 > 0) {
              IOLOG_WARN("Invalid length(%d) in BRIDGE_FILTERTYPE_DEVICE_*\n", static_cast<int>(length));
            }
          }
          break;

        case BRIDGE_FILTERTYPE_ELAPSEDTIMESINCELASTPRESSED_GREATERTHAN:
        case BRIDGE_FILTERTYPE_ELAPSEDTIMESINCELASTPRESSED_LESSTHAN:
          p_.elapsedTimeSinceLastPressedFilter = new ElapsedTimeSinceLastPressedFilter(type_);
          if (p_.elapsedTimeSinceLastPressedFilter) {
            for (size_t i = 1; i < length - 1; i += 2) {
              (p_.elapsedTimeSinceLastPressedFilter)->add(AddDataType(vec[i]), AddValue(vec[i + 1]));
            }
          }
          break;

        case BRIDGE_FILTERTYPE_INPUTSOURCE_NOT:
        case BRIDGE_FILTERTYPE_INPUTSOURCE_ONLY:
        case BRIDGE_FILTERTYPE_INPUTSOURCEDETAIL_NOT:
        case BRIDGE_FILTERTYPE_INPUTSOURCEDETAIL_ONLY:
          p_.inputSourceFilter = new InputSourceFilter(type_);
          if (p_.inputSourceFilter) {
            for (size_t i = 1; i < length; ++i) {
              (p_.inputSourceFilter)->add(AddValue(vec[i]));
            }
          }
          break;

        case BRIDGE_FILTERTYPE_LASTPRESSEDPHYSICALKEY_NOT:
        case BRIDGE_FILTERTYPE_LASTPRESSEDPHYSICALKEY_ONLY:
          p_.lastPressedPhysicalKeyFilter = new LastPressedPhysicalKeyFilter(type_);
          if (p_.lastPressedPhysicalKeyFilter) {
            for (size_t i = 1; i < length - 1; i += 2) {
              (p_.lastPressedPhysicalKeyFilter)->add(AddDataType(vec[i]), AddValue(vec[i + 1]));
            }
          }
          break;

        case BRIDGE_FILTERTYPE_MODIFIER_NOT:
        case BRIDGE_FILTERTYPE_MODIFIER_ONLY:
          p_.modifierFilter = new ModifierFilter(type_);
          if (p_.modifierFilter) {
            for (size_t i = 1; i < length - 1; i += 2) {
              (p_.modifierFilter)->add(AddDataType(vec[i]), AddValue(vec[i + 1]));
            }
          }
          break;

        case BRIDGE_FILTERTYPE_WINDOWNAME_NOT:
        case BRIDGE_FILTERTYPE_WINDOWNAME_ONLY:
          p_.windowNameFilter = new WindowNameFilter(type_);
          if (p_.windowNameFilter) {
            for (size_t i = 1; i < length; ++i) {
              (p_.windowNameFilter)->add(AddValue(vec[i]));
            }
          }
          break;

        case BRIDGE_FILTERTYPE_UIELEMENTROLE_NOT:
        case BRIDGE_FILTERTYPE_UIELEMENTROLE_ONLY:
          p_.uiElementRoleFilter = new UIElementRoleFilter(type_);
          if (p_.uiElementRoleFilter) {
            for (size_t i = 1; i < length; ++i) {
              (p_.uiElementRoleFilter)->add(AddValue(vec[i]));
            }
          }
          break;

        default:
          IOLOG_ERROR("FilterUnion::initialize unknown type_:%d.\n", type_);
          goto error;
      }

      return;

    error:
      terminate();
    }
Beispiel #4
0
  static RemapFuncBase* create(const unsigned int* vec, size_t length, AutogenId autogenId) {
    // ------------------------------------------------------------
    // check parameters.
    //
    if (!vec || length == 0) {
      IOLOG_ERROR("RemapFuncFactory::create invalid parameter %p, %ld.\n", vec, length);
      return nullptr;
    }

    // ------------------------------------------------------------
    unsigned int type = vec[0];

    RemapFuncBase* p = nullptr;

    switch (type) {
    case BRIDGE_REMAPTYPE_KEYTOKEY:
      p = new KeyToKey(autogenId);
      break;
    case BRIDGE_REMAPTYPE_DOUBLEPRESSMODIFIER:
      p = new DoublePressModifier(autogenId);
      break;
    case BRIDGE_REMAPTYPE_DROPALLKEYS:
      p = new DropAllKeys(autogenId);
      break;
    case BRIDGE_REMAPTYPE_DROPKEYAFTERREMAP:
      p = new DropKeyAfterRemap(autogenId);
      break;
    case BRIDGE_REMAPTYPE_DROPPOINTINGRELATIVECURSORMOVE:
      p = new DropPointingRelativeCursorMove(autogenId);
      break;
    case BRIDGE_REMAPTYPE_DROPSCROLLWHEEL:
      p = new DropScrollWheel(autogenId);
      break;
    case BRIDGE_REMAPTYPE_FLIPPOINTINGRELATIVE:
      p = new FlipPointingRelative(autogenId);
      break;
    case BRIDGE_REMAPTYPE_FLIPSCROLLWHEEL:
      p = new FlipScrollWheel(autogenId);
      break;
    case BRIDGE_REMAPTYPE_FORCENUMLOCKON:
      p = new ForceNumLockOn(autogenId);
      break;
    case BRIDGE_REMAPTYPE_HOLDINGKEYTOKEY:
      p = new HoldingKeyToKey(autogenId);
      break;
    case BRIDGE_REMAPTYPE_IGNOREMULTIPLESAMEKEYPRESS:
      p = new IgnoreMultipleSameKeyPress(autogenId);
      break;
    case BRIDGE_REMAPTYPE_KEYOVERLAIDMODIFIER:
      p = new KeyOverlaidModifier(autogenId);
      break;
    case BRIDGE_REMAPTYPE_KEYDOWNUPTOKEY:
      p = new KeyDownUpToKey(autogenId);
      break;
    case BRIDGE_REMAPTYPE_POINTINGRELATIVETOKEY:
      p = new PointingRelativeToKey(autogenId);
      break;
    case BRIDGE_REMAPTYPE_POINTINGRELATIVETOSCROLL:
      p = new PointingRelativeToScroll(autogenId);
      break;
    case BRIDGE_REMAPTYPE_SIMULTANEOUSKEYPRESSES:
      p = new SimultaneousKeyPresses(autogenId);
      break;
    case BRIDGE_REMAPTYPE_SETKEYBOARDTYPE:
      p = new SetKeyboardType(autogenId);
      break;
    case BRIDGE_REMAPTYPE_SCROLLWHEELTOSCROLLWHEEL:
      p = new ScrollWheelToScrollWheel(autogenId);
      break;
    case BRIDGE_REMAPTYPE_SCROLLWHEELTOKEY:
      p = new ScrollWheelToKey(autogenId);
      break;
    case BRIDGE_REMAPTYPE_BLOCKUNTILKEYUP:
      p = new BlockUntilKeyUp(autogenId);
      break;
    case BRIDGE_REMAPTYPE_PASSTHROUGH:
      p = new PassThrough(autogenId);
      break;
    default:
      IOLOG_ERROR("RemapFuncFactory::create unknown type: %d\n", type);
      return nullptr;
    }

    if (!p) {
      IOLOG_ERROR("RemapFuncFactory::create failed to allocate: %d\n", type);
      return nullptr;
    }

    // ------------------------------------------------------------
    for (size_t i = 1;; i += 2) {
      size_t datatype_index = i;
      size_t value_index = i + 1;
      if (value_index >= length) break;

      if (vec[datatype_index] == BRIDGE_DATATYPE_OPTION &&
          Option(vec[value_index]) == Option::IGNORE_PASSTHROUGH) {
        p->setIgnorePassThrough(true);
      } else {
        p->add(AddDataType(vec[datatype_index]), AddValue(vec[value_index]));
      }
    }

    return p;
  }
 void add(KeyToKeyType::Value type, Option newval) {
   add(type, AddDataType(BRIDGE_DATATYPE_OPTION), AddValue(newval.get()));
 }
 void add(KeyToKeyType::Value type, KeyCode newval) {
   add(type, AddDataType(BRIDGE_DATATYPE_KEYCODE), AddValue(newval.get()));
 }