service/vi: Correct scaling mode conversions

These values are not equivalent, based off RE. The internal value is put
into a lookup table with the following values:

[3, 0, 1, 2, 4]

So the values absolutely do not map 1:1 like the comment was indicating.
This commit is contained in:
Lioncash 2019-01-04 20:32:29 -05:00
parent 56e51da1d9
commit 9e8737b535

View file

@ -878,21 +878,19 @@ public:
private: private:
enum class ConvertedScaleMode : u64 { enum class ConvertedScaleMode : u64 {
None = 0, // VI seems to name this as "Unknown" but lots of games pass it, assume it's no Freeze = 0,
// scaling/default ScaleToWindow = 1,
Freeze = 1, ScaleAndCrop = 2,
ScaleToWindow = 2, None = 3,
Crop = 3, PreserveAspectRatio = 4,
NoCrop = 4,
}; };
// This struct is different, currently it's 1:1 but this might change in the future.
enum class NintendoScaleMode : u32 { enum class NintendoScaleMode : u32 {
None = 0, None = 0,
Freeze = 1, Freeze = 1,
ScaleToWindow = 2, ScaleToWindow = 2,
Crop = 3, ScaleAndCrop = 3,
NoCrop = 4, PreserveAspectRatio = 4,
}; };
void GetRelayService(Kernel::HLERequestContext& ctx) { void GetRelayService(Kernel::HLERequestContext& ctx) {
@ -1007,14 +1005,14 @@ private:
IPC::ResponseBuilder rb{ctx, 2}; IPC::ResponseBuilder rb{ctx, 2};
if (scaling_mode > NintendoScaleMode::NoCrop) { if (scaling_mode > NintendoScaleMode::PreserveAspectRatio) {
LOG_ERROR(Service_VI, "Invalid scaling mode provided."); LOG_ERROR(Service_VI, "Invalid scaling mode provided.");
rb.Push(ERR_OPERATION_FAILED); rb.Push(ERR_OPERATION_FAILED);
return; return;
} }
if (scaling_mode != NintendoScaleMode::ScaleToWindow && if (scaling_mode != NintendoScaleMode::ScaleToWindow &&
scaling_mode != NintendoScaleMode::NoCrop) { scaling_mode != NintendoScaleMode::PreserveAspectRatio) {
LOG_ERROR(Service_VI, "Unsupported scaling mode supplied."); LOG_ERROR(Service_VI, "Unsupported scaling mode supplied.");
rb.Push(ERR_UNSUPPORTED); rb.Push(ERR_UNSUPPORTED);
return; return;
@ -1125,10 +1123,10 @@ private:
return MakeResult(ConvertedScaleMode::Freeze); return MakeResult(ConvertedScaleMode::Freeze);
case NintendoScaleMode::ScaleToWindow: case NintendoScaleMode::ScaleToWindow:
return MakeResult(ConvertedScaleMode::ScaleToWindow); return MakeResult(ConvertedScaleMode::ScaleToWindow);
case NintendoScaleMode::Crop: case NintendoScaleMode::ScaleAndCrop:
return MakeResult(ConvertedScaleMode::Crop); return MakeResult(ConvertedScaleMode::ScaleAndCrop);
case NintendoScaleMode::NoCrop: case NintendoScaleMode::PreserveAspectRatio:
return MakeResult(ConvertedScaleMode::NoCrop); return MakeResult(ConvertedScaleMode::PreserveAspectRatio);
default: default:
return ERR_OPERATION_FAILED; return ERR_OPERATION_FAILED;
} }