Skip to content

Commit d0a9206

Browse files
committed
Port some hotkeys over to Android and console
1 parent 62759d1 commit d0a9206

15 files changed

+433
-272
lines changed

src/android/cpp/interface.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int showFpsCounter = 0;
3333
int buttonScale = 5;
3434
int buttonSpacing = 10;
3535
int vibrateStrength = 1;
36-
int keyBinds[12] = {};
36+
int keyBinds[15] = {};
3737

3838
std::string ndsPath = "", gbaPath = "";
3939
int ndsRomFd = -1, gbaRomFd = -1;
@@ -105,7 +105,10 @@ extern "C" JNIEXPORT jboolean JNICALL Java_com_hydra_noods_FileBrowser_loadSetti
105105
Setting("keyR", &keyBinds[8], false),
106106
Setting("keyL", &keyBinds[9], false),
107107
Setting("keyX", &keyBinds[10], false),
108-
Setting("keyY", &keyBinds[11], false)
108+
Setting("keyY", &keyBinds[11], false),
109+
Setting("keyFastHold", &keyBinds[12], false),
110+
Setting("keyFastToggle", &keyBinds[13], false),
111+
Setting("keyScreenSwap", &keyBinds[14], false)
109112
};
110113

111114
// Add the platform settings

src/android/java/com/hydra/noods/FileBrowser.java

-6
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,11 @@ public boolean onOptionsItemSelected(MenuItem item)
144144
update();
145145
break;
146146

147-
case R.id.bindings_action:
148-
// Open the input bindings menu
149-
startActivity(new Intent(this, BindingsMenu.class));
150-
return true;
151-
152147
case R.id.settings_action:
153148
// Open the settings menu
154149
startActivity(new Intent(this, SettingsMenu.class));
155150
return true;
156151
}
157-
158152
return super.onOptionsItemSelected(item);
159153
}
160154

src/android/java/com/hydra/noods/NooActivity.java

+52
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class NooActivity extends AppCompatActivity
4949
private NooRenderer renderer;
5050
private NooButton buttons[];
5151
private TextView fpsCounter;
52+
private int fpsLimiterBackup = 0;
5253
private boolean initButtons = true;
5354
private boolean showingButtons = true;
5455
private boolean showingFps;
@@ -114,6 +115,13 @@ protected void onPause()
114115
{
115116
pauseCore();
116117
super.onPause();
118+
119+
// Restore the FPS limiter
120+
if (fpsLimiterBackup != 0)
121+
{
122+
SettingsMenu.setFpsLimiter(fpsLimiterBackup);
123+
fpsLimiterBackup = 0;
124+
}
117125
}
118126

119127
@Override
@@ -316,6 +324,39 @@ public boolean onKeyDown(int keyCode, KeyEvent event)
316324
}
317325
}
318326

327+
// Handle pressing special hotkeys
328+
if (keyCode == BindingsPreference.getKeyBind(12) - 1) // Fast Forward Hold
329+
{
330+
// Disable the FPS limiter
331+
if (SettingsMenu.getFpsLimiter() != 0)
332+
{
333+
fpsLimiterBackup = SettingsMenu.getFpsLimiter();
334+
SettingsMenu.setFpsLimiter(0);
335+
}
336+
return true;
337+
}
338+
else if (keyCode == BindingsPreference.getKeyBind(13) - 1) // Fast Forward Toggle
339+
{
340+
// Toggle between disabling and restoring the FPS limiter
341+
if (SettingsMenu.getFpsLimiter() != 0)
342+
{
343+
fpsLimiterBackup = SettingsMenu.getFpsLimiter();
344+
SettingsMenu.setFpsLimiter(0);
345+
}
346+
else if (fpsLimiterBackup != 0)
347+
{
348+
SettingsMenu.setFpsLimiter(fpsLimiterBackup);
349+
fpsLimiterBackup = 0;
350+
}
351+
return true;
352+
}
353+
else if (keyCode == BindingsPreference.getKeyBind(14) - 1) // Screen Swap Toggle
354+
{
355+
// Toggle between favoring the top or bottom screen
356+
SettingsMenu.setScreenSizing((SettingsMenu.getScreenSizing() == 1) ? 2 : 1);
357+
renderer.updateLayout(renderer.width, renderer.height);
358+
return true;
359+
}
319360
return super.onKeyDown(keyCode, event);
320361
}
321362

@@ -332,6 +373,17 @@ public boolean onKeyUp(int keyCode, KeyEvent event)
332373
}
333374
}
334375

376+
// Handle releasing special hotkeys
377+
if (keyCode == BindingsPreference.getKeyBind(12) - 1) // Fast Forward Hold
378+
{
379+
// Restore the FPS limiter
380+
if (fpsLimiterBackup != 0)
381+
{
382+
SettingsMenu.setFpsLimiter(fpsLimiterBackup);
383+
fpsLimiterBackup = 0;
384+
}
385+
return true;
386+
}
335387
return super.onKeyUp(keyCode, event);
336388
}
337389

src/android/java/com/hydra/noods/SettingsMenu.java

+23
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@
2929
import androidx.preference.SwitchPreferenceCompat;
3030

3131
import android.content.Context;
32+
import android.content.Intent;
3233
import android.content.SharedPreferences;
3334
import android.content.pm.PackageManager;
3435
import android.os.Bundle;
36+
import android.view.Menu;
37+
import android.view.MenuItem;
3538

3639
public class SettingsMenu extends AppCompatActivity
3740
{
@@ -107,6 +110,26 @@ protected void onCreate(Bundle savedInstanceState)
107110
.commit();
108111
}
109112

113+
@Override
114+
public boolean onCreateOptionsMenu(Menu menu)
115+
{
116+
getMenuInflater().inflate(R.menu.settings_menu, menu);
117+
return true;
118+
}
119+
120+
@Override
121+
public boolean onOptionsItemSelected(MenuItem item)
122+
{
123+
switch (item.getItemId())
124+
{
125+
case R.id.bindings_action:
126+
// Open the input bindings menu
127+
startActivity(new Intent(this, BindingsMenu.class));
128+
return true;
129+
}
130+
return super.onOptionsItemSelected(item);
131+
}
132+
110133
@Override
111134
public void onBackPressed()
112135
{

src/android/res/menu/file_menu.xml

-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
android:visible="false"
1515
app:showAsAction="always" />
1616

17-
<item android:id="@+id/bindings_action"
18-
android:icon="@drawable/bindings"
19-
android:title="Input Bindings"
20-
app:showAsAction="always" />
21-
2217
<item android:id="@+id/settings_action"
2318
android:icon="@drawable/settings"
2419
android:title="Settings"
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
4+
5+
<item android:id="@+id/bindings_action"
6+
android:icon="@drawable/bindings"
7+
android:title="Input Bindings"
8+
app:showAsAction="always" />
9+
10+
</menu>

0 commit comments

Comments
 (0)