libnx  v4.7.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 pad_x12[0x6]; ///< padding
98 
99 /// AlbumEntry
100 typedef struct {
101  u64 size; ///< Size.
102  CapsAlbumFileId file_id; ///< \ref CapsAlbumFileId
104 
105 /// ApplicationAlbumEntry
106 typedef struct {
107  union {
108  u8 data[0x20]; ///< Data.
109 
110  struct {
111  u8 unk_x0[0x20]; ///< aes256 with random key over \ref AlbumEntry.
112  } v0; ///< Pre-7.0.0
113 
114  struct {
115  u64 size; ///< size of the entry
116  u64 hash; ///< aes256 with hardcoded key over \ref AlbumEntry.
117  CapsAlbumFileDateTime datetime; ///< \ref CapsAlbumFileDateTime
118  u8 storage; ///< \ref CapsAlbumStorage
119  u8 content; ///< \ref CapsAlbumFileContents
120  u8 pad_x1a[0x5]; ///< padding
121  u8 unk_x1f; ///< Set to 1 by official software
122  } v1; ///< [7.0.0+]
123  };
125 
126 /// ApplicationAlbumFileEntry
127 typedef struct {
128  CapsApplicationAlbumEntry entry; ///< \ref CapsApplicationAlbumEntry
129  CapsAlbumFileDateTime datetime; ///< \ref CapsAlbumFileDateTime
130  u64 unk_x28; ///< Unknown.
132 
133 /// ApplicationData
134 typedef struct {
135  u8 userdata[0x400]; ///< UserData.
136  u32 size; ///< UserData size.
138 
139 /// AlbumFileContents
140 typedef enum {
141  CapsAlbumFileContents_ScreenShot = 0,
142  CapsAlbumFileContents_Movie = 1,
143  CapsAlbumFileContents_ExtraScreenShot = 2,
144  CapsAlbumFileContents_ExtraMovie = 3,
146 
147 typedef enum {
148  CapsAlbumContentsUsageFlag_HasGreaterUsage = BIT(0), ///< Indicates that there are additional files not captured by the count/size fields of CapsAlbumContentsUsage
149  CapsAlbumContentsUsageFlag_IsUnknownContents = BIT(1), ///< Indicates that the file is not a known content type
151 
152 typedef struct {
153  s64 count; ///< Count.
154  s64 size; ///< Size. Used storage space.
155  u32 flags; ///< \ref CapsAlbumContentsUsageFlag
156  u8 file_contents; ///< \ref CapsAlbumFileContents
157  u8 pad_x15[0x3]; ///< Unused
159 
160 typedef struct {
161  CapsAlbumContentsUsage usages[2]; ///< \ref CapsAlbumContentsUsage
163 
164 typedef struct {
165  CapsAlbumContentsUsage usages[3]; ///< \ref CapsAlbumContentsUsage
167 
168 typedef struct {
169  CapsAlbumContentsUsage usages[16]; ///< \ref CapsAlbumContentsUsage
171 
172 /// UserIdList
173 typedef struct {
174  AccountUid uids[ACC_USER_LIST_SIZE]; ///< \ref AccountUid
175  u8 count; ///< Total userIDs.
176  u8 pad[7]; ///< Padding.
178 
179 /// LoadAlbumScreenShotImageOutputForApplication
180 typedef struct {
181  s64 width; ///< Width. Official sw copies this to a s32 output field.
182  s64 height; ///< Height. Official sw copies this to a s32 output field.
183  CapsScreenShotAttributeForApplication attr; ///< \ref CapsScreenShotAttributeForApplication
184  CapsApplicationData appdata; ///< \ref CapsApplicationData
185  u8 reserved[0xac]; ///< Unused.
187 
188 /// LoadAlbumScreenShotImageOutput
189 typedef struct {
190  s64 width; ///< Width. Official sw copies this to a s32 output field.
191  s64 height; ///< Height. Official sw copies this to a s32 output field.
192  CapsScreenShotAttribute attr; ///< \ref CapsScreenShotAttribute
193  u8 unk_x50[0x400]; ///< Unused.
195 
196 /// AlbumFileContentsFlag
197 typedef enum {
198  CapsAlbumFileContentsFlag_ScreenShot = BIT(0), ///< Query for ScreenShot files.
199  CapsAlbumFileContentsFlag_Movie = BIT(1), ///< Query for Movie files.
201 
202 /// AlbumCache
203 typedef struct {
204  u64 count; ///< Count
205  u64 unk_x8; ///< Unknown
207 
208 /// Gets the ShimLibraryVersion.
210 
211 /// Gets the default start_datetime.
213  return (CapsAlbumFileDateTime){.year = 1970, .month = 1, .day = 1};
214 }
215 
216 /// Gets the default end_datetime.
218  return (CapsAlbumFileDateTime){.year = 3000, .month = 1, .day = 1};
219 }
220 
221 /// Convert a \ref CapsApplicationAlbumFileEntry to \ref CapsApplicationAlbumEntry.
223  *out = in->entry;
224 }
225 
226 /// Convert a \ref CapsApplicationAlbumEntry to \ref CapsApplicationAlbumFileEntry. Should only be used on [7.0.0+].
228  out->entry = *in;
229  out->datetime = in->v1.datetime;
230  out->unk_x28 = 0;
231 }
232 
static void capsConvertApplicationAlbumEntryToApplicationAlbumFileEntry(CapsApplicationAlbumFileEntry *out, CapsApplicationAlbumEntry *in)
Convert a CapsApplicationAlbumEntry to CapsApplicationAlbumFileEntry. Should only be used on [7....
Definition: caps.h:227
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:212
CapsAlbumFileContentsFlag
AlbumFileContentsFlag.
Definition: caps.h:197
@ CapsAlbumFileContentsFlag_ScreenShot
Query for ScreenShot files.
Definition: caps.h:198
@ CapsAlbumFileContentsFlag_Movie
Query for Movie files.
Definition: caps.h:199
static void capsConvertApplicationAlbumFileEntryToApplicationAlbumEntry(CapsApplicationAlbumEntry *out, CapsApplicationAlbumFileEntry *in)
Convert a CapsApplicationAlbumFileEntry to CapsApplicationAlbumEntry.
Definition: caps.h:222
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:140
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:147
@ CapsAlbumContentsUsageFlag_HasGreaterUsage
Indicates that there are additional files not captured by the count/size fields of CapsAlbumContentsU...
Definition: caps.h:148
@ CapsAlbumContentsUsageFlag_IsUnknownContents
Indicates that the file is not a known content type.
Definition: caps.h:149
static CapsAlbumFileDateTime capsGetDefaultEndDateTime(void)
Gets the default end_datetime.
Definition: caps.h:217
u64 capsGetShimLibraryVersion(void)
Gets the ShimLibraryVersion.
Account UserId.
Definition: acc.h:25
AlbumCache.
Definition: caps.h:203
u64 count
Count.
Definition: caps.h:204
u64 unk_x8
Unknown.
Definition: caps.h:205
Definition: caps.h:152
s64 size
Size. Used storage space.
Definition: caps.h:154
s64 count
Count.
Definition: caps.h:153
u32 flags
CapsAlbumContentsUsageFlag
Definition: caps.h:155
u8 file_contents
CapsAlbumFileContents
Definition: caps.h:156
AlbumEntry.
Definition: caps.h:100
u64 size
Size.
Definition: caps.h:101
CapsAlbumFileId file_id
CapsAlbumFileId
Definition: caps.h:102
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
u64 application_id
ApplicationId.
Definition: caps.h:92
u8 content
CapsAlbumFileContents
Definition: caps.h:95
u8 storage
CapsAlbumStorage
Definition: caps.h:94
CapsAlbumFileDateTime datetime
CapsAlbumFileDateTime
Definition: caps.h:93
Definition: caps.h:168
Definition: caps.h:160
Definition: caps.h:164
ApplicationAlbumEntry.
Definition: caps.h:106
u8 storage
CapsAlbumStorage
Definition: caps.h:118
u8 content
CapsAlbumFileContents
Definition: caps.h:119
u8 unk_x1f
Set to 1 by official software.
Definition: caps.h:121
u64 hash
aes256 with hardcoded key over AlbumEntry.
Definition: caps.h:116
CapsAlbumFileDateTime datetime
CapsAlbumFileDateTime
Definition: caps.h:117
struct CapsApplicationAlbumEntry::@130::@133 v1
[7.0.0+]
u64 size
size of the entry
Definition: caps.h:115
ApplicationAlbumFileEntry.
Definition: caps.h:127
CapsApplicationAlbumEntry entry
CapsApplicationAlbumEntry
Definition: caps.h:128
u64 unk_x28
Unknown.
Definition: caps.h:130
CapsAlbumFileDateTime datetime
CapsAlbumFileDateTime
Definition: caps.h:129
ApplicationData.
Definition: caps.h:134
u32 size
UserData size.
Definition: caps.h:136
LoadAlbumScreenShotImageOutputForApplication.
Definition: caps.h:180
CapsScreenShotAttributeForApplication attr
CapsScreenShotAttributeForApplication
Definition: caps.h:183
s64 width
Width. Official sw copies this to a s32 output field.
Definition: caps.h:181
s64 height
Height. Official sw copies this to a s32 output field.
Definition: caps.h:182
CapsApplicationData appdata
CapsApplicationData
Definition: caps.h:184
LoadAlbumScreenShotImageOutput.
Definition: caps.h:189
s64 width
Width. Official sw copies this to a s32 output field.
Definition: caps.h:190
CapsScreenShotAttribute attr
CapsScreenShotAttribute
Definition: caps.h:192
s64 height
Height. Official sw copies this to a s32 output field.
Definition: caps.h:191
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:173
u8 count
Total userIDs.
Definition: caps.h:175
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