blob: 916068edb229340705d76401be1fc29c190d7ae2 [file] [log] [blame]
// Copyright 2014 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <string>
#include <vector>
#include "permission_broker/hid_basictypes.h"
#include "permission_broker/rule.h"
namespace permission_broker {
// HidrawSubsystemUdevRule is a Rule that calls ProcessHidrawDevice on every
// device that belongs to the hidraw subsystem. All non-hidraw devices are
// ignored by this rule.
class HidrawSubsystemUdevRule : public Rule {
explicit HidrawSubsystemUdevRule(const std::string &name);
~HidrawSubsystemUdevRule() override = default;
// Called with every device belonging to the hidraw subsystem.
virtual Result ProcessHidrawDevice(struct udev_device *device) = 0;
Result ProcessDevice(struct udev_device *device) override;
// This parses toplevel items from a report descriptor and extracts the usage
// parameters of any toplevel collections.
static bool ParseToplevelCollectionUsages(
const HidReportDescriptor& descriptor,
std::vector<HidUsage>* usages);
// Populates a vector of HidUsage items using information parsed from a given
// device's descriptor. Returns true iff the descriptor was processed without
// errors.
static bool GetHidToplevelUsages(struct udev_device* device,
std::vector<HidUsage>* usages);
} // namespace permission_broker