16f783602c05c519238200fed55b0afa097737ca1Michael Wright/*
26f783602c05c519238200fed55b0afa097737ca1Michael Wright * Copyright (C) 2015 The Android Open Source Project
36f783602c05c519238200fed55b0afa097737ca1Michael Wright *
46f783602c05c519238200fed55b0afa097737ca1Michael Wright * Licensed under the Apache License, Version 2.0 (the "License");
56f783602c05c519238200fed55b0afa097737ca1Michael Wright * you may not use this file except in compliance with the License.
66f783602c05c519238200fed55b0afa097737ca1Michael Wright * You may obtain a copy of the License at
76f783602c05c519238200fed55b0afa097737ca1Michael Wright *
86f783602c05c519238200fed55b0afa097737ca1Michael Wright *      http://www.apache.org/licenses/LICENSE-2.0
96f783602c05c519238200fed55b0afa097737ca1Michael Wright *
106f783602c05c519238200fed55b0afa097737ca1Michael Wright * Unless required by applicable law or agreed to in writing, software
116f783602c05c519238200fed55b0afa097737ca1Michael Wright * distributed under the License is distributed on an "AS IS" BASIS,
126f783602c05c519238200fed55b0afa097737ca1Michael Wright * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
136f783602c05c519238200fed55b0afa097737ca1Michael Wright * See the License for the specific language governing permissions and
146f783602c05c519238200fed55b0afa097737ca1Michael Wright * limitations under the License.
156f783602c05c519238200fed55b0afa097737ca1Michael Wright */
166f783602c05c519238200fed55b0afa097737ca1Michael Wright
176f783602c05c519238200fed55b0afa097737ca1Michael Wright#include <vector>
186f783602c05c519238200fed55b0afa097737ca1Michael Wright
196f783602c05c519238200fed55b0afa097737ca1Michael Wright#include "InputDriver.h"
206f783602c05c519238200fed55b0afa097737ca1Michael Wright#include "InputHost.h"
216f783602c05c519238200fed55b0afa097737ca1Michael Wright
226f783602c05c519238200fed55b0afa097737ca1Michael Wright#include <utils/Log.h>
236f783602c05c519238200fed55b0afa097737ca1Michael Wright#include <utils/String8.h>
246f783602c05c519238200fed55b0afa097737ca1Michael Wright
256f783602c05c519238200fed55b0afa097737ca1Michael Wright#define INDENT "  "
266f783602c05c519238200fed55b0afa097737ca1Michael Wright
276f783602c05c519238200fed55b0afa097737ca1Michael Wrightnamespace android {
286f783602c05c519238200fed55b0afa097737ca1Michael Wright
296f783602c05c519238200fed55b0afa097737ca1Michael Wrightvoid InputHost::registerInputDriver(InputDriverInterface* driver) {
306f783602c05c519238200fed55b0afa097737ca1Michael Wright    LOG_ALWAYS_FATAL_IF(driver == nullptr, "Cannot register a nullptr as an InputDriver!");
312e7f0146a04fe2dbe5ca0389752709e235c64accTim Kilbourn    driver->init();
326f783602c05c519238200fed55b0afa097737ca1Michael Wright    mDrivers.push_back(driver);
336f783602c05c519238200fed55b0afa097737ca1Michael Wright}
346f783602c05c519238200fed55b0afa097737ca1Michael Wright
356f783602c05c519238200fed55b0afa097737ca1Michael Wrightvoid InputHost::dump(String8& result) {
366f783602c05c519238200fed55b0afa097737ca1Michael Wright    result.append(INDENT "Input Drivers:\n");
376f783602c05c519238200fed55b0afa097737ca1Michael Wright    for (size_t i = 0; i < mDrivers.size(); i++) {
386f783602c05c519238200fed55b0afa097737ca1Michael Wright        mDrivers[i]->dump(result);
396f783602c05c519238200fed55b0afa097737ca1Michael Wright    }
406f783602c05c519238200fed55b0afa097737ca1Michael Wright}
416f783602c05c519238200fed55b0afa097737ca1Michael Wright
426f783602c05c519238200fed55b0afa097737ca1Michael Wright} // namespace android
43