Exemplo n.º 1
0
void
KeyboardRepeat::set(EventType eventType,
                    Flags flags,
                    ConsumerKeyCode key,
                    int delayUntilRepeat,
                    int keyRepeat) {
  if (key == ConsumerKeyCode::VK_NONE) return;

  if (eventType == EventType::UP) {
    goto cancel;

  } else if (eventType == EventType::DOWN) {
    if (!key.isRepeatable()) {
      goto cancel;
    }

    cancel();

    primitive_add(eventType, flags, key);
    primitive_start(delayUntilRepeat, keyRepeat);

    IOLOG_DEVEL("KeyboardRepeat::set consumer key:%d flags:0x%x\n", key.get(), flags.get());

  } else {
    goto cancel;
  }

  return;

cancel:
  cancel();
}
Exemplo n.º 2
0
void
PressDownKeys::clear(void) {
  IOLOG_DEVEL("PressDownKeys::clear list_.size = %d\n", static_cast<int>(list_.size()));

  Item* p = static_cast<Item*>(list_.safe_front());
  for (;;) {
    if (!p) break;

    Params_KeyboardEventCallBack params(EventType::UP, Flags(0), p->key, p->keyboardType, false);

    EventOutputQueue::push(params);
    IOLOG_DEVEL("PressDownKeys::clear key:%d, keyboardType:%d\n", params.key.get(), params.keyboardType.get());

    p = static_cast<Item*>(list_.erase_and_delete(p));
  }
}
Exemplo n.º 3
0
size_t ListHookedDevice::pressingPhysicalKeysCountAll(void) {
  size_t count = ListHookedKeyboard::instance().pressingPhysicalKeysCount() +
                 ListHookedConsumer::instance().pressingPhysicalKeysCount() +
                 ListHookedPointing::instance().pressingPhysicalKeysCount();
  IOLOG_DEVEL("ListHookedDevice::pressingPhysicalKeysCountAll: %ld\n", count);
  return count;
}
Exemplo n.º 4
0
  void
  KeyboardRepeat::set(EventType eventType,
                      Flags flags,
                      ConsumerKeyCode key)
  {
    if (! queue_) return;

    if (key == ConsumerKeyCode::VK_NONE) return;

    if (eventType == EventType::UP) {
      goto cancel;

    } else if (eventType == EventType::DOWN) {
      if (! key.isRepeatable()) {
        goto cancel;
      }

      cancel();

      primitive_add(eventType, flags, key);
      primitive_start(Config::get_repeat_consumer_initial_wait(),
                      Config::get_repeat_consumer_wait());

      IOLOG_DEVEL("KeyboardRepeat::set consumer key:%d flags:0x%x\n", key.get(), flags.get());

    } else {
      goto cancel;
    }

    return;

  cancel:
    cancel();
  }
Exemplo n.º 5
0
  void
  CommonData::setcurrent_workspacedata(void)
  {
    // ------------------------------------------------------------
    // When we press the functional key (ex. F2) with the keyboard of the third vendor,
    // KeyRemap4MacBook_client::sendmsg returns EIO.
    //
    // We use the previous value when the error occurred.
    static KeyRemap4MacBook_bridge::GetWorkspaceData::Reply last = {
      0,
      0,
      0,
    };

    int error = KeyRemap4MacBook_client::sendmsg(KeyRemap4MacBook_bridge::REQUEST_GET_WORKSPACE_DATA, NULL, 0, &current_workspacedata_, sizeof(current_workspacedata_));
    IOLOG_DEVEL("GetWorkspaceData: type:%d, inputmode:%d, inputmodedetail:%d, error:%d\n",
                current_workspacedata_.type,
                current_workspacedata_.inputmode,
                current_workspacedata_.inputmodedetail,
                error);
    if (error == 0) {
      last = current_workspacedata_;
    } else {
      // use last info.
      current_workspacedata_ = last;
    }
  }
Exemplo n.º 6
0
void
PressDownKeys::add(KeyCode key, KeyboardType keyboardType) {
  if (key == KeyCode::VK_NONE) return;

  list_.push_back(new Item(key, keyboardType));

  IOLOG_DEVEL("PressDownKeys::add key:%d, keyboardType:%d\n", key.get(), keyboardType.get());
}
Exemplo n.º 7
0
void ListHookedDevice::erase(IOHIDevice* p) {
  ListHookedDevice::Item* item = get(p);
  if (!item) return;

  list_.erase_and_delete(item);

  IOLOG_DEVEL("ListHookedDevice::erase list_.size = %d\n", static_cast<int>(list_.size()));

  refresh();
}
Exemplo n.º 8
0
  void
  EventWatcher::on(void)
  {
    if (! list_) return;

    IOLOG_DEVEL("EventWatcher::on (list_->size:%d)\n", static_cast<int>(list_->size()));

    for (Item* p = static_cast<Item*>(list_->front()); p; p = static_cast<Item*>(p->getnext())) {
      p->on();
    }
  }
Exemplo n.º 9
0
void FlagStatus::log(void) const {
  for (size_t i = 0; i < item_.size(); ++i) {
    int sum = item_[i].sum(false);
    if (sum != 0) {
      const char* name = ModifierName::getName(item_[i].flag_);
      if (name) {
        IOLOG_DEVEL("FlagStatus %s: %d\n", name, sum);
      }
    }
  }
}
Exemplo n.º 10
0
void ListHookedDevice::push_back(ListHookedDevice::Item* newp) {
  if (!newp) return;

  last_ = newp->device_;
  list_.push_back(newp);

  IOLOG_DEVEL("ListHookedDevice::push_back list_.size = %d\n", static_cast<int>(list_.size()));

  refresh();
  start_refreshInProgressDevices_timer();
}
Exemplo n.º 11
0
  void
  PressDownKeys::clear(void)
  {
    if (! list_) return;

    IOLOG_DEVEL("PressDownKeys::clear list_->size = %d\n", static_cast<int>(list_->size()));

    Item* p = static_cast<Item*>(list_->front());
    for (;;) {
      if (! p) break;

      Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(EventType::UP, Flags(0), p->key, p->keyboardType, false));
      if (! ptr) break;

      EventOutputQueue::push(*ptr);
      IOLOG_DEVEL("PressDownKeys::clear key:%d, keyboardType:%d\n", (p->key).get(), (p->keyboardType).get());

      p = static_cast<Item*>(list_->erase_and_delete(p));
    }
  }
Exemplo n.º 12
0
  void
  ListHookedDevice::push_back(ListHookedDevice::Item* newp)
  {
    if (! list_) return;
    if (! newp) return;

    last_ = newp->device_;
    list_->push_back(newp);

    // Call reset whenever the device status is changed.
    reset();

    IOLOG_DEVEL("ListHookedDevice::push_back list_->size = %d\n", static_cast<int>(list_->size()));

    refresh();
  }
Exemplo n.º 13
0
void
PressDownKeys::remove(KeyCode key, KeyboardType keyboardType) {
  Item* p = static_cast<Item*>(list_.safe_front());
  for (;;) {
    if (!p) break;

    if (p->key == key &&
        p->keyboardType == keyboardType) {
      p = static_cast<Item*>(list_.erase_and_delete(p));
    } else {
      p = static_cast<Item*>(p->getnext());
    }
  }

  IOLOG_DEVEL("PressDownKeys::remove key:%d, keyboardType:%d\n", key.get(), keyboardType.get());
}
Exemplo n.º 14
0
  void
  ListHookedDevice::erase(IOHIDevice* p)
  {
    if (! list_) return;

    ListHookedDevice::Item* item = get(p);
    if (! item) return;

    list_->erase(item);

    // Call reset whenever the device status is changed.
    reset();

    IOLOG_DEVEL("ListHookedDevice::erase list_->size = %d\n", static_cast<int>(list_->size()));

    refresh();
  }
Exemplo n.º 15
0
  void
  KeyboardRepeat::set(EventType eventType,
                      Flags flags,
                      KeyCode key,
                      KeyboardType keyboardType,
                      int delayUntilRepeat,
                      int keyRepeat)
  {
    if (! queue_) return;

    if (key == KeyCode::VK_NONE) return;

    if (eventType == EventType::MODIFY) {
      goto cancel;

    } else if (eventType == EventType::UP) {
      // The repetition of plural keys is controlled by manual operation.
      // So, we ignore it.
      if (queue_->size() != 1) return;

      // We stop key repeat only when the repeating key is up.
      KeyboardRepeat::Item* p = static_cast<KeyboardRepeat::Item*>(queue_->front());
      if (p && (p->params).type == ParamsUnion::KEYBOARD) {
        Params_KeyboardEventCallBack* params = (p->params).params.params_KeyboardEventCallBack;
        if (params && key == params->key) {
          goto cancel;
        }
      }

    } else if (eventType == EventType::DOWN) {
      cancel();

      primitive_add(eventType, flags, key, keyboardType, Item::TYPE_NORMAL);
      primitive_start(delayUntilRepeat, keyRepeat);

      IOLOG_DEVEL("KeyboardRepeat::set key:%d flags:0x%x\n", key.get(), flags.get());

    } else {
      goto cancel;
    }

    return;

  cancel:
    cancel();
  }
Exemplo n.º 16
0
void
KeyboardRepeat::fire_timer_callback(OSObject* owner, IOTimerEventSource* sender) {
  IOLOG_DEVEL("KeyboardRepeat::fire queue_.size = %d\n", static_cast<int>(queue_.size()));

  // ----------------------------------------
  for (KeyboardRepeat::Item* p = static_cast<KeyboardRepeat::Item*>(queue_.safe_front()); p; p = static_cast<KeyboardRepeat::Item*>(p->getnext())) {
    {
      {
        auto params = (p->getParamsBase()).get_Params_KeyboardEventCallBack();
        if (params) {
          EventOutputQueue::FireKey::fire(
              Params_KeyboardEventCallBack(
                  params->eventType,
                  params->flags,
                  params->key,
                  params->keyboardType,
                  queue_.size() == 1 ? true : false));
        }
      }

      {
        auto params = (p->getParamsBase()).get_Params_KeyboardSpecialEventCallback();
        if (params) {
          EventOutputQueue::FireConsumer::fire(
              Params_KeyboardSpecialEventCallback(
                  params->eventType,
                  params->flags,
                  params->key,
                  queue_.size() == 1 ? true : false));
        }
      }

      {
        auto params = (p->getParamsBase()).get_Params_RelativePointerEventCallback();
        if (params) {
          EventOutputQueue::FireRelativePointer::fire(params->buttons, params->dx, params->dy);
        }
      }
    }
  }

  fire_timer_.setTimeoutMS(keyRepeat_);
}
Exemplo n.º 17
0
void KeyboardRepeat::set(EventType eventType,
                         Flags flags,
                         KeyCode key,
                         KeyboardType keyboardType,
                         int delayUntilRepeat,
                         int keyRepeat) {
  if (key == KeyCode::VK_NONE) return;

  if (eventType == EventType::MODIFY) {
    goto cancel;

  } else if (eventType == EventType::UP) {
    // The repetition of multiple keys is controlled by manual operation.
    // So, we ignore it.
    if (queue_.size() != 1) return;

    // We stop key repeat only when the repeating key is up.
    KeyboardRepeat::Item* p = static_cast<KeyboardRepeat::Item*>(queue_.safe_front());
    if (p) {
      auto params = (p->getParamsBase()).get_Params_KeyboardEventCallBack();
      if (params && key == params->key) {
        goto cancel;
      }
    }

  } else if (eventType == EventType::DOWN) {
    cancel();

    primitive_add(eventType, flags, key, keyboardType);
    primitive_start(delayUntilRepeat, keyRepeat);

    IOLOG_DEVEL("KeyboardRepeat::set key:%d flags:0x%x\n", key.get(), flags.get());

  } else {
    goto cancel;
  }

  return;

cancel:
  cancel();
}
Exemplo n.º 18
0
  void
  ListHookedDevice::erase(IOHIDevice* p)
  {
    IOLockWrapper::ScopedLock lk(list_lock_);
    if (! lk) return;

    if (! list_) return;

    ListHookedDevice::Item* item = get_nolock(p);
    if (! item) return;

    list_->erase(item);

    // Call reset whenever the device status is changed.
    reset();

    IOLOG_DEVEL("ListHookedDevice::erase list_->size = %d\n", static_cast<int>(list_->size()));

    refresh_nolock();
  }
Exemplo n.º 19
0
 static void setcurrent_lastsentevent(const Params_Base& newval) {
   current_lastsentevent_.update(newval);
   IOLOG_DEVEL("LastSentEvent: %s:0x%04x, %s\n",
               (current_lastsentevent_.get_datatype() == BRIDGE_DATATYPE_KEYCODE
                    ? "KeyCode"
                    : (current_lastsentevent_.get_datatype() == BRIDGE_DATATYPE_CONSUMERKEYCODE
                           ? "ConsumerKeyCode"
                           : (current_lastsentevent_.get_datatype() == BRIDGE_DATATYPE_POINTINGBUTTON
                                  ? "PointingButton"
                                  : (current_lastsentevent_.get_datatype() == BRIDGE_DATATYPE_SCROLLWHEEL
                                         ? "ScrollWheel"
                                         : "Unknown")))),
               current_lastsentevent_.get_value(),
               (current_lastsentevent_.get_eventtype() == EventType::NONE
                    ? "EventType::NONE"
                    : (current_lastsentevent_.get_eventtype() == EventType::DOWN
                           ? "EventType::DOWN"
                           : (current_lastsentevent_.get_eventtype() == EventType::UP
                                  ? "EventType::UP"
                                  : (current_lastsentevent_.get_eventtype() == EventType::MODIFY
                                         ? "EventType::MODIFY"
                                         : "Unknown")))));
 }
 void
 NumHeldDownKeys::log(void)
 {
   IOLOG_DEVEL("NumHeldDownKeys = %d\n", num_);
 }
 void
 NumHeldDownKeys::reset(void)
 {
   IOLOG_DEVEL("NumHeldDownKeys::reset\n");
   num_ = 0;
 }
Exemplo n.º 22
0
  void
  KeyboardRepeat::fire_timer_callback(OSObject* owner, IOTimerEventSource* sender)
  {
    if (! queue_) return;

    IOLOG_DEVEL("KeyboardRepeat::fire queue_->size = %d\n", static_cast<int>(queue_->size()));

    // ----------------------------------------
    for (KeyboardRepeat::Item* p = static_cast<KeyboardRepeat::Item*>(queue_->front()); p; p = static_cast<KeyboardRepeat::Item*>(p->getnext())) {
      switch ((p->params).type) {
        case ParamsUnion::KEYBOARD:
        {
          Params_KeyboardEventCallBack* params = (p->params).params.params_KeyboardEventCallBack;
          if (params) {
            switch (p->type) {
              case Item::TYPE_NORMAL:
              {
                Params_KeyboardEventCallBack::auto_ptr ptr(Params_KeyboardEventCallBack::alloc(params->eventType,
                                                                                               params->flags,
                                                                                               params->key,
                                                                                               params->keyboardType,
                                                                                               queue_->size() == 1 ? true : false));
                if (ptr) {
                  EventOutputQueue::FireKey::fire(*ptr);
                }
                break;
              }

              case Item::TYPE_DOWNUP:
              {
                EventOutputQueue::FireKey::fire_downup(params->flags,
                                                       params->key,
                                                       params->keyboardType);
                break;
              }
            }
          }
          break;
        }

        case ParamsUnion::KEYBOARD_SPECIAL:
        {
          Params_KeyboardSpecialEventCallback* params = (p->params).params.params_KeyboardSpecialEventCallback;
          if (params) {
            Params_KeyboardSpecialEventCallback::auto_ptr ptr(Params_KeyboardSpecialEventCallback::alloc(params->eventType,
                                                                                                         params->flags,
                                                                                                         params->key,
                                                                                                         queue_->size() == 1 ? true : false));
            if (ptr) {
              EventOutputQueue::FireConsumer::fire(*ptr);
            }
          }
          break;
        }

        case ParamsUnion::UPDATE_FLAGS:
        case ParamsUnion::RELATIVE_POINTER:
        case ParamsUnion::SCROLL_WHEEL:
        case ParamsUnion::WAIT:
          // do nothing
          break;
      }
    }

    fire_timer_.setTimeoutMS(keyRepeat_);
  }