libnx  v4.6.0
vi.h
Go to the documentation of this file.
1 /**
2  * @file vi.h
3  * @brief Display (vi:*) service IPC wrapper.
4  * @author yellows8
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../kernel/event.h"
10 #include "../sf/service.h"
11 #include "pl.h"
12 
13 typedef struct {
14  char data[0x40];
16 
17 typedef struct {
18  u64 display_id;
19  ViDisplayName display_name;
20  bool initialized;
21 } ViDisplay;
22 
23 typedef struct {
24  u64 layer_id;
25  u32 igbp_binder_obj_id;
26  bool initialized : 1;
27  bool stray_layer : 1;
28 } ViLayer;
29 
30 typedef enum {
31  ViServiceType_Default = -1,
32  ViServiceType_Application = 0,
33  ViServiceType_System = 1,
34  ViServiceType_Manager = 2,
35 } ViServiceType;
36 
37 /// Used by viCreateLayer when CreateStrayLayer is used internally.
38 typedef enum {
39  ViLayerFlags_Default = 0x1,
40 } ViLayerFlags;
41 
42 /// Used with viSetLayerScalingMode.
43 typedef enum {
44  ViScalingMode_None = 0x0,
45  ViScalingMode_FitToLayer = 0x2,
46  ViScalingMode_PreserveAspectRatio = 0x4,
47 
48  ViScalingMode_Default = ViScalingMode_FitToLayer,
50 
51 /// Used with viSetDisplayPowerState.
52 typedef enum {
53  ViPowerState_Off = 0, ///< Screen is off.
54  ViPowerState_NotScanning = 1, ///< [3.0.0+] Screen is on, but not scanning content.
55  ViPowerState_On = 2, ///< [3.0.0+] Screen is on.
56 
57  ViPowerState_On_Deprecated = 1, ///< [1.0.0 - 2.3.0] Screen is on.
58 } ViPowerState;
59 
60 /// Used as argument to many capture functions.
61 typedef enum {
62  ViLayerStack_Default = 0, ///< Default layer stack, includes all layers.
63  ViLayerStack_Lcd = 1, ///< Includes only layers for the LCD.
64  ViLayerStack_Screenshot = 2, ///< Includes only layers for user screenshots.
65  ViLayerStack_Recording = 3, ///< Includes only layers for recording videos.
66  ViLayerStack_LastFrame = 4, ///< Includes only layers for the last applet-transition frame.
67  ViLayerStack_Arbitrary = 5, ///< Captures some arbitrary layer. This is normally only for am.
68  ViLayerStack_ApplicationForDebug = 6, ///< Captures layers for the current application. This is normally used by creport/debugging tools.
69  ViLayerStack_Null = 10, ///< Layer stack for the empty display.
70 } ViLayerStack;
71 
72 /// Used as argument for certain drawing commands.
74 typedef u32 ViColorRgba8888;
75 
76 Result viInitialize(ViServiceType service_type);
77 void viExit(void);
78 
79 Service* viGetSession_IApplicationDisplayService(void);
80 Service* viGetSession_IHOSBinderDriverRelay(void);
81 Service* viGetSession_ISystemDisplayService(void);
82 Service* viGetSession_IManagerDisplayService(void);
83 Service* viGetSession_IHOSBinderDriverIndirect(void);
84 
85 // Misc functions
86 Result viSetContentVisibility(bool v);
87 
88 // Display functions
89 
90 Result viOpenDisplay(const char *display_name, ViDisplay *display);
91 Result viCloseDisplay(ViDisplay *display);
92 
93 static inline Result viOpenDefaultDisplay(ViDisplay *display)
94 {
95  return viOpenDisplay("Default", display);
96 }
97 
98 Result viGetDisplayResolution(ViDisplay *display, s32 *width, s32 *height);
99 Result viGetDisplayLogicalResolution(ViDisplay *display, s32 *width, s32 *height);
100 /// Only available on [3.0.0+].
101 Result viSetDisplayMagnification(ViDisplay *display, s32 x, s32 y, s32 width, s32 height);
102 Result viGetDisplayVsyncEvent(ViDisplay *display, Event *event_out);
103 Result viSetDisplayPowerState(ViDisplay *display, ViPowerState state);
104 Result viSetDisplayAlpha(ViDisplay *display, float alpha);
105 Result viGetZOrderCountMin(ViDisplay *display, s32 *z);
106 Result viGetZOrderCountMax(ViDisplay *display, s32 *z);
107 
108 // Layer functions
109 
110 Result viCreateLayer(const ViDisplay *display, ViLayer *layer);
111 Result viCreateManagedLayer(const ViDisplay *display, ViLayerFlags layer_flags, u64 aruid, u64 *layer_id);
112 Result viSetLayerSize(ViLayer *layer, s32 width, s32 height);
113 Result viSetLayerZ(ViLayer *layer, s32 z);
114 Result viSetLayerPosition(ViLayer *layer, float x, float y);
115 Result viCloseLayer(ViLayer *layer);
116 Result viDestroyManagedLayer(ViLayer *layer);
117 
118 Result viSetLayerScalingMode(ViLayer *layer, ViScalingMode scaling_mode);
119 
120 // IndirectLayer functions
121 
122 Result viGetIndirectLayerImageMap(void* buffer, size_t size, s32 width, s32 height, u64 IndirectLayerConsumerHandle, u64 *out_size, u64 *out_stride);
123 Result viGetIndirectLayerImageRequiredMemoryInfo(s32 width, s32 height, u64 *out_size, u64 *out_alignment);
124 
125 // Manager functions
126 Result viManagerPrepareFatal(void); ///< [16.0.0+]
127 Result viManagerShowFatal(void); ///< [16.0.0+]
128 Result viManagerDrawFatalRectangle(s32 x, s32 y, s32 end_x, s32 end_y, ViColorRgba4444 color); ///< [16.0.0+]
129 Result viManagerDrawFatalText32(s32 *out_advance, s32 x, s32 y, const u32 *utf32_codepoints, size_t num_codepoints, float scale_x, float scale_y, PlSharedFontType font_type, ViColorRgba8888 bg_color, ViColorRgba8888 fg_color, s32 initial_advance); ///< [16.0.0+]
pl:u service IPC wrapper.
PlSharedFontType
SharedFontType.
Definition: pl.h:17
Kernel-mode event structure.
Definition: event.h:13
Service object structure.
Definition: service.h:14
Definition: vi.h:13
Definition: vi.h:17
Definition: vi.h:23
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
uint16_t u16
16-bit unsigned integer.
Definition: types.h:20
u32 Result
Function error code result type.
Definition: types.h:44
int32_t s32
32-bit signed integer.
Definition: types.h:27
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21
Result viManagerPrepareFatal(void)
[16.0.0+]
ViLayerFlags
Used by viCreateLayer when CreateStrayLayer is used internally.
Definition: vi.h:38
ViScalingMode
Used with viSetLayerScalingMode.
Definition: vi.h:43
Result viManagerShowFatal(void)
[16.0.0+]
Result viSetDisplayMagnification(ViDisplay *display, s32 x, s32 y, s32 width, s32 height)
Only available on [3.0.0+].
u16 ViColorRgba4444
Used as argument for certain drawing commands.
Definition: vi.h:73
Result viManagerDrawFatalText32(s32 *out_advance, s32 x, s32 y, const u32 *utf32_codepoints, size_t num_codepoints, float scale_x, float scale_y, PlSharedFontType font_type, ViColorRgba8888 bg_color, ViColorRgba8888 fg_color, s32 initial_advance)
[16.0.0+]
ViLayerStack
Used as argument to many capture functions.
Definition: vi.h:61
@ ViLayerStack_Recording
Includes only layers for recording videos.
Definition: vi.h:65
@ ViLayerStack_Default
Default layer stack, includes all layers.
Definition: vi.h:62
@ ViLayerStack_Lcd
Includes only layers for the LCD.
Definition: vi.h:63
@ ViLayerStack_Screenshot
Includes only layers for user screenshots.
Definition: vi.h:64
@ ViLayerStack_Arbitrary
Captures some arbitrary layer. This is normally only for am.
Definition: vi.h:67
@ ViLayerStack_Null
Layer stack for the empty display.
Definition: vi.h:69
@ ViLayerStack_ApplicationForDebug
Captures layers for the current application. This is normally used by creport/debugging tools.
Definition: vi.h:68
@ ViLayerStack_LastFrame
Includes only layers for the last applet-transition frame.
Definition: vi.h:66
ViPowerState
Used with viSetDisplayPowerState.
Definition: vi.h:52
@ ViPowerState_On_Deprecated
[1.0.0 - 2.3.0] Screen is on.
Definition: vi.h:57
@ ViPowerState_Off
Screen is off.
Definition: vi.h:53
@ ViPowerState_On
[3.0.0+] Screen is on.
Definition: vi.h:55
@ ViPowerState_NotScanning
[3.0.0+] Screen is on, but not scanning content.
Definition: vi.h:54
Result viManagerDrawFatalRectangle(s32 x, s32 y, s32 end_x, s32 end_y, ViColorRgba4444 color)
[16.0.0+]