Rework java structure
This commit is contained in:
parent
e2eef30159
commit
1022f2d86a
@ -1,26 +1,26 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol __PROJECT_NAME__.java
|
||||
* @brief Java __PROJECT_NAME__ code.
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
*******************************************************************************
|
||||
* @file ewol __PROJECT_NAME__.java
|
||||
* @brief Java __PROJECT_NAME__ code.
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
package __PROJECT_ORG_TYPE__.__PROJECT_VENDOR__.__PROJECT_PACKAGE__;
|
||||
@ -54,185 +54,182 @@ import android.content.res.AssetFileDescriptor;
|
||||
import android.content.res.AssetManager;
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
// inport the ewol package :
|
||||
import org.ewol.interfaceJNI;
|
||||
import org.ewol.interfaceSurfaceView;
|
||||
import org.ewol.interfaceAudio;
|
||||
// import the ewol package :
|
||||
import org.ewol.Ewol;
|
||||
import org.ewol.EwolSurfaceViewGL;
|
||||
import org.ewol.EwolAudioTask;
|
||||
import org.ewol.EwolCallback;
|
||||
import org.ewol.EwolConstants;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.ewol.Ewol.EWOL;
|
||||
|
||||
/**
|
||||
* @brief Class :
|
||||
*
|
||||
*/
|
||||
public class __PROJECT_NAME__ extends Activity {
|
||||
public class __PROJECT_NAME__ extends Activity implements EwolCallback, EwolConstants{
|
||||
|
||||
private static native void ActivitySetJavaVortualMachineStart(__PROJECT_NAME__ ActivityInstance);
|
||||
private static native void ActivitySetJavaVortualMachineStop();
|
||||
private static native void ActivityParamSetArchiveDir(int mode, String myString);
|
||||
private EwolSurfaceViewGL mGLView;
|
||||
private EwolAudioTask mStreams;
|
||||
private Thread mAudioThread;
|
||||
|
||||
private interfaceSurfaceView mGLView;
|
||||
private interfaceAudio mStreams;
|
||||
private Thread mAudioThread;
|
||||
static {
|
||||
System.loadLibrary("__PROJECT_NAME__");
|
||||
}
|
||||
|
||||
static {
|
||||
System.loadLibrary("__PROJECT_NAME__");
|
||||
@Override protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// set the java evironement in the C sources :
|
||||
Ewol.setJavaVirtualMachineStart(this);
|
||||
|
||||
// Load the application directory
|
||||
Ewol.paramSetArchiveDir(1, getFilesDir().toString());
|
||||
Ewol.paramSetArchiveDir(2, getCacheDir().toString());
|
||||
// to enable extarnal storage: add in the manifest the restriction needed ...
|
||||
//packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED;
|
||||
//Ewol.paramSetArchiveDir(3, getExternalCacheDir().toString());
|
||||
|
||||
// return apk file path (or null on error)
|
||||
String apkFilePath = null;
|
||||
ApplicationInfo appInfo = null;
|
||||
PackageManager packMgmr = getPackageManager();
|
||||
try {
|
||||
appInfo = packMgmr.getApplicationInfo("__PROJECT_ORG_TYPE__.__PROJECT_VENDOR__.__PROJECT_PACKAGE__", 0);
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Unable to locate assets, aborting...");
|
||||
}
|
||||
apkFilePath = appInfo.sourceDir;
|
||||
Ewol.paramSetArchiveDir(0, apkFilePath);
|
||||
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
EWOL.displayPropertyMetrics(metrics.xdpi, metrics.ydpi);
|
||||
|
||||
@Override protected void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
// call C init ...
|
||||
EWOL.onCreate();
|
||||
|
||||
// set the java evironement in the C sources :
|
||||
ActivitySetJavaVortualMachineStart(this);
|
||||
// Remove the title of the current display :
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
// set full screen Mode :
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
// display keyboard:
|
||||
//getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||
// hide keyboard :
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
|
||||
// Load the application directory
|
||||
ActivityParamSetArchiveDir(1, getFilesDir().toString());
|
||||
ActivityParamSetArchiveDir(2, getCacheDir().toString());
|
||||
// to enable extarnal storage: add in the manifest the restriction needed ...
|
||||
//packageManager.checkPermission("android.permission.READ_SMS", myPackage) == PERMISSION_GRANTED;
|
||||
//ActivityParamSetArchiveDir(3, getExternalCacheDir().toString());
|
||||
// create bsurface system
|
||||
mGLView = new EwolSurfaceViewGL(this, __CONF_OGL_ES_V__);
|
||||
|
||||
// return apk file path (or null on error)
|
||||
String apkFilePath = null;
|
||||
ApplicationInfo appInfo = null;
|
||||
PackageManager packMgmr = getPackageManager();
|
||||
try {
|
||||
appInfo = packMgmr.getApplicationInfo("__PROJECT_ORG_TYPE__.__PROJECT_VENDOR__.__PROJECT_PACKAGE__", 0);
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Unable to locate assets, aborting...");
|
||||
}
|
||||
apkFilePath = appInfo.sourceDir;
|
||||
ActivityParamSetArchiveDir(0, apkFilePath);
|
||||
// create element audio ...
|
||||
mStreams = new EwolAudioTask();
|
||||
|
||||
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
interfaceJNI.DisplayPropertyMetrics(metrics.xdpi, metrics.ydpi);
|
||||
|
||||
// call C init ...
|
||||
interfaceJNI.ActivityOnCreate();
|
||||
|
||||
// Remove the title of the current display :
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
// set full screen Mode :
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
// display keyboard:
|
||||
//getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
|
||||
// hide keyboard :
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
|
||||
|
||||
// create bsurface system
|
||||
mGLView = new interfaceSurfaceView(this, __CONF_OGL_ES_V__);
|
||||
|
||||
// create element audio ...
|
||||
mStreams = new interfaceAudio();
|
||||
|
||||
setContentView(mGLView);
|
||||
}
|
||||
setContentView(mGLView);
|
||||
}
|
||||
|
||||
@Override protected void onStart()
|
||||
{
|
||||
super.onStart();
|
||||
// call C
|
||||
interfaceJNI.ActivityOnStart();
|
||||
}
|
||||
@Override protected void onStart()
|
||||
{
|
||||
super.onStart();
|
||||
// call C
|
||||
EWOL.onStart();
|
||||
}
|
||||
|
||||
@Override protected void onRestart()
|
||||
{
|
||||
super.onRestart();
|
||||
// call C
|
||||
interfaceJNI.ActivityOnReStart();
|
||||
}
|
||||
@Override protected void onRestart()
|
||||
{
|
||||
super.onRestart();
|
||||
// call C
|
||||
EWOL.onReStart();
|
||||
}
|
||||
|
||||
@Override protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
mGLView.onResume();
|
||||
mAudioThread = new Thread(mStreams);
|
||||
if (mAudioThread != null) {
|
||||
mAudioThread.start();
|
||||
}
|
||||
// call C
|
||||
interfaceJNI.ActivityOnResume();
|
||||
@Override protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
mGLView.onResume();
|
||||
mAudioThread = new Thread(mStreams);
|
||||
if (mAudioThread != null) {
|
||||
mAudioThread.start();
|
||||
}
|
||||
// call C
|
||||
EWOL.onResume();
|
||||
}
|
||||
|
||||
@Override protected void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
mGLView.onPause();
|
||||
if (mAudioThread != null) {
|
||||
// request audio stop
|
||||
mStreams.AutoStop();
|
||||
// wait the thread ended ...
|
||||
try {
|
||||
mAudioThread.join();
|
||||
} catch(InterruptedException e) { }
|
||||
}
|
||||
// call C
|
||||
interfaceJNI.ActivityOnPause();
|
||||
@Override protected void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
mGLView.onPause();
|
||||
if (mAudioThread != null) {
|
||||
// request audio stop
|
||||
mStreams.AutoStop();
|
||||
// wait the thread ended ...
|
||||
try {
|
||||
mAudioThread.join();
|
||||
} catch(InterruptedException e) { }
|
||||
}
|
||||
// call C
|
||||
EWOL.onPause();
|
||||
}
|
||||
|
||||
@Override protected void onStop()
|
||||
{
|
||||
super.onStop();
|
||||
// call C
|
||||
interfaceJNI.ActivityOnStop();
|
||||
}
|
||||
@Override protected void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
// call C
|
||||
interfaceJNI.ActivityOnDestroy();
|
||||
// Remove the java Virtual machine pointer form the C code
|
||||
ActivitySetJavaVortualMachineStop();
|
||||
}
|
||||
@Override protected void onStop()
|
||||
{
|
||||
super.onStop();
|
||||
// call C
|
||||
EWOL.onStop();
|
||||
}
|
||||
@Override protected void onDestroy()
|
||||
{
|
||||
super.onDestroy();
|
||||
// call C
|
||||
EWOL.onDestroy();
|
||||
// Remove the java Virtual machine pointer form the C code
|
||||
Ewol.setJavaVirtualMachineStop();
|
||||
}
|
||||
|
||||
@Override protected void finalize() throws Throwable
|
||||
{
|
||||
super.finalize();
|
||||
// cleanup your object here
|
||||
}
|
||||
@Override protected void finalize() throws Throwable
|
||||
{
|
||||
super.finalize();
|
||||
// cleanup your object here
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig)
|
||||
{
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
public void onConfigurationChanged(Configuration newConfig)
|
||||
{
|
||||
super.onConfigurationChanged(newConfig);
|
||||
}
|
||||
|
||||
public void CPP_keyboardShow()
|
||||
{
|
||||
//interfaceJNI.TouchEvent();
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
|
||||
@Override public void keyboardUpdate(boolean show)
|
||||
{
|
||||
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if(show) {
|
||||
//EWOL.touchEvent();
|
||||
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED,0);
|
||||
} else {
|
||||
imm.toggleSoftInput(0 ,InputMethodManager.HIDE_IMPLICIT_ONLY + InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
//imm.hideSoftInputFromWindow(view.getWindowToken(),0);
|
||||
}
|
||||
}
|
||||
|
||||
public void CPP_keyboardHide()
|
||||
{
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.toggleSoftInput(0 ,InputMethodManager.HIDE_IMPLICIT_ONLY + InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
//imm.hideSoftInputFromWindow(view.getWindowToken(),0);
|
||||
}
|
||||
@Override public static void eventNotifier(String[] args)
|
||||
{
|
||||
// just for the test ...
|
||||
EWOL.touchEvent();
|
||||
}
|
||||
|
||||
public static void eventFromCPP(String[] args)
|
||||
{
|
||||
// just for the test ...
|
||||
interfaceJNI.TouchEvent();
|
||||
}
|
||||
|
||||
public void CPP_OrientationChange(int screenMode)
|
||||
{
|
||||
if (screenMode == 1) {
|
||||
//Force landscape
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
} else if (screenMode == 2) {
|
||||
//Force portrait
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
} else {
|
||||
//Force auto Rotation
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||
}
|
||||
public void orientationUpdate(int screenMode)
|
||||
{
|
||||
if (screenMode == EWOL_ORIENTATION_LANDSCAPE) {
|
||||
//Force landscape
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
} else if (screenMode == EWOL_ORIENTATION_PORTRAIT) {
|
||||
//Force portrait
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
} else {
|
||||
//Force auto Rotation
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
8
sources/android/README.txt
Normal file
8
sources/android/README.txt
Normal file
@ -0,0 +1,8 @@
|
||||
- A l'aide de JAVAH générer le code JNI des classes org.ewol.Ewol et org.ewol.EwolConstants
|
||||
- Le fichier JAVA PROJECT_NAME.java n'est plus à référencer dans le code JNI.
|
||||
- Le fichier JNI peut s'appeler gui.Android.cpp et non gui.Android.base.cpp
|
||||
|
||||
|
||||
/!\ Cette version des classes JAVA necessite un rework du code JNI.
|
||||
|
||||
|
80
sources/android/src/org/ewol/Ewol.java
Normal file
80
sources/android/src/org/ewol/Ewol.java
Normal file
@ -0,0 +1,80 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol NativeInterface.java
|
||||
* @brief Java interface to the CPP code.
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package org.ewol;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
public class Ewol {
|
||||
public static final Ewol EWOL = getInstance();
|
||||
private static Ewol instance = null;
|
||||
|
||||
/* Default constructor (why not ?)*/
|
||||
private Ewol() {}
|
||||
/* Use singleton */
|
||||
public static Ewol getInstance() {
|
||||
if(instance == null)
|
||||
instance = new Ewol();
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static native void setJavaVirtualMachineStart(Activity activityInstance);
|
||||
public static native void setJavaVirtualMachineStop();
|
||||
public static native void paramSetArchiveDir(int mode, String myString);
|
||||
|
||||
|
||||
public native void touchEvent();
|
||||
// activity status
|
||||
public native void onCreate();
|
||||
public native void onStart();
|
||||
public native void onReStart();
|
||||
public native void onResume();
|
||||
public native void onPause();
|
||||
public native void onStop();
|
||||
public native void onDestroy();
|
||||
// set display properties :
|
||||
public native void displayPropertyMetrics(float ratioX, float ratioY);
|
||||
// IO native function :
|
||||
// Specific for the type of input : TOOL_TYPE_FINGER and TOOL_TYPE_STYLUS (work as the same)
|
||||
public native void inputEventMotion(int pointerID, float x, float y);
|
||||
public native void inputEventState(int pointerID, boolean isDown, float x, float y);
|
||||
// Specific for the type of input : TOOL_TYPE_MOUSE
|
||||
public native void mouseEventMotion(int pointerID, float x, float y);
|
||||
public native void mouseEventState(int pointerID, boolean isDown, float x, float y);
|
||||
// other unknow event ...
|
||||
public native void unknowEvent(int eventID);
|
||||
|
||||
public native void keyboardEventMove(int type, boolean isDown);
|
||||
public native void keyboardEventKey(int uniChar, boolean isDown);
|
||||
|
||||
// Audio section ...
|
||||
public native void audioPlayback(short[] bufferData, int frames, int nbChannels);
|
||||
|
||||
public native void keyboardEventKeySystem(int keyVal, boolean isDown);
|
||||
// renderer Event :
|
||||
public native void renderInit();
|
||||
public native void renderResize(int w, int h);
|
||||
public native void renderDraw();
|
||||
}
|
||||
|
100
sources/android/src/org/ewol/EwolAudioTask.java
Normal file
100
sources/android/src/org/ewol/EwolAudioTask.java
Normal file
@ -0,0 +1,100 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol EwolAudioTask.java
|
||||
* @brief Java Audio interface code.
|
||||
* @author Edouard DUPIN
|
||||
* @date 29/06/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package org.ewol;
|
||||
|
||||
import android.media.AudioTrack;
|
||||
import android.media.AudioFormat;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioRecord;
|
||||
|
||||
// import the ewol package :
|
||||
/* no need in same package... */
|
||||
//import org.ewol.NativeInterface;
|
||||
|
||||
import static org.ewol.Ewol.EWOL;
|
||||
|
||||
|
||||
public class EwolAudioTask implements Runnable, EwolConstants
|
||||
{
|
||||
public static final int SAMPLE_FREQ_44100 = 44100;
|
||||
private boolean m_stopAudioThreads = false;
|
||||
private AudioTrack m_musicTrack = null;
|
||||
|
||||
// constructor :
|
||||
public AudioTask()
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
if(m_musicTrack != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int sampleFreq = SAMPLE_FREQ_44100; //AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
|
||||
int channelConfig = AudioFormat.CHANNEL_CONFIGURATION_STEREO;
|
||||
int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
||||
int nbChannels = 2;
|
||||
// we keep the minimum buffer size, otherwite the delay is too big ...
|
||||
int bufferSize = AudioTrack.getMinBufferSize(sampleFreq, channelConfig, audioFormat);
|
||||
// Create a streaming AudioTrack for music playback
|
||||
short[] streamBuffer = new short[bufferSize];
|
||||
m_musicTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
|
||||
SAMPLE_FREQ_44100,
|
||||
AudioFormat.CHANNEL_CONFIGURATION_STEREO,
|
||||
AudioFormat.ENCODING_PCM_16BIT,
|
||||
bufferSize,
|
||||
AudioTrack.MODE_STREAM);
|
||||
m_musicTrack.play();
|
||||
//m_musicTrack.setPositionNotificationPeriod(2048);
|
||||
|
||||
while (!m_stopAudioThreads) {
|
||||
// Fill buffer with PCM data from C++
|
||||
EWOL.audioPlayback(streamBuffer, NATIVE_AUDIO_BUFFER_SIZE, nbChannels);
|
||||
|
||||
// Stream PCM data into the music AudioTrack
|
||||
m_musicTrack.write(streamBuffer, 0, NATIVE_AUDIO_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
m_musicTrack.flush();
|
||||
m_musicTrack.stop();
|
||||
}
|
||||
public void Pause()
|
||||
{
|
||||
if(m_musicTrack == null) return;
|
||||
m_musicTrack.pause();
|
||||
}
|
||||
public void Resume()
|
||||
{
|
||||
if(m_musicTrack == null) return;
|
||||
m_musicTrack.play();
|
||||
}
|
||||
public void AutoStop()
|
||||
{
|
||||
if(m_musicTrack == null) return;
|
||||
m_stopAudioThreads=true;
|
||||
}
|
||||
}/* no ; here !!! */
|
33
sources/android/src/org/ewol/EwolCallback.java
Normal file
33
sources/android/src/org/ewol/EwolCallback.java
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol EwolCallback.java
|
||||
* @brief CPP callback.
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package org.ewol;
|
||||
|
||||
public interface NativeCallback {
|
||||
|
||||
public void keyboardUpdate(boolean show);
|
||||
public void eventNotifier(String[] args);
|
||||
public void orientationUpdate(int screenMode);
|
||||
|
||||
}
|
46
sources/android/src/org/ewol/EwolConstants.java
Normal file
46
sources/android/src/org/ewol/EwolConstants.java
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol EwolConstants.java
|
||||
* @brief Java Contants interface.
|
||||
* @author Edouard DUPIN
|
||||
* @date 29/06/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package org.ewol;
|
||||
|
||||
|
||||
|
||||
public interface EwolConstants {
|
||||
public static final int SDK_VERSION = android.os.Build.VERSION.SDK_INT;
|
||||
public static final int NATIVE_AUDIO_BUFFER_SIZE = 512;
|
||||
public static final int EWOL_SYSTEM_KEY_VOLUME_UP = 1;
|
||||
public static final int EWOL_SYSTEM_KEY_VOLUME_DOWN = 2;
|
||||
public static final int EWOL_SYSTEM_KEY_MENU = 3;
|
||||
public static final int EWOL_SYSTEM_KEY_CAMERA = 4;
|
||||
public static final int EWOL_SYSTEM_KEY_HOME = 5;
|
||||
public static final int EWOL_SYSTEM_KEY_POWER = 6;
|
||||
// the back key is wrapped in the <esc> key to simplify PC validation ...
|
||||
public static final int EWOL_SYSTEM_KEY_BACK = 0x1B;
|
||||
public static final int EWOL_SYSTEM_KEY_DEL = 0x08;
|
||||
|
||||
public static final int EWOL_ORIENTATION_AUTO = 0;
|
||||
public static final int EWOL_ORIENTATION_LANDSCAPE = 1;
|
||||
public static final int EWOL_ORIENTATION_PORTRAIT = 2;
|
||||
|
||||
}
|
56
sources/android/src/org/ewol/EwolRendererGL.java
Normal file
56
sources/android/src/org/ewol/EwolRendererGL.java
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol EwolRendererGL.java
|
||||
* @brief Java openGl interface code.
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package org.ewol;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLSurfaceView;
|
||||
|
||||
// import the ewol package :
|
||||
/* no need in same package... */
|
||||
//import org.ewol.Ewol;
|
||||
|
||||
import static org.ewol.Ewol.EWOL;
|
||||
|
||||
/**
|
||||
* @brief Class :
|
||||
*
|
||||
*/
|
||||
public class EwolRendererGL implements GLSurfaceView.Renderer {
|
||||
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
|
||||
EWOL.renderInit();
|
||||
}
|
||||
|
||||
public void onSurfaceChanged(GL10 gl, int w, int h) {
|
||||
EWOL.renderResize(w, h);
|
||||
}
|
||||
|
||||
public void onDrawFrame(GL10 gl) {
|
||||
EWOL.renderDraw();
|
||||
}
|
||||
}
|
316
sources/android/src/org/ewol/EwolSurfaceViewGL.java
Normal file
316
sources/android/src/org/ewol/EwolSurfaceViewGL.java
Normal file
@ -0,0 +1,316 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol EwolSurfaceViewGL.java
|
||||
* @brief Java interface of the java Surface viewer code.
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package org.ewol;
|
||||
|
||||
// import the ewol package :
|
||||
/* No need in same package... */
|
||||
//import org.ewol.Ewol;
|
||||
//import org.ewol.EwolRendererGL;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import static org.ewol.Ewol.EWOL;
|
||||
|
||||
/**
|
||||
* @brief Class :
|
||||
*
|
||||
*/
|
||||
public class EwolSurfaceViewGL extends GLSurfaceView implements EwolConstants {
|
||||
private EwolRendererGL m_ewolDrawer = null;
|
||||
private boolean inputDown1 = false;
|
||||
private boolean inputDown2 = false;
|
||||
private boolean inputDown3 = false;
|
||||
|
||||
public EwolSurfaceViewGL(Context context, int openGlVersion) {
|
||||
// super must be first statement in constructor
|
||||
super(context);
|
||||
/*
|
||||
List of the Android API :
|
||||
Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights
|
||||
Android 4.0.3, 4.0.4 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights
|
||||
Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH
|
||||
Android 3.2 13 HONEYCOMB_MR2
|
||||
Android 3.1.x 12 HONEYCOMB_MR1 Platform Highlights
|
||||
Android 3.0.x 11 HONEYCOMB Platform Highlights
|
||||
Android 2.3.4
|
||||
Android 2.3.3 10 GINGERBREAD_MR1 Platform Highlights
|
||||
Android 2.3.2
|
||||
Android 2.3.1
|
||||
Android 2.3 9 GINGERBREAD
|
||||
Android 2.2.x 8 FROYO Platform Highlights
|
||||
Android 2.1.x 7 ECLAIR_MR1 Platform Highlights
|
||||
Android 2.0.1 6 ECLAIR_0_1
|
||||
Android 2.0 5 ECLAIR
|
||||
Android 1.6 4 DONUT Platform Highlights
|
||||
Android 1.5 3 CUPCAKE Platform Highlights
|
||||
Android 1.1 2 BASE_1_1
|
||||
Android 1.0 1 BASE
|
||||
*/
|
||||
// Create an OpenGL ES 2.0 context
|
||||
if (openGlVersion == 2) {
|
||||
setEGLContextClientVersion(2);
|
||||
}
|
||||
|
||||
// je n'ai pas compris ...
|
||||
m_ewolDrawer = new EwolRendererGL();
|
||||
setRenderer(m_ewolDrawer);
|
||||
|
||||
// Can get the focus ==> get keyboard from JAVA :
|
||||
setFocusable(true);
|
||||
setFocusableInTouchMode(true);
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(final MotionEvent event) {
|
||||
// Wrapper on input events :
|
||||
|
||||
int tmpActionType = event.getAction();
|
||||
|
||||
if (tmpActionType == MotionEvent.ACTION_MOVE) {
|
||||
final int pointerCount = event.getPointerCount();
|
||||
for (int p = 0; p < pointerCount; p++) {
|
||||
if (SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(p);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
EWOL.inputEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
EWOL.mouseEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p));
|
||||
}
|
||||
} else {
|
||||
EWOL.inputEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p));
|
||||
}
|
||||
}
|
||||
} else if( tmpActionType == MotionEvent.ACTION_POINTER_1_DOWN
|
||||
|| tmpActionType == MotionEvent.ACTION_DOWN) {
|
||||
if (SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(0);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
EWOL.inputEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
EWOL.mouseEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
} else {
|
||||
EWOL.inputEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
inputDown1 = true;
|
||||
} else if(tmpActionType == MotionEvent.ACTION_POINTER_1_UP) {
|
||||
if (SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(0);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
} else {
|
||||
EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
inputDown1 = false;
|
||||
} else if (tmpActionType == MotionEvent.ACTION_POINTER_2_DOWN) {
|
||||
if (SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(1);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
EWOL.inputEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
EWOL.mouseEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1));
|
||||
}
|
||||
} else {
|
||||
EWOL.inputEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1));
|
||||
}
|
||||
inputDown2 = true;
|
||||
} else if (tmpActionType == MotionEvent.ACTION_POINTER_2_UP) {
|
||||
if (SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(1);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
EWOL.inputEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
EWOL.mouseEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1));
|
||||
}
|
||||
} else {
|
||||
EWOL.inputEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1));
|
||||
}
|
||||
inputDown2 = false;
|
||||
} else if (tmpActionType == MotionEvent.ACTION_POINTER_3_DOWN) {
|
||||
if (SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(2);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
EWOL.inputEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
EWOL.mouseEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2));
|
||||
}
|
||||
} else {
|
||||
EWOL.inputEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2));
|
||||
}
|
||||
inputDown3 = true;
|
||||
} else if (tmpActionType == MotionEvent.ACTION_POINTER_3_UP) {
|
||||
if (SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(2);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
EWOL.inputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
EWOL.mouseEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2));
|
||||
}
|
||||
|
||||
} else {
|
||||
EWOL.inputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2));
|
||||
}
|
||||
inputDown3 = false;
|
||||
} else if(tmpActionType == MotionEvent.ACTION_UP){
|
||||
if (inputDown1) {
|
||||
if (SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(0);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
} else {
|
||||
EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
inputDown1 = false;
|
||||
} else if (inputDown2) {
|
||||
if (SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(0);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
} else {
|
||||
EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
inputDown2 = false;
|
||||
} else {
|
||||
if (SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(0);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
EWOL.mouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
} else {
|
||||
EWOL.inputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
inputDown3 = false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean keyboardEvent(int keyCode, KeyEvent event, boolean isDown)
|
||||
{
|
||||
int actionDone = event.getAction();
|
||||
switch(keyCode)
|
||||
{
|
||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||
EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_DOWN, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||
EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_VOLUME_UP, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_MENU:
|
||||
EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_MENU, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_CAMERA:
|
||||
EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_CAMERA, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_HOME:
|
||||
EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_HOME, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_POWER:
|
||||
EWOL.keyboardEventKeySystem(EWOL_SYSTEM_KEY_POWER, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_BACK:
|
||||
// the back key is wrapped in the <esc> key to simplify PC validation ...
|
||||
EWOL.keyboardEventKey(EWOL_SYSTEM_KEY_BACK, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_DEL:
|
||||
EWOL.keyboardEventKey(EWOL_SYSTEM_KEY_DEL, isDown);
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_ALT_LEFT:
|
||||
// TODO : ...
|
||||
break;
|
||||
case KeyEvent.KEYCODE_SHIFT_LEFT:
|
||||
// TODO : ...
|
||||
break;
|
||||
case KeyEvent.KEYCODE_ENTER:
|
||||
// TODO : ...
|
||||
break;
|
||||
// Joystick event :
|
||||
case KeyEvent.KEYCODE_DPAD_UP:
|
||||
break;
|
||||
case KeyEvent.KEYCODE_DPAD_DOWN:
|
||||
break;
|
||||
case KeyEvent.KEYCODE_DPAD_LEFT:
|
||||
break;
|
||||
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
||||
break;
|
||||
case KeyEvent.KEYCODE_DPAD_CENTER:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// key wrapping :
|
||||
if( (actionDone == KeyEvent.ACTION_DOWN)
|
||||
|| (actionDone == KeyEvent.ACTION_MULTIPLE)
|
||||
|| (actionDone == KeyEvent.ACTION_UP))
|
||||
{
|
||||
// convert the key in UniChar to prevent errors ...
|
||||
int uchar = event.getUnicodeChar();
|
||||
// pb on the return methode ... in java it is like windows ...
|
||||
if (uchar == '\r') {
|
||||
uchar = '\n';
|
||||
}
|
||||
// send it to ewol ...
|
||||
EWOL.keyboardEventKey(uchar, isDown);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||
{
|
||||
return keyboardEvent(keyCode, event, true);
|
||||
}
|
||||
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event)
|
||||
{
|
||||
return keyboardEvent(keyCode, event, false);
|
||||
}
|
||||
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol interfaceAudio.java
|
||||
* @brief Java Audio interface code.
|
||||
* @author Edouard DUPIN
|
||||
* @date 29/06/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package org.ewol;
|
||||
|
||||
import android.media.AudioTrack;
|
||||
import android.media.AudioFormat;
|
||||
import android.media.AudioManager;
|
||||
import android.media.AudioRecord;
|
||||
|
||||
// inport the ewol package :
|
||||
import org.ewol.interfaceJNI;
|
||||
|
||||
public class interfaceAudio implements Runnable
|
||||
{
|
||||
private boolean m_stopAudioThreads = false;
|
||||
private AudioTrack m_musicTrack;
|
||||
// constructor :
|
||||
public interfaceAudio()
|
||||
{
|
||||
// nothing to do ...
|
||||
}
|
||||
public void run()
|
||||
{
|
||||
if(m_musicTrack != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int sampleFreq = 44100; //AudioTrack.getNativeOutputSampleRate(AudioManager.STREAM_MUSIC);
|
||||
int channelConfig = AudioFormat.CHANNEL_CONFIGURATION_STEREO;
|
||||
int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
||||
int nbChannels = 2;
|
||||
// we keep the minimum buffer size, otherwite the delay is too big ...
|
||||
int bufferSize = AudioTrack.getMinBufferSize(sampleFreq, channelConfig, audioFormat);
|
||||
// Create a streaming AudioTrack for music playback
|
||||
short[] streamBuffer = new short[bufferSize];
|
||||
m_musicTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
|
||||
44100,
|
||||
AudioFormat.CHANNEL_CONFIGURATION_STEREO,
|
||||
AudioFormat.ENCODING_PCM_16BIT,
|
||||
bufferSize,
|
||||
AudioTrack.MODE_STREAM);
|
||||
m_musicTrack.play();
|
||||
//m_musicTrack.setPositionNotificationPeriod(2048);
|
||||
|
||||
while (!m_stopAudioThreads) {
|
||||
// Fill buffer with PCM data from C++
|
||||
interfaceJNI.IOAudioPlayback(streamBuffer, 512, nbChannels);
|
||||
|
||||
// Stream PCM data into the music AudioTrack
|
||||
m_musicTrack.write(streamBuffer, 0, 512);
|
||||
}
|
||||
|
||||
m_musicTrack.flush();
|
||||
m_musicTrack.stop();
|
||||
}
|
||||
public void Pause()
|
||||
{
|
||||
if(m_musicTrack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_musicTrack.pause();
|
||||
}
|
||||
public void Resume()
|
||||
{
|
||||
if(m_musicTrack == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_musicTrack.play();
|
||||
}
|
||||
public void AutoStop()
|
||||
{
|
||||
if(m_musicTrack == null) {
|
||||
return;
|
||||
}
|
||||
m_stopAudioThreads=true;
|
||||
}
|
||||
};
|
@ -1,67 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol interfaceJNI.java
|
||||
* @brief Java interface to the CPP code.
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package org.ewol;
|
||||
|
||||
public class interfaceJNI {
|
||||
public static native void TouchEvent();
|
||||
// activity status
|
||||
public static native void ActivityOnCreate();
|
||||
public static native void ActivityOnStart();
|
||||
public static native void ActivityOnReStart();
|
||||
public static native void ActivityOnResume();
|
||||
public static native void ActivityOnPause();
|
||||
public static native void ActivityOnStop();
|
||||
public static native void ActivityOnDestroy();
|
||||
// set display properties :
|
||||
public static native void DisplayPropertyMetrics(float ratioX, float ratioY);
|
||||
// IO native function :
|
||||
// Specific for the type of input : TOOL_TYPE_FINGER and TOOL_TYPE_STYLUS (work as the same)
|
||||
public static native void IOInputEventMotion(int pointerID, float x, float y);
|
||||
public static native void IOInputEventState(int pointerID, boolean isDown, float x, float y);
|
||||
// Specific for the type of input : TOOL_TYPE_MOUSE
|
||||
public static native void IOMouseEventMotion(int pointerID, float x, float y);
|
||||
public static native void IOMouseEventState(int pointerID, boolean isDown, float x, float y);
|
||||
// other unknow event ...
|
||||
public static native void IOUnknowEvent(int eventID);
|
||||
|
||||
public static native void IOKeyboardEventMove(int type, boolean isDown);
|
||||
public static native void IOKeyboardEventKey(int uniChar, boolean isDown);
|
||||
|
||||
// Audio section ...
|
||||
public static native void IOAudioPlayback(short[] bufferData, int frames, int nbChannels);
|
||||
|
||||
public static final int EWOL_SYSTEM_KEY__VOLUME_UP = 1;
|
||||
public static final int EWOL_SYSTEM_KEY__VOLUME_DOWN = 2;
|
||||
public static final int EWOL_SYSTEM_KEY__MENU = 3;
|
||||
public static final int EWOL_SYSTEM_KEY__CAMERA = 4;
|
||||
public static final int EWOL_SYSTEM_KEY__HOME = 5;
|
||||
public static final int EWOL_SYSTEM_KEY__POWER = 6;
|
||||
public static native void IOKeyboardEventKeySystem(int keyVal, boolean isDown);
|
||||
// renderer Event :
|
||||
public static native void RenderInit();
|
||||
public static native void RenderResize(int w, int h);
|
||||
public static native void RenderDraw();
|
||||
}
|
||||
|
@ -1,55 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol interfaceOpenGL.java
|
||||
* @brief Java openGl interface code.
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package org.ewol;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
//import javax.microedition.khronos.opengl.GLES20;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLSurfaceView;
|
||||
|
||||
// inport the ewol package :
|
||||
import org.ewol.interfaceJNI;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Class :
|
||||
*
|
||||
*/
|
||||
public class interfaceOpenGL implements GLSurfaceView.Renderer {
|
||||
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
|
||||
interfaceJNI.RenderInit();
|
||||
}
|
||||
|
||||
public void onSurfaceChanged(GL10 gl, int w, int h) {
|
||||
interfaceJNI.RenderResize(w, h);
|
||||
}
|
||||
|
||||
public void onDrawFrame(GL10 gl) {
|
||||
interfaceJNI.RenderDraw();
|
||||
}
|
||||
}
|
@ -1,316 +0,0 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol interfaceSurfaceView.java
|
||||
* @brief Java interface of the java Surface viewer code.
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package org.ewol;
|
||||
|
||||
// inport the ewol package :
|
||||
import org.ewol.interfaceJNI;
|
||||
import org.ewol.interfaceOpenGL;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
/**
|
||||
* @brief Class :
|
||||
*
|
||||
*/
|
||||
public class interfaceSurfaceView extends GLSurfaceView {
|
||||
|
||||
private interfaceOpenGL m_ewolDrawer;
|
||||
private int M_SDK_VERSION;
|
||||
|
||||
public interfaceSurfaceView(Context context, int OpenGlVersion) {
|
||||
// super must be first statement in constructor
|
||||
super(context);
|
||||
M_SDK_VERSION = android.os.Build.VERSION.SDK_INT;
|
||||
/*
|
||||
List of the Android API :
|
||||
Android 4.1, 4.1.1 16 JELLY_BEAN Platform Highlights
|
||||
Android 4.0.3, 4.0.4 15 ICE_CREAM_SANDWICH_MR1 Platform Highlights
|
||||
Android 4.0, 4.0.1, 4.0.2 14 ICE_CREAM_SANDWICH
|
||||
Android 3.2 13 HONEYCOMB_MR2
|
||||
Android 3.1.x 12 HONEYCOMB_MR1 Platform Highlights
|
||||
Android 3.0.x 11 HONEYCOMB Platform Highlights
|
||||
Android 2.3.4
|
||||
Android 2.3.3 10 GINGERBREAD_MR1 Platform Highlights
|
||||
Android 2.3.2
|
||||
Android 2.3.1
|
||||
Android 2.3 9 GINGERBREAD
|
||||
Android 2.2.x 8 FROYO Platform Highlights
|
||||
Android 2.1.x 7 ECLAIR_MR1 Platform Highlights
|
||||
Android 2.0.1 6 ECLAIR_0_1
|
||||
Android 2.0 5 ECLAIR
|
||||
Android 1.6 4 DONUT Platform Highlights
|
||||
Android 1.5 3 CUPCAKE Platform Highlights
|
||||
Android 1.1 2 BASE_1_1
|
||||
Android 1.0 1 BASE
|
||||
*/
|
||||
// Create an OpenGL ES 2.0 context
|
||||
if (OpenGlVersion == 2) {
|
||||
setEGLContextClientVersion(2);
|
||||
}
|
||||
|
||||
// je n'ai pas compris ...
|
||||
m_ewolDrawer = new interfaceOpenGL();
|
||||
setRenderer(m_ewolDrawer);
|
||||
|
||||
// Can get the focus ==> get keyboard from JAVA :
|
||||
setFocusable(true);
|
||||
setFocusableInTouchMode(true);
|
||||
}
|
||||
|
||||
private boolean InputDown1 = false;
|
||||
private boolean InputDown2 = false;
|
||||
private boolean InputDown3 = false;
|
||||
|
||||
public boolean onTouchEvent(final MotionEvent event) {
|
||||
// Wrapper on input events :
|
||||
|
||||
int tmpActionType = event.getAction();
|
||||
|
||||
if (tmpActionType == MotionEvent.ACTION_MOVE) {
|
||||
final int pointerCount = event.getPointerCount();
|
||||
for (int p = 0; p < pointerCount; p++) {
|
||||
if (M_SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(p);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
interfaceJNI.IOInputEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
interfaceJNI.IOMouseEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p));
|
||||
}
|
||||
} else {
|
||||
interfaceJNI.IOInputEventMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p));
|
||||
}
|
||||
}
|
||||
} else if( tmpActionType == MotionEvent.ACTION_POINTER_1_DOWN
|
||||
|| tmpActionType == MotionEvent.ACTION_DOWN) {
|
||||
if (M_SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(0);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
interfaceJNI.IOMouseEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
} else {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
InputDown1 = true;
|
||||
} else if(tmpActionType == MotionEvent.ACTION_POINTER_1_UP) {
|
||||
if (M_SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(0);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
interfaceJNI.IOMouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
} else {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
InputDown1 = false;
|
||||
} else if (tmpActionType == MotionEvent.ACTION_POINTER_2_DOWN) {
|
||||
if (M_SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(1);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
interfaceJNI.IOMouseEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1));
|
||||
}
|
||||
} else {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1));
|
||||
}
|
||||
InputDown2 = true;
|
||||
} else if (tmpActionType == MotionEvent.ACTION_POINTER_2_UP) {
|
||||
if (M_SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(1);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
interfaceJNI.IOMouseEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1));
|
||||
}
|
||||
} else {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1));
|
||||
}
|
||||
InputDown2 = false;
|
||||
} else if (tmpActionType == MotionEvent.ACTION_POINTER_3_DOWN) {
|
||||
if (M_SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(2);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
interfaceJNI.IOMouseEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2));
|
||||
}
|
||||
} else {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2));
|
||||
}
|
||||
InputDown3 = true;
|
||||
} else if (tmpActionType == MotionEvent.ACTION_POINTER_3_UP) {
|
||||
if (M_SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(2);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
interfaceJNI.IOMouseEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2));
|
||||
}
|
||||
} else {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2));
|
||||
}
|
||||
InputDown3 = false;
|
||||
} else if(tmpActionType == MotionEvent.ACTION_UP){
|
||||
if (InputDown1) {
|
||||
if (M_SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(0);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
interfaceJNI.IOMouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
} else {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
InputDown1 = false;
|
||||
} else if (InputDown2) {
|
||||
if (M_SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(0);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
interfaceJNI.IOMouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
} else {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
InputDown2 = false;
|
||||
} else {
|
||||
if (M_SDK_VERSION>=14) {
|
||||
final int typeOfPointer = event.getToolType(0);
|
||||
if( typeOfPointer == MotionEvent.TOOL_TYPE_FINGER
|
||||
|| typeOfPointer == MotionEvent.TOOL_TYPE_STYLUS) {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
} else if(typeOfPointer == MotionEvent.TOOL_TYPE_MOUSE) {
|
||||
interfaceJNI.IOMouseEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
} else {
|
||||
interfaceJNI.IOInputEventState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
|
||||
}
|
||||
InputDown3 = false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean keyboardEvent(int keyCode, KeyEvent event, boolean isDown)
|
||||
{
|
||||
int actionDone = event.getAction();
|
||||
switch(keyCode)
|
||||
{
|
||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
||||
interfaceJNI.IOKeyboardEventKeySystem(interfaceJNI.EWOL_SYSTEM_KEY__VOLUME_DOWN, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
||||
interfaceJNI.IOKeyboardEventKeySystem(interfaceJNI.EWOL_SYSTEM_KEY__VOLUME_UP, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_MENU:
|
||||
interfaceJNI.IOKeyboardEventKeySystem(interfaceJNI.EWOL_SYSTEM_KEY__MENU, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_CAMERA:
|
||||
interfaceJNI.IOKeyboardEventKeySystem(interfaceJNI.EWOL_SYSTEM_KEY__CAMERA, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_HOME:
|
||||
interfaceJNI.IOKeyboardEventKeySystem(interfaceJNI.EWOL_SYSTEM_KEY__HOME, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_POWER:
|
||||
interfaceJNI.IOKeyboardEventKeySystem(interfaceJNI.EWOL_SYSTEM_KEY__POWER, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_BACK:
|
||||
// the back key is wrapped in the <esc> key to simplify PC validation ...
|
||||
interfaceJNI.IOKeyboardEventKey(0x1B, isDown);
|
||||
return false;
|
||||
case KeyEvent.KEYCODE_DEL:
|
||||
interfaceJNI.IOKeyboardEventKey(0x08, isDown);
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_ALT_LEFT:
|
||||
// TODO : ...
|
||||
break;
|
||||
case KeyEvent.KEYCODE_SHIFT_LEFT:
|
||||
// TODO : ...
|
||||
break;
|
||||
case KeyEvent.KEYCODE_ENTER:
|
||||
// TODO : ...
|
||||
break;
|
||||
// Joystick event :
|
||||
case KeyEvent.KEYCODE_DPAD_UP:
|
||||
break;
|
||||
case KeyEvent.KEYCODE_DPAD_DOWN:
|
||||
break;
|
||||
case KeyEvent.KEYCODE_DPAD_LEFT:
|
||||
break;
|
||||
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
||||
break;
|
||||
case KeyEvent.KEYCODE_DPAD_CENTER:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// key wrapping :
|
||||
if( (actionDone == KeyEvent.ACTION_DOWN)
|
||||
|| (actionDone == KeyEvent.ACTION_MULTIPLE)
|
||||
|| (actionDone == KeyEvent.ACTION_UP))
|
||||
{
|
||||
// convert the key in UniChar to prevent errors ...
|
||||
int uchar = event.getUnicodeChar();
|
||||
// pb on the return methode ... in java it is like windows ...
|
||||
if (uchar == '\r') {
|
||||
uchar = '\n';
|
||||
}
|
||||
// send it to ewol ...
|
||||
interfaceJNI.IOKeyboardEventKey(uchar, isDown);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||
{
|
||||
return keyboardEvent(keyCode, event, true);
|
||||
}
|
||||
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event)
|
||||
{
|
||||
return keyboardEvent(keyCode, event, false);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user