-
-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Application: onDisplayOrientation and onDeviceOrientation events for …
…iOS and Android Device orientation is the orientation of the phone/tablet. Display orientation is the orientation of what is rendered on the display. By default, they should usually be the same. If orientation is locked, device orientation will update, but display orientation usually won't.
- Loading branch information
1 parent
2da06fa
commit 8f0b8f3
Showing
17 changed files
with
549 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef LIME_SYSTEM_ORIENTATION_EVENT_H | ||
#define LIME_SYSTEM_ORIENTATION_EVENT_H | ||
|
||
|
||
#include <system/CFFI.h> | ||
#include <system/ValuePointer.h> | ||
|
||
|
||
namespace lime { | ||
|
||
|
||
enum OrientationEventType { | ||
|
||
DISPLAY_ORIENTATION_CHANGE, | ||
DEVICE_ORIENTATION_CHANGE | ||
|
||
}; | ||
|
||
|
||
struct OrientationEvent { | ||
|
||
hl_type* t; | ||
int orientation; | ||
int display; | ||
OrientationEventType type; | ||
|
||
static ValuePointer* callback; | ||
static ValuePointer* eventObject; | ||
|
||
OrientationEvent (); | ||
|
||
static void Dispatch (OrientationEvent* event); | ||
|
||
}; | ||
|
||
|
||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#include <system/CFFI.h> | ||
#include <system/OrientationEvent.h> | ||
|
||
|
||
namespace lime { | ||
|
||
|
||
ValuePointer* OrientationEvent::callback = 0; | ||
ValuePointer* OrientationEvent::eventObject = 0; | ||
|
||
static int id_type; | ||
static int id_orientation; | ||
static int id_display; | ||
static bool init = false; | ||
|
||
|
||
OrientationEvent::OrientationEvent () { | ||
|
||
orientation = 0; // SDL_ORIENTATION_UNKNOWN | ||
display = 0; | ||
type = DISPLAY_ORIENTATION_CHANGE; | ||
|
||
} | ||
|
||
|
||
void OrientationEvent::Dispatch (OrientationEvent* event) { | ||
|
||
if (OrientationEvent::callback) { | ||
|
||
if (OrientationEvent::eventObject->IsCFFIValue ()) { | ||
|
||
if (!init) { | ||
|
||
id_orientation = val_id ("orientation"); | ||
id_display = val_id ("display"); | ||
id_type = val_id ("type"); | ||
init = true; | ||
|
||
} | ||
|
||
value object = (value)OrientationEvent::eventObject->Get (); | ||
|
||
alloc_field (object, id_orientation, alloc_int (event->orientation)); | ||
alloc_field (object, id_display, alloc_int (event->display)); | ||
alloc_field (object, id_type, alloc_int (event->type)); | ||
|
||
} else { | ||
|
||
OrientationEvent* eventObject = (OrientationEvent*)OrientationEvent::eventObject->Get (); | ||
|
||
eventObject->orientation = event->orientation; | ||
eventObject->display = event->display; | ||
eventObject->type = event->type; | ||
|
||
} | ||
|
||
OrientationEvent::callback->Call (); | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.