libnx  v4.8.0
caps.h
Go to the documentation of this file.
1 /**
2  * @file caps.h
3  * @brief Common caps (caps:*) service IPC header.
4  * @author yellows8
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../services/acc.h"
10 
11 /// ImageOrientation
12 typedef enum {
13  AlbumImageOrientation_Unknown0 = 0, ///< Unknown. Default.
14  AlbumImageOrientation_Unknown1 = 1, ///< Unknown.
15  AlbumImageOrientation_Unknown2 = 2, ///< Unknown.
16  AlbumImageOrientation_Unknown3 = 3, ///< Unknown.
18 
19 /// AlbumReportOption
20 typedef enum {
21  AlbumReportOption_Disable = 0, ///< Don't display the screenshot-taken Overlay-applet notification.
22  AlbumReportOption_Enable = 1, ///< Display the screenshot-taken Overlay notification.
24 
25 typedef enum {
26  CapsAlbumStorage_Nand = 0, ///< Nand
27  CapsAlbumStorage_Sd = 1, ///< Sd
29 
30 /// ContentType
31 typedef enum {
32  CapsContentType_Screenshot = 0, ///< Album screenshots.
33  CapsContentType_Movie = 1, ///< Album videos.
34  CapsContentType_ExtraMovie = 3, ///< Videos recorded by the current host Application via \ref grcCreateMovieMaker.
36 
37 /// ScreenShotAttribute
38 typedef struct {
39  u32 unk_x0; ///< Always set to 0 by official sw.
40  u32 orientation; ///< \ref AlbumImageOrientation
41  u32 unk_x8; ///< Always set to 0 by official sw.
42  u32 unk_xc; ///< Always set to 1 by official sw.
43  u8 unk_x10[0x30]; ///< Always set to 0 by official sw.
45 
46 /// ScreenShotAttributeForApplication. Only unk_x0 is used by official sw.
47 typedef struct {
48  u32 unk_x0; ///< Unknown.
49  u8 unk_x4; ///< Unknown.
50  u8 unk_x5; ///< Unknown.
51  u8 unk_x6; ///< Unknown.
52  u8 pad; ///< Padding.
53  u32 unk_x8; ///< Unknown.
54  u32 unk_xc; ///< Unknown.
55  u32 unk_x10; ///< Unknown.
56  u32 unk_x14; ///< Unknown.
57  u32 unk_x18; ///< Unknown.
58  u32 unk_x1c; ///< Unknown.
59  u16 unk_x20; ///< Unknown.
60  u16 unk_x22; ///< Unknown.
61  u16 unk_x24; ///< Unknown.
62  u16 unk_x26; ///< Unknown.
63  u8 reserved[0x18]; ///< Always zero.
65 
66 /// ScreenShotDecoderFlag
67 typedef enum {
68  CapsScreenShotDecoderFlag_None = 0, ///< No special processing.
69  CapsScreenShotDecoderFlag_EnableFancyUpsampling = BIT(0), ///< See libjpeg-turbo do_fancy_upsampling.
70  CapsScreenShotDecoderFlag_EnableBlockSmoothing = BIT(1), ///< See libjpeg-turbo do_block_smoothing.
72 
73 /// ScreenShotDecodeOption
74 typedef struct {
75  u64 flags; ///< Bitflags, see \ref CapsScreenShotDecoderFlag.
76  u64 reserved[0x3]; ///< Reserved. Unused by official sw.
78 
79 /// AlbumFileDateTime. This corresponds to each field in the Album entry filename, prior to the "-": "YYYYMMDDHHMMSSII".
80 typedef struct {
81  u16 year; ///< Year.
82  u8 month; ///< Month.
83  u8 day; ///< Day of the month.
84  u8 hour; ///< Hour.
85  u8 minute; ///< Minute.
86  u8 second; ///< Second.
87  u8 id; ///< Unique ID for when there's multiple Album files with the same timestamp.
89 
90 /// AlbumEntryId
91 typedef struct {
92  u64 application_id; ///< ApplicationId
93  CapsAlbumFileDateTime datetime; ///< \ref CapsAlbumFileDateTime
94  u8 storage; ///< \ref CapsAlbumStorage
95  u8 content; ///< \ref CapsAlbumFileContents
96  u8 unknown_12; ///< [19.0.0+]
97  u8 unknown_13; ///< [19.0.0+]
98  u8 pad_x14[0x4]; ///< padding
100 
101 /// AlbumEntry
102 typedef struct {
103  u64 size; ///< Size.
104  CapsAlbumFileId file_id; ///< \ref CapsAlbumFileId
106 
107 /// ApplicationAlbumEntry
108 typedef struct {
109  union {
110  u8 data[0x20]; ///< Data.
111 
112  struct {
113  u8 unk_x0[0x20]; ///< aes256 with random key over \ref AlbumEntry.
114  } v0; ///< Pre-7.0.0
115 
116  struct {
117  u64 size; ///< size of the entry
118  u64 hash; ///< aes256 with hardcoded key over \ref AlbumEntry.
119  CapsAlbumFileDateTime datetime; ///< \ref CapsAlbumFileDateTime
120  u8 storage; ///< \ref CapsAlbumStorage
121  u8 content; ///< \ref CapsAlbumFileContents
122  u8 pad_x1a[0x5]; ///< padding
123  u8 unk_x1f; ///< Set to 1 by official software
124  } v1; ///< [7.0.0+]
125  };
127 
128 /// ApplicationAlbumFileEntry
129 typedef struct {
130  CapsApplicationAlbumEntry entry; ///< \ref CapsApplicationAlbumEntry
131  CapsAlbumFileDateTime datetime; ///< \ref CapsAlbumFileDateTime
132  u64 unk_x28; ///< Unknown.
134 
135 /// ApplicationData
136 typedef struct {
137  u8 userdata[0x400]; ///< UserData.
138  u32 size; ///< UserData size.
140 
141 /// AlbumFileContents
142 typedef enum {
143  CapsAlbumFileContents_ScreenShot = 0,
144  CapsAlbumFileContents_Movie = 1,
145  CapsAlbumFileContents_ExtraScreenShot = 2,
146  CapsAlbumFileContents_ExtraMovie = 3,
148 
149 typedef enum {
150  CapsAlbumContentsUsageFlag_HasGreaterUsage = BIT(0), ///< Indicates that there are additional files not captured by the count/size fields of CapsAlbumContentsUsage
151  CapsAlbumContentsUsageFlag_IsUnknownContents = BIT(1), ///< Indicates that the file is not a known content type
153 
154 typedef struct {
155  s64 count; ///< Count.
156  s64 size; ///< Size. Used storage space.
157  u32 flags; ///< \ref CapsAlbumContentsUsageFlag
158  u8 file_contents; ///< \ref CapsAlbumFileContents
159  u8 pad_x15[0x3]; ///< Unused
161 
162 typedef struct {
163  CapsAlbumContentsUsage usages[2]; ///< \ref CapsAlbumContentsUsage
165 
166 typedef struct {
167  CapsAlbumContentsUsage usages[3]; ///< \ref CapsAlbumContentsUsage
169 
170 typedef struct {
171  CapsAlbumContentsUsage usages[16]; ///< \ref CapsAlbumContentsUsage
173 
174 /// UserIdList
175 typedef struct {
176  AccountUid uids[ACC_USER_LIST_SIZE]; ///< \ref AccountUid
177  u8 count; ///< Total userIDs.
178  u8 pad[7]; ///< Padding.
180 
181 /// LoadAlbumScreenShotImageOutputForApplication
182 typedef struct {
183  s64 width; ///< Width. Official sw copies this to a s32 output field.
184  s64 height; ///< Height. Official sw copies this to a s32 output field.
185  CapsScreenShotAttributeForApplication attr; ///< \ref CapsScreenShotAttributeForApplication
186  CapsApplicationData appdata; ///< \ref CapsApplicationData
187  u8 reserved[0xac]; ///< Unused.
189 
190 /// LoadAlbumScreenShotImageOutput
191 typedef struct {
192  s64 width; ///< Width. Official sw copies this to a s32 output field.
193  s64 height; ///< Height. Official sw copies this to a s32 output field.
194  CapsScreenShotAttribute attr; ///< \ref CapsScreenShotAttribute
195  u8 unk_x50[0x400]; ///< Unused.
197 
198 /// AlbumFileContentsFlag
199 typedef enum {
200  CapsAlbumFileContentsFlag_ScreenShot = BIT(0), ///< Query for ScreenShot files.
201  CapsAlbumFileContentsFlag_Movie = BIT(1), ///< Query for Movie files.
203 
204 /// AlbumCache
205 typedef struct {
206  u64 count; ///< Count
207  u64 unk_x8; ///< Unknown
209 
210 /// Gets the ShimLibraryVersion.
212 
213 /// Gets the default start_datetime.
215  return (CapsAlbumFileDateTime){.year = 1970, .month = 1, .day = 1};
216 }
217 
218 /// Gets the default end_datetime.
220  return (CapsAlbumFileDateTime){.year = 3000, .month = 1, .day = 1};
221 }
222 
223 /// Convert a \ref CapsApplicationAlbumFileEntry to \ref CapsApplicationAlbumEntry.
225  *out = in->entry;
226 }
227 
228 /// Convert a \ref CapsApplicationAlbumEntry to \ref CapsApplicationAlbumFileEntry. Should only be used on [7.0.0+].
230  out->entry = *in;
231  out->datetime = in->v1.datetime;
232  out->unk_x28 = 0;
233 }
234 
static void capsConvertApplicationAlbumEntryToApplicationAlbumFileEntry(CapsApplicationAlbumFileEntry *out, CapsApplicationAlbumEntry *in)
Convert a CapsApplicationAlbumEntry to CapsApplicationAlbumFileEntry. Should only be used on [7....
Definition: caps.h:229
CapsScreenShotDecoderFlag
ScreenShotDecoderFlag.
Definition: caps.h:67
@ CapsScreenShotDecoderFlag_EnableFancyUpsampling
See libjpeg-turbo do_fancy_upsampling.
Definition: caps.h:69
@ CapsScreenShotDecoderFlag_None
No special processing.
Definition: caps.h:68
@ CapsScreenShotDecoderFlag_EnableBlockSmoothing
See libjpeg-turbo do_block_smoothing.
Definition: caps.h:70
static CapsAlbumFileDateTime capsGetDefaultStartDateTime(void)
Gets the default start_datetime.
Definition: caps.h:214
CapsAlbumFileContentsFlag
AlbumFileContentsFlag.
Definition: caps.h:199
@ CapsAlbumFileContentsFlag_ScreenShot
Query for ScreenShot files.
Definition: caps.h:200
@ CapsAlbumFileContentsFlag_Movie
Query for Movie files.
Definition: caps.h:201
static void capsConvertApplicationAlbumFileEntryToApplicationAlbumEntry(CapsApplicationAlbumEntry *out, CapsApplicationAlbumFileEntry *in)
Convert a CapsApplicationAlbumFileEntry to CapsApplicationAlbumEntry.
Definition: caps.h:224
CapsContentType
ContentType.
Definition: caps.h:31
@ CapsContentType_Movie
Album videos.
Definition: caps.h:33
@ CapsContentType_Screenshot
Album screenshots.
Definition: caps.h:32
@ CapsContentType_ExtraMovie
Videos recorded by the current host Application via grcCreateMovieMaker.
Definition: caps.h:34
CapsAlbumFileContents
AlbumFileContents.
Definition: caps.h:142
AlbumImageOrientation
ImageOrientation.
Definition: caps.h:12
@ AlbumImageOrientation_Unknown2
Unknown.
Definition: caps.h:15
@ AlbumImageOrientation_Unknown3
Unknown.
Definition: caps.h:16
@ AlbumImageOrientation_Unknown1
Unknown.
Definition: caps.h:14
@ AlbumImageOrientation_Unknown0
Unknown. Default.
Definition: caps.h:13
CapsAlbumStorage
Definition: caps.h:25
@ CapsAlbumStorage_Sd
Sd.
Definition: caps.h:27
@ CapsAlbumStorage_Nand
Nand.
Definition: caps.h:26
AlbumReportOption
AlbumReportOption.
Definition: caps.h:20
@ AlbumReportOption_Disable
Don't display the screenshot-taken Overlay-applet notification.
Definition: caps.h:21
@ AlbumReportOption_Enable
Display the screenshot-taken Overlay notification.
Definition: caps.h:22
CapsAlbumContentsUsageFlag
Definition: caps.h:149
@ CapsAlbumContentsUsageFlag_HasGreaterUsage
Indicates that there are additional files not captured by the count/size fields of CapsAlbumContentsU...
Definition: caps.h:150
@ CapsAlbumContentsUsageFlag_IsUnknownContents
Indicates that the file is not a known content type.
Definition: caps.h:151
static CapsAlbumFileDateTime capsGetDefaultEndDateTime(void)
Gets the default end_datetime.
Definition: caps.h:219
u64 capsGetShimLibraryVersion(void)
Gets the ShimLibraryVersion.
Account UserId.
Definition: acc.h:25
AlbumCache.
Definition: caps.h:205
u64 count
Count.
Definition: caps.h:206
u64 unk_x8
Unknown.
Definition: caps.h:207
Definition: caps.h:154
s64 size
Size. Used storage space.
Definition: caps.h:156
s64 count
Count.
Definition: caps.h:155
u32 flags
CapsAlbumContentsUsageFlag
Definition: caps.h:157
u8 file_contents
CapsAlbumFileContents
Definition: caps.h:158
AlbumEntry.
Definition: caps.h:102
u64 size
Size.
Definition: caps.h:103
CapsAlbumFileId file_id
CapsAlbumFileId
Definition: caps.h:104
AlbumFileDateTime. This corresponds to each field in the Album entry filename, prior to the "-": "YYY...
Definition: caps.h:80
u8 minute
Minute.
Definition: caps.h:85
u8 month
Month.
Definition: caps.h:82
u8 second
Second.
Definition: caps.h:86
u8 hour
Hour.
Definition: caps.h:84
u16 year
Year.
Definition: caps.h:81
u8 id
Unique ID for when there's multiple Album files with the same timestamp.
Definition: caps.h:87
u8 day
Day of the month.
Definition: caps.h:83
AlbumEntryId.
Definition: caps.h:91
u8 unknown_13
[19.0.0+]
Definition: caps.h:97
u64 application_id
ApplicationId.
Definition: caps.h:92
u8 content
CapsAlbumFileContents
Definition: caps.h:95
u8 storage
CapsAlbumStorage
Definition: caps.h:94
u8 unknown_12
[19.0.0+]
Definition: caps.h:96
CapsAlbumFileDateTime datetime
CapsAlbumFileDateTime
Definition: caps.h:93
Definition: caps.h:170
Definition: caps.h:162
Definition: caps.h:166
ApplicationAlbumEntry.
Definition: caps.h:108
u8 storage
CapsAlbumStorage
Definition: caps.h:120
u8 content
CapsAlbumFileContents
Definition: caps.h:121
u8 unk_x1f
Set to 1 by official software.
Definition: caps.h:123
u64 hash
aes256 with hardcoded key over AlbumEntry.
Definition: caps.h:118
CapsAlbumFileDateTime datetime
CapsAlbumFileDateTime
Definition: caps.h:119
struct CapsApplicationAlbumEntry::@130::@133 v1
[7.0.0+]
u64 size
size of the entry
Definition: caps.h:117
ApplicationAlbumFileEntry.
Definition: caps.h:129
CapsApplicationAlbumEntry entry
CapsApplicationAlbumEntry
Definition: caps.h:130
u64 unk_x28
Unknown.
Definition: caps.h:132
CapsAlbumFileDateTime datetime
CapsAlbumFileDateTime
Definition: caps.h:131
ApplicationData.
Definition: caps.h:136
u32 size
UserData size.
Definition: caps.h:138
LoadAlbumScreenShotImageOutputForApplication.
Definition: caps.h:182
CapsScreenShotAttributeForApplication attr
CapsScreenShotAttributeForApplication
Definition: caps.h:185
s64 width
Width. Official sw copies this to a s32 output field.
Definition: caps.h:183
s64 height
Height. Official sw copies this to a s32 output field.
Definition: caps.h:184
CapsApplicationData appdata
CapsApplicationData
Definition: caps.h:186
LoadAlbumScreenShotImageOutput.
Definition: caps.h:191
s64 width
Width. Official sw copies this to a s32 output field.
Definition: caps.h:192
CapsScreenShotAttribute attr
CapsScreenShotAttribute
Definition: caps.h:194
s64 height
Height. Official sw copies this to a s32 output field.
Definition: caps.h:193
ScreenShotAttributeForApplication. Only unk_x0 is used by official sw.
Definition: caps.h:47
u32 unk_xc
Unknown.
Definition: caps.h:54
u32 unk_x18
Unknown.
Definition: caps.h:57
u32 unk_x14
Unknown.
Definition: caps.h:56
u32 unk_x10
Unknown.
Definition: caps.h:55
u16 unk_x24
Unknown.
Definition: caps.h:61
u32 unk_x0
Unknown.
Definition: caps.h:48
u16 unk_x22
Unknown.
Definition: caps.h:60
u8 unk_x5
Unknown.
Definition: caps.h:50
u32 unk_x8
Unknown.
Definition: caps.h:53
u16 unk_x20
Unknown.
Definition: caps.h:59
u32 unk_x1c
Unknown.
Definition: caps.h:58
u16 unk_x26
Unknown.
Definition: caps.h:62
u8 pad
Padding.
Definition: caps.h:52
u8 unk_x6
Unknown.
Definition: caps.h:51
u8 unk_x4
Unknown.
Definition: caps.h:49
ScreenShotAttribute.
Definition: caps.h:38
u32 unk_x0
Always set to 0 by official sw.
Definition: caps.h:39
u32 unk_xc
Always set to 1 by official sw.
Definition: caps.h:42
u32 orientation
AlbumImageOrientation
Definition: caps.h:40
u32 unk_x8
Always set to 0 by official sw.
Definition: caps.h:41
ScreenShotDecodeOption.
Definition: caps.h:74
u64 flags
Bitflags, see CapsScreenShotDecoderFlag.
Definition: caps.h:75
UserIdList.
Definition: caps.h:175
u8 count
Total userIDs.
Definition: caps.h:177
int64_t s64
64-bit signed integer.
Definition: types.h:28
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:54
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
uint16_t u16
16-bit unsigned integer.
Definition: types.h:20
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21