IR问题:
mouse按键使用不了
然后排查:
1.排查上报
ir_key6{
rockchip,usercode = <0xbf00>;
rockchip,key_table =
<0xff KEY_POWER>,
<0xfe KEY_MUTE>,
<0xfd KEY_1>,
<0xfc KEY_2>,
<0xfb KEY_3>,
<0xfa KEY_4>,
<0xf9 KEY_5>,
<0xf8 KEY_6>,
<0xf7 KEY_7>,
<0xf6 KEY_8>,
<0xf5 KEY_9>,
<0xf3 KEY_0>,
<0xb5 KEY_CHANNELUP>, //pin+
<0xb4 KEY_CHANNELDOWN>, //pin-
<0xb7 KEY_VOLUMEUP>,
<0xb6 KEY_VOLUMEDOWN>,
<0x9e KEY_HOME>,
<0xec KEY_UP>,
<0xeb KEY_DOWN>,
<0xee KEY_LEFT>,
<0xed KEY_RIGHT>,
<0xef KEY_ENTER>,//KEY_ENTER>,
<0xe8 KEY_ENTER>,//KEY_ENTER>,
<0xe9 KEY_MENU>,
<0xbf KEY_SCREENLOCK>,//mouse switch pinxian
<0xf0 388>,//mouse switch xinhao
<0xea KEY_BACK>,
<0xae KEY_PLAYPAUSE>,
<0xb2 KEY_CLOSE>, //3d
<0xad KEY_STOPCD>,
<0xa9 KEY_REWIND>,
<0xa8 KEY_FASTFORWARD>,
<0xab KEY_PREVIOUSSONG>,
<0xaa KEY_NEXTSONG>;
};
可以知道<0xf0 388>,使我们这个博客的主角
//插播一下,IR就三个引脚,检查硬件接好后按动遥控器
echo 1 > /sys/module/rockchip_pwm_remotectl/parameters/code_print
可以在串口打印上看到键码值
rk3288:/ # cat proc/kmsg
<6>[ 753.280233] USERCODE=0xbf00
<6>[ 753.307258] RMC_GETDATA=ec
然后先获取到你的遥控器的CODE值和键码值
这时候硬件是好的
然后,
rk3288:/ # getevent
add device 1: /dev/input/event2
name: "rk29-keypad"
add device 2: /dev/input/event1
name: "SIGMACHIP Usb Mouse"
add device 3: /dev/input/event0
name: "ff680020.pwm"
/dev/input/event0: 0001 0067 00000001
/dev/input/event0: 0000 0000 00000000
/dev/input/event0: 0001 0067 00000000
/dev/input/event0: 0000 0000 00000000
^C
130|rk3288:/ #
130|rk3288:/ # getevent -l
add device 1: /dev/input/event2
name: "rk29-keypad"
add device 2: /dev/input/event1
name: "SIGMACHIP Usb Mouse"
add device 3: /dev/input/event0
name: "ff680020.pwm"
/dev/input/event0: EV_KEY KEY_UP DOWN
/dev/input/event0: EV_SYN SYN_REPORT 00000000
/dev/input/event0: EV_KEY KEY_UP UP
/dev/input/event0: EV_SYN SYN_REPORT 00000000
"ff680020.pwm"这个是映射表
#$_FOR_ROCKCHIP_RBOX_$
#$_rbox_$_modify_$_chenzhi_20120220: add for IR remote
key 28 ENTER
key 116 POWER
key 158 BACK
key 139 MENU
key 217 SEARCH
key 232 DPAD_CENTER
key 108 DPAD_DOWN
key 103 DPAD_UP
key 102 HOME
key 105 DPAD_LEFT
key 106 DPAD_RIGHT
key 115 VOLUME_UP
key 114 VOLUME_DOWN
key 143 NOTIFICATION
key 113 VOLUME_MUTE
key 388 TV_KEYMOUSE_MODE_SWITCH
key 164 MEDIA_PLAY_PAUSE
key 141 SETTINGS
key 2 1
key 3 2
key 4 3
key 5 4
key 6 5
key 7 6
key 8 7
key 9 8
key 10 9
key 11 0
key 14 DEL
key 407 MEDIA_NEXT
key 412 MEDIA_PREVIOUS
#key 400 TV_MEDIA_MULT_BACKWARD
#key 401 TV_MEDIA_MULT_FORWARD
#key 402 TV_MEDIA_PLAY_PAUSE
#key 64 TV_MEDIA_PLAY
#key 65 TV_MEDIA_PAUSE
#key 66 TV_MEDIA_STOP
#key 67 TV_MEDIA_REWIND
#key 68 TV_MEDIA_FAST_FORWARD
#key 87 TV_MEDIA_PREVIOUS
#key 88 TV_MEDIA_NEXT
key 388 TV_KEYMOUSE_MODE_SWITCH
就是驱动映射到android的键值
rk3288-8.1/sdk$ grep -rnH "AKEYCODE_TV_KEYMOUSE_MODE_SWITCH" ./frameworks/
./frameworks/native/include/android/keycodes.h:777: AKEYCODE_TV_KEYMOUSE_MODE_SWITCH = 289
./frameworks/native/services/inputflinger/InputReader.cpp:2478: if (keyCode == AKEYCODE_TV_KEYMOUSE_MODE_SWITCH) {
android会再把TV_KEYMOUSE_MODE_SWITCH映射成AKEYCODE_TV_KEYMOUSE_MODE_SWITCH=289
然后我发现遥控按键并没有反应
然后查阅资料发现这一段是关于遥控鼠标和遥控按键
查询log
374 446 D WindowManager: interceptKeyTq keycode=0 interactive=true keyguardActive=false policyFlags=22000000
发现这个按键的keycode=0
问题已经找到了,哪里回事导致=0呢
然后追查到
03-02 10:16:19.061 370 443 D InputReader: BatchSize: 2 Count: 2
03-02 10:16:19.061 370 443 D InputReader: Input event: device=3 type=0x0001 code=0x0184 value=0x00000000 when=189219995000
03-02 10:16:19.061 370 443 I InputReader: KeyboardInputMapper::processKey key= keyCode=0
03-02 10:16:19.061 370 443 I InputReader: InputDevice::process key= keyCode=388
03-02 10:16:19.062 370 443 D InputReader: Input event: device=3 type=0x0000 code=0x0000 value=0x00000000 when=189219995000
03-02 10:16:19.062 370 443 I InputReader: InputDevice::process key= keyCode=0
经过排查发现
这里上报的code=0x0184不就是我们的键值388吗?
然后我发现这里都上报到了,但是到
到这里就变成keycode=0了,我强行吧keycode拉到289发现功能正常,果然就是这中间丢失了keycode导致的,于是我在上面设置一个变量让num作为标志位,388上报的时候让num=1;
然后keycode=0的时候判断一下是不是388的上报,如果num==1,则手动keycode=289;强行到按键值后发现功能正常;
Index: InputReader.cpp
===================================================================
--- InputReader.cpp (revision 101)
+++ InputReader.cpp (working copy)
@@ -89,7 +89,8 @@
static const int KEYCODE_ENTER = 28;
static const int KEYCODE_DPAD_CENTER = 232;
-
+static const int KEYCODE_KEYMOUSE_MODE_SWITCH = 289;
+static int num=0;
// --- Static Functions ---
template<typename T>
@@ -1208,6 +1209,10 @@
ALOGD("Input event: device=%d type=0x%04x code=0x%04x value=0x%08x when=%lld",
rawEvent->deviceId, rawEvent->type, rawEvent->code, rawEvent->value,
rawEvent->when);
+ if(rawEvent->code==0x0184)
+ {
+ num=1;
+ }
#endif
if (mDropUntilNextSync) {
@@ -2448,7 +2453,7 @@
uint32_t policyFlags;
if (getEventHub()->mapKey(getDeviceId(), scanCode, usageCode, mMetaState,
- &keyCode, &keyMetaState, &policyFlags)) {
+ &keyCode, &keyMetaState, &policyFlags)) {
keyCode = AKEYCODE_UNKNOWN;
keyMetaState = mMetaState;
policyFlags = 0;
@@ -2463,6 +2468,12 @@
sprintf(mID,"%d",getDeviceId());
property_set("sys.ID.mID",mID);
+ if(keyCode==0&&num==1)
+ {
+ num=0;
+ keyCode=289;
+ }
+
if (down) {
if (keyCode == AKEYCODE_TV_KEYMOUSE_MODE_SWITCH) {
if (strcmp(mKeyMouseState, "on")==0) {
@@ -3760,28 +3771,8 @@
newViewport.setNonDisplayViewport(rawWidth, rawHeight);
}
bool viewportChanged = mViewport != newViewport;
- char value_private[PROP_VALUE_MAX];
if (viewportChanged) {
mViewport = newViewport;
- property_get("persist.sys.displayrot", value_private, "0");
- int cmpRet = atoi(value_private);
- ALOGD("tp persist.sys.displayrot~~~~~~~~~~~~~~~~~~~~~~~~~ = %d",cmpRet);
- if (cmpRet == 0)
- {
- mViewport.orientation = DISPLAY_ORIENTATION_0;
- }
- else if(cmpRet == 90)
- {
- mViewport.orientation = DISPLAY_ORIENTATION_90;
- }
- else if(cmpRet == 180)
- {
- mViewport.orientation = DISPLAY_ORIENTATION_180;
- }
- else if(cmpRet == 270)
- {
- mViewport.orientation = DISPLAY_ORIENTATION_270;
- }
if (mDeviceMode == DEVICE_MODE_DIRECT || mDeviceMode == DEVICE_MODE_POINTER) {
// Convert rotated viewport to natural surface coordinates.
@@ -6380,6 +6371,8 @@
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_X, x);
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y);
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
+ mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, deltaX);
+ mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, deltaY);
} else if (currentFingerCount == 0) {
// Case 3. No fingers down and button is not pressed. (NEUTRAL)
if (mPointerGesture.lastGestureMode != PointerGesture::NEUTRAL) {
@@ -6538,6 +6531,10 @@
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y, y);
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE,
down ? 1.0f : 0.0f);
+ mPointerGesture.currentGestureCoords[0].setAxisValue(
+ AMOTION_EVENT_AXIS_RELATIVE_X, deltaX);
+ mPointerGesture.currentGestureCoords[0].setAxisValue(
+ AMOTION_EVENT_AXIS_RELATIVE_Y, deltaY);
if (lastFingerCount == 0 && currentFingerCount != 0) {
mPointerGesture.resetTap();
@@ -6784,6 +6781,10 @@
mPointerGesture.referenceGestureX);
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_Y,
mPointerGesture.referenceGestureY);
+ mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X,
+ commonDeltaX);
+ mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y,
+ commonDeltaY);
mPointerGesture.currentGestureCoords[0].setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
} else if (mPointerGesture.currentGestureMode == PointerGesture::FREEFORM) {
// FREEFORM mode.
@@ -6880,6 +6881,10 @@
AMOTION_EVENT_AXIS_Y, mPointerGesture.referenceGestureY + deltaY);
mPointerGesture.currentGestureCoords[i].setAxisValue(
AMOTION_EVENT_AXIS_PRESSURE, 1.0f);
+ mPointerGesture.currentGestureCoords[i].setAxisValue(
+ AMOTION_EVENT_AXIS_RELATIVE_X, deltaX);
+ mPointerGesture.currentGestureCoords[i].setAxisValue(
+ AMOTION_EVENT_AXIS_RELATIVE_Y, deltaY);
}
if (mPointerGesture.activeGestureId < 0) {
@@ -7002,6 +7007,8 @@
mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y);
mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE,
hovering ? 0.0f : 1.0f);
+ mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_X, x);
+ mPointerSimple.currentCoords.setAxisValue(AMOTION_EVENT_AXIS_RELATIVE_Y, y);
mPointerSimple.currentProperties.id = 0;
mPointerSimple.currentProperties.toolType =
mCurrentCookedState.cookedPointerData.pointerProperties[currentIndex].toolType;
大概补丁就这样,仅供参考!