1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "EventHub.h"
20 #include "InputDevice.h"
21 #include "InputListener.h"
22 #include "InputReaderContext.h"
23 
24 namespace android {
25 
26 /* A peripheral controller manages the input device peripherals associated with the input device,
27  * like the sysfs based battery and light class devices.
28  *
29  */
30 class PeripheralControllerInterface {
31 public:
PeripheralControllerInterface()32     PeripheralControllerInterface() {}
~PeripheralControllerInterface()33     virtual ~PeripheralControllerInterface() {}
34 
35     virtual int32_t getEventHubId() const = 0;
36 
37     // Interface methods for Battery
38     virtual std::optional<int32_t> getBatteryCapacity(int32_t batteryId) = 0;
39     virtual std::optional<int32_t> getBatteryStatus(int32_t batteryId) = 0;
40 
41     // Interface methods for Light
42     virtual bool setLightColor(int32_t lightId, int32_t color) = 0;
43     virtual bool setLightPlayerId(int32_t lightId, int32_t playerId) = 0;
44     virtual std::optional<int32_t> getLightColor(int32_t lightId) = 0;
45     virtual std::optional<int32_t> getLightPlayerId(int32_t lightId) = 0;
46 
47     virtual void populateDeviceInfo(InputDeviceInfo* deviceInfo) = 0;
48     virtual void dump(std::string& dump) = 0;
49 };
50 
51 } // namespace android
52