Log in or register to post comments

Sensitivity of buttons

November 29, 2010 - 6:43am #1

Hi,
I try to change the sensitivity of virtual buttons.
ndk-build don't find any enum of SENSITIVITY.

I hape this is the right thing to do :

button->setSensitivity(LOW)

:(

Re: Sensitivity of buttons

January 4, 2011 - 8:48am #9

I had that error when I changed the name of a java package, I mean that the declaration of the native function in Java must be in the package referred in C code and vice versa.

For example in C:
Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargets_getOpenGlEsVersionNative(JNIEnv *, jobject)

That function in Java is inside the package "com.qualcomm.QCARSamples.ImageTargets" in ImageTargets.java class.

I hope this helps.

Re: Sensitivity of buttons

January 4, 2011 - 8:42am #8

It sounds like you are missing one of the shared libraries. What version of the QCAR SDK are you using, 0.9.7 or 0.10.0? In 0.10.0, the libs folders should contain both libVirtualButtons.so and libQCAR.so. First run ndk-build on the command line. Then refresh the project in Eclipse (right-click on the project in the Package Explorer and choose Refresh). Finally, when you build the project in Eclipse libQCAR.so should be added. You may need to Refresh again to see it.

- Kim

Re: Sensitivity of buttons

January 4, 2011 - 8:35am #7

Here it's what the adb command gived me :

FATAL EXCEPTION: main
java.lang.UnsatisfiedLinkError: getOpenGlEsVersionNativ

Re: Sensitivity of buttons

January 4, 2011 - 8:11am #6

First of all, you should upgrade to QCAR v0.10.0 if you haven't already. The new VirtualButton sample application should have some code that will help you.

Could you give us the log output for the crash? In Eclipse, open the DDMS perspective and look at the LogCat section. Or you can run "adb logcat" on the command line. Run your application and look for any error messages in the log.

Thanks,

- Kim

Re: Sensitivity of buttons

January 4, 2011 - 6:18am #5

Sorry for the late answer
I try the modification on the cpp and it worked.
But when I add the 2 methods in the java one, it crash the app.
Thanks for your help

Re: Sensitivity of buttons

November 30, 2010 - 6:24am #4

I agree that the sensitivity doesn't seem to be working correctly right now, let me ask around. Here is what I did to set it:

In VirtualButtons.cpp I added the following method. Note, you probably shouldn't set the sensitivity of the button each frame, so this does it once on initialization:

JNIEXPORT void JNICALL
Java_com_qualcomm_QCARSamples_VirtualButtons_VirtualButtons_onQCARInitializedNative(JNIEnv *, jobject)
{
	LOG("Java_com_qualcomm_QCARSamples_VirtualButtons_VirtualButtons_onQCARInitializedNative");
	
	const QCAR::Tracker& tracker = QCAR::Tracker::getInstance();
	
	for (int i = 0; i < tracker.getNumTrackables(); i++)
	{
		const QCAR::Trackable* trackable = tracker.getTrackable(0);
		
		assert(trackable->getType() == QCAR::Trackable::IMAGE_TARGET);
		const QCAR::ImageTarget* target =
			static_cast<const QCAR::ImageTarget*>(trackable);
		
		for (int i = 0; i < target->getNumVirtualButtons(); ++i)
		{
			const QCAR::VirtualButton* button = target->getVirtualButton(i);
			((QCAR::VirtualButton*)button)->setSensitivity(QCAR::VirtualButton::LOW);
		}
	}
}

Then, in the VirtualButtons.java class I added the following code to call our native initialization method:

/** Inherited classes may override this method to do sample specific
 * initialization after QCAR has been initialized. */
protected void onQCARInitialized()
{  
	// Call the native method:
	onQCARInitializedNative();
}

/** Native sample initialization. */
public native void onQCARInitializedNative();

This should at least compile and run, but I didn't see much change in the behavior of the virtual buttons. Let me look into it.

- Kim

Re: Sensitivity of buttons

November 30, 2010 - 2:16am #3

It doesnt work :(
It s just in the virtualbutton sample

Re: Sensitivity of buttons

November 29, 2010 - 7:30am #2

Try this:

button->setSensitivity(QCAR::VirtualButton::LOW);

- Kim

Log in or register to post comments