add touch events handling

This commit is contained in:
2026-01-08 22:35:59 +01:00
parent 1074a1e59a
commit c101d647dd
23 changed files with 435 additions and 818 deletions

View File

@@ -4,8 +4,9 @@ project("mosis")
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(ANDROID_SDK "/Users/omar/Library/Android/sdk")
#set(ANDROID_SDK "/Users/omar/Library/Android/sdk")
set(BINDER_DIR "${ANDROID_SDK}/platforms/android-36/optional/libbinder_ndk_cpp")
set(AIDL_EXE "${ANDROID_SDK}/build-tools/36.1.0/aidl.exe")
find_package(RmlUi CONFIG REQUIRED)
@@ -15,10 +16,26 @@ find_package(RmlUi CONFIG REQUIRED)
# message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/com/omixlab/mosis/IMosisService.cpp"
COMMAND ${AIDL_EXE} --lang=ndk --min_sdk_version=36 -o ${CMAKE_CURRENT_BINARY_DIR} -h ${CMAKE_CURRENT_BINARY_DIR} -I ..\\aidl ..\\aidl\\com\\omixlab\\mosis\\IMosisService.aidl
DEPENDS ../aidl/com/omixlab/mosis/IMosisService.aidl
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
VERBATIM
)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/com/omixlab/mosis/IMosisListener.cpp"
COMMAND ${AIDL_EXE} --lang=ndk --min_sdk_version=36 -o ${CMAKE_CURRENT_BINARY_DIR} -h ${CMAKE_CURRENT_BINARY_DIR} -I ..\\aidl ..\\aidl\\com\\omixlab\\mosis\\IMosisListener.aidl
DEPENDS ../aidl/com/omixlab/mosis/IMosisListener.aidl
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
VERBATIM
)
add_library(mosis-service SHARED
mosis-service.cpp
com/omixlab/mosis/IMosisService.cpp
com/omixlab/mosis/IMosisListener.cpp
${CMAKE_CURRENT_BINARY_DIR}/com/omixlab/mosis/IMosisService.cpp
${CMAKE_CURRENT_BINARY_DIR}/com/omixlab/mosis/IMosisListener.cpp
assets_manager.cpp
shader.cpp
external_texture.cpp
@@ -37,6 +54,7 @@ target_compile_definitions(mosis-service PUBLIC
)
target_include_directories(mosis-service PUBLIC
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${BINDER_DIR}
glad/include
)
@@ -46,8 +64,8 @@ target_link_libraries(mosis-service
)
add_library(mosis-test SHARED
com/omixlab/mosis/IMosisService.cpp
com/omixlab/mosis/IMosisListener.cpp
${CMAKE_CURRENT_BINARY_DIR}/com/omixlab/mosis/IMosisService.cpp
${CMAKE_CURRENT_BINARY_DIR}/com/omixlab/mosis/IMosisListener.cpp
mosis-test.cpp
assets_manager.cpp
shader.cpp
@@ -61,6 +79,7 @@ add_library(mosis-test SHARED
)
target_include_directories(mosis-test PUBLIC
${CMAKE_CURRENT_LIST_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${BINDER_DIR}
glad/include
)

View File

@@ -1,56 +0,0 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisListener.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include "aidl/com/omixlab/mosis/IMosisListener.h"
#include <android/binder_ibinder.h>
#include <cassert>
#ifndef __BIONIC__
#ifndef __assert2
#define __assert2(a,b,c,d) ((void)0)
#endif
#endif
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class BnMosisListener : public ::ndk::BnCInterface<IMosisListener> {
public:
BnMosisListener();
virtual ~BnMosisListener();
protected:
::ndk::SpAIBinder createBinder() override;
private:
};
class IMosisListenerDelegator : public BnMosisListener {
public:
explicit IMosisListenerDelegator(const std::shared_ptr<IMosisListener> &impl) : _impl(impl) {
}
::ndk::ScopedAStatus onServiceInitialized(bool in_success) override {
return _impl->onServiceInitialized(in_success);
}
::ndk::ScopedAStatus onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& in_buffer) override {
return _impl->onBufferAvailable(in_buffer);
}
::ndk::ScopedAStatus onFrameAvailable() override {
return _impl->onFrameAvailable();
}
protected:
private:
std::shared_ptr<IMosisListener> _impl;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -1,53 +0,0 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisService.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include "aidl/com/omixlab/mosis/IMosisService.h"
#include <android/binder_ibinder.h>
#include <cassert>
#ifndef __BIONIC__
#ifndef __assert2
#define __assert2(a,b,c,d) ((void)0)
#endif
#endif
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class BnMosisService : public ::ndk::BnCInterface<IMosisService> {
public:
BnMosisService();
virtual ~BnMosisService();
protected:
::ndk::SpAIBinder createBinder() override;
private:
};
class IMosisServiceDelegator : public BnMosisService {
public:
explicit IMosisServiceDelegator(const std::shared_ptr<IMosisService> &impl) : _impl(impl) {
}
::ndk::ScopedAStatus initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& in_listener, bool* _aidl_return) override {
return _impl->initOS(in_listener, _aidl_return);
}
::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) override {
return _impl->getNumber(_aidl_return);
}
protected:
private:
std::shared_ptr<IMosisService> _impl;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -1,31 +0,0 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisListener.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include "aidl/com/omixlab/mosis/IMosisListener.h"
#include <android/binder_ibinder.h>
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class BpMosisListener : public ::ndk::BpCInterface<IMosisListener> {
public:
explicit BpMosisListener(const ::ndk::SpAIBinder& binder);
virtual ~BpMosisListener();
::ndk::ScopedAStatus onServiceInitialized(bool in_success) override;
::ndk::ScopedAStatus onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& in_buffer) override;
::ndk::ScopedAStatus onFrameAvailable() override;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -1,30 +0,0 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisService.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include "aidl/com/omixlab/mosis/IMosisService.h"
#include <android/binder_ibinder.h>
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class BpMosisService : public ::ndk::BpCInterface<IMosisService> {
public:
explicit BpMosisService(const ::ndk::SpAIBinder& binder);
virtual ~BpMosisService();
::ndk::ScopedAStatus initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& in_listener, bool* _aidl_return) override;
::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) override;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -1,61 +0,0 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisListener.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <android/binder_interface_utils.h>
#include <android/hardware_buffer_aidl.h>
#ifdef BINDER_STABILITY_SUPPORT
#include <android/binder_stability.h>
#endif // BINDER_STABILITY_SUPPORT
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class IMosisListenerDelegator;
class IMosisListener : public ::ndk::ICInterface {
public:
typedef IMosisListenerDelegator DefaultDelegator;
static const char* descriptor;
IMosisListener();
virtual ~IMosisListener();
static constexpr uint32_t TRANSACTION_onServiceInitialized = FIRST_CALL_TRANSACTION + 0;
static constexpr uint32_t TRANSACTION_onBufferAvailable = FIRST_CALL_TRANSACTION + 1;
static constexpr uint32_t TRANSACTION_onFrameAvailable = FIRST_CALL_TRANSACTION + 2;
static std::shared_ptr<IMosisListener> fromBinder(const ::ndk::SpAIBinder& binder);
static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<IMosisListener>& instance);
static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<IMosisListener>* instance);
static bool setDefaultImpl(const std::shared_ptr<IMosisListener>& impl);
static const std::shared_ptr<IMosisListener>& getDefaultImpl();
virtual ::ndk::ScopedAStatus onServiceInitialized(bool in_success) = 0;
virtual ::ndk::ScopedAStatus onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& in_buffer) = 0;
virtual ::ndk::ScopedAStatus onFrameAvailable() = 0;
private:
static std::shared_ptr<IMosisListener> default_impl;
};
class IMosisListenerDefault : public IMosisListener {
public:
::ndk::ScopedAStatus onServiceInitialized(bool in_success) override;
::ndk::ScopedAStatus onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& in_buffer) override;
::ndk::ScopedAStatus onFrameAvailable() override;
::ndk::SpAIBinder asBinder() override;
bool isRemote() override;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -1,61 +0,0 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisService.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#pragma once
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <vector>
#include <android/binder_interface_utils.h>
#include <aidl/com/omixlab/mosis/IMosisListener.h>
#ifdef BINDER_STABILITY_SUPPORT
#include <android/binder_stability.h>
#endif // BINDER_STABILITY_SUPPORT
namespace aidl::com::omixlab::mosis {
class IMosisListener;
} // namespace aidl::com::omixlab::mosis
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
class IMosisServiceDelegator;
class IMosisService : public ::ndk::ICInterface {
public:
typedef IMosisServiceDelegator DefaultDelegator;
static const char* descriptor;
IMosisService();
virtual ~IMosisService();
static constexpr uint32_t TRANSACTION_initOS = FIRST_CALL_TRANSACTION + 0;
static constexpr uint32_t TRANSACTION_getNumber = FIRST_CALL_TRANSACTION + 1;
static std::shared_ptr<IMosisService> fromBinder(const ::ndk::SpAIBinder& binder);
static binder_status_t writeToParcel(AParcel* parcel, const std::shared_ptr<IMosisService>& instance);
static binder_status_t readFromParcel(const AParcel* parcel, std::shared_ptr<IMosisService>* instance);
static bool setDefaultImpl(const std::shared_ptr<IMosisService>& impl);
static const std::shared_ptr<IMosisService>& getDefaultImpl();
virtual ::ndk::ScopedAStatus initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& in_listener, bool* _aidl_return) = 0;
virtual ::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) = 0;
private:
static std::shared_ptr<IMosisService> default_impl;
};
class IMosisServiceDefault : public IMosisService {
public:
::ndk::ScopedAStatus initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& in_listener, bool* _aidl_return) override;
::ndk::ScopedAStatus getNumber(int32_t* _aidl_return) override;
::ndk::SpAIBinder asBinder() override;
bool isRemote() override;
};
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -1,242 +0,0 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisListener.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#include "aidl/com/omixlab/mosis/IMosisListener.h"
#include <cstdint>
#include <android/binder_parcel.h>
#include <android/binder_parcel_utils.h>
#include <android/binder_status.h>
#include <aidl/com/omixlab/mosis/BnMosisListener.h>
#include <aidl/com/omixlab/mosis/BpMosisListener.h>
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
static binder_status_t _aidl_com_omixlab_mosis_IMosisListener_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) {
(void)_aidl_in;
(void)_aidl_out;
binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION;
std::shared_ptr<BnMosisListener> _aidl_impl = std::static_pointer_cast<BnMosisListener>(::ndk::ICInterface::asInterface(_aidl_binder));
switch (_aidl_code) {
case (FIRST_CALL_TRANSACTION + 0 /*onServiceInitialized*/): {
bool in_success;
_aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_success);
if (_aidl_ret_status != STATUS_OK) break;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->onServiceInitialized(in_success);
_aidl_ret_status = STATUS_OK;
break;
}
case (FIRST_CALL_TRANSACTION + 1 /*onBufferAvailable*/): {
::aidl::android::hardware::HardwareBuffer in_buffer;
_aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_buffer);
if (_aidl_ret_status != STATUS_OK) break;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->onBufferAvailable(in_buffer);
_aidl_ret_status = STATUS_OK;
break;
}
case (FIRST_CALL_TRANSACTION + 2 /*onFrameAvailable*/): {
::ndk::ScopedAStatus _aidl_status = _aidl_impl->onFrameAvailable();
_aidl_ret_status = STATUS_OK;
break;
}
}
return _aidl_ret_status;
}
static AIBinder_Class* _g_aidl_com_omixlab_mosis_IMosisListener_clazz = ::ndk::ICInterface::defineClass(IMosisListener::descriptor, _aidl_com_omixlab_mosis_IMosisListener_onTransact, nullptr, 0);
BpMosisListener::BpMosisListener(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
BpMosisListener::~BpMosisListener() {}
::ndk::ScopedAStatus BpMosisListener::onServiceInitialized(bool in_success) {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinderReference().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = ::ndk::AParcel_writeData(_aidl_in.get(), in_success);
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinderReference().get(),
(FIRST_CALL_TRANSACTION + 0 /*onServiceInitialized*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_ONEWAY
#ifdef BINDER_STABILITY_SUPPORT
| static_cast<int>(FLAG_PRIVATE_LOCAL)
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IMosisListener::getDefaultImpl()) {
_aidl_status = IMosisListener::getDefaultImpl()->onServiceInitialized(in_success);
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
::ndk::ScopedAStatus BpMosisListener::onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& in_buffer) {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinderReference().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = ::ndk::AParcel_writeData(_aidl_in.get(), in_buffer);
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinderReference().get(),
(FIRST_CALL_TRANSACTION + 1 /*onBufferAvailable*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_ONEWAY
#ifdef BINDER_STABILITY_SUPPORT
| static_cast<int>(FLAG_PRIVATE_LOCAL)
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IMosisListener::getDefaultImpl()) {
_aidl_status = IMosisListener::getDefaultImpl()->onBufferAvailable(in_buffer);
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
::ndk::ScopedAStatus BpMosisListener::onFrameAvailable() {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinderReference().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinderReference().get(),
(FIRST_CALL_TRANSACTION + 2 /*onFrameAvailable*/),
_aidl_in.getR(),
_aidl_out.getR(),
FLAG_ONEWAY
#ifdef BINDER_STABILITY_SUPPORT
| static_cast<int>(FLAG_PRIVATE_LOCAL)
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IMosisListener::getDefaultImpl()) {
_aidl_status = IMosisListener::getDefaultImpl()->onFrameAvailable();
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
// Source for BnMosisListener
BnMosisListener::BnMosisListener() {}
BnMosisListener::~BnMosisListener() {}
::ndk::SpAIBinder BnMosisListener::createBinder() {
AIBinder* binder = AIBinder_new(_g_aidl_com_omixlab_mosis_IMosisListener_clazz, static_cast<void*>(this));
#ifdef BINDER_STABILITY_SUPPORT
AIBinder_markCompilationUnitStability(binder);
#endif // BINDER_STABILITY_SUPPORT
return ::ndk::SpAIBinder(binder);
}
// Source for IMosisListener
const char* IMosisListener::descriptor = "com.omixlab.mosis.IMosisListener";
IMosisListener::IMosisListener() {}
IMosisListener::~IMosisListener() {}
std::shared_ptr<IMosisListener> IMosisListener::fromBinder(const ::ndk::SpAIBinder& binder) {
if (!AIBinder_associateClass(binder.get(), _g_aidl_com_omixlab_mosis_IMosisListener_clazz)) {
#if __ANDROID_API__ >= 31
const AIBinder_Class* originalClass = AIBinder_getClass(binder.get());
if (originalClass == nullptr) return nullptr;
if (0 == strcmp(AIBinder_Class_getDescriptor(originalClass), descriptor)) {
return ::ndk::SharedRefBase::make<BpMosisListener>(binder);
}
#endif
return nullptr;
}
std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get());
if (interface) {
return std::static_pointer_cast<IMosisListener>(interface);
}
return ::ndk::SharedRefBase::make<BpMosisListener>(binder);
}
binder_status_t IMosisListener::writeToParcel(AParcel* parcel, const std::shared_ptr<IMosisListener>& instance) {
return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
}
binder_status_t IMosisListener::readFromParcel(const AParcel* parcel, std::shared_ptr<IMosisListener>* instance) {
::ndk::SpAIBinder binder;
binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
if (status != STATUS_OK) return status;
*instance = IMosisListener::fromBinder(binder);
return STATUS_OK;
}
bool IMosisListener::setDefaultImpl(const std::shared_ptr<IMosisListener>& impl) {
// Only one user of this interface can use this function
// at a time. This is a heuristic to detect if two different
// users in the same process use this function.
assert(!IMosisListener::default_impl);
if (impl) {
IMosisListener::default_impl = impl;
return true;
}
return false;
}
const std::shared_ptr<IMosisListener>& IMosisListener::getDefaultImpl() {
return IMosisListener::default_impl;
}
std::shared_ptr<IMosisListener> IMosisListener::default_impl = nullptr;
::ndk::ScopedAStatus IMosisListenerDefault::onServiceInitialized(bool /*in_success*/) {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::ScopedAStatus IMosisListenerDefault::onBufferAvailable(const ::aidl::android::hardware::HardwareBuffer& /*in_buffer*/) {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::ScopedAStatus IMosisListenerDefault::onFrameAvailable() {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::SpAIBinder IMosisListenerDefault::asBinder() {
return ::ndk::SpAIBinder();
}
bool IMosisListenerDefault::isRemote() {
return false;
}
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -1,227 +0,0 @@
/*
* This file is auto-generated. DO NOT MODIFY.
* Using: /Users/omar/Library/Android/sdk/build-tools/36.1.0/aidl --lang=ndk --min_sdk_version=36 -o src/main/cpp -h src/main/cpp -I src/main/aidl src/main/aidl/com/omixlab/mosis/IMosisService.aidl
*
* DO NOT CHECK THIS FILE INTO A CODE TREE (e.g. git, etc..).
* ALWAYS GENERATE THIS FILE FROM UPDATED AIDL COMPILER
* AS A BUILD INTERMEDIATE ONLY. THIS IS NOT SOURCE CODE.
*/
#include "aidl/com/omixlab/mosis/IMosisService.h"
#include <cstdint>
#include <android/binder_parcel.h>
#include <android/binder_parcel_utils.h>
#include <android/binder_status.h>
#include <aidl/com/omixlab/mosis/BnMosisListener.h>
#include <aidl/com/omixlab/mosis/BnMosisService.h>
#include <aidl/com/omixlab/mosis/BpMosisListener.h>
#include <aidl/com/omixlab/mosis/BpMosisService.h>
#include <aidl/com/omixlab/mosis/IMosisListener.h>
namespace aidl {
namespace com {
namespace omixlab {
namespace mosis {
static binder_status_t _aidl_com_omixlab_mosis_IMosisService_onTransact(AIBinder* _aidl_binder, transaction_code_t _aidl_code, const AParcel* _aidl_in, AParcel* _aidl_out) {
(void)_aidl_in;
(void)_aidl_out;
binder_status_t _aidl_ret_status = STATUS_UNKNOWN_TRANSACTION;
std::shared_ptr<BnMosisService> _aidl_impl = std::static_pointer_cast<BnMosisService>(::ndk::ICInterface::asInterface(_aidl_binder));
switch (_aidl_code) {
case (FIRST_CALL_TRANSACTION + 0 /*initOS*/): {
std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener> in_listener;
bool _aidl_return;
_aidl_ret_status = ::ndk::AParcel_readData(_aidl_in, &in_listener);
if (_aidl_ret_status != STATUS_OK) break;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->initOS(in_listener, &_aidl_return);
_aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
if (_aidl_ret_status != STATUS_OK) break;
if (!AStatus_isOk(_aidl_status.get())) break;
_aidl_ret_status = ::ndk::AParcel_writeData(_aidl_out, _aidl_return);
if (_aidl_ret_status != STATUS_OK) break;
break;
}
case (FIRST_CALL_TRANSACTION + 1 /*getNumber*/): {
int32_t _aidl_return;
::ndk::ScopedAStatus _aidl_status = _aidl_impl->getNumber(&_aidl_return);
_aidl_ret_status = AParcel_writeStatusHeader(_aidl_out, _aidl_status.get());
if (_aidl_ret_status != STATUS_OK) break;
if (!AStatus_isOk(_aidl_status.get())) break;
_aidl_ret_status = ::ndk::AParcel_writeData(_aidl_out, _aidl_return);
if (_aidl_ret_status != STATUS_OK) break;
break;
}
}
return _aidl_ret_status;
}
static AIBinder_Class* _g_aidl_com_omixlab_mosis_IMosisService_clazz = ::ndk::ICInterface::defineClass(IMosisService::descriptor, _aidl_com_omixlab_mosis_IMosisService_onTransact, nullptr, 0);
BpMosisService::BpMosisService(const ::ndk::SpAIBinder& binder) : BpCInterface(binder) {}
BpMosisService::~BpMosisService() {}
::ndk::ScopedAStatus BpMosisService::initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& in_listener, bool* _aidl_return) {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinderReference().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = ::ndk::AParcel_writeData(_aidl_in.get(), in_listener);
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinderReference().get(),
(FIRST_CALL_TRANSACTION + 0 /*initOS*/),
_aidl_in.getR(),
_aidl_out.getR(),
0
#ifdef BINDER_STABILITY_SUPPORT
| static_cast<int>(FLAG_PRIVATE_LOCAL)
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IMosisService::getDefaultImpl()) {
_aidl_status = IMosisService::getDefaultImpl()->initOS(in_listener, _aidl_return);
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
_aidl_ret_status = ::ndk::AParcel_readData(_aidl_out.get(), _aidl_return);
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
::ndk::ScopedAStatus BpMosisService::getNumber(int32_t* _aidl_return) {
binder_status_t _aidl_ret_status = STATUS_OK;
::ndk::ScopedAStatus _aidl_status;
::ndk::ScopedAParcel _aidl_in;
::ndk::ScopedAParcel _aidl_out;
_aidl_ret_status = AIBinder_prepareTransaction(asBinderReference().get(), _aidl_in.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AIBinder_transact(
asBinderReference().get(),
(FIRST_CALL_TRANSACTION + 1 /*getNumber*/),
_aidl_in.getR(),
_aidl_out.getR(),
0
#ifdef BINDER_STABILITY_SUPPORT
| static_cast<int>(FLAG_PRIVATE_LOCAL)
#endif // BINDER_STABILITY_SUPPORT
);
if (_aidl_ret_status == STATUS_UNKNOWN_TRANSACTION && IMosisService::getDefaultImpl()) {
_aidl_status = IMosisService::getDefaultImpl()->getNumber(_aidl_return);
goto _aidl_status_return;
}
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_ret_status = AParcel_readStatusHeader(_aidl_out.get(), _aidl_status.getR());
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
if (!AStatus_isOk(_aidl_status.get())) goto _aidl_status_return;
_aidl_ret_status = ::ndk::AParcel_readData(_aidl_out.get(), _aidl_return);
if (_aidl_ret_status != STATUS_OK) goto _aidl_error;
_aidl_error:
_aidl_status.set(AStatus_fromStatus(_aidl_ret_status));
_aidl_status_return:
return _aidl_status;
}
// Source for BnMosisService
BnMosisService::BnMosisService() {}
BnMosisService::~BnMosisService() {}
::ndk::SpAIBinder BnMosisService::createBinder() {
AIBinder* binder = AIBinder_new(_g_aidl_com_omixlab_mosis_IMosisService_clazz, static_cast<void*>(this));
#ifdef BINDER_STABILITY_SUPPORT
AIBinder_markCompilationUnitStability(binder);
#endif // BINDER_STABILITY_SUPPORT
return ::ndk::SpAIBinder(binder);
}
// Source for IMosisService
const char* IMosisService::descriptor = "com.omixlab.mosis.IMosisService";
IMosisService::IMosisService() {}
IMosisService::~IMosisService() {}
std::shared_ptr<IMosisService> IMosisService::fromBinder(const ::ndk::SpAIBinder& binder) {
if (!AIBinder_associateClass(binder.get(), _g_aidl_com_omixlab_mosis_IMosisService_clazz)) {
#if __ANDROID_API__ >= 31
const AIBinder_Class* originalClass = AIBinder_getClass(binder.get());
if (originalClass == nullptr) return nullptr;
if (0 == strcmp(AIBinder_Class_getDescriptor(originalClass), descriptor)) {
return ::ndk::SharedRefBase::make<BpMosisService>(binder);
}
#endif
return nullptr;
}
std::shared_ptr<::ndk::ICInterface> interface = ::ndk::ICInterface::asInterface(binder.get());
if (interface) {
return std::static_pointer_cast<IMosisService>(interface);
}
return ::ndk::SharedRefBase::make<BpMosisService>(binder);
}
binder_status_t IMosisService::writeToParcel(AParcel* parcel, const std::shared_ptr<IMosisService>& instance) {
return AParcel_writeStrongBinder(parcel, instance ? instance->asBinder().get() : nullptr);
}
binder_status_t IMosisService::readFromParcel(const AParcel* parcel, std::shared_ptr<IMosisService>* instance) {
::ndk::SpAIBinder binder;
binder_status_t status = AParcel_readStrongBinder(parcel, binder.getR());
if (status != STATUS_OK) return status;
*instance = IMosisService::fromBinder(binder);
return STATUS_OK;
}
bool IMosisService::setDefaultImpl(const std::shared_ptr<IMosisService>& impl) {
// Only one user of this interface can use this function
// at a time. This is a heuristic to detect if two different
// users in the same process use this function.
assert(!IMosisService::default_impl);
if (impl) {
IMosisService::default_impl = impl;
return true;
}
return false;
}
const std::shared_ptr<IMosisService>& IMosisService::getDefaultImpl() {
return IMosisService::default_impl;
}
std::shared_ptr<IMosisService> IMosisService::default_impl = nullptr;
::ndk::ScopedAStatus IMosisServiceDefault::initOS(const std::shared_ptr<::aidl::com::omixlab::mosis::IMosisListener>& /*in_listener*/, bool* /*_aidl_return*/) {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::ScopedAStatus IMosisServiceDefault::getNumber(int32_t* /*_aidl_return*/) {
::ndk::ScopedAStatus _aidl_status;
_aidl_status.set(AStatus_fromStatus(STATUS_UNKNOWN_TRANSACTION));
return _aidl_status;
}
::ndk::SpAIBinder IMosisServiceDefault::asBinder() {
return ::ndk::SpAIBinder();
}
bool IMosisServiceDefault::isRemote() {
return false;
}
} // namespace mosis
} // namespace omixlab
} // namespace com
} // namespace aidl

View File

@@ -94,7 +94,7 @@ void Kernel::main_loop()
return;
}
m_render_target = std::make_unique<RenderTarget>();
if (!m_render_target->create_exported(1024, 1024))
if (!m_render_target->create_exported(540, 960))
{
Logger::Log("failed to create render target");
return;
@@ -117,7 +117,7 @@ void Kernel::main_loop()
Rml::SetFileInterface(&AssetFilesInterface::Instance());
Rml::SetSystemInterface(&SystemInterface::Instance());
Rml::Initialise();
Rml::Context* context = Rml::CreateContext("default", Rml::Vector2i(1024, 1024));
Rml::Context* context = Rml::CreateContext("default", Rml::Vector2i(540, 960));
if (!context)
{
Logger::Log("RMLUI failed to create a context");
@@ -126,6 +126,7 @@ void Kernel::main_loop()
}
Rml::LoadFontFace("Roboto/static/Roboto_Condensed-Regular.ttf");
Rml::LoadFontFace("LatoLatin-Regular.ttf");
Rml::LoadFontFace("NotoEmoji-Regular.ttf", true);
// Now we are ready to load our document.
Rml::ElementDocument* document = context->LoadDocument("demo.rml");
@@ -133,15 +134,21 @@ void Kernel::main_loop()
while (true)
{
static float angle = 0.0f;
angle += 0.1f;
if (!m_tasks.empty())
{
std::lock_guard _lock(m_mutex);
for (const auto &task: m_tasks)
task(context);
m_tasks.clear();
}
m_render_target->bind();
glClearColor(fabs(sin(angle)), 0.0f, 0.0f, 1.0f);
glClearColor(0.f, 0.f, 0.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT);
glViewport(0, 0, 1024, 1024);
glViewport(0, 0, 540, 960);
context->Update();
rmlui_render_interface.SetViewport(1024, 1024);
rmlui_render_interface.SetViewport(540, 960);
rmlui_render_interface.BeginFrame();
context->Render();
rmlui_render_interface.EndFrame(m_render_target->framebuffer());
@@ -171,4 +178,23 @@ void Kernel::add_listener(const std::shared_ptr<IMosisListener> &listener)
listener->onBufferAvailable(*m_aidl_buffer);
}
void Kernel::on_touch_down(float x, float y)
{
Logger::Log(std::format("on_touch_down {} - {}", x, y));
}
void Kernel::on_touch_move(float x, float y)
{
Logger::Log(std::format("on_touch_move {} - {}", x, y));
std::lock_guard _lock(m_mutex);
m_tasks.emplace_back([x, y](Rml::Context* context){
context->ProcessMouseMove(x * 540, y * 960, 0);
});
}
void Kernel::on_touch_up(float x, float y)
{
Logger::Log(std::format("on_touch_up {} - {}", x, y));
}
Kernel::~Kernel() = default;

View File

@@ -3,11 +3,14 @@
#include <memory>
#include <unordered_map>
#include <thread>
#include <vector>
#include <functional>
class RenderTarget;
namespace egl { class Context; }
namespace aidl::com::omixlab::mosis { class IMosisListener; }
namespace aidl::android::hardware { struct HardwareBuffer; }
namespace Rml { class Context; }
class Kernel
{
@@ -15,6 +18,7 @@ class Kernel
std::unique_ptr<RenderTarget> m_render_target;
std::unordered_map<pid_t, std::shared_ptr<aidl::com::omixlab::mosis::IMosisListener>> m_listeners;
std::unique_ptr<aidl::android::hardware::HardwareBuffer> m_aidl_buffer;
std::vector<std::function<void(Rml::Context*)>> m_tasks;
std::mutex m_mutex;
std::thread m_main_loop_thread;
void main_loop();
@@ -22,4 +26,7 @@ public:
explicit Kernel(const std::shared_ptr<aidl::com::omixlab::mosis::IMosisListener>& listener);
virtual ~Kernel();
void add_listener(const std::shared_ptr<aidl::com::omixlab::mosis::IMosisListener>& listener);
void on_touch_down(float x, float y);
void on_touch_move(float x, float y);
void on_touch_up(float x, float y);
};

View File

@@ -31,11 +31,6 @@ class NativeService : public BnMosisService
std::unique_ptr<Kernel> m_kernel;
public:
NativeService() = default;
ndk::ScopedAStatus getNumber(int32_t *_aidl_return) override
{
*_aidl_return = 100;
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus initOS(const std::shared_ptr<IMosisListener>& listener,
bool *_aidl_return) override
{
@@ -51,6 +46,27 @@ public:
}
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus onTouchDown(float in_x, float in_y) override
{
if (m_kernel)
m_kernel->on_touch_down(in_x, in_y);
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus onTouchMove(float in_x, float in_y) override
{
if (m_kernel)
m_kernel->on_touch_move(in_x, in_y);
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus onTouchUp(float in_x, float in_y) override
{
if (m_kernel)
m_kernel->on_touch_up(in_x, in_y);
return ndk::ScopedAStatus::ok();
}
};
extern "C"