Skip to content

Commit 0db2c8e

Browse files
committed
camera: Fix rotation on Android.
1 parent 5c34815 commit 0db2c8e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/camera/android/SDL_camera_android.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,11 @@ static SDL_CameraFrameResult ANDROIDCAMERA_AcquireFrame(SDL_Camera *device, SDL_
376376
default: SDL_assert(!"Unexpected device rotation!"); dev_rotation = 0; break;
377377
}
378378

379-
*rotation = dev_rotation - device->hidden->rotation; // current phone orientation, static camera orientation in relation to phone.
379+
if (device->position == SDL_CAMERA_POSITION_BACK_FACING) {
380+
dev_rotation = -dev_rotation; // we want to subtract this value, instead of add, if back-facing.
381+
}
382+
383+
*rotation = dev_rotation + device->hidden->rotation; // current phone orientation, static camera orientation in relation to phone.
380384

381385
return result;
382386
}

0 commit comments

Comments
 (0)