Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanQueueRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

using namespace PPSSPP_VK;

// Debug help: adb logcat -s DEBUG AndroidRuntime PPSSPPNativeActivity PPSSPP NativeGLView NativeRenderer NativeSurfaceView PowerSaveModeReceiver InputDeviceState PpssppActivity CameraHelper
// Debug help: adb logcat -s DEBUG AndroidRuntime PPSSPPNativeActivity PPSSPP NativeGLView NativeRenderer NativeSurfaceView PowerSaveModeReceiver InputDeviceState PpssppActivity CameraHelper PPSSPPSizeManager

static void MergeRenderAreaRectInto(VkRect2D *dest, const VkRect2D &src) {
if (dest->offset.x > src.offset.x) {
Expand Down
5 changes: 4 additions & 1 deletion Core/ControlMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,11 @@ void ControlMapper::Axis(const AxisInput *axes, size_t count) {
KeyMap::UnlockMappings();
}

void ControlMapper::Update(const DisplayLayoutConfig &config, double now) {
void ControlMapper::UpdateConfig(const DisplayLayoutConfig &config) {
iInternalScreenRotationCached_ = config.bRotateControlsWithScreen ? config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;
}

void ControlMapper::UpdateAutoMovements(double now) {
if (autoRotatingAnalogCW_) {
// Clamp to a square
float x = std::min(1.0f, std::max(-1.0f, 1.42f * (float)cos(now * -g_Config.fAnalogAutoRotSpeed)));
Expand Down
3 changes: 2 additions & 1 deletion Core/ControlMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class ControlListener {
// Main use is of course from EmuScreen.cpp, but also useful from control settings etc.
class ControlMapper {
public:
void Update(const DisplayLayoutConfig &config, double now);
void UpdateConfig(const DisplayLayoutConfig &config);
void UpdateAutoMovements(double now);

// Inputs to the table-based mapping
// These functions are free-threaded.
Expand Down
4 changes: 4 additions & 0 deletions Core/HLE/sceDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "Core/HW/Display.h"
#include "Core/Util/PPGeDraw.h"
#include "Core/RetroAchievements.h"
#include "Core/ControlMapper.h"

#include "GPU/GPU.h"
#include "GPU/GPUState.h"
Expand Down Expand Up @@ -541,6 +542,9 @@ void hleEnterVblank(u64 userdata, int cyclesLate) {
__KernelReSchedule("entered vblank");
}

// We use the emulation timebase here, for auto movements to be smooth as seen from the game.
g_controlMapper.UpdateAutoMovements(CoreTiming::GetGlobalTimeUs() / 1000000.0);

numVBlanksSinceFlip++;

// TODO: Should this be done here or in hleLeaveVblank?
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ What's new in 1.19
- As usual a lot of tweaks, perf fixes, and fixes for hangs and crashes ([#20343], [#20332], [#20305], [#20303], [#20299], [#20163], [#20152], [#20143], [#20079], [#20137], [#20374])
- Two new color themes ([#20334], [#20335]), related themability fixes ([#19984], [#19995], [#20308])
- Improvements and bug fixes in the savedata manager ([#19771], [#20170])
- Add "Move to trash" deletion funcionality to multiple platforms ([#20230], [#20261])
- Add "Move to trash" deletion functionality to multiple platforms ([#20230], [#20261])
- Add ability to take "raw" screenshots of gameplay ([#20029])
- More files can be loaded directly from ZIP ([#20243])
- Developer Settings are now tabbed for easier access ([#20228])
Expand Down Expand Up @@ -463,4 +463,4 @@ See [history.md](history.md).
[#21432]: https://github.com/hrydgard/ppsspp/issues/21432 "Rename \"Hostname\" to \"Hostname or IP\" in adhoc server settings"
[#21433]: https://github.com/hrydgard/ppsspp/issues/21433 "Add a \"quick-edit\" button for the current server host/ip, if it's custom"
[#21434]: https://github.com/hrydgard/ppsspp/issues/21434 "Fix support for custom game configs for homebrews"
[#21437]: https://github.com/hrydgard/ppsspp/issues/21437 "Android: Handle inset adjustments on the C++ side, handle them better in the UI."
[#21437]: https://github.com/hrydgard/ppsspp/issues/21437 "Android: Handle inset adjustments on the C++ side, handle them better in the UI."
2 changes: 1 addition & 1 deletion UI/ControlMappingScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ void AnalogCalibrationScreen::SetRawAnalog(int stick, float x, float y) {
}

void AnalogCalibrationScreen::update() {
g_controlMapper.Update(g_Config.GetDisplayLayoutConfig(GetDeviceOrientation()), time_now_d());
g_controlMapper.UpdateConfig(g_Config.GetDisplayLayoutConfig(GetDeviceOrientation()));
// We ignore the secondary stick for now and just use the two views
// for raw and psp input.
if (stickView_[0]) {
Expand Down
2 changes: 1 addition & 1 deletion UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ void EmuScreen::update() {
double now = time_now_d();

DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GetDeviceOrientation());
g_controlMapper.Update(config, now);
g_controlMapper.UpdateConfig(config);

if (saveStatePreview_ && !bootPending_) {
int currentSlot = SaveState::GetCurrentSlot();
Expand Down
1 change: 0 additions & 1 deletion android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
android:theme="@style/ppsspp_style"
android:launchMode="singleInstance"
android:exported="true">
<!-- android:screenOrientation="landscape" -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
40 changes: 25 additions & 15 deletions android/src/org/ppsspp/ppsspp/PpssppActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import android.view.SurfaceView;
import android.view.View;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
Expand Down Expand Up @@ -195,7 +194,7 @@ private void detectOptimalAudioSettings() {
try {
optimalFramesPerBuffer = Integer.parseInt(this.audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER));
} catch (NumberFormatException e) {
// Ignore, if we can't parse it it's bogus and zero is a fine value (means we couldn't detect it).
// Ignore, if we can't parse it, it's bogus and zero is a fine value (means we couldn't detect it).
}
try {
optimalSampleRate = Integer.parseInt(this.audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
Expand Down Expand Up @@ -576,6 +575,7 @@ private void updateScreenRotation(String cause) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (isInMultiWindowMode()) {
// Do not try to enforce rotation! This can result in re-init loops.
Log.e(TAG, "Multi window mode, not setting orientation");
return;
}
}
Expand All @@ -589,28 +589,37 @@ private void updateScreenRotation(String cause) {
Log.e(TAG, "Invalid rotation: " + rotString);
return;
}
Log.i(TAG, "Setting requested rotation: " + rot + " ('" + rotString + "') (" + cause + ")");

// WARNING: when adding new modes here, check SizeManager's workaround in surfaceCreated.j

int nativeRotation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
switch (rot) {
case 0:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
nativeRotation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
break;
case 1:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
nativeRotation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
break;
case 2:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
nativeRotation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
break;
case 3:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
nativeRotation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
break;
case 4:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
nativeRotation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
break;
case 5:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
nativeRotation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
break;
}

if (getRequestedOrientation() != nativeRotation) {
Log.i(TAG, "Changing requested rotation to " + rot + " ('" + rotString + "') (" + cause + ")");
setRequestedOrientation(nativeRotation);
} else {
Log.i(TAG, "Rotation already set.");
}
}

private boolean useImmersive() {
Expand Down Expand Up @@ -775,7 +784,8 @@ public void run() {
sizeManager.setSurfaceView(mSurfaceView);
setInsetsListener(mSurfaceView);
setContentView(mSurfaceView);
startRenderLoopThread();

// render loop thread will be started once we get a surface.
}

if (shortcutParam != null && !shortcutParam.isEmpty()) {
Expand Down Expand Up @@ -922,29 +932,29 @@ private void updateInsets(WindowInsetsCompat insetCompat) {
}

public void notifySurface(Surface surface) {
Log.i(TAG, "notifySurface begin");
mSurface = surface;

if (!javaGL) {
if (!initialized) {
Log.e(TAG, "notifySurface end: Saving surface, but can't start/stop threads while not initialized");
Log.e(TAG, "notifySurface: Saving surface, but can't start/stop threads while not initialized");
return;
}

// If we got a surface, this starts the thread. If not, it doesn't.
// NOTE: We do not try to join the thread here
if (mSurface != null) {
// applyFramerate is called in here.
Log.i(TAG, "notifySurface: got surface, starting thread.");
startRenderLoopThread();
} else {
Log.i(TAG, "Notified surface is null, not starting thread.");
Log.i(TAG, "notifySurface: Notified surface is null, not starting thread.");
}
} else if (mSurface != null) {
// JavaGL path.
Log.i(TAG, "notifySurface: Applying framerate.");
applyFrameRate(mSurface, 60.0f);
}
updateSustainedPerformanceMode();
Log.i(TAG, "notifySurface end");
}

// The render loop thread (EmuThread) is now spawned from the native side.
Expand Down Expand Up @@ -1125,8 +1135,8 @@ public void onAttachedToWindow() {

@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
Log.i(TAG, "onConfigurationChanged");
super.onConfigurationChanged(newConfig);
Log.i(TAG, "onConfigurationChanged");
updateSystemUiVisibility();
sizeManager.updateDpi((float)newConfig.densityDpi);
}
Expand Down
3 changes: 2 additions & 1 deletion android/src/org/ppsspp/ppsspp/SizeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ public void surfaceCreated(SurfaceHolder holder) {
int pixelHeight = holder.getSurfaceFrame().height();

// Workaround for terrible bug when locking and unlocking the screen in landscape mode on Nexus 5X.
// TODO: Look into removing this.
int requestedOr = activity.getRequestedOrientation();
boolean requestedPortrait = requestedOr == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || requestedOr == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
boolean detectedPortrait = pixelHeight > pixelWidth;
if (badOrientationCount < 3 && requestedPortrait != detectedPortrait && requestedOr != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
if (badOrientationCount < 3 && requestedPortrait != detectedPortrait && requestedOr != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED && requestedOr != ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE && requestedOr != ActivityInfo.SCREEN_ORIENTATION_SENSOR) {
Log.e(TAG, "Bad orientation detected (w=" + pixelWidth + " h=" + pixelHeight + "! Recreating activity.");
badOrientationCount++;
activity.recreate();
Expand Down
Loading