forked from geode-sdk/android-launcher
implement internal callbacks
This commit is contained in:
3 files changed
+25
-30
No files matched your search
@@ -588,6 +588,10 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
||||
mGLSurfaceView?.sendTimestampEvents = true
|
||||
true
|
||||
}
|
||||
GeodeUtils.CAPABILITY_INTERNAL_CALLBACKS -> {
|
||||
mGLSurfaceView?.sendInternalTimestampEvents = true
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,6 +542,7 @@ object GeodeUtils {
|
||||
|
||||
const val CAPABILITY_EXTENDED_INPUT = "extended_input"
|
||||
const val CAPABILITY_TIMESTAMP_INPUT = "timestamp_inputs"
|
||||
const val CAPABILITY_INTERNAL_CALLBACKS = "internal_callbacks_v1"
|
||||
|
||||
private var capabilityListener: WeakReference<CapabilityListener?> = WeakReference(null)
|
||||
|
||||
@@ -582,4 +583,5 @@ object GeodeUtils {
|
||||
* @see reportPlatformCapability
|
||||
*/
|
||||
external fun setNextInputTimestamp(timestamp: Long)
|
||||
external fun setNextInputTimestampInternal(timestamp: Long)
|
||||
}
|
||||
@@ -56,6 +56,7 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
}
|
||||
|
||||
var sendTimestampEvents = false
|
||||
var sendInternalTimestampEvents = false
|
||||
var manualBackEvents = false
|
||||
|
||||
var cocos2dxEditText: AppCompatEditText? = null
|
||||
@@ -150,6 +151,14 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
queueEvent { cocos2dxRenderer.handleOnResume() }
|
||||
}
|
||||
|
||||
private fun sendNextEventTimestamp(timestamp: Long) {
|
||||
if (sendTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestamp(timestamp)
|
||||
|
||||
if (sendInternalTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestampInternal(timestamp)
|
||||
}
|
||||
|
||||
override fun onTouchEvent(motionEvent: MotionEvent): Boolean {
|
||||
val pointerNumber = motionEvent.pointerCount
|
||||
val ids = IntArray(pointerNumber)
|
||||
@@ -169,9 +178,7 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
val xDown = xs[0]
|
||||
val f = ys[0]
|
||||
queueEvent {
|
||||
if (sendTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestamp(timestamp)
|
||||
|
||||
sendNextEventTimestamp(timestamp)
|
||||
cocos2dxRenderer.handleActionDown(idDown, xDown, f)
|
||||
}
|
||||
true
|
||||
@@ -181,27 +188,21 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
val f2 = xs[0]
|
||||
val f3 = ys[0]
|
||||
queueEvent {
|
||||
if (sendTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestamp(timestamp)
|
||||
|
||||
sendNextEventTimestamp(timestamp)
|
||||
cocos2dxRenderer.handleActionUp(idUp, f2, f3)
|
||||
}
|
||||
true
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
queueEvent {
|
||||
if (sendTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestamp(timestamp)
|
||||
|
||||
sendNextEventTimestamp(timestamp)
|
||||
cocos2dxRenderer.handleActionMove(ids, xs, ys)
|
||||
}
|
||||
true
|
||||
}
|
||||
MotionEvent.ACTION_CANCEL -> {
|
||||
queueEvent {
|
||||
if (sendTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestamp(timestamp)
|
||||
|
||||
sendNextEventTimestamp(timestamp)
|
||||
cocos2dxRenderer.handleActionCancel(ids, xs, ys)
|
||||
}
|
||||
true
|
||||
@@ -212,9 +213,7 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
val xPointerDown = motionEvent.getX(indexPointerDown)
|
||||
val y = motionEvent.getY(indexPointerDown)
|
||||
queueEvent {
|
||||
if (sendTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestamp(timestamp)
|
||||
|
||||
sendNextEventTimestamp(timestamp)
|
||||
cocos2dxRenderer.handleActionDown(idPointerDown, xPointerDown, y)
|
||||
}
|
||||
true
|
||||
@@ -225,9 +224,7 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
val xPointerUp = motionEvent.getX(indexPointUp)
|
||||
val y2 = motionEvent.getY(indexPointUp)
|
||||
queueEvent {
|
||||
if (sendTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestamp(timestamp)
|
||||
|
||||
sendNextEventTimestamp(timestamp)
|
||||
cocos2dxRenderer.handleActionUp(idPointerUp, xPointerUp, y2)
|
||||
}
|
||||
true
|
||||
@@ -276,9 +273,7 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
} else {
|
||||
val currentTime = System.nanoTime()
|
||||
queueEvent {
|
||||
if (sendTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestamp(currentTime)
|
||||
|
||||
sendNextEventTimestamp(currentTime)
|
||||
GeodeUtils.nativeKeyDown(KeyEvent.KEYCODE_BACK, 0, false)
|
||||
}
|
||||
}
|
||||
@@ -300,9 +295,7 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
}
|
||||
|
||||
queueEvent {
|
||||
if (sendTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestamp(event.eventTime * MS_TO_NS)
|
||||
|
||||
sendNextEventTimestamp(event.eventTime * MS_TO_NS)
|
||||
GeodeUtils.nativeKeyDown(keyCode, event.modifiers, event.repeatCount != 0)
|
||||
}
|
||||
true
|
||||
@@ -325,9 +318,7 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
}
|
||||
|
||||
queueEvent {
|
||||
if (sendTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestamp(event.eventTime * MS_TO_NS)
|
||||
|
||||
sendNextEventTimestamp(event.eventTime * MS_TO_NS)
|
||||
GeodeUtils.nativeKeyUp(keyCode, event.modifiers)
|
||||
}
|
||||
|
||||
@@ -348,9 +339,7 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
event.eventTimeNanos else event.eventTime * MS_TO_NS
|
||||
|
||||
queueEvent {
|
||||
if (sendTimestampEvents)
|
||||
GeodeUtils.setNextInputTimestamp(timestamp)
|
||||
|
||||
sendNextEventTimestamp(timestamp)
|
||||
GeodeUtils.nativeActionScroll(scrollX, scrollY)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user