Import from http://drts.cvs.sourceforge.net/viewvc/drts/projects/jxinput/ tarball
This commit is contained in:
98
java/de/hardcode/jxinput/util/LatestChangedValueAxis.java
Normal file
98
java/de/hardcode/jxinput/util/LatestChangedValueAxis.java
Normal file
@@ -0,0 +1,98 @@
|
||||
//**********************************************************************************************
|
||||
// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development
|
||||
// All rights reserved. Copying, modification,
|
||||
// distribution or publication without the prior written
|
||||
// consent of the author is prohibited.
|
||||
//
|
||||
// Created on 17. April 2002, 23:24
|
||||
//**********************************************************************************************
|
||||
package de.hardcode.jxinput.util;
|
||||
|
||||
import de.hardcode.jxinput.Axis;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Herkules
|
||||
*/
|
||||
public class LatestChangedValueAxis implements Axis
|
||||
{
|
||||
private final Axis mAxis1;
|
||||
private final Axis mAxis2;
|
||||
private Axis mAxisInUse;
|
||||
|
||||
private double mSaved1;
|
||||
private double mSaved2;
|
||||
|
||||
/**
|
||||
* Creates a new instance of MeanValueAxis.
|
||||
*/
|
||||
public LatestChangedValueAxis(Axis a1, Axis a2)
|
||||
{
|
||||
mAxis1 = a1;
|
||||
mAxis2 = a2;
|
||||
mAxisInUse = a1;
|
||||
|
||||
mSaved1 = a1.getValue();
|
||||
mSaved2 = a2.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Features may have a name provided e.g. by the driver.
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return mAxis1.getName();
|
||||
}
|
||||
|
||||
/** Inform about the resolution of the axis.
|
||||
*
|
||||
* @return resolution, e.g. 2^-16
|
||||
*/
|
||||
public double getResolution()
|
||||
{
|
||||
return mAxis1.getResolution();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the type of the axis.
|
||||
*
|
||||
* @return [ TRANSLATION | ROTATION | SLIDER ]
|
||||
*/
|
||||
public int getType()
|
||||
{
|
||||
return mAxis1.getType();
|
||||
}
|
||||
|
||||
/** Returns the current value of the axis.
|
||||
* The range of the result depends on the axis type.
|
||||
*s
|
||||
* @return value [-1.0,1.0] or [0.0,1.0]
|
||||
*/
|
||||
public double getValue()
|
||||
{
|
||||
double v1 = mAxis1.getValue();
|
||||
double v2 = mAxis2.getValue();
|
||||
|
||||
if ( Math.abs( v2 - mSaved2 ) > 0.2 )
|
||||
{
|
||||
mAxisInUse = mAxis2;
|
||||
mSaved2 = v2;
|
||||
}
|
||||
if ( Math.abs( v1 - mSaved1 ) > 0.2 )
|
||||
{
|
||||
mAxisInUse = mAxis1;
|
||||
mSaved1 = v1;
|
||||
}
|
||||
|
||||
return mAxisInUse.getValue();
|
||||
}
|
||||
|
||||
/** Denote wether this feature has changed beyond it's resolution since it got last
|
||||
* updated.
|
||||
*/
|
||||
public boolean hasChanged()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
52
java/de/hardcode/jxinput/util/OrButton.java
Normal file
52
java/de/hardcode/jxinput/util/OrButton.java
Normal file
@@ -0,0 +1,52 @@
|
||||
//**********************************************************************************************
|
||||
// (C) Copyright 2002 by Dipl. Phys. Joerg Plewe, HARDCODE Development
|
||||
// All rights reserved. Copying, modification,
|
||||
// distribution or publication without the prior written
|
||||
// consent of the author is prohibited.
|
||||
//
|
||||
// Created on 23. Dezember 2002, 19:21
|
||||
//**********************************************************************************************
|
||||
package de.hardcode.jxinput.util;
|
||||
|
||||
import de.hardcode.jxinput.Button;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Herkules
|
||||
*/
|
||||
public class OrButton implements Button
|
||||
{
|
||||
private final Button mButton1;
|
||||
private final Button mButton2;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new instance of OrButton.
|
||||
*/
|
||||
public OrButton( Button b1, Button b2 )
|
||||
{
|
||||
mButton1 = b1;
|
||||
mButton2 = b2;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return mButton1.getName();
|
||||
}
|
||||
|
||||
public boolean getState()
|
||||
{
|
||||
return mButton1.getState() || mButton2.getState();
|
||||
}
|
||||
|
||||
public int getType()
|
||||
{
|
||||
return mButton1.getType();
|
||||
}
|
||||
|
||||
public boolean hasChanged()
|
||||
{
|
||||
return mButton1.hasChanged() || mButton2.hasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user