nwlink 0.0.16 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/eadk/eadk.h CHANGED
@@ -31,7 +31,8 @@ typedef struct {
31
31
 
32
32
  #define EADK_SCREEN_WIDTH 320
33
33
  #define EADK_SCREEN_HEIGHT 240
34
- static const eadk_rect_t eadk_screen_rect = {0, 0, EADK_SCREEN_WIDTH, EADK_SCREEN_HEIGHT};
34
+ static const eadk_rect_t eadk_screen_rect = {0, 0, EADK_SCREEN_WIDTH,
35
+ EADK_SCREEN_HEIGHT};
35
36
 
36
37
  typedef uint64_t eadk_keyboard_state_t;
37
38
  typedef enum {
@@ -83,23 +84,41 @@ typedef enum {
83
84
  eadk_key_exe = 52
84
85
  } eadk_key_t;
85
86
 
87
+ #if PLATFORM_DEVICE
86
88
  eadk_keyboard_state_t eadk_keyboard_scan();
87
- static inline bool eadk_keyboard_key_down(eadk_keyboard_state_t state, eadk_key_t key) {
88
- return (state>>(uint8_t)key) & 1;
89
+ #else
90
+ /* Returning a 64 bit value with emscripten would require WASM_BIGINT that
91
+ * causes some issue when the external app use a libc. */
92
+ void _eadk_keyboard_scan_do_scan();
93
+ uint32_t _eadk_keyboard_scan_low();
94
+ uint32_t _eadk_keyboard_scan_high();
95
+
96
+ static inline eadk_keyboard_state_t eadk_keyboard_scan() {
97
+ _eadk_keyboard_scan_do_scan();
98
+ uint64_t state = _eadk_keyboard_scan_high();
99
+ state <<= 32;
100
+ state |= _eadk_keyboard_scan_low();
101
+ return state;
102
+ }
103
+ #endif
104
+
105
+ static inline bool eadk_keyboard_key_down(eadk_keyboard_state_t state,
106
+ eadk_key_t key) {
107
+ return (state >> (uint8_t)key) & 1;
89
108
  }
90
109
 
91
110
  typedef uint16_t eadk_event_t;
92
111
  enum {
93
112
  eadk_event_left = 0,
94
113
  eadk_event_up = 1,
95
- eadk_event_down = 2,
114
+ eadk_event_down = 2,
96
115
  eadk_event_right = 3,
97
- eadk_event_ok = 4,
98
- eadk_event_back = 5,
116
+ eadk_event_ok = 4,
117
+ eadk_event_back = 5,
99
118
  eadk_event_shift = 12,
100
119
  eadk_event_alpha = 13,
101
- eadk_event_xnt = 14,
102
- eadk_event_var = 15,
120
+ eadk_event_xnt = 14,
121
+ eadk_event_var = 15,
103
122
  eadk_event_toolbox = 16,
104
123
  eadk_event_backspace = 17,
105
124
  eadk_event_exp = 18,
@@ -124,7 +143,7 @@ enum {
124
143
  eadk_event_six = 38,
125
144
  eadk_event_multiplication = 39,
126
145
  eadk_event_division = 40,
127
- eadk_event_one = 42,
146
+ eadk_event_one = 42,
128
147
  eadk_event_two = 43,
129
148
  eadk_event_three = 44,
130
149
  eadk_event_plus = 45,
@@ -134,9 +153,9 @@ enum {
134
153
  eadk_event_ee = 50,
135
154
  eadk_event_ans = 51,
136
155
  eadk_event_exe = 52,
137
- eadk_event_shift_left = 54,
138
- eadk_event_shift_up = 55,
139
- eadk_event_shift_down = 56,
156
+ eadk_event_shift_left = 54,
157
+ eadk_event_shift_up = 55,
158
+ eadk_event_shift_down = 56,
140
159
  eadk_event_shift_right = 57,
141
160
  eadk_event_alpha_lock = 67,
142
161
  eadk_event_cut = 68,
@@ -216,7 +235,7 @@ enum {
216
235
  eadk_event_upper_z = 207,
217
236
  };
218
237
 
219
- eadk_event_t eadk_event_get(int32_t * timeout);
238
+ eadk_event_t eadk_event_get(int32_t* timeout);
220
239
 
221
240
  // Backlight
222
241
 
@@ -231,21 +250,36 @@ float eadk_battery_voltage();
231
250
 
232
251
  // Display
233
252
 
234
- void eadk_display_push_rect(eadk_rect_t rect, const eadk_color_t * pixels);
253
+ void eadk_display_push_rect(eadk_rect_t rect, const eadk_color_t* pixels);
235
254
  void eadk_display_push_rect_uniform(eadk_rect_t rect, eadk_color_t color);
236
- void eadk_display_pull_rect(eadk_rect_t rect, eadk_color_t * pixels);
255
+ void eadk_display_pull_rect(eadk_rect_t rect, eadk_color_t* pixels);
237
256
  bool eadk_display_wait_for_vblank();
238
- void eadk_display_draw_string(const char * text, eadk_point_t point, bool large_font, eadk_color_t text_color, eadk_color_t background_color);
257
+ void eadk_display_draw_string(const char* text, eadk_point_t point,
258
+ bool large_font, eadk_color_t text_color,
259
+ eadk_color_t background_color);
239
260
 
240
261
  // Timing
241
262
 
242
263
  void eadk_timing_usleep(uint32_t us);
243
264
  void eadk_timing_msleep(uint32_t ms);
265
+
266
+ #if PLATFORM_DEVICE
244
267
  uint64_t eadk_timing_millis();
268
+ #else
269
+ uint32_t _eadk_timing_millis_low();
270
+ uint32_t _eadk_timing_millis_high();
271
+
272
+ static inline uint64_t eadk_timing_millis() {
273
+ uint64_t millis = _eadk_timing_millis_high();
274
+ millis <<= 32;
275
+ millis |= _eadk_timing_millis_low();
276
+ return millis;
277
+ }
278
+ #endif
245
279
 
246
280
  // External data
247
281
 
248
- extern const char * eadk_external_data;
282
+ extern const char* eadk_external_data;
249
283
  extern size_t eadk_external_data_size;
250
284
 
251
285
  // Misc