summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/caps/caps_types.h
blob: 589ac28d31fd1b90aa79ef49b66273fb1a86775b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include "common/common_funcs.h"
#include "common/common_types.h"

namespace Service::Capture {

// This is nn::album::ImageOrientation
enum class AlbumImageOrientation {
    None,
    Rotate90,
    Rotate180,
    Rotate270,
};

// This is nn::album::AlbumReportOption
enum class AlbumReportOption : s32 {
    Disable,
    Enable,
    Unknown2,
    Unknown3,
};

enum class ContentType : u8 {
    Screenshot = 0,
    Movie = 1,
    ExtraMovie = 3,
};

enum class AlbumStorage : u8 {
    Nand,
    Sd,
};

enum class ScreenShotDecoderFlag : u64 {
    None = 0,
    EnableFancyUpsampling = 1 << 0,
    EnableBlockSmoothing = 1 << 1,
};

// This is nn::capsrv::AlbumFileDateTime
struct AlbumFileDateTime {
    s16 year{};
    s8 month{};
    s8 day{};
    s8 hour{};
    s8 minute{};
    s8 second{};
    s8 unique_id{};

    friend constexpr bool operator==(const AlbumFileDateTime&, const AlbumFileDateTime&) = default;
    friend constexpr bool operator>(const AlbumFileDateTime& a, const AlbumFileDateTime& b) {
        if (a.year > b.year) {
            return true;
        }
        if (a.month > b.month) {
            return true;
        }
        if (a.day > b.day) {
            return true;
        }
        if (a.hour > b.hour) {
            return true;
        }
        if (a.minute > b.minute) {
            return true;
        }
        return a.second > b.second;
    };
    friend constexpr bool operator<(const AlbumFileDateTime& a, const AlbumFileDateTime& b) {
        if (a.year < b.year) {
            return true;
        }
        if (a.month < b.month) {
            return true;
        }
        if (a.day < b.day) {
            return true;
        }
        if (a.hour < b.hour) {
            return true;
        }
        if (a.minute < b.minute) {
            return true;
        }
        return a.second < b.second;
    };
};
static_assert(sizeof(AlbumFileDateTime) == 0x8, "AlbumFileDateTime has incorrect size.");

// This is nn::album::AlbumEntry
struct AlbumFileEntry {
    u64 size{}; // Size of the entry
    u64 hash{}; // AES256 with hardcoded key over AlbumEntry
    AlbumFileDateTime datetime{};
    AlbumStorage storage{};
    ContentType content{};
    INSERT_PADDING_BYTES(5);
    u8 unknown{}; // Set to 1 on official SW
};
static_assert(sizeof(AlbumFileEntry) == 0x20, "AlbumFileEntry has incorrect size.");

struct AlbumFileId {
    u64 application_id{};
    AlbumFileDateTime date{};
    AlbumStorage storage{};
    ContentType type{};
    INSERT_PADDING_BYTES(0x5);
    u8 unknown{};

    friend constexpr bool operator==(const AlbumFileId&, const AlbumFileId&) = default;
};
static_assert(sizeof(AlbumFileId) == 0x18, "AlbumFileId is an invalid size");

// This is nn::capsrv::AlbumEntry
struct AlbumEntry {
    u64 entry_size{};
    AlbumFileId file_id{};
};
static_assert(sizeof(AlbumEntry) == 0x20, "AlbumEntry has incorrect size.");

// This is nn::capsrv::ApplicationAlbumEntry
struct ApplicationAlbumEntry {
    u64 size{}; // Size of the entry
    u64 hash{}; // AES256 with hardcoded key over AlbumEntry
    AlbumFileDateTime datetime{};
    AlbumStorage storage{};
    ContentType content{};
    INSERT_PADDING_BYTES(5);
    u8 unknown{1}; // Set to 1 on official SW
};
static_assert(sizeof(ApplicationAlbumEntry) == 0x20, "ApplicationAlbumEntry has incorrect size.");

// This is nn::capsrv::ApplicationAlbumFileEntry
struct ApplicationAlbumFileEntry {
    ApplicationAlbumEntry entry{};
    AlbumFileDateTime datetime{};
    u64 unknown{};
};
static_assert(sizeof(ApplicationAlbumFileEntry) == 0x30,
              "ApplicationAlbumFileEntry has incorrect size.");

struct ApplicationData {
    std::array<u8, 0x400> data{};
    u32 data_size{};
};
static_assert(sizeof(ApplicationData) == 0x404, "ApplicationData is an invalid size");

struct ScreenShotAttribute {
    u32 unknown_0{};
    AlbumImageOrientation orientation{};
    u32 unknown_1{};
    u32 unknown_2{};
    INSERT_PADDING_BYTES(0x30);
};
static_assert(sizeof(ScreenShotAttribute) == 0x40, "ScreenShotAttribute is an invalid size");

struct ScreenShotDecodeOption {
    ScreenShotDecoderFlag flags{};
    INSERT_PADDING_BYTES(0x18);
};
static_assert(sizeof(ScreenShotDecodeOption) == 0x20, "ScreenShotDecodeOption is an invalid size");

struct LoadAlbumScreenShotImageOutput {
    s64 width{};
    s64 height{};
    ScreenShotAttribute attribute{};
    INSERT_PADDING_BYTES(0x400);
};
static_assert(sizeof(LoadAlbumScreenShotImageOutput) == 0x450,
              "LoadAlbumScreenShotImageOutput is an invalid size");

struct LoadAlbumScreenShotImageOutputForApplication {
    s64 width{};
    s64 height{};
    ScreenShotAttribute attribute{};
    ApplicationData data{};
    INSERT_PADDING_BYTES(0xAC);
};
static_assert(sizeof(LoadAlbumScreenShotImageOutputForApplication) == 0x500,
              "LoadAlbumScreenShotImageOutput is an invalid size");

} // namespace Service::Capture