#endif
// *** NATIVE APP GLUE ********
-enum LooperID : byte { main = 1, input = 2, user = 3 };
+enum LooperID { main = 1, input = 2, user = 3 };
enum AppCommand : byte
{
error = 0, inputChanged, initWindow, termWindow, windowResized, windowRedrawNeeded,
static int desktopW, desktopH;
static char * clipBoardData;
+static int mouseX, mouseY;
class AndroidInterface : Interface
{
bool ProcessInput(bool processAll)
{
bool eventAvailable = false;
- if(androidActivity.ident >= 0)
+
+ if(androidActivity.ident < 0)
+ androidActivity.ident = (LooperID)ALooper_pollAll(0, null, &androidActivity.events, (void**)&androidActivity.source);
+ while(androidActivity.ident >= 0)
{
AndroidPollSource source = androidActivity.source;
- //PrintLn("androidActivity.ident >= 0");
- // Process this event.
- androidActivity.ident = 0;
+
androidActivity.source = null;
if(source)
source.process(source.userData);
}
}
*/
- // eventAvailable = true;
+ if(gotInit && androidActivity.window)
+ {
+ int w = ANativeWindow_getWidth(androidActivity.window);
+ int h = ANativeWindow_getHeight(androidActivity.window);
+ if(desktopW != w || desktopH != h)
+ {
+ guiApp.SetDesktopPosition(0, 0, w, h, true);
+ desktopW = w;
+ desktopH = h;
+ guiApp.desktop.Update(null);
+ }
+ }
+
+ eventAvailable = true;
if(androidActivity.destroyRequested)
{
guiApp.desktop.Destroy(0);
eventAvailable = true;
+ androidActivity.ident = (LooperID)-1;
}
+ else if(processAll)
+ androidActivity.ident = (LooperID)ALooper_pollAll(0, null, &androidActivity.events, (void**)&androidActivity.source);
+ else
+ androidActivity.ident = (LooperID)-1;
}
-
- if(androidActivity.animating)
- guiApp.desktop.Update(null);
-
- if(!eventAvailable)
- return false;
- return true;
+ return eventAvailable;
}
void Wait()
{
- androidActivity.ident = (LooperID)ALooper_pollAll(androidActivity.animating ? 0 : -1, null, &androidActivity.events, (void**)&androidActivity.source);
+ androidActivity.ident = (LooperID)ALooper_pollAll((int)(1000/18.2f), null, &androidActivity.events, (void**)&androidActivity.source);
// guiApp.WaitEvent();
}
int rootWindow, childWindow;
int mx, my;
unsigned int state;
+
+ *x = mouseX;
+ *y = mouseY;
}
void SetMousePosition(int x, int y)
{
-
+ mouseX = x;
+ mouseY = y;
}
void SetMouseRange(Window window, Box box)
if(window && window.windowData)
{
}
- }
+ }
void ClearClipboard()
{
{
bool result = false;
if((clipBoard.text = new0 byte[size]))
- result = true;
+ result = true;
return result;
}
void SetTimerResolution(uint hertz)
{
// timerDelay = hertz ? (1000000 / hertz) : MAXINT;
- }
+ }
bool SetIcon(Window window, BitmapResource resource)
{
static AndroidActivity androidActivity;
+default const char * AndroidInterface_GetLibLocation()
+{
+ if(androidActivity)
+ {
+ static char loc[MAX_LOCATION];
+ sprintf(loc, "/data/data/com.ecere.%s/lib/lib", androidActivity.moduleName);
+ return loc;
+ }
+ return null;
+}
+
static bool gotInit;
default float AMotionEvent_getAxisValue(const AInputEvent* motion_event,
const ASensor* accelerometerSensor;
ASensorEventQueue* sensorEventQueue;
*/
- bool animating;
SavedState state;
int onInputEvent(AInputEvent* event)
//PrintLn("Got a motion input event: ", action);
/*
if(action == 8) //AMOTION_EVENT_ACTION_SCROLL)
- axis = AMotionEvent_getAxisValue(event, 9, index); //AMOTION_EVENT_AXIS_VSCROLL);
+ axis = AMotionEvent_getAxisValue(event, 9, index); //AMOTION_EVENT_AXIS_VSCROLL);
*/
AInputQueue_finishEvent(inputQueue, event, 1);
break;
*/
case AMOTION_EVENT_ACTION_DOWN:
+ mouseX = x, mouseY = y;
window.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonDown, x, y, &keyFlags, false, true);
break;
case AMOTION_EVENT_ACTION_UP:
+ mouseX = x, mouseY = y;
window.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftButtonUp, x, y, &keyFlags, false, true);
break;
case AMOTION_EVENT_ACTION_MOVE:
+ mouseX = x, mouseY = y;
window.MouseMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnMouseMove, x, y, &keyFlags, false, true);
break;
case AMOTION_EVENT_ACTION_CANCEL: break;
case AMOTION_EVENT_ACTION_POINTER_DOWN: break;
case AMOTION_EVENT_ACTION_POINTER_UP: break;
}
-
- animating = true;
return 1;
}
else if(type == AINPUT_EVENT_TYPE_KEY)
}
break;
case termWindow:
- animating = false;
guiApp.desktop.UnloadGraphics(false);
break;
case gainedFocus:
- androidActivity.animating = true;
+ guiApp.desktop.Update(null);
guiApp.SetAppFocus(true);
/*
if(accelerometerSensor)
if(accelerometerSensor)
ASensorEventQueue_disableSensor(sensorEventQueue, accelerometerSensor);
*/
- animating = false;
guiApp.SetAppFocus(false);
guiApp.desktop.Update(null);
break;
+ case configChanged:
+ if(window)
+ guiApp.desktop.UpdateDisplay();
+ break;
}
}
{
Module app;
-
+
// Evolve the Application class into a GuiApplication
eInstance_Evolve((Instance *)&__androidCurrentModule, class(GuiApplication));
}
// Call Main()
- __androidCurrentModule._vTbl[12](__androidCurrentModule);
+ ((void (*)(void *))(void *)__androidCurrentModule._vTbl[12])(__androidCurrentModule);
}
if(!destroyRequested)