如何在inputreader中拦截相应的virtual key
#include <cutils/properties.h>
void TouchInputMapper::dispatchVirtualKey(nsecs_t when, uint32_t policyFlags,
int32_t keyEventAction, int32_t keyEventFlags) {
int32_t keyCode = mCurrentVirtualKey.keyCode;
int32_t scanCode = mCurrentVirtualKey.scanCode;
nsecs_t downTime = mCurrentVirtualKey.downTime;
int32_t metaState = mContext->getGlobalMetaState();
int32_t x=0;
policyFlags |= POLICY_FLAG_VIRTUAL;
NotifyKeyArgs args(when, getDeviceId(), AINPUT_SOURCE_KEYBOARD, policyFlags,
keyEventAction, keyEventFlags, keyCode, scanCode, metaState, downTime);
char value[256];
if(property_get("persist.cancel.key", value, "0")==0)//这个prperty并没有被设置,如果property被设置成home则get的返回值是4,是按照property的字符数来的
getListener()->notifyKey(&args);
if(strspn(value,"home")!=0)
{
ALOGE("matt- if(strspn0) ");
if ( keyCode!= 3)
{
ALOGE("matt- if ( keyCode!= 82) ");//keycode这个东西是从keycodes.h里得到的
getListener()->notifyKey(&args);
}
}
if(strspn(value,"back")!=0)
{
ALOGE("matt- if(strspn1) ");
if ( keyCode!= 4)
getListener()->notifyKey(&args);
}
if(strspn(value,"menu")!=0)
{
ALOGE("matt- if(strspn2) ");
if ( keyCode!= 82)
getListener()->notifyKey(&args);
}
}
#include <cutils/properties.h>
void TouchInputMapper::dispatchVirtualKey(nsecs_t when, uint32_t policyFlags,
int32_t keyEventAction, int32_t keyEventFlags) {
int32_t keyCode = mCurrentVirtualKey.keyCode;
int32_t scanCode = mCurrentVirtualKey.scanCode;
nsecs_t downTime = mCurrentVirtualKey.downTime;
int32_t metaState = mContext->getGlobalMetaState();
int32_t x=0;
policyFlags |= POLICY_FLAG_VIRTUAL;
NotifyKeyArgs args(when, getDeviceId(), AINPUT_SOURCE_KEYBOARD, policyFlags,
keyEventAction, keyEventFlags, keyCode, scanCode, metaState, downTime);
char value[256];
if(property_get("persist.cancel.key", value, "0")==0)//这个prperty并没有被设置,如果property被设置成home则get的返回值是4,是按照property的字符数来的
getListener()->notifyKey(&args);
if(strspn(value,"home")!=0)
{
ALOGE("matt- if(strspn0) ");
if ( keyCode!= 3)
{
ALOGE("matt- if ( keyCode!= 82) ");//keycode这个东西是从keycodes.h里得到的
getListener()->notifyKey(&args);
}
}
if(strspn(value,"back")!=0)
{
ALOGE("matt- if(strspn1) ");
if ( keyCode!= 4)
getListener()->notifyKey(&args);
}
if(strspn(value,"menu")!=0)
{
ALOGE("matt- if(strspn2) ");
if ( keyCode!= 82)
getListener()->notifyKey(&args);
}
}