xiaojiangren 2016-01-31 07:06 采纳率: 27%
浏览 1401
已采纳

求大神看下代码 这是什么意思啊

@Override
public boolean onSDKGenericMotionEvent(MotionEvent ev) {
updateConnected(ev.getDeviceId());
float ltrigger = ev.getAxisValue(MotionEvent.AXIS_LTRIGGER);
float rtrigger = ev.getAxisValue(MotionEvent.AXIS_RTRIGGER);
btnL2.setTriggerValue(ltrigger);
btnR2.setTriggerValue(rtrigger);
float x = ev.getAxisValue(MotionEvent.AXIS_X);
float y = ev.getAxisValue(MotionEvent.AXIS_Y);
float hatx = ev.getAxisValue(MotionEvent.AXIS_HAT_X);
float haty = ev.getAxisValue(MotionEvent.AXIS_HAT_Y);
float z = ev.getAxisValue(MotionEvent.AXIS_Z);
float rz = ev.getAxisValue(MotionEvent.AXIS_RZ);
joystick1.setPos(x, y);
joystick2.setPos(z, rz);
btnLeft.setTriggerValue(0);
btnRight.setTriggerValue(0);
btnUp.setTriggerValue(0);
btnDown.setTriggerValue(0);
if (hatx < 0) {
btnLeft.setTriggerValue(hatx);
} else {
btnRight.setTriggerValue(hatx);
}
if (haty < 0) {
btnUp.setTriggerValue(haty);
} else {
btnDown.setTriggerValue(haty);
}
return true;
}

joystick1 joystick2 这个是两个类似于街机的摇动方向的那个button 这代码是什么意思啊大概

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-01-31 07:11
    关注

    这个是sdk里面的运动感应传感器

    详细的参数:
    http://cs.szpt.edu.cn/android/reference/android/view/MotionEvent.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序
  • ¥15 onvif+openssl,vs2022编译openssl64
  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示