mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-22 16:42:38 +00:00
add keyboard input support
This commit is contained in:
4 files changed
+109
-2
No files matched your search
@@ -35,7 +35,7 @@ import java.io.FileInputStream
|
||||
import java.io.FileOutputStream
|
||||
|
||||
|
||||
class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperListener {
|
||||
class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperListener, GeodeUtils.CapabilityListener {
|
||||
private var mGLSurfaceView: Cocos2dxGLSurfaceView? = null
|
||||
private val sTag = GeometryDashActivity::class.simpleName
|
||||
private var mIsRunning = false
|
||||
@@ -107,7 +107,9 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
||||
setupRedirection(gdPackageInfo)
|
||||
|
||||
Cocos2dxHelper.init(this, this)
|
||||
|
||||
GeodeUtils.setContext(this)
|
||||
GeodeUtils.setCapabilityListener(this)
|
||||
|
||||
tryLoadLibrary(gdPackageInfo, Constants.FMOD_LIB_NAME)
|
||||
tryLoadLibrary(gdPackageInfo, Constants.COCOS_LIB_NAME)
|
||||
@@ -448,4 +450,10 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCapabilityAdded(capability: String) {
|
||||
if (capability == GeodeUtils.CAPABILITY_EXTENDED_INPUT) {
|
||||
mGLSurfaceView?.useKeyboardEvents = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -446,4 +446,30 @@ object GeodeUtils {
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
interface CapabilityListener {
|
||||
fun onCapabilityAdded(capability: String)
|
||||
}
|
||||
|
||||
const val CAPABILITY_EXTENDED_INPUT = "extended_input"
|
||||
|
||||
private var capabilityListener: WeakReference<CapabilityListener?> = WeakReference(null)
|
||||
|
||||
fun setCapabilityListener(listener: CapabilityListener) {
|
||||
capabilityListener = WeakReference(listener)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun reportPlatformCapability(capability: String?) {
|
||||
if (capability.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
capabilityListener.get()?.onCapabilityAdded(capability)
|
||||
}
|
||||
|
||||
external fun nativeKeyUp(keyCode: Int, modifiers: Int)
|
||||
external fun nativeKeyDown(keyCode: Int, modifiers: Int, isRepeating: Boolean)
|
||||
external fun nativeActionScroll(scrollX: Float, scrollY: Float)
|
||||
external fun resizeSurface(width: Int, height: Int)
|
||||
}
|
||||
Reference in new issue
Block a user