Merge "Improve support for external keyboards."
This commit is contained in:
@@ -358,16 +358,6 @@ public class InputManager {
|
||||
}
|
||||
}
|
||||
|
||||
private static final class VirtualKeyDefinition {
|
||||
public int scanCode;
|
||||
|
||||
// configured position data, specified in display coords
|
||||
public int centerX;
|
||||
public int centerY;
|
||||
public int width;
|
||||
public int height;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callbacks from native.
|
||||
*/
|
||||
@@ -437,54 +427,6 @@ public class InputManager {
|
||||
com.android.internal.R.bool.config_filterJumpyTouchEvents);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public VirtualKeyDefinition[] getVirtualKeyDefinitions(String deviceName) {
|
||||
ArrayList<VirtualKeyDefinition> keys = new ArrayList<VirtualKeyDefinition>();
|
||||
|
||||
try {
|
||||
FileInputStream fis = new FileInputStream(
|
||||
"/sys/board_properties/virtualkeys." + deviceName);
|
||||
InputStreamReader isr = new InputStreamReader(fis);
|
||||
BufferedReader br = new BufferedReader(isr, 2048);
|
||||
String str = br.readLine();
|
||||
if (str != null) {
|
||||
String[] it = str.split(":");
|
||||
if (DEBUG_VIRTUAL_KEYS) Slog.v(TAG, "***** VIRTUAL KEYS: " + it);
|
||||
final int N = it.length-6;
|
||||
for (int i=0; i<=N; i+=6) {
|
||||
if (!"0x01".equals(it[i])) {
|
||||
Slog.w(TAG, "Unknown virtual key type at elem #"
|
||||
+ i + ": " + it[i] + " for device " + deviceName);
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
VirtualKeyDefinition key = new VirtualKeyDefinition();
|
||||
key.scanCode = Integer.parseInt(it[i+1]);
|
||||
key.centerX = Integer.parseInt(it[i+2]);
|
||||
key.centerY = Integer.parseInt(it[i+3]);
|
||||
key.width = Integer.parseInt(it[i+4]);
|
||||
key.height = Integer.parseInt(it[i+5]);
|
||||
if (DEBUG_VIRTUAL_KEYS) Slog.v(TAG, "Virtual key "
|
||||
+ key.scanCode + ": center=" + key.centerX + ","
|
||||
+ key.centerY + " size=" + key.width + "x"
|
||||
+ key.height);
|
||||
keys.add(key);
|
||||
} catch (NumberFormatException e) {
|
||||
Slog.w(TAG, "Bad number in virtual key definition at region "
|
||||
+ i + " in: " + str + " for device " + deviceName, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
br.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
Slog.i(TAG, "No virtual keys found for device " + deviceName + ".");
|
||||
} catch (IOException e) {
|
||||
Slog.w(TAG, "Error reading virtual keys for device " + deviceName + ".", e);
|
||||
}
|
||||
|
||||
return keys.toArray(new VirtualKeyDefinition[keys.size()]);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String[] getExcludedDeviceNames() {
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
|
||||
@@ -56,21 +56,10 @@ static struct {
|
||||
jmethodID checkInjectEventsPermission;
|
||||
jmethodID filterTouchEvents;
|
||||
jmethodID filterJumpyTouchEvents;
|
||||
jmethodID getVirtualKeyDefinitions;
|
||||
jmethodID getExcludedDeviceNames;
|
||||
jmethodID getMaxEventsPerSecond;
|
||||
} gCallbacksClassInfo;
|
||||
|
||||
static struct {
|
||||
jclass clazz;
|
||||
|
||||
jfieldID scanCode;
|
||||
jfieldID centerX;
|
||||
jfieldID centerY;
|
||||
jfieldID width;
|
||||
jfieldID height;
|
||||
} gVirtualKeyDefinitionClassInfo;
|
||||
|
||||
static struct {
|
||||
jclass clazz;
|
||||
|
||||
@@ -176,8 +165,6 @@ public:
|
||||
int32_t* width, int32_t* height, int32_t* orientation);
|
||||
virtual bool filterTouchEvents();
|
||||
virtual bool filterJumpyTouchEvents();
|
||||
virtual void getVirtualKeyDefinitions(const String8& deviceName,
|
||||
Vector<VirtualKeyDefinition>& outVirtualKeyDefinitions);
|
||||
virtual void getExcludedDeviceNames(Vector<String8>& outExcludedDeviceNames);
|
||||
|
||||
/* --- InputDispatcherPolicyInterface implementation --- */
|
||||
@@ -442,41 +429,6 @@ bool NativeInputManager::filterJumpyTouchEvents() {
|
||||
return mFilterJumpyTouchEvents;
|
||||
}
|
||||
|
||||
void NativeInputManager::getVirtualKeyDefinitions(const String8& deviceName,
|
||||
Vector<VirtualKeyDefinition>& outVirtualKeyDefinitions) {
|
||||
outVirtualKeyDefinitions.clear();
|
||||
|
||||
JNIEnv* env = jniEnv();
|
||||
|
||||
jstring deviceNameStr = env->NewStringUTF(deviceName.string());
|
||||
if (! checkAndClearExceptionFromCallback(env, "getVirtualKeyDefinitions")) {
|
||||
jobjectArray result = jobjectArray(env->CallObjectMethod(mCallbacksObj,
|
||||
gCallbacksClassInfo.getVirtualKeyDefinitions, deviceNameStr));
|
||||
if (! checkAndClearExceptionFromCallback(env, "getVirtualKeyDefinitions") && result) {
|
||||
jsize length = env->GetArrayLength(result);
|
||||
for (jsize i = 0; i < length; i++) {
|
||||
jobject item = env->GetObjectArrayElement(result, i);
|
||||
|
||||
outVirtualKeyDefinitions.add();
|
||||
outVirtualKeyDefinitions.editTop().scanCode =
|
||||
int32_t(env->GetIntField(item, gVirtualKeyDefinitionClassInfo.scanCode));
|
||||
outVirtualKeyDefinitions.editTop().centerX =
|
||||
int32_t(env->GetIntField(item, gVirtualKeyDefinitionClassInfo.centerX));
|
||||
outVirtualKeyDefinitions.editTop().centerY =
|
||||
int32_t(env->GetIntField(item, gVirtualKeyDefinitionClassInfo.centerY));
|
||||
outVirtualKeyDefinitions.editTop().width =
|
||||
int32_t(env->GetIntField(item, gVirtualKeyDefinitionClassInfo.width));
|
||||
outVirtualKeyDefinitions.editTop().height =
|
||||
int32_t(env->GetIntField(item, gVirtualKeyDefinitionClassInfo.height));
|
||||
|
||||
env->DeleteLocalRef(item);
|
||||
}
|
||||
env->DeleteLocalRef(result);
|
||||
}
|
||||
env->DeleteLocalRef(deviceNameStr);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeInputManager::getExcludedDeviceNames(Vector<String8>& outExcludedDeviceNames) {
|
||||
outExcludedDeviceNames.clear();
|
||||
|
||||
@@ -1366,36 +1318,12 @@ int register_android_server_InputManager(JNIEnv* env) {
|
||||
GET_METHOD_ID(gCallbacksClassInfo.filterJumpyTouchEvents, gCallbacksClassInfo.clazz,
|
||||
"filterJumpyTouchEvents", "()Z");
|
||||
|
||||
GET_METHOD_ID(gCallbacksClassInfo.getVirtualKeyDefinitions, gCallbacksClassInfo.clazz,
|
||||
"getVirtualKeyDefinitions",
|
||||
"(Ljava/lang/String;)[Lcom/android/server/InputManager$VirtualKeyDefinition;");
|
||||
|
||||
GET_METHOD_ID(gCallbacksClassInfo.getExcludedDeviceNames, gCallbacksClassInfo.clazz,
|
||||
"getExcludedDeviceNames", "()[Ljava/lang/String;");
|
||||
|
||||
GET_METHOD_ID(gCallbacksClassInfo.getMaxEventsPerSecond, gCallbacksClassInfo.clazz,
|
||||
"getMaxEventsPerSecond", "()I");
|
||||
|
||||
// VirtualKeyDefinition
|
||||
|
||||
FIND_CLASS(gVirtualKeyDefinitionClassInfo.clazz,
|
||||
"com/android/server/InputManager$VirtualKeyDefinition");
|
||||
|
||||
GET_FIELD_ID(gVirtualKeyDefinitionClassInfo.scanCode, gVirtualKeyDefinitionClassInfo.clazz,
|
||||
"scanCode", "I");
|
||||
|
||||
GET_FIELD_ID(gVirtualKeyDefinitionClassInfo.centerX, gVirtualKeyDefinitionClassInfo.clazz,
|
||||
"centerX", "I");
|
||||
|
||||
GET_FIELD_ID(gVirtualKeyDefinitionClassInfo.centerY, gVirtualKeyDefinitionClassInfo.clazz,
|
||||
"centerY", "I");
|
||||
|
||||
GET_FIELD_ID(gVirtualKeyDefinitionClassInfo.width, gVirtualKeyDefinitionClassInfo.clazz,
|
||||
"width", "I");
|
||||
|
||||
GET_FIELD_ID(gVirtualKeyDefinitionClassInfo.height, gVirtualKeyDefinitionClassInfo.clazz,
|
||||
"height", "I");
|
||||
|
||||
// InputWindow
|
||||
|
||||
FIND_CLASS(gInputWindowClassInfo.clazz, "com/android/server/InputWindow");
|
||||
|
||||
Reference in New Issue
Block a user