WOWCube Docs logo
WOWCube Docs
Mission Control
Section Shortcuts
APIExamplesSourceWOWConnectChangelog
Filters
SDK and language defaults persist in cookies.
SDK version
Navigation Tree
Collapsed by default, focused on the active path.
Made byMcKay Seamons
GitHub
  1. Home
  2. Docs
  3. Source
  4. native.h
Mission NodeSDK 6.1C++native.h

native.h

SDK Source File: native.h

Source / SDK 6.1 / C++ / Core

native.h

native.h
CPP
1/* Copyright Statement:
2 *
3 * (C) 2021-2024 Cubios Inc. All rights reserved.
4 */
5
6#pragma once
7#include <stdint.h>
8#include "native_access.h"
9#include "native_defines.h"
10
11typedef uint32_t u32_t;
12typedef int32_t i32_t;
13
14namespace Cubios {
15
16 union __attribute__((packed)) AppVersion_t {
17 uint32_t full;
18 struct {
19 uint16_t patch : 16;
20 uint8_t minor : 4;
21 uint8_t major : 4;
22 uint8_t reserved: 8;
23 };
24};
25
26typedef int32_t soundID_t;
27typedef int32_t spriteID_t;
28struct TOPOLOGY_faceletInfo_t {
29 int32_t module;
30 int32_t screen;
31 int32_t connected;
32};
33
34struct TOPOLOGY_place_t {
35 int32_t face;
36 int32_t position;
37};
38
39struct TOPOLOGY_twistInfo_t {
40 int32_t screen;
41 int32_t count;
42 int32_t direction;
43};
44
45enum TOPOLOGY_twist_t {
46 TWIST_UNINDENTIFIED = 0,
47 TWIST_LEFT,
48 TWIST_RIGHT,
49 TWIST_DOUBLE,
50 TWIST_MAX,
51};
52
53enum TOPOLOGY_orientation_mode_t {
54 ORIENTATION_MODE_MENU = 0,
55 ORIENTATION_MODE_GRAVITY,
56 ORIENTATION_MODE_SPLASH,
57 ORIENTATION_MODE_MAX,
58};
59
60enum text_align_t{
61 TEXT_ALIGN_CENTER,
62 TEXT_ALIGN_TOP_CENTER,
63 TEXT_ALIGN_BOTTOM_CENTER,
64 TEXT_ALIGN_LEFT_CORNER,
65 TEXT_ALIGN_LEFT_TOP_CORNER,
66 TEXT_ALIGN_LEFT_BOTTOM_CORNER,
67 TEXT_ALIGN_RIGHT_CORNER,
68 TEXT_ALIGN_RIGHT_TOP_CORNER,
69 TEXT_ALIGN_RIGHT_BOTTOM_CORNER
70};
71
72enum TOPOLOGY_orientation_t{
73 ORIENTATION_UP = 0,
74 ORIENTATION_DOWN,
75 ORIENTATION_FRONT,
76 ORIENTATION_BACK,
77 ORIENTATION_LEFT,
78 ORIENTATION_RIGHT,
79 ORIENTATION_MAX,
80};
81
82enum TOPOLOGY_neighbor_t{
83 NEIGHBOR_SELF = 0,
84 NEIGHBOR_LEFT,
85 NEIGHBOR_DIAGONAL,
86 NEIGHBOR_TOP,
87 NEIGHBOR_RIGHT,
88 NEIGHBOR_BOTTOM,
89 NEIGHBOR_MAX,
90};
91
92struct LB_info_t {
93 int32_t boardCount;
94 int32_t selfPosition;
95 int32_t selfScore;
96 int32_t wholeUserListCount;
97};
98
99struct GFX_Particle_t {
100 int32_t ttl;
101 int32_t vx;
102 int32_t vy;
103 int32_t ax;
104 int32_t ay;
105 int32_t explosion;
106 int32_t velocity;
107 int32_t duration;
108 int32_t frequency;
109 int32_t max;
110 int32_t loop;
111 uint32_t time;
112};
113
114enum GFX_mirror_t {
115 MIRROR_BLANK = 0,
116 MIRROR_X,
117 MIRROR_Y,
118 MIRROR_XY,
119};
120
121enum GFX_PixelFormat_t {
122 FORMAT_RGB565 = 0,
123 FORMAT_ARGB6666,
124 FORMAT_ARGB8888,
125};
126
127WASM_IMPORT("sendPacket") i32_t sendPacket(u32_t type, uint8_t* pkt, u32_t size);
128WASM_IMPORT("recvPacket") i32_t recvPacket(u32_t size, uint32_t* type, uint8_t* pkt);
129WASM_IMPORT("getTime") i32_t getTime();
130WASM_IMPORT("getUserName") i32_t getUserName(uint8_t* buffer, u32_t bufSize);
131WASM_IMPORT("toggleDebugInfo") i32_t toggleDebugInfo();
132WASM_IMPORT("saveState") i32_t saveState(void* data, u32_t size);
133WASM_IMPORT("loadState") i32_t loadState(u32_t* id, void* data, u32_t size);
134WASM_IMPORT("random") i32_t random(u32_t min, u32_t max);
135WASM_IMPORT("getAppVersion") i32_t getAppVersion(Cubios::AppVersion_t *version);
136WASM_IMPORT("LOG") i32_t LOG(uint8_t level, const char* text);
137WASM_IMPORT("getTap") i32_t getTap();
138WASM_IMPORT("sendBleData") i32_t sendBleData(u32_t type, uint8_t* pkt, u32_t size);
139WASM_IMPORT("recvBleData") i32_t recvBleData(uint8_t* pkt, u32_t size);
140
141WASM_IMPORT("TOPOLOGY_getAdjacentFacelet") i32_t TOPOLOGY_getAdjacentFacelet(u32_t module, u32_t screen, u32_t direction, Cubios::TOPOLOGY_faceletInfo_t* result);
142WASM_IMPORT("TOPOLOGY_getFacelet") i32_t TOPOLOGY_getFacelet(u32_t face, u32_t position, Cubios::TOPOLOGY_orientation_mode_t mode, Cubios::TOPOLOGY_faceletInfo_t* result);
143WASM_IMPORT("TOPOLOGY_getPlace") i32_t TOPOLOGY_getPlace(u32_t module, u32_t screen, Cubios::TOPOLOGY_orientation_mode_t mode, Cubios::TOPOLOGY_place_t* result);
144WASM_IMPORT("TOPOLOGY_getOppositeFacelet") i32_t TOPOLOGY_getOppositeFacelet(u32_t module, u32_t screen, Cubios::TOPOLOGY_faceletInfo_t* result);
145WASM_IMPORT("TOPOLOGY_getAngle") i32_t TOPOLOGY_getAngle(u32_t module, u32_t screen, Cubios::TOPOLOGY_orientation_mode_t mode);
146WASM_IMPORT("TOPOLOGY_getFaceletOrientation") i32_t TOPOLOGY_getFaceletOrientation(u32_t module, u32_t screen);
147WASM_IMPORT("TOPOLOGY_getPlaceOrientation") i32_t TOPOLOGY_getPlaceOrientation(u32_t face, u32_t position);
148WASM_IMPORT("TOPOLOGY_getFace") i32_t TOPOLOGY_getFace(u32_t orientation);
149WASM_IMPORT("TOPOLOGY_isAssembled") i32_t TOPOLOGY_isAssembled();
150WASM_IMPORT("TOPOLOGY_getTwist") i32_t TOPOLOGY_getTwist(Cubios::TOPOLOGY_twistInfo_t* twist);
151
152WASM_IMPORT("LB_getInfo") i32_t LB_getInfo(Cubios::LB_info_t* info);
153WASM_IMPORT("LB_getScore") i32_t LB_getScore(uint8_t* leadTableBin, u32_t bufSize);
154
155WASM_IMPORT("MS_getFaceAccelX") i32_t MS_getFaceAccelX(u32_t display);
156WASM_IMPORT("MS_getFaceAccelY") i32_t MS_getFaceAccelY(u32_t display);
157WASM_IMPORT("MS_getFaceAccelZ") i32_t MS_getFaceAccelZ(u32_t display);
158WASM_IMPORT("MS_getFaceGyroX") i32_t MS_getFaceGyroX(u32_t display);
159WASM_IMPORT("MS_getFaceGyroY") i32_t MS_getFaceGyroY(u32_t display);
160WASM_IMPORT("MS_getFaceGyroZ")i32_t MS_getFaceGyroZ(u32_t display);
161
162WASM_IMPORT("GFX_getAssetId") i32_t GFX_getAssetId(const char* spriteName);
163WASM_IMPORT("GFX_clear") i32_t GFX_clear(u32_t color);
164WASM_IMPORT("GFX_drawText") i32_t GFX_drawText(i32_t x, i32_t y, u32_t scale, u32_t angle, u32_t align, u32_t color, const char* text);
165WASM_IMPORT("GFX_drawPoint") i32_t GFX_drawPoint(i32_t x, i32_t y, u32_t color);
166WASM_IMPORT("GFX_drawCircle") i32_t GFX_drawCircle(u32_t x, u32_t y, u32_t radius, u32_t width, u32_t color);
167WASM_IMPORT("GFX_drawSolidCircle") i32_t GFX_drawSolidCircle(u32_t x, u32_t y, u32_t radius, u32_t color); // DEPRECATED: use fill shader intead
168WASM_IMPORT("GFX_drawArc") i32_t GFX_drawArc(i32_t x, i32_t y, u32_t radius, u32_t width, u32_t angle0, u32_t angle1, u32_t color);
169WASM_IMPORT("GFX_drawSector") i32_t GFX_drawSector(i32_t x, i32_t y, u32_t radius, u32_t angle0, u32_t angle1, u32_t color);
170WASM_IMPORT("GFX_drawLine") i32_t GFX_drawLine(i32_t x0, i32_t y0, i32_t x1, i32_t y1, u32_t thickness, u32_t color);
171WASM_IMPORT("GFX_drawRectangle") i32_t GFX_drawRectangle(i32_t x, i32_t y, i32_t w, i32_t h, u32_t color);
172WASM_IMPORT("GFX_bakeImage") i32_t GFX_bakeImage(spriteID_t id, u32_t width, u32_t height, GFX_PixelFormat_t format, u32_t overwrite);
173WASM_IMPORT("GFX_setRenderTarget") i32_t GFX_setRenderTarget(u32_t display);
174WASM_IMPORT("GFX_drawImage") i32_t GFX_drawImage(spriteID_t id, i32_t x, i32_t y, u32_t opacity, u32_t colorKey, u32_t scale_x, u32_t scale_y, u32_t angle, u32_t mirror);
175WASM_IMPORT("GFX_drawBakedImage") i32_t GFX_drawBakedImage(i32_t x, i32_t y, u32_t opacity, u32_t colorKey, u32_t scale_x, u32_t scale_y, u32_t angle, u32_t mirror, spriteID_t id);
176WASM_IMPORT("GFX_drawParticles") i32_t GFX_drawParticles(i32_t x, i32_t y, u32_t opacity, u32_t colorKey, u32_t angle, u32_t id, Cubios::GFX_Particle_t* particle);
177WASM_IMPORT("GFX_drawQrCode") i32_t GFX_drawQRCode(i32_t x, i32_t y, u32_t size, u32_t color0, u32_t color1, u32_t angle, u32_t id, const char *text);
178WASM_IMPORT("GFX_render") i32_t GFX_render();
179WASM_IMPORT("GFX_clearCache") i32_t GFX_clearCache();
180WASM_IMPORT("GFX_removeBakedImage") i32_t GFX_removeBakedImage(spriteID_t id);
181WASM_IMPORT("GFX_cacheImages") i32_t GFX_cacheImages(spriteID_t* spriteIDs, u32_t count);
182WASM_IMPORT("GFX_setFpsWindow") i32_t GFX_setFpsWindow(u32_t size);
183WASM_IMPORT("GFX_getAssetsCount") i32_t GFX_getAssetsCount();
184WASM_IMPORT("GFX_setFillShader") i32_t GFX_setFillShader(u32_t color);
185WASM_IMPORT("GFX_setLinearGradientShader") i32_t GFX_setLinearGradientShader(u32_t x0, u32_t y0, u32_t x1, u32_t y1, u32_t color0, u32_t color1);
186WASM_IMPORT("GFX_setRadialGradientShader") i32_t GFX_setRadialGradientShader(u32_t x0, u32_t y0, u32_t radius, u32_t color0, u32_t color1);
187WASM_IMPORT("GFX_removeShader") i32_t GFX_removeShader();
188
189WASM_IMPORT("GFX_drawSubImage") i32_t GFX_drawSubImage(spriteID_t id,i32_t x,i32_t y,u32_t rect_x,u32_t rect_y,u32_t rect_w,u32_t rect_h,u32_t colorKey,u32_t scale_x, u32_t scale_y,u32_t opacity,u32_t angle, u32_t mirror);
190
191WASM_IMPORT("SND_getAssetId") i32_t SND_getAssetId(const char* soundName);
192WASM_IMPORT("SND_play") i32_t SND_play(soundID_t soundID, u32_t volume);
193WASM_IMPORT("SND_cacheSounds") i32_t SND_cacheSounds(soundID_t* soundIDs, u32_t count);
194WASM_IMPORT("SND_isPlaying") i32_t SND_isPlaying();
195WASM_IMPORT("SND_stop") i32_t SND_stop();
196WASM_IMPORT("SND_getAssetsCount") i32_t SND_getAssetsCount();
197
198WASM_IMPORT("EVENT_getList") i32_t EVENT_getList();
199
200
201extern uint32_t cubeN;
202
203static const uint8_t NET_BROADCAST = 0xFF;
204
205enum uartID_t {
206 UART0 = 0,
207 UART1,
208 UART2
209};
210
211enum eventMask_t {
212 WASM_EVENT_ON_NET_UART0_RX = (1 << 0),
213 WASM_EVENT_ON_NET_UART1_RX = (1 << 1),
214 WASM_EVENT_ON_NET_UART2_RX = (1 << 2),
215 WASM_EVENT_ON_PHYSICAL_TICK = (1 << 3),
216 WASM_EVENT_ON_CLOSE = (1 << 4),
217 WASM_EVENT_ON_TWIST = (1 << 5),
218 WASM_EVENT_ON_TAP = (1 << 6),
219 WASM_EVENT_ON_CFG_DATA = (1 << 7),
220 WASM_EVENT_ON_UART_RX = (1 << 8),
221};
222
223enum LogLevel_t {
224 LOG_LVL_ASSERT,
225 LOG_LVL_ERROR,
226 LOG_LVL_WARN,
227 LOG_LVL_INFO,
228 ELOG_LVL_DEBUG,
229 LOG_LVL_VERBOSE
230};
231
232void log(uint8_t logLvl, const char *format, ...);
233
234#define LOG_a(...) Cubios::log(Cubios::LOG_LVL_ASSERT, __VA_ARGS__)
235#define LOG_e(...) Cubios::log(Cubios::LOG_LVL_ERROR, __VA_ARGS__)
236#define LOG_w(...) Cubios::log(Cubios::LOG_LVL_WARN, __VA_ARGS__)
237#define LOG_i(...) Cubios::log(Cubios::LOG_LVL_INFO, __VA_ARGS__)
238#define LOG_d(...) Cubios::log(Cubios::ELOG_LVL_DEBUG, __VA_ARGS__)
239#define LOG_v(...) Cubios::log(Cubios::LOG_LVL_VERBOSE, __VA_ARGS__)
240
241}
242
243
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.
Context Rail

Related nodes

AppManager.cpp
Source / SDK 6.1 / C++ / Core
AppManager.h
Source / SDK 6.1 / C++ / Core
Gfx.h
Source / SDK 6.1 / C++ / Core
native access.h
Source / SDK 6.1 / C++ / Core
Previous Node
native.cpp
Source / SDK 6.1 / C++ / Core
Next Node
NetworkMessage.cpp
Source / SDK 6.1 / C++ / Core