// Path: cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java
// public enum Configuration {
//     // Channel Count, Max Touch Inputs, LED Count
//     CAP1203(3,3,0),
//     CAP1293(3,3,0),
//     CAP1206(6,4,0),
//     CAP1296(6,4,0),
//     CAP1208(8,4,0),
//     CAP1298(8,4,0),
//     CAP1105(5,3,0),
//     CAP1106(6,4,0),
//     CAP1126(6,4,2),
//     CAP1128(8,4,2),
//     CAP1133(3,3,3),
//     CAP1166(6,4,6),
//     CAP1188(8,4,8);
// 
//     final int channelCount;
//     final int maxTouch;
//     final int ledCount;
//     Configuration(int channelCount, int maxTouch, int ledCount) {
//         this.channelCount = channelCount;
//         this.maxTouch = maxTouch;
//         this.ledCount = ledCount;
//     }
// }


import android.content.Context;
import android.os.Handler;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
import android.view.InputDevice;
import android.view.KeyEvent;
import com.google.android.things.contrib.driver.cap1xxx.Cap1xxx.Configuration;
import com.google.android.things.userdriver.input.InputDriver;
import com.google.android.things.userdriver.UserDriverManager;
import com.google.android.things.userdriver.input.InputDriverEvent;
import java.io.IOException;
/*
 * Copyright 2016 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.things.contrib.driver.cap1xxx;




/**
 * User-space driver to process capacitive touch events from the
 * CAP1xxx family of touch controllers and forward them to the
 * Android input framework.
 */
@SuppressWarnings("WeakerAccess")
public class Cap1xxxInputDriver implements AutoCloseable {
    private static final String TAG = "Cap1xxxInputDriver";

    // Driver parameters
    private static final String DRIVER_NAME = "Cap1xxx";

    private Cap1xxx mPeripheralDevice;
    // Framework input driver
    private InputDriver mInputDriver;
    // Key codes mapped to input channels
    private int[] mKeycodes;

    /**
     * @deprecated Use {@link #Cap1xxxInputDriver(String, String, Configuration, int[])} instead.
     */
    @Deprecated
// Path: cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxx.java
// public enum Configuration {
//     // Channel Count, Max Touch Inputs, LED Count
//     CAP1203(3,3,0),
//     CAP1293(3,3,0),
//     CAP1206(6,4,0),
//     CAP1296(6,4,0),
//     CAP1208(8,4,0),
//     CAP1298(8,4,0),
//     CAP1105(5,3,0),
//     CAP1106(6,4,0),
//     CAP1126(6,4,2),
//     CAP1128(8,4,2),
//     CAP1133(3,3,3),
//     CAP1166(6,4,6),
//     CAP1188(8,4,8);
// 
//     final int channelCount;
//     final int maxTouch;
//     final int ledCount;
//     Configuration(int channelCount, int maxTouch, int ledCount) {
//         this.channelCount = channelCount;
//         this.maxTouch = maxTouch;
//         this.ledCount = ledCount;
//     }
// }


// Path: cap1xxx/src/main/java/com/google/android/things/contrib/driver/cap1xxx/Cap1xxxInputDriver.java
import android.content.Context;
import android.os.Handler;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
import android.view.InputDevice;
import android.view.KeyEvent;
import com.google.android.things.contrib.driver.cap1xxx.Cap1xxx.Configuration;
import com.google.android.things.userdriver.input.InputDriver;
import com.google.android.things.userdriver.UserDriverManager;
import com.google.android.things.userdriver.input.InputDriverEvent;
import java.io.IOException;

/*
 * Copyright 2016 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.things.contrib.driver.cap1xxx;




/**
 * User-space driver to process capacitive touch events from the
 * CAP1xxx family of touch controllers and forward them to the
 * Android input framework.
 */
@SuppressWarnings("WeakerAccess")
public class Cap1xxxInputDriver implements AutoCloseable {
    private static final String TAG = "Cap1xxxInputDriver";

    // Driver parameters
    private static final String DRIVER_NAME = "Cap1xxx";

    private Cap1xxx mPeripheralDevice;
    // Framework input driver
    private InputDriver mInputDriver;
    // Key codes mapped to input channels
    private int[] mKeycodes;

    /**
     * @deprecated Use {@link #Cap1xxxInputDriver(String, String, Configuration, int[])} instead.
     */
    @Deprecated
    public Cap1xxxInputDriver(Context context, String i2cName, String alertName, Configuration chip,