本文整理了Java中android.view.MotionEvent.getAxisValue()
方法的一些代码示例,展示了MotionEvent.getAxisValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MotionEvent.getAxisValue()
方法的具体详情如下:
包路径:android.view.MotionEvent
类名称:MotionEvent
方法名:getAxisValue
暂无
代码示例来源:origin: termux/termux-app
/** Overriding {@link View#onGenericMotionEvent(MotionEvent)}. */
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if (mEmulator != null && event.isFromSource(InputDevice.SOURCE_MOUSE) && event.getAction() == MotionEvent.ACTION_SCROLL) {
// Handle mouse wheel scrolling.
boolean up = event.getAxisValue(MotionEvent.AXIS_VSCROLL) > 0.0f;
doScroll(event, up ? -3 : 3);
return true;
}
return false;
}
代码示例来源:origin: libgdx/libgdx
public boolean onGenericMotion (MotionEvent event, AndroidInput input) {
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) return false;
final int action = event.getAction() & MotionEvent.ACTION_MASK;
int x = 0, y = 0;
int scrollAmount = 0;
long timeStamp = System.nanoTime();
synchronized (input) {
switch (action) {
case MotionEvent.ACTION_HOVER_MOVE:
x = (int)event.getX();
y = (int)event.getY();
if ((x != deltaX) || (y != deltaY)) { // Avoid garbage events
postTouchEvent(input, TouchEvent.TOUCH_MOVED, x, y, 0, timeStamp);
deltaX = x;
deltaY = y;
}
break;
case MotionEvent.ACTION_SCROLL:
scrollAmount = (int)-Math.signum(event.getAxisValue(MotionEvent.AXIS_VSCROLL));
postTouchEvent(input, TouchEvent.TOUCH_SCROLLED, 0, 0, scrollAmount, timeStamp);
}
}
Gdx.app.getGraphics().requestRendering();
return true;
}
代码示例来源:origin: libgdx/libgdx
public boolean onGenericMotion (MotionEvent event, AndroidInput input) {
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == 0) return false;
final int action = event.getAction() & MotionEvent.ACTION_MASK;
int x = 0, y = 0;
int scrollAmount = 0;
long timeStamp = System.nanoTime();
synchronized (input) {
switch (action) {
case MotionEvent.ACTION_HOVER_MOVE:
x = (int)event.getX();
y = (int)event.getY();
if ((x != deltaX) || (y != deltaY)) { // Avoid garbage events
postTouchEvent(input, TouchEvent.TOUCH_MOVED, x, y, 0, timeStamp);
deltaX = x;
deltaY = y;
}
break;
case MotionEvent.ACTION_SCROLL:
scrollAmount = (int)-Math.signum(event.getAxisValue(MotionEvent.AXIS_VSCROLL));
postTouchEvent(input, TouchEvent.TOUCH_SCROLLED, 0, 0, scrollAmount, timeStamp);
}
}
Gdx.app.getGraphics().requestRendering();
return true;
}
代码示例来源:origin: libgdx/libgdx
float povX = motionEvent.getAxisValue(MotionEvent.AXIS_HAT_X);
float povY = motionEvent.getAxisValue(MotionEvent.AXIS_HAT_Y);
if (Float.compare(povY, -1.0f) == 0) {
direction |= 0x00000001;
float axisValue = motionEvent.getAxisValue(axisId);
if(controller.getAxis(axisIndex) == axisValue) {
axisIndex++;
代码示例来源:origin: jMonkeyEngine/jmonkeyengine
for (int androidAxis: joystick.getAndroidAxes()) {
String axisName = MotionEvent.axisToString(androidAxis);
float value = event.getAxisValue(androidAxis);
int action = event.getAction();
if (action == MotionEvent.ACTION_MOVE) {
代码示例来源:origin: moagrius/TileView
case MotionEvent.ACTION_SCROLL: {
if (!mIsBeingDragged) {
final float vscroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
final float hscroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL);
if (vscroll != 0) {
final int verticalScrollRange = getVerticalScrollRange();
代码示例来源:origin: gearvrf/GearVRf-Demos
public static void input(MotionEvent event) {
newGamepadMap.axisX = event.getAxisValue(MotionEvent.AXIS_X);
newGamepadMap.axisY = event.getAxisValue(MotionEvent.AXIS_Y);
newGamepadMap.axisHatX = event.getAxisValue(MotionEvent.AXIS_HAT_X);
newGamepadMap.axisHatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y);
newGamepadMap.axisRX = event.getAxisValue(MotionEvent.AXIS_RX);
newGamepadMap.axisRY = event.getAxisValue(MotionEvent.AXIS_RY);
}
代码示例来源:origin: stackoverflow.com
public class Sniffer extends Activity {
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
float x = event.getAxisValue(MotionEvent.AXIS_X);
float y = event.getAxisValue(MotionEvent.AXIS_Y);
Log.i("t...OUCH: ", x + " " + y);
return super.dispatchTouchEvent(event);
}
}
代码示例来源:origin: MrWangChong/DragPhotoView
static float getAxisValue(MotionEvent event, int axis, int pointerIndex) {
return event.getAxisValue(axis, pointerIndex);
}
}
代码示例来源:origin: MrWangChong/DragPhotoView
static float getAxisValue(MotionEvent event, int axis) {
return event.getAxisValue(axis);
}
代码示例来源:origin: stackoverflow.com
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
Log.d("Right Trigger Value", event.getAxisValue(MotionEvent.AXIS_RTRIGGER) + "");
Log.d("Left Trigger Value", event.getAxisValue(MotionEvent.AXIS_LTRIGGER) + "");
Log.d("Left Stick X", event.getX() + "");
Log.d("Left Stick Y", event.getY() + "");
Log.d("Right Stick Y", event.getAxisValue(MotionEvent.AXIS_RZ) + "");
Log.d("Right Stick X", event.getAxisValue(MotionEvent.AXIS_Z) + "");
return super.onGenericMotionEvent(event);
}
代码示例来源:origin: gearvrf/GearVRf-Demos
public static void input(MotionEvent event) {
// https://github.com/Samsung/GearVRf/issues/231
newTouchPadMap.axisX = event.getAxisValue(MotionEvent.AXIS_X);
newTouchPadMap.axisY = event.getAxisValue(MotionEvent.AXIS_Y);
if (event.getAction() == KeyEvent.ACTION_DOWN) {
newTouchPadMap.buttonState.pressed = true;
}
if (event.getAction() == KeyEvent.ACTION_UP) {
newTouchPadMap.buttonState.pressed = false;
}
}
代码示例来源:origin: gearvrf/GearVRf-Demos
public static void input(MotionEvent event) {
// https://github.com/Samsung/GearVRf/issues/231
newTouchPadMap.axisX = event.getAxisValue(MotionEvent.AXIS_X);
newTouchPadMap.axisY = event.getAxisValue(MotionEvent.AXIS_Y);
if (event.getAction() == KeyEvent.ACTION_DOWN) {
newTouchPadMap.buttonState.pressed = true;
}
if (event.getAction() == KeyEvent.ACTION_UP) {
newTouchPadMap.buttonState.pressed = false;
}
}
代码示例来源:origin: ouya/ouya-sdk-examples
public static void debugOuyaMotionEvent(MotionEvent motionEvent) {
Log.i(TAG, "("+RazerController.AXIS_DPAD_X + ") OuyaController.AXIS_LS_X value="+motionEvent.getAxisValue(RazerController.AXIS_DPAD_X));
Log.i(TAG, "("+RazerController.AXIS_DPAD_Y + ") OuyaController.AXIS_LS_X value="+motionEvent.getAxisValue(RazerController.AXIS_DPAD_Y));
Log.i(TAG, "("+RazerController.AXIS_LS_X + ") OuyaController.AXIS_LS_X value="+motionEvent.getAxisValue(RazerController.AXIS_LS_X));
Log.i(TAG, "("+RazerController.AXIS_LS_Y + ") OuyaController.AXIS_LS_Y value="+motionEvent.getAxisValue(RazerController.AXIS_LS_Y));
Log.i(TAG, "("+RazerController.AXIS_RS_X + ") OuyaController.AXIS_RS_X value="+motionEvent.getAxisValue(RazerController.AXIS_RS_X));
Log.i(TAG, "("+RazerController.AXIS_RS_Y + ") OuyaController.AXIS_RS_Y value="+motionEvent.getAxisValue(RazerController.AXIS_RS_Y));
Log.i(TAG, "("+RazerController.AXIS_L2 + ") OuyaController.AXIS_L2 value="+motionEvent.getAxisValue(RazerController.AXIS_L2));
Log.i(TAG, "("+RazerController.AXIS_R2 + ") OuyaController.AXIS_R2 value="+motionEvent.getAxisValue(RazerController.AXIS_R2));
}
代码示例来源:origin: stackoverflow.com
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if (0 != (event.getSource() & InputDevice.SOURCE_CLASS_POINTER)) {
switch (event.getAction()) {
case MotionEvent.ACTION_SCROLL:
if (event.getAxisValue(MotionEvent.AXIS_VSCROLL) < 0.0f)
selectNext()
else
selectPrev();
return true;
}
}
return super.onGenericMotionEvent(event);
}
代码示例来源:origin: stackoverflow.com
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if (0 != (event.getSource() & InputDevice.SOURCE_CLASS_POINTER)) {
switch (event.getAction()) {
case MotionEvent.ACTION_SCROLL:
if (event.getAxisValue(MotionEvent.AXIS_VSCROLL) < 0.0f)
selectNext()
else
selectPrev();
return true;
}
}
return super.onGenericMotionEvent(event);
}
代码示例来源:origin: CypherpunkArmory/UserLAnd
/** Overriding {@link View#onGenericMotionEvent(MotionEvent)}. */
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
if (mEmulator != null && event.isFromSource(InputDevice.SOURCE_MOUSE) && event.getAction() == MotionEvent.ACTION_SCROLL) {
// Handle mouse wheel scrolling.
boolean up = event.getAxisValue(MotionEvent.AXIS_VSCROLL) > 0.0f;
doScroll(event, up ? -3 : 3);
return true;
}
return false;
}
代码示例来源:origin: KDE/kdeconnect-android
@Override
public boolean onGenericMotionEvent(MotionEvent e) {
if (e.getAction() == MotionEvent.ACTION_SCROLL) {
final float distanceY = e.getAxisValue(MotionEvent.AXIS_VSCROLL);
accumulatedDistanceY += distanceY;
if (accumulatedDistanceY > MinDistanceToSendGenericScroll || accumulatedDistanceY < -MinDistanceToSendGenericScroll) {
sendScroll(accumulatedDistanceY);
accumulatedDistanceY = 0;
}
}
return super.onGenericMotionEvent(e);
}
代码示例来源:origin: qiubiteme/android_api_demos
private static float getCenteredAxis(MotionEvent event, InputDevice device,
int axis, int historyPos) {
final InputDevice.MotionRange range = device.getMotionRange(axis, event.getSource());
if (range != null) {
final float flat = range.getFlat();
final float value = historyPos < 0 ? event.getAxisValue(axis)
: event.getHistoricalAxisValue(axis, historyPos);
// Ignore axis values that are within the 'flat' region of the joystick axis center.
// A joystick at rest does not always report an absolute position of (0,0).
if (Math.abs(value) > flat) {
return value;
}
}
return 0;
}
代码示例来源:origin: li2/learning-android-open-source
private static float getCenteredAxis(MotionEvent event, InputDevice device,
int axis, int historyPos) {
final InputDevice.MotionRange range = device.getMotionRange(axis, event.getSource());
if (range != null) {
final float flat = range.getFlat();
final float value = historyPos < 0 ? event.getAxisValue(axis)
: event.getHistoricalAxisValue(axis, historyPos);
// Ignore axis values that are within the 'flat' region of the joystick axis center.
// A joystick at rest does not always report an absolute position of (0,0).
if (Math.abs(value) > flat) {
return value;
}
}
return 0;
}
内容来源于网络,如有侵权,请联系作者删除!