We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › JNI and ObjectiveC
Page Index Toggle Pages: 1
JNI and ObjectiveC (Read 2348 times)
JNI and ObjectiveC
May 14th, 2006, 12:31pm
 
I'm playing around with native code from within processing at the moment to try and get Pen Pressure readings from a Wacom tablet on OSX.

Here's where I'm up to:

native.pde

Code:


HelloWorld hw;

void setup() {
size(400, 400);

hw = new HelloWorld();
}


void draw() {
hw.displayHelloWorld();
}



new tab: HelloWorld.java

Code:


class HelloWorld {

public native void displayHelloWorld();

static {
System.loadLibrary("hello");
}

public static void main(String[] args) {
new HelloWorld().displayHelloWorld();
}
}




save sketch and then compile the helloworld class with:

javac HelloWorld.java

create .h file with:

javah -jni HelloWorld

Write the native method implementation in file called HelloWorldImp.c, like this:

Code:

#include <jni.h>
#include "HelloWorld.h"
#include <stdio.h>

JNIEXPORT void JNICALL
Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj) {
printf("Hello world!\n");
return;
}



and then compile using:

cc -c -I/System/Library/Frameworks/JavaVM.framework/Headers HelloWorldImp.c

followed by:

cc -dynamiclib -o libhello.jnilib HelloWorldImp.o -framework JavaVM

create a code folder and insert the jnilib into it:

libhello.jnilib


Run your sketch, and bob's your uncle: Hello World!

(based on TomC's original Alpha thread http://processing.org/discourse/yabb/YaBB.cgi?board=Tools;action=display;num=1085053494)
Re: JNI and ObjectiveC
Reply #1 - May 14th, 2006, 12:34pm
 
Question is:

It looks like pen can be got using ObjC.

Has anyone managed this from within processing using the JNI?
Any pointers, much appreciated.

I suspect it's a case of having the right headers.h
Re: JNI and ObjectiveC
Reply #2 - May 15th, 2006, 3:35pm
 
This post suggests that Pen events can be had on OSX. Does this look possible within processing?

I'm experimenting with native code a bit, but lack the expertise to make an assessment as to whether it's possible following this thread:

http://www.jhlabs.com/java/tablet/index.html
Re: JNI and ObjectiveC
Reply #3 - Nov 14th, 2006, 9:07pm
 
Hi,

We are trying to get the tablet working as well and following the same threads. Has anyone managed to get a tablet Library written? If not maybe I could find some time this month to try and develop one... it looks like we have a pretty good start. Let me know if any of you have any advice on this..

Best,
Seth
Re: JNI and ObjectiveC
Reply #4 - Nov 17th, 2006, 10:05am
 
Me no, I try different things with no results Sad
Re: JNI and ObjectiveC
Reply #5 - Mar 20th, 2008, 1:50am
 
Happy to see that Marcus finally done in Java

http://www.infostuka.org/2008/3/18/tablet-library-for-processing
Page Index Toggle Pages: 1