Kinda hooked up options a little, something weird going on in there... Added a simple auto-detect to map for PS3 controllers with default to Ouya controller.
This commit is contained in:
parent
f7ad678d3b
commit
ae1fcf503a
|
@ -11,5 +11,5 @@
|
|||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-15
|
||||
target=android-16
|
||||
android.library.reference.1=../../newdc/android/libnewdc
|
||||
|
|
|
@ -3,6 +3,85 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
android:text="System Path(location of dc_boot.bin/dc_flash.bin)" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
|
||||
|
||||
<EditText
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/main_path"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:inputType="textPersonName" >
|
||||
|
||||
<requestFocus />
|
||||
</EditText>
|
||||
|
||||
<Button
|
||||
|
||||
android:id="@+id/browse_main_path"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Browse" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dip"
|
||||
android:layout_weight="1"
|
||||
android:text="Default Browser Path" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
|
||||
|
||||
<EditText
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/browse_path"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:ems="10"
|
||||
android:inputType="textPersonName" >
|
||||
|
||||
|
||||
</EditText>
|
||||
|
||||
<Button
|
||||
|
||||
android:id="@+id/browse_main_path"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Browse" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -251,11 +251,11 @@ public class FileBrowser extends Fragment {
|
|||
|
||||
mCallback.onFolderSelected(Uri.fromFile(new File(root_sd.getAbsolutePath())));
|
||||
vib.vibrate(250);
|
||||
}
|
||||
}
|
||||
else if(ImgBrowse)
|
||||
{
|
||||
vib.vibrate(50);
|
||||
mCallback.onGameSelected(Uri.fromFile(f));
|
||||
mCallback.onGameSelected(f!=null? Uri.fromFile(f):Uri.EMPTY);
|
||||
//Intent inte = new Intent(Intent.ACTION_VIEW,f!=null? Uri.fromFile(f):Uri.EMPTY,parentActivity.getBaseContext(),GL2JNIActivity.class);
|
||||
//FileBrowser.this.startActivity(inte);
|
||||
vib.vibrate(250);
|
||||
|
|
|
@ -9,7 +9,9 @@ import com.reicast.emulator.GL2JNIView.EmuThread;
|
|||
import com.example.newdc.JNIdc;
|
||||
|
||||
import android.view.InputDevice;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
|
@ -30,11 +32,13 @@ import android.content.res.AssetManager;
|
|||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
|
||||
public class GL2JNIActivity extends Activity
|
||||
{
|
||||
GL2JNIView mView;
|
||||
PopupWindow popUp;
|
||||
LayoutParams params;
|
||||
int map[];
|
||||
|
||||
View addbut(int x, OnClickListener ocl)
|
||||
{
|
||||
|
@ -142,6 +146,47 @@ public class GL2JNIActivity extends Activity
|
|||
|
||||
// Call parent onCreate()
|
||||
super.onCreate(icicle);
|
||||
|
||||
/*int joys[] =InputDevice.getDeviceIds();
|
||||
for(int i = 0;i<joys.length; i++){
|
||||
Log.d("reidc", "InputDevice ID: "+joys[i]);
|
||||
Log.d("reidc", "InputDevice Name: "+ InputDevice.getDevice(joys[i]).getName());*/int joys[] =InputDevice.getDeviceIds();
|
||||
for(int i = 0;i<joys.length; i++){
|
||||
Log.d("reidc", "InputDevice ID: "+joys[i]);
|
||||
Log.d("reidc", "InputDevice Name: "+ InputDevice.getDevice(joys[i]).getName());
|
||||
if(InputDevice.getDevice(joys[i]).getName()=="Sony PLAYSTATION(R)3 Controller"){
|
||||
map = new int[] {
|
||||
OuyaController.BUTTON_Y, key_CONT_B,
|
||||
OuyaController.BUTTON_U, key_CONT_A,
|
||||
OuyaController.BUTTON_O, key_CONT_X,
|
||||
OuyaController.BUTTON_A, key_CONT_Y,
|
||||
|
||||
OuyaController.BUTTON_DPAD_UP, key_CONT_DPAD_UP,
|
||||
OuyaController.BUTTON_DPAD_DOWN, key_CONT_DPAD_DOWN,
|
||||
OuyaController.BUTTON_DPAD_LEFT, key_CONT_DPAD_LEFT,
|
||||
OuyaController.BUTTON_DPAD_RIGHT, key_CONT_DPAD_RIGHT,
|
||||
|
||||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_L1, key_CONT_START
|
||||
|
||||
};
|
||||
}else{ // Ouya controller
|
||||
map = new int[] {
|
||||
OuyaController.BUTTON_O, key_CONT_A,
|
||||
OuyaController.BUTTON_A, key_CONT_B,
|
||||
OuyaController.BUTTON_Y, key_CONT_Y,
|
||||
OuyaController.BUTTON_U, key_CONT_X,
|
||||
|
||||
OuyaController.BUTTON_DPAD_UP, key_CONT_DPAD_UP,
|
||||
OuyaController.BUTTON_DPAD_DOWN, key_CONT_DPAD_DOWN,
|
||||
OuyaController.BUTTON_DPAD_LEFT, key_CONT_DPAD_LEFT,
|
||||
OuyaController.BUTTON_DPAD_RIGHT, key_CONT_DPAD_RIGHT,
|
||||
|
||||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_L1, key_CONT_START
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// When viewing a resource, pass its URI to the native code for opening
|
||||
Intent intent = getIntent();
|
||||
|
@ -194,11 +239,13 @@ public class GL2JNIActivity extends Activity
|
|||
private static final int key_CONT_Y = 0x0200;
|
||||
private static final int key_CONT_X = 0x0400;
|
||||
|
||||
int map[] = new int[] {
|
||||
OuyaController.BUTTON_O, key_CONT_A,
|
||||
OuyaController.BUTTON_A, key_CONT_B,
|
||||
OuyaController.BUTTON_Y, key_CONT_Y,
|
||||
OuyaController.BUTTON_U, key_CONT_X,
|
||||
|
||||
// TODO: Controller mapping in options. Trunk has Ouya layout. This is a DS3 layout.
|
||||
;/*map[]= new int[] {
|
||||
OuyaController.BUTTON_Y, key_CONT_B,
|
||||
OuyaController.BUTTON_U, key_CONT_A,
|
||||
OuyaController.BUTTON_O, key_CONT_X,
|
||||
OuyaController.BUTTON_A, key_CONT_Y,
|
||||
|
||||
OuyaController.BUTTON_DPAD_UP, key_CONT_DPAD_UP,
|
||||
OuyaController.BUTTON_DPAD_DOWN, key_CONT_DPAD_DOWN,
|
||||
|
@ -208,7 +255,23 @@ public class GL2JNIActivity extends Activity
|
|||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_L1, key_CONT_START
|
||||
|
||||
};
|
||||
};*/
|
||||
|
||||
/*int map[] = new int[] {
|
||||
OuyaController.BUTTON_Y, key_CONT_B,
|
||||
OuyaController.BUTTON_U, key_CONT_A,
|
||||
OuyaController.BUTTON_O, key_CONT_X,
|
||||
OuyaController.BUTTON_A, key_CONT_Y,
|
||||
|
||||
OuyaController.BUTTON_DPAD_UP, key_CONT_DPAD_UP,
|
||||
OuyaController.BUTTON_DPAD_DOWN, key_CONT_DPAD_DOWN,
|
||||
OuyaController.BUTTON_DPAD_LEFT, key_CONT_DPAD_LEFT,
|
||||
OuyaController.BUTTON_DPAD_RIGHT, key_CONT_DPAD_RIGHT,
|
||||
|
||||
OuyaController.BUTTON_MENU, key_CONT_START,
|
||||
OuyaController.BUTTON_L1, key_CONT_START
|
||||
|
||||
};*/
|
||||
|
||||
boolean handle_key(int kc, boolean down) {
|
||||
boolean rav = false;
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.content.Intent;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
@ -13,7 +14,8 @@ import android.view.View.OnClickListener;
|
|||
import android.view.View.OnTouchListener;
|
||||
|
||||
public class MainActivity extends FragmentActivity implements
|
||||
FileBrowser.OnItemSelectedListener{
|
||||
FileBrowser.OnItemSelectedListener,
|
||||
OptionsFragment.OnClickListener{
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -131,9 +133,35 @@ public class MainActivity extends FragmentActivity implements
|
|||
}
|
||||
|
||||
public void onFolderSelected(Uri uri){
|
||||
FileBrowser browserFrag = (FileBrowser)getSupportFragmentManager().findFragmentByTag("MAIN_BROWSER");
|
||||
if(browserFrag != null){
|
||||
if(browserFrag.isVisible()){
|
||||
|
||||
Log.d("reicast", "Main folder: "+uri.toString());
|
||||
//return;
|
||||
}
|
||||
}
|
||||
|
||||
OptionsFragment optsFrag = new OptionsFragment();
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragment_container,optsFrag, "OPTIONS_FRAG").commit();
|
||||
return;
|
||||
}
|
||||
|
||||
public void onMainBrowseSelected(){
|
||||
FileBrowser firstFragment = new FileBrowser();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("ImgBrowse", false); // specify ImgBrowse option. true = images, false = folders only
|
||||
firstFragment.setArguments(args);
|
||||
// In case this activity was started with special instructions from
|
||||
// an
|
||||
// Intent, pass the Intent's extras to the fragment as arguments
|
||||
// firstFragment.setArguments(getIntent().getExtras());
|
||||
|
||||
// Add the fragment to the 'fragment_container' FrameLayout
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragment_container, firstFragment, "MAIN_BROWSER").addToBackStack(null).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
|
|
|
@ -1,16 +1,66 @@
|
|||
package com.reicast.emulator;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.InputDevice;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
|
||||
public class OptionsFragment extends Fragment{
|
||||
|
||||
Activity parentActivity;
|
||||
Button mainBrowse;
|
||||
OnClickListener mCallback;
|
||||
|
||||
// Container Activity must implement this interface
|
||||
public interface OnClickListener {
|
||||
public void onMainBrowseSelected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
super.onAttach(activity);
|
||||
|
||||
// This makes sure that the container activity has implemented
|
||||
// the callback interface. If not, it throws an exception
|
||||
try {
|
||||
mCallback = (OnClickListener) activity;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException(activity.toString()
|
||||
+ " must implement OnClickListener");
|
||||
}
|
||||
|
||||
int joys[] =InputDevice.getDeviceIds();
|
||||
for(int i = 0;i<joys.length; i++){
|
||||
Log.d("reidc", "InputDevice ID: "+joys[i]);
|
||||
Log.d("reidc", "InputDevice Name: "+ InputDevice.getDevice(joys[i]).getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.options_fragment, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState){
|
||||
//setContentView(R.layout.activity_main);
|
||||
|
||||
parentActivity = getActivity();
|
||||
mainBrowse = (Button)getView().findViewById(R.id.browse_main_path);
|
||||
mainBrowse.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
mCallback.onMainBrowseSelected();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue