⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wraccelerationevent.java

📁 支持任天堂wii2手柄的java中间件
💻 JAVA
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   WRAccelerationEvent.java

package wiiremotej.event;

import wiiremotej.AccelerationConstants;
import wiiremotej.WiiRemote;

// Referenced classes of package wiiremotej.event:
//			WREvent

public class WRAccelerationEvent extends WREvent
{

	private double xAcceleration;
	private double yAcceleration;
	private double zAcceleration;
	private boolean isStill;
	private double pitch;
	private double roll;

	public WRAccelerationEvent(WiiRemote wiiremote, byte abyte0[])
	{
		super(wiiremote);
		int i = ((abyte0[4] & 0xff) << 2) + ((abyte0[2] & 0x60) >> 5);
		int j = ((abyte0[5] & 0xff) << 2) + ((abyte0[3] & 0x60) >> 5);
		int k = ((abyte0[6] & 0xff) << 2) + ((abyte0[3] & 0x80) >> 6);
		initHelper(i, j, k);
	}

	public WRAccelerationEvent(WiiRemote wiiremote, byte abyte0[], byte abyte1[])
	{
		super(wiiremote);
		initHelper(interleavedXAcceleration(abyte0), interleavedYAcceleration(abyte1), interleavedZAcceleration(abyte0, abyte1));
	}

	public WRAccelerationEvent(WiiRemote wiiremote, double d, double d1, double d2)
	{
		super(wiiremote);
		xAcceleration = d;
		yAcceleration = d1;
		zAcceleration = d2;
		initImplied();
	}

	private static int interleavedXAcceleration(byte abyte0[])
	{
		return abyte0[4] << 2;
	}

	private static int interleavedYAcceleration(byte abyte0[])
	{
		return abyte0[4] << 2;
	}

	private static int interleavedZAcceleration(byte abyte0[], byte abyte1[])
	{
		int i = (abyte0[2] & 0xff00000) << 1 + ((abyte0[3] & 0xff00000) << 3);
		i += ((abyte1[2] & 0xff00000) >> 3) + ((abyte1[3] & 0xff00000) >> 1);
		return i;
	}

	private void initHelper(int i, int j, int k)
	{
		AccelerationConstants accelerationconstants = getSource().getAccelerationConstants();
		xAcceleration = ((double)i - accelerationconstants.xZero()) / accelerationconstants.xOne();
		yAcceleration = ((double)j - accelerationconstants.yZero()) / accelerationconstants.yOne();
		zAcceleration = ((double)k - accelerationconstants.zZero()) / accelerationconstants.zOne();
		initImplied();
	}

	private void initImplied()
	{
		isStill = isStill(xAcceleration, yAcceleration, zAcceleration);
		if (isStill)
		{
			if (yAcceleration > 1.0D)
				pitch = 1.5707963267948966D;
			else
			if (yAcceleration < -1D)
				pitch = -1.5707963267948966D;
			else
				pitch = Math.asin(yAcceleration);
			if (xAcceleration > 1.0D)
				roll = 1.5707963267948966D;
			else
			if (xAcceleration < -1D)
			{
				roll = -1.5707963267948966D;
			} else
			{
				roll = Math.asin(xAcceleration);
				if (zAcceleration < 0.0D)
					roll = 3.1415926535897931D - roll;
				roll = (roll + 6.2831853071795862D) % 6.2831853071795862D;
			}
		} else
		{
			pitch = (0.0D / 0.0D);
			roll = (0.0D / 0.0D);
		}
	}

	public boolean isStill()
	{
		return isStill;
	}

	private static boolean isStill(double d, double d1, double d2)
	{
		double d3 = Math.sqrt(d * d + d1 * d1 + d2 * d2);
		return d3 > 0.69999999999999996D && d3 < 1.3999999999999999D;
	}

	public double getXAcceleration()
	{
		return xAcceleration;
	}

	public double getYAcceleration()
	{
		return yAcceleration;
	}

	public double getZAcceleration()
	{
		return zAcceleration;
	}

	public double getPitch()
	{
		return pitch;
	}

	public double getRoll()
	{
		return roll;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -