-
Notifications
You must be signed in to change notification settings - Fork 0
/
moai.cpp
752 lines (474 loc) · 20.5 KB
/
moai.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
#include <android/log.h>
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , "SDL", __VA_ARGS__)
#include <SDL.h>
#include <jni.h>
#include <time.h>
#include <android/log.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <moaicore/moaicore.h>
#include <lua-headers/moai_lua.h>
#include <moaiext-android/moaiext-android.h>
#include <moaiext-android/moaiext-jni.h>
#include <aku/AKU.h>
#include <aku/AKU-luaext.h>
#ifdef USE_FMOD
#include <aku/AKU-fmod-ex.h>
#endif
#ifdef USE_UNTZ
#include <aku/AKU-untz.h>
#endif
namespace {
SDL_Window *SDL_MOAI_WINDOW;
SDL_GLContext SDL_MOAI_GLCONTEXT;
bool isRunning;
}
//================================================================//
// Input event locking queue
//================================================================//
template < class T >
class LockingQueue {
public:
pthread_mutex_t mutex;
int tail;
int num;
static const int kMaxMessages = 100;
T messages [ kMaxMessages ];
//----------------------------------------------------------------//
void Push ( const T &message ) {
pthread_mutex_lock ( &mutex );
if ( num >= LockingQueue::kMaxMessages ) {
printf ( "ERROR: g_MessageQueue, kMaxMessages (%d) exceeded\n", LockingQueue::kMaxMessages );
}
else {
int head = ( tail + num) % LockingQueue::kMaxMessages;
messages [ head ] = message;
++num;
if ( num >= LockingQueue::kMaxMessages ) {
num -= LockingQueue::kMaxMessages;
}
}
pthread_mutex_unlock ( &mutex );
}
//----------------------------------------------------------------//
int Pop ( T &message ) {
pthread_mutex_lock ( &mutex );
int result = 0;
if ( num > 0) {
result = 1;
message = messages [ tail ];
++tail;
if ( tail >= LockingQueue::kMaxMessages) {
tail -= LockingQueue::kMaxMessages;
}
--num;
}
pthread_mutex_unlock ( &mutex );
return result;
}
};
struct InputEvent {
enum {
INPUTEVENT_LEVEL,
INPUTEVENT_COMPASS,
INPUTEVENT_LOCATION,
INPUTEVENT_TOUCH,
};
// all
int m_type;
int m_deviceId;
int m_sensorId;
// touch, level
float m_x;
float m_y;
// level
float m_z;
// compass
int m_heading;
// touch
int m_touchId;
bool m_down;
int m_tapCount;
// location
double m_longitude;
double m_latitude;
double m_altitude;
float m_hAccuracy;
float m_vAccuracy;
float m_speed;
};
LockingQueue < InputEvent > * inputQueue = NULL;
//================================================================//
// JNI set up
//================================================================//
JavaVM* jvm;
//----------------------------------------------------------------//
int JNI_OnLoad ( JavaVM* vm, void* reserved ) {
jvm = vm;
return JNI_VERSION_1_4;
}
//*****************************************************************************
//SDL
int main(int argc, char* argv[])
{
LOGD("C++-->trace-8-->SDL_INIT_VIDEO");
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return 1;
//these get set in callback
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
LOGD("C++-->trace--9->SDL_CreateWindow");//ALL THESE SETTING ARE IGONRED
SDL_MOAI_WINDOW = SDL_CreateWindow("myWindow", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,0, 0,SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL );
LOGD("C++-->trace--10->SDL_GL_CreateContext");
SDL_MOAI_GLCONTEXT = SDL_GL_CreateContext(SDL_MOAI_WINDOW); //call back to java
LOGD("C++-->trace--16->SDL_GL_MakeCurrent");
SDL_GL_MakeCurrent(SDL_MOAI_WINDOW,SDL_MOAI_GLCONTEXT);
//CAN USE RENDER INSTEAD OF SDL_GL_CreateContext & SDL_GL_MakeCurrent
//SDL_Renderer* renderer=NULL;
//renderer = SDL_CreateRenderer(SDL_MOAI_WINDOW, -1,SDL_RENDERER_TARGETTEXTURE);
//DETECT CAN BE DONE IN JAVA
//LOGD("C++-->number-->AKU-DetectGfxContext");
//AKUDetectGfxContext();
isRunning = true;
while (isRunning) {
SDL_GL_SwapWindow(SDL_MOAI_WINDOW); //HAS TO GO INTO JAVA FOR THREAD LOCK
//CAN BE USED IF YOU ARE USING SDL_Renderer
//SDL_RenderPresent(renderer);
SDL_Delay(5);
};
LOGD("C++-->trace-100-->GAME LOOPED STOPPED");
return 0;
}
//----------------------------------------------------------------//
//clean up from java
extern "C" int Java_com_ziplinegames_moai_Moai_AKUStopGame ( JNIEnv* env, jclass obj ) {
isRunning = false;
SDL_DestroyWindow(SDL_MOAI_WINDOW);
SDL_GL_DeleteContext(SDL_MOAI_GLCONTEXT);
SDL_Quit();
LOGD("C++-->trace-100--->OBJECTS DESTORYED");
}
// SDL_Delay(100); //for controls
//LOGD("---------------------------------------------------");
//LOGD("---------------------------------------------------");
//LOGD("RUNN SCRIPTS---------------------------------------------------");
//AKURunScript("init.lua");
//AKURunScript("main.lua");
//================================================================//
// Miscellaneous JNI Functions
//================================================================//
//----------------------------------------------------------------//
extern "C" int Java_com_ziplinegames_moai_Moai_AKUCreateContext ( JNIEnv* env, jclass obj ) {
return AKUCreateContext ();
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUDeleteContext ( JNIEnv* env, jclass obj, jint contextId ) {
AKUDeleteContext ( contextId );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUDetectGfxContext ( JNIEnv* env, jclass obj ) {
AKUDetectGfxContext ();
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUEnqueueCompassEvent ( JNIEnv* env, jclass obj, jint deviceId, jint sensorId, jfloat heading ) {
InputEvent ievent;
ievent.m_type = InputEvent::INPUTEVENT_COMPASS;
ievent.m_deviceId = deviceId;
ievent.m_sensorId = sensorId;
ievent.m_heading = heading;
inputQueue->Push ( ievent );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUEnqueueLevelEvent ( JNIEnv* env, jclass obj, jint deviceId, jint sensorId, jfloat x, jfloat y, jfloat z ) {
InputEvent ievent;
ievent.m_type = InputEvent::INPUTEVENT_LEVEL;
ievent.m_deviceId = deviceId;
ievent.m_sensorId = sensorId;
ievent.m_x = x;
ievent.m_y = y;
ievent.m_z = z;
inputQueue->Push ( ievent );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUEnqueueLocationEvent ( JNIEnv* env, jclass obj, jint deviceId, jint sensorId, jdouble longitude, jdouble latitude, jdouble altitude, jfloat hAccuracy, jfloat vAccuracy, jfloat speed ) {
InputEvent ievent;
ievent.m_type = InputEvent::INPUTEVENT_LOCATION;
ievent.m_deviceId = deviceId;
ievent.m_sensorId = sensorId;
ievent.m_longitude = longitude;
ievent.m_latitude = latitude;
ievent.m_altitude = altitude;
ievent.m_hAccuracy = hAccuracy;
ievent.m_vAccuracy = vAccuracy;
ievent.m_speed = speed ;
inputQueue->Push ( ievent );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUEnqueueTouchEvent ( JNIEnv* env, jclass obj, jint deviceId, jint sensorId, jint touchId, jboolean down, jint x, jint y ) {
InputEvent ievent;
ievent.m_type = InputEvent::INPUTEVENT_TOUCH;
ievent.m_deviceId = deviceId;
ievent.m_sensorId = sensorId;
ievent.m_touchId = touchId;
ievent.m_down = down;
ievent.m_x = x;
ievent.m_y = y;
inputQueue->Push ( ievent );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUExtLoadLuacrypto ( JNIEnv* env, jclass obj ) {
AKUExtLoadLuacrypto ();
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUExtLoadLuacurl ( JNIEnv* env, jclass obj ) {
AKUExtLoadLuacurl ();
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUExtLoadLuasocket ( JNIEnv* env, jclass obj ) {
AKUExtLoadLuasocket ();
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUExtLoadLuafilesystem ( JNIEnv* env, jclass obj ) {
AKUExtLoadLuafilesystem ();
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUExtLoadLuasql ( JNIEnv* env, jclass obj ) {
AKUExtLoadLuasql ();
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUFinalize ( JNIEnv* env, jclass obj ) {
AKUFinalize ();
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUFMODExInit ( JNIEnv* env, jclass obj ) {
#ifdef USE_FMOD
AKUFmodExInit ();
#endif
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUInit ( JNIEnv* env, jclass obj ) {
MOAIAppAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAIAppAndroid );
MOAIDialogAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAIDialogAndroid );
MOAIMoviePlayerAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAIMoviePlayerAndroid );
MOAIKeyboardAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAIKeyboardAndroid );
#ifndef DISABLE_ADCOLONY
MOAIAdColonyAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAIAdColonyAndroid );
#endif
#ifndef DISABLE_BILLING
MOAIBillingAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAIBillingAndroid );
#endif
#ifndef DISABLE_CHARTBOOST
MOAIChartBoostAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAIChartBoostAndroid );
#endif
#ifndef DISABLE_CRITTERCISM
MOAICrittercismAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAICrittercismAndroid );
#endif
#ifndef DISABLE_FACEBOOK
MOAIFacebookAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAIFacebookAndroid );
#endif
#ifndef DISABLE_NOTIFICATIONS
MOAINotificationsAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAINotificationsAndroid );
#endif
#ifndef DISABLE_TAPJOY
MOAITapjoyAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAITapjoyAndroid );
#endif
///////////////////////////////////
//registar OUYA
MOAIOuyaAndroid::Affirm ();
REGISTER_LUA_CLASS ( MOAIOuyaAndroid );
AKURunBytecode ( moai_lua, moai_lua_SIZE );
inputQueue = new LockingQueue < InputEvent > ();
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUMountVirtualDirectory ( JNIEnv* env, jclass obj, jstring jvirtualPath, jstring jarchive ) {
JNI_GET_CSTRING ( jvirtualPath, virtualPath );
JNI_GET_CSTRING ( jarchive, archive );
AKUMountVirtualDirectory ( virtualPath, archive );
JNI_RELEASE_CSTRING ( jvirtualPath, virtualPath );
JNI_RELEASE_CSTRING ( jarchive, archive );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUPause ( JNIEnv* env, jclass obj, jboolean paused ) {
AKUPause ( paused );
if ( paused ) {
#ifdef USE_UNTZ
AKUUntzSuspend ();
#endif
} else {
#ifdef USE_UNTZ
AKUUntzResume ();
#endif
}
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUReleaseGfxContext ( JNIEnv* env, jclass obj ) {
AKUReleaseGfxContext ();
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKURender ( JNIEnv* env, jclass obj ) {
AKURender ();
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUReserveInputDevices ( JNIEnv* env, jclass obj, jint total ) {
AKUReserveInputDevices ( total );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUReserveInputDeviceSensors ( JNIEnv* env, jclass obj, jint deviceId, jint total ) {
AKUReserveInputDeviceSensors ( deviceId, total );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKURunScript ( JNIEnv* env, jclass obj, jstring jfilename ) {
JNI_GET_CSTRING ( jfilename, filename );
AKURunScript ( filename );
JNI_RELEASE_CSTRING ( jfilename, filename );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetConnectionType ( JNIEnv* env, jclass obj, jlong connectionType ) {
MOAIEnvironment::Get ().SetValue ( MOAI_ENV_connectionType, ( int )connectionType );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetContext ( JNIEnv* env, jclass obj, jint contextId ) {
AKUSetContext ( contextId );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetDeviceProperties ( JNIEnv* env, jclass obj, jstring jappName, jstring jappId, jstring jappVersion, jstring jabi, jstring jdevBrand, jstring jdevName, jstring jdevManufacturer, jstring jdevModel, jstring jdevProduct, jint jnumProcessors, jstring josBrand, jstring josVersion, jstring judid ) {
JNI_GET_CSTRING ( jappName, appName );
JNI_GET_CSTRING ( jappId, appId );
JNI_GET_CSTRING ( jappVersion, appVersion );
JNI_GET_CSTRING ( jabi, abi );
JNI_GET_CSTRING ( jdevBrand, devBrand );
JNI_GET_CSTRING ( jdevName, devName );
JNI_GET_CSTRING ( jdevManufacturer, devManufacturer );
JNI_GET_CSTRING ( jdevModel, devModel );
JNI_GET_CSTRING ( jdevProduct, devProduct );
JNI_GET_CSTRING ( josBrand, osBrand );
JNI_GET_CSTRING ( josVersion, osVersion );
JNI_GET_CSTRING ( judid, udid );
MOAIEnvironment& environment = MOAIEnvironment::Get ();
environment.SetValue ( MOAI_ENV_appDisplayName, appName );
environment.SetValue ( MOAI_ENV_appID, appId );
environment.SetValue ( MOAI_ENV_appVersion, appVersion );
environment.SetValue ( MOAI_ENV_cpuabi, abi );
environment.SetValue ( MOAI_ENV_devBrand, devBrand );
environment.SetValue ( MOAI_ENV_devName, devName );
environment.SetValue ( MOAI_ENV_devManufacturer, devManufacturer );
environment.SetValue ( MOAI_ENV_devModel, devModel );
environment.SetValue ( MOAI_ENV_devProduct, devProduct );
environment.SetValue ( MOAI_ENV_numProcessors, jnumProcessors );
environment.SetValue ( MOAI_ENV_osBrand, osBrand );
environment.SetValue ( MOAI_ENV_osVersion, osVersion );
environment.SetValue ( MOAI_ENV_udid, udid );
JNI_RELEASE_CSTRING ( jappName, appName );
JNI_RELEASE_CSTRING ( jappId, appId );
JNI_RELEASE_CSTRING ( jappVersion, appVersion );
JNI_RELEASE_CSTRING ( jabi, abi );
JNI_RELEASE_CSTRING ( jdevBrand, devBrand );
JNI_RELEASE_CSTRING ( jdevName, devName );
JNI_RELEASE_CSTRING ( jdevManufacturer, devManufacturer );
JNI_RELEASE_CSTRING ( jdevModel, devModel );
JNI_RELEASE_CSTRING ( jdevProduct, devProduct );
JNI_RELEASE_CSTRING ( josBrand, osBrand );
JNI_RELEASE_CSTRING ( josVersion, osVersion );
JNI_RELEASE_CSTRING ( judid, udid );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetDocumentDirectory ( JNIEnv* env, jclass obj, jstring jpath ) {
JNI_GET_CSTRING ( jpath, path );
MOAIEnvironment::Get ().SetValue ( MOAI_ENV_documentDirectory, path );
JNI_RELEASE_CSTRING ( jpath, path );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetInputConfigurationName ( JNIEnv* env, jclass obj, jstring jname ) {
JNI_GET_CSTRING ( jname, name );
AKUSetInputConfigurationName ( name );
JNI_RELEASE_CSTRING ( jname, name );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetInputDevice ( JNIEnv* env, jclass obj, jint deviceId, jstring jname ) {
JNI_GET_CSTRING ( jname, name );
AKUSetInputDevice ( deviceId, name );
JNI_RELEASE_CSTRING ( jname, name );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetInputDeviceCompass ( JNIEnv* env, jclass obj, jint deviceId, jint sensorId, jstring jname ) {
JNI_GET_CSTRING ( jname, name );
AKUSetInputDeviceCompass ( deviceId, sensorId, name );
JNI_RELEASE_CSTRING ( jname, name );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetInputDeviceLevel ( JNIEnv* env, jclass obj, jint deviceId, jint sensorId, jstring jname ) {
JNI_GET_CSTRING ( jname, name );
AKUSetInputDeviceLevel ( deviceId, sensorId, name );
JNI_RELEASE_CSTRING ( jname, name );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetInputDeviceLocation ( JNIEnv* env, jclass obj, jint deviceId, jint sensorId, jstring jname ) {
JNI_GET_CSTRING ( jname, name );
AKUSetInputDeviceLocation ( deviceId, sensorId, name );
JNI_RELEASE_CSTRING ( jname, name );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetInputDeviceTouch ( JNIEnv* env, jclass obj, jint deviceId, jint sensorId, jstring jname ) {
JNI_GET_CSTRING ( jname, name );
AKUSetInputDeviceTouch ( deviceId, sensorId, name );
JNI_RELEASE_CSTRING ( jname, name );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetScreenDpi ( JNIEnv* env, jclass obj, jint dpi ) {
AKUSetScreenDpi ( dpi );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetScreenSize ( JNIEnv* env, jclass obj, jint width, jint height ) {
AKUSetScreenSize ( width, height );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetViewSize ( JNIEnv* env, jclass obj, jint width, jint height ) {
AKUSetViewSize ( width, height );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUSetWorkingDirectory ( JNIEnv* env, jclass obj, jstring jpath ) {
JNI_GET_CSTRING ( jpath, path );
USFileSys::SetCurrentPath ( path );
MOAILuaRuntime::Get ().SetPath ( path );
JNI_RELEASE_CSTRING ( jpath, path );
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUUntzInit ( JNIEnv* env, jclass obj ) {
#ifdef USE_UNTZ
AKUUntzInit ();
#endif
}
//----------------------------------------------------------------//
extern "C" void Java_com_ziplinegames_moai_Moai_AKUUpdate ( JNIEnv* env, jclass obj ) {
InputEvent ievent;
while ( inputQueue->Pop ( ievent )) {
switch ( ievent.m_type ) {
case InputEvent::INPUTEVENT_TOUCH:
AKUEnqueueTouchEvent ( ievent.m_deviceId, ievent.m_sensorId, ievent.m_touchId, ievent.m_down, ievent.m_x, ievent.m_y );
break;
case InputEvent::INPUTEVENT_LEVEL:
AKUEnqueueLevelEvent ( ievent.m_deviceId, ievent.m_sensorId, ievent.m_x, ievent.m_y, ievent.m_z );
break;
case InputEvent::INPUTEVENT_COMPASS:
AKUEnqueueCompassEvent ( ievent.m_deviceId, ievent.m_sensorId, ievent.m_heading );
break;
case InputEvent::INPUTEVENT_LOCATION:
AKUEnqueueLocationEvent ( ievent.m_deviceId, ievent.m_sensorId, ievent.m_longitude, ievent.m_latitude, ievent.m_altitude, ievent.m_hAccuracy, ievent.m_vAccuracy, ievent.m_speed );
break;
}
}
AKUUpdate ();
}