Remove the adaptation source code of qnx (#10616)

* Remove the adaptation source code of qnx
This commit is contained in:
qiuguohua
2022-04-01 10:54:44 +08:00
committed by GitHub
parent 9f83fb1ae9
commit 2ed00a11e0
24 changed files with 20 additions and 1693 deletions
+13 -50
View File
@@ -392,11 +392,6 @@ elseif(LINUX)
cocos/platform/linux/LinuxPlatform.cpp
cocos/platform/linux/LinuxPlatform.h
)
elseif(QNX)
cocos_source_files(
cocos/platform/qnx/QnxPlatform.cpp
cocos/platform/qnx/QnxPlatform.h
)
elseif(ANDROID)
cocos_source_files(
cocos/platform/android/AndroidPlatform.cpp
@@ -473,11 +468,6 @@ elseif(MACOSX OR IOS)
cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.mm
cocos/platform/apple/modules/CanvasRenderingContext2DDelegate.h
)
elseif(QNX)
cocos_source_files(
cocos/platform/qnx/modules/CanvasRenderingContext2DDelegate.cpp
cocos/platform/qnx/modules/CanvasRenderingContext2DDelegate.h
)
elseif(LINUX)
cocos_source_files(
cocos/platform/linux/modules/CanvasRenderingContext2DDelegate.cpp
@@ -606,23 +596,6 @@ elseif(LINUX)
cocos/platform/linux/modules/SystemWindow.cpp
cocos/platform/linux/modules/SystemWindow.h
)
elseif(QNX)
cocos_source_files(
cocos/platform/qnx/modules/Accelerometer.cpp
cocos/platform/qnx/modules/Accelerometer.h
cocos/platform/qnx/modules/Battery.cpp
cocos/platform/qnx/modules/Battery.h
cocos/platform/qnx/modules/Screen.cpp
cocos/platform/qnx/modules/Screen.h
cocos/platform/qnx/modules/Network.cpp
cocos/platform/qnx/modules/Network.h
cocos/platform/qnx/modules/Vibrator.cpp
cocos/platform/qnx/modules/Vibrator.h
cocos/platform/qnx/modules/System.cpp
cocos/platform/qnx/modules/System.h
cocos/platform/qnx/modules/SystemWindow.cpp
cocos/platform/qnx/modules/SystemWindow.h
)
endif()
############ module log
@@ -946,11 +919,6 @@ elseif(LINUX)
cocos/platform/linux/FileUtils-linux.cpp
cocos/platform/linux/FileUtils-linux.h
)
elseif(QNX)
cocos_source_files(MODULE ccfilesystem
cocos/platform/qnx/FileUtils-qnx.cpp
cocos/platform/qnx/FileUtils-qnx.h
)
endif()
##### renderer
@@ -1937,10 +1905,6 @@ elseif(LINUX)
cocos_source_files(
NO_WERROR cocos/bindings/manual/jsb_platfrom_linux.cpp
)
elseif(QNX)
cocos_source_files(
NO_WERROR cocos/bindings/manual/jsb_platfrom_qnx.cpp
)
endif()
############# module bindings
@@ -2135,13 +2099,7 @@ elseif(WIN32)
NO_WERROR cocos/ui/edit-box/EditBox-win32.cpp
)
endif()
elseif(LINUX)
if(USE_EDIT_BOX)
cocos_source_files(
NO_WERROR cocos/ui/edit-box/EditBox-linux.cpp
)
endif()
elseif(QNX)
elseif(LINUX OR QNX)
if(USE_EDIT_BOX)
cocos_source_files(
NO_WERROR cocos/ui/edit-box/EditBox-linux.cpp
@@ -2167,7 +2125,6 @@ cocos_source_files(
list(APPEND COCOS2D_SOURCE_LIST ${CC_EXTERNAL_SOURCES})
if(USE_MODULES)
add_library(ccmath ${ccmath_SOURCE_LIST})
add_library(cclog ${cclog_SOURCE_LIST})
@@ -2254,6 +2211,15 @@ else()
)
endif()
source_group(TREE ${CWD} PREFIX "Source Files" FILES ${COCOS2D_SOURCE_LIST})
if(QNX)
include(${QNX_PATH}/source.cmake)
qnx_source_list(ccqnx_SOURCE_LIST ${QNX_PATH})
source_group(TREE ${QNX_PATH} PREFIX "Source Files" FILES ${ccqnx_SOURCE_LIST}})
list(APPEND COCOS2D_SOURCE_LIST ${ccqnx_SOURCE_LIST})
endif()
add_library(cocos2d ${COCOS2D_SOURCE_LIST})
if(USE_MODULES)
@@ -2510,10 +2476,9 @@ if(APPLE)
endif()
if(QNX)
include(${QNX_PATH}/setup.cmake)
qnx_set_property(cocos2d)
target_link_libraries(cocos2d PUBLIC
socket
ssl
screen
${CC_EXTERNAL_LIBS}
)
elseif(LINUX)
@@ -2525,6 +2490,4 @@ elseif(LINUX)
${LINUX_GRAPHIC_LIBS}
${CC_EXTERNAL_LIBS}
)
endif()
source_group(TREE ${CWD} PREFIX "Source Files" FILES ${COCOS2D_SOURCE_LIST})
endif()
+5
View File
@@ -54,6 +54,10 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "iOS")
set(PLATFORM_FOLDER ios)
set(CC_PLATFORM ${CC_PLATFORM_MAC_IOS})
elseif(${CMAKE_SYSTEM_NAME} MATCHES "QNX")
if(NOT IS_DIRECTORY ${QNX_PATH})
message(FATAL_ERROR "platform adaptation package not found")
return()
endif()
set(QNX TRUE)
set(PLATFORM_FOLDER qnx)
set(CC_PLATFORM ${CC_PLATFORM_QNX})
@@ -210,6 +214,7 @@ elseif(ANDROID)
include(${CMAKE_CURRENT_LIST_DIR}/../templates/cmake/android.cmake)
elseif(OHOS)
include(${CMAKE_CURRENT_LIST_DIR}/../templates/cmake/ohos.cmake)
elseif(QNX)
else()
message(FATAL_ERROR "Unhandled platform specified cmake utils!")
endif()
@@ -1,87 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "jsb_platform.h"
#include "cocos/bindings/jswrapper/SeApi.h"
#include "cocos/bindings/manual/jsb_conversions.h"
#include "cocos/bindings/manual/jsb_global_init.h"
#include "cocos/platform/FileUtils.h"
#include <regex>
using namespace cc;
static std::unordered_map<std::string, std::string> _fontFamilyNameMap;
const std::unordered_map<std::string, std::string> &getFontFamilyNameMap() {
return _fontFamilyNameMap;
}
static bool JSB_loadFont(se::State &s) {
const auto & args = s.args();
size_t argc = args.size();
CC_UNUSED bool ok = true;
if (argc >= 1) {
s.rval().setNull();
std::string originalFamilyName;
ok &= seval_to_std_string(args[0], &originalFamilyName);
SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: originalFamilyName");
std::string source;
ok &= seval_to_std_string(args[1], &source);
SE_PRECONDITION2(ok, false, "JSB_loadFont : Error processing argument: source");
std::string fontFilePath;
std::regex re("url\\(\\s*'\\s*(.*?)\\s*'\\s*\\)");
std::match_results<std::string::const_iterator> results;
if (std::regex_search(source.cbegin(), source.cend(), results, re)) {
fontFilePath = results[1].str();
}
fontFilePath = FileUtils::getInstance()->fullPathForFilename(fontFilePath);
if (fontFilePath.empty()) {
SE_LOGE("Font (%s) doesn't exist!", fontFilePath.c_str());
return true;
}
// just put the path info, used at CanvasRenderingContext2DImpl::updateFont()
_fontFamilyNameMap.emplace(originalFamilyName, fontFilePath);
s.rval().setString(originalFamilyName);
return true;
}
SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1);
return false;
}
SE_BIND_FUNC(JSB_loadFont)
bool register_platform_bindings(se::Object *obj) {
__jsbObj->defineFunction("loadFont", _SE(JSB_loadFont));
return true;
}
@@ -123,6 +123,7 @@ void CanvasRenderingContext2D::strokeText(const std::string &text, float x, floa
cc::Size CanvasRenderingContext2D::measureText(const std::string &text) {
//SE_LOGD("CanvasRenderingContext2D::measureText: %s\n", text.c_str());
recreateBufferIfNeeded();
auto s = _delegate->measureText(text);
return cc::Size(s[0], s[1]);
}
@@ -235,6 +236,7 @@ void CanvasRenderingContext2D::rect(float x, float y, float w, float h) {
}
void CanvasRenderingContext2D::setFont(const std::string &font) {
recreateBufferIfNeeded();
#if CC_PLATFORM == CC_PLATFORM_WINDOWS
if (_font != font) {
_font = font;
-125
View File
@@ -1,125 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "FileUtils-qnx.h"
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fstream>
#include "base/Log.h"
#define DECLARE_GUARD std::lock_guard<std::recursive_mutex> mutexGuard(_mutex)
#ifndef CC_RESOURCE_FOLDER_LINUX
#define CC_RESOURCE_FOLDER_LINUX ("/Resources/")
#endif
namespace cc {
FileUtils *FileUtils::getInstance() {
if (FileUtils::sharedFileUtils == nullptr) {
FileUtils::sharedFileUtils = new FileUtilsQNX();
if (!FileUtils::sharedFileUtils->init()) {
delete FileUtils::sharedFileUtils;
FileUtils::sharedFileUtils = nullptr;
CC_LOG_DEBUG("ERROR: Could not init CCFileUtilsQNX");
}
}
return FileUtils::sharedFileUtils;
}
bool FileUtilsQNX::init() {
// get application path
// In QNX /proc/self/exefile is not a symbolic link; It's a regular file.
std::ifstream file("/proc/self/exefile");
if (!file) {
return false;
}
std::string appPath;
std::getline(file, appPath);
if (appPath.empty()) {
return false;
}
_defaultResRootPath = appPath.substr(0, appPath.find_last_of('/'));
_defaultResRootPath += CC_RESOURCE_FOLDER_LINUX;
// Set writable path to $XDG_CONFIG_HOME or ~/.config/<app name>/ if $XDG_CONFIG_HOME not exists.
const char *xdg_config_path = getenv("XDG_CONFIG_HOME");
std::string xdgConfigPath;
if (xdg_config_path == NULL) {
xdg_config_path = getenv("HOME");
if (xdg_config_path) {
xdgConfigPath = xdg_config_path;
}
#if _DEBUG
// In qnx debugging mode, the environment variables of HOME cannot be obtained.
// To facilitate debugging. Set a default directory
if (!xdg_config_path) {
// Set up a user directory and resources in the same directory.
xdgConfigPath = "/data/home/root";
// You can get the current application directory through API
// char* buf = getcwd(NULL, 0);
// xdgConfigPath = buf;
// free(buf);
}
#endif
xdgConfigPath += "/.config";
} else {
xdgConfigPath = xdg_config_path;
}
_writablePath = xdgConfigPath;
_writablePath += appPath.substr(appPath.find_last_of('/'));
_writablePath += "/";
return FileUtils::init();
}
bool FileUtilsQNX::isFileExistInternal(const std::string &filename) const {
if (filename.empty()) {
return false;
}
std::string strPath = filename;
if (!isAbsolutePath(strPath)) { // Not absolute path, add the default root path at the beginning.
strPath.insert(0, _defaultResRootPath);
}
struct stat sts;
return (stat(strPath.c_str(), &sts) == 0) && S_ISREG(sts.st_mode);
}
std::string FileUtilsQNX::getWritablePath() const {
struct stat st;
stat(_writablePath.c_str(), &st);
if (!S_ISDIR(st.st_mode)) {
mkdir(_writablePath.c_str(), 0744);
}
return _writablePath;
}
} // namespace cc
-40
View File
@@ -1,40 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include "platform/FileUtils.h"
namespace cc {
class CC_DLL FileUtilsQNX : public FileUtils {
public:
friend class FileUtils;
bool isFileExistInternal(const std::string &filename) const override;
std::string getWritablePath() const override;
bool init() override;
private:
std::string _writablePath;
};
} // namespace cc
-102
View File
@@ -1,102 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/qnx/QnxPlatform.h"
#include <sys/time.h>
#include <unistd.h>
#include "platform/interfaces/OSInterface.h"
#include "modules/Accelerometer.h"
#include "modules/Battery.h"
#include "modules/Network.h"
#include "modules/Screen.h"
#include "modules/System.h"
#include "modules/SystemWindow.h"
#include "modules/Vibrator.h"
namespace {
} // namespace
namespace cc {
QnxPlatform::QnxPlatform() {
// _sdl = std::make_unique<SDLHelper>(this);
}
QnxPlatform::~QnxPlatform() {
}
int32_t QnxPlatform::init() {
registerInterface(std::make_shared<Accelerometer>());
registerInterface(std::make_shared<Battery>());
registerInterface(std::make_shared<Network>());
registerInterface(std::make_shared<Screen>());
registerInterface(std::make_shared<System>());
_window = std::make_shared<SystemWindow>();
registerInterface(_window);
registerInterface(std::make_shared<Vibrator>());
return 0;
}
static long getCurrentMillSecond() {
long lLastTime;
struct timeval stCurrentTime;
gettimeofday(&stCurrentTime, NULL);
lLastTime = stCurrentTime.tv_sec * 1000 + stCurrentTime.tv_usec * 0.001; // milliseconds
return lLastTime;
}
int32_t QnxPlatform::loop() {
long lastTime = 0L;
long curTime = 0L;
long desiredInterval = 0L;
long actualInterval = 0L;
onResume();
while (!_quit) {
curTime = getCurrentMillSecond();
desiredInterval = static_cast<long>(1000.0 / getFps());
pollEvent();
actualInterval = curTime - lastTime;
if (actualInterval >= desiredInterval) {
lastTime = getCurrentMillSecond();
runTask();
//_sdl->swapWindow();
} else {
usleep((desiredInterval - curTime + lastTime) * 1000);
}
}
onDestory();
return 0;
}
void QnxPlatform::pollEvent() {
//_sdl->pollEvent(&_quit);
}
} // namespace cc
-52
View File
@@ -1,52 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include "platform/UniversalPlatform.h"
namespace cc {
class SystemWindow;
class CC_DLL QnxPlatform : public UniversalPlatform {
public:
QnxPlatform();
/**
* Destructor of WindowPlatform.
*/
~QnxPlatform() override;
/**
* Implementation of Windows platform initialization.
*/
int32_t init() override;
int32_t loop() override;
private:
void pollEvent() override;
bool _quit{false};
std::shared_ptr<SystemWindow> _window;
};
} // namespace cc
@@ -1,40 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/qnx/modules/Accelerometer.h"
namespace cc {
void Accelerometer::setAccelerometerEnabled(bool isEnabled) {
}
void Accelerometer::setAccelerometerInterval(float interval) {
}
const Accelerometer::MotionValue& Accelerometer::getDeviceMotionValue() {
static MotionValue motionValue;
return motionValue;
}
} // namespace cc
@@ -1,50 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include "platform/interfaces/modules/IAccelerometer.h"
namespace cc {
class CC_DLL Accelerometer : public IAccelerometer {
public:
/**
* To enable or disable accelerometer.
*/
void setAccelerometerEnabled(bool isEnabled) override;
/**
* Sets the interval of accelerometer.
*/
void setAccelerometerInterval(float interval) override;
/**
* Gets the motion value of current device.
*/
const MotionValue &getDeviceMotionValue() override;
};
} // namespace cc
@@ -1,34 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/qnx/modules/Battery.h"
namespace cc {
float Battery::getBatteryLevel() const {
return 1.0F;
}
} // namespace cc
@@ -1,37 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include "platform/interfaces/modules/IBattery.h"
namespace cc {
class CC_DLL Battery : public IBattery {
public:
float getBatteryLevel() const override;
};
} // namespace cc
@@ -1,302 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/qnx/modules/CanvasRenderingContext2DDelegate.h"
#include <iostream>
namespace {
#define RGB(r, g, b) (int)((int)r | (((int)g) << 8) | (((int)b) << 16))
#define RGBA(r, g, b, a) (int)((int)r | (((int)g) << 8) | (((int)b) << 16) | (((int)a) << 24))
} // namespace
namespace {
void fillRectWithColor(uint8_t *buf, uint32_t totalWidth, uint32_t totalHeight, uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
assert(x + width <= totalWidth);
assert(y + height <= totalHeight);
uint32_t y0 = y;
uint32_t y1 = y + height;
uint8_t *p;
for (uint32_t offsetY = y0; offsetY < y1; ++offsetY) {
for (uint32_t offsetX = x; offsetX < (x + width); ++offsetX) {
p = buf + (totalWidth * offsetY + offsetX) * 4;
*p++ = r;
*p++ = g;
*p++ = b;
*p++ = a;
}
}
}
} // namespace
namespace cc {
//static const char gdefaultFontName[] = "-*-helvetica-medium-o-*-*-24-*-*-*-*-*-iso8859-*";
//static const char gdefaultFontName[] = "lucidasanstypewriter-bold-24";
static const char gdefaultFontName[] = "lucidasans-24";
static const char gdefaultFontName1[] = "lucidasans";
CanvasRenderingContext2DDelegate::CanvasRenderingContext2DDelegate() {
//_surface = cairo_image_surface_create_for_data(pointer , CAIRO_FORMAT_ARGB32,size[0], size[1], stride);
//_cr = cairo_create (_surface);
}
CanvasRenderingContext2DDelegate::~CanvasRenderingContext2DDelegate() {
if (_cr != nullptr) {
cairo_destroy(_cr);
}
if (_surface) {
cairo_surface_destroy(_surface);
}
}
void CanvasRenderingContext2DDelegate::recreateBuffer(float w, float h) {
_bufferWidth = w;
_bufferHeight = h;
if (_bufferWidth < 1.0F || _bufferHeight < 1.0F) {
return;
}
auto textureSize = static_cast<int>(_bufferWidth * _bufferHeight * 4);
auto *data = static_cast<int8_t *>(malloc(sizeof(int8_t) * textureSize));
memset(data, 0x00, textureSize);
_imageData.fastSet((unsigned char *)data, textureSize);
if (_cr) {
cairo_destroy(_cr);
}
if (_surface) {
cairo_surface_destroy(_surface);
}
_surface = cairo_image_surface_create_for_data((unsigned char *)data, CAIRO_FORMAT_ARGB32, _bufferWidth, _bufferHeight, _bufferWidth * 4);
_cr = cairo_create(_surface);
}
void CanvasRenderingContext2DDelegate::beginPath() {
}
void CanvasRenderingContext2DDelegate::closePath() {
}
void CanvasRenderingContext2DDelegate::moveTo(float x, float y) {
CCASSERT(_cr != nullptr, "Cr pointer cannot be empty");
cairo_move_to(_cr, x, y);
}
void CanvasRenderingContext2DDelegate::lineTo(float x, float y) {
CCASSERT(_cr != nullptr, "Cr pointer cannot be empty");
cairo_line_to(_cr, x, y);
}
void CanvasRenderingContext2DDelegate::stroke() {
}
void CanvasRenderingContext2DDelegate::saveContext() {
}
void CanvasRenderingContext2DDelegate::restoreContext() {
}
void CanvasRenderingContext2DDelegate::clearRect(float x, float y, float w, float h) {
if (_bufferWidth < 1.0F || _bufferHeight < 1.0F) {
return;
}
if (_imageData.isNull()) {
return;
}
recreateBuffer(w, h);
}
void CanvasRenderingContext2DDelegate::fillRect(float x, float y, float w, float h) {
if (_bufferWidth < 1.0F || _bufferHeight < 1.0F) {
return;
}
CCASSERT(_cr != nullptr, "Cr pointer cannot be empty");
cairo_set_source_rgba(_cr, _fillStyle[0], _fillStyle[1], _fillStyle[2], _fillStyle[3]);
cairo_rectangle(_cr, x, y, w, h);
cairo_fill(_cr);
}
void CanvasRenderingContext2DDelegate::fillText(const std::string &text, float x, float y, float /*maxWidth*/) {
if (text.empty() || _bufferWidth < 1.0F || _bufferHeight < 1.0F) {
return;
}
// cairo_font_weight_t fontWeight = CAIRO_FONT_WEIGHT_NORMAL; // bold ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL;
// cairo_font_slant_t fontSlant = CAIRO_FONT_SLANT_NORMAL;
// cairo_select_font_face (_cr, "Arial", fontSlant, fontWeight);
cairo_set_font_size(_cr, _fontSize);
Point offsetPoint = convertDrawPoint(Point{x, y}, text);
cairo_set_source_rgba(_cr, _fillStyle[0], _fillStyle[1], _fillStyle[2], _fillStyle[3]);
cairo_move_to(_cr, offsetPoint[0], offsetPoint[1]);
cairo_show_text(_cr, text.c_str());
}
void CanvasRenderingContext2DDelegate::strokeText(const std::string &text, float /*x*/, float /*y*/, float /*maxWidth*/) const {
if (text.empty() || _bufferWidth < 1.0F || _bufferHeight < 1.0F) {
return;
}
}
CanvasRenderingContext2DDelegate::Size CanvasRenderingContext2DDelegate::measureText(const std::string &text) {
if (text.empty())
return std::array<float, 2>{0.0f, 0.0f};
cairo_text_extents_t extents;
cairo_text_extents(_cr, text.c_str(), &extents);
return std::array<float, 2>{static_cast<float>(extents.x_advance),
static_cast<float>(extents.height)};
}
void CanvasRenderingContext2DDelegate::updateFont(const std::string &fontName,
float fontSize,
bool bold,
bool italic,
bool oblique,
bool /* smallCaps */) {
do {
_fontName = fontName;
_fontSize = static_cast<int>(fontSize);
cairo_font_weight_t fontWeight = bold ? CAIRO_FONT_WEIGHT_BOLD : CAIRO_FONT_WEIGHT_NORMAL;
cairo_font_slant_t fontSlant = CAIRO_FONT_SLANT_NORMAL;
if (italic) {
fontSlant = CAIRO_FONT_SLANT_ITALIC;
} else if (oblique) {
fontSlant = CAIRO_FONT_SLANT_OBLIQUE;
}
std::cout << _fontName << std::endl;
cairo_select_font_face(_cr, _fontName.c_str(), fontSlant, fontWeight);
cairo_set_font_size(_cr, _fontSize);
} while (false);
}
void CanvasRenderingContext2DDelegate::setTextAlign(CanvasTextAlign align) {
_textAlign = align;
}
void CanvasRenderingContext2DDelegate::setTextBaseline(CanvasTextBaseline baseline) {
_textBaseLine = baseline;
}
void CanvasRenderingContext2DDelegate::setFillStyle(float r, float g, float b, float a) {
_fillStyle = {r, g, b, a};
}
void CanvasRenderingContext2DDelegate::setStrokeStyle(float r, float g, float b, float a) {
_strokeStyle = {r, g, b, a};
}
void CanvasRenderingContext2DDelegate::setLineWidth(float lineWidth) {
_lineWidth = lineWidth;
}
const cc::Data &CanvasRenderingContext2DDelegate::getDataRef() const {
return _imageData;
}
void CanvasRenderingContext2DDelegate::removeCustomFont() {
}
// x, y offset value
int CanvasRenderingContext2DDelegate::drawText(const std::string &text, int x, int y) {
cairo_move_to(_cr, x, y);
cairo_show_text(_cr, text.c_str());
return 0;
}
CanvasRenderingContext2DDelegate::Size CanvasRenderingContext2DDelegate::sizeWithText(const wchar_t *pszText, int nLen) {
return std::array<float, 2>{0.0F, 0.0F};
}
void CanvasRenderingContext2DDelegate::prepareBitmap(int nWidth, int nHeight) {
}
void CanvasRenderingContext2DDelegate::deleteBitmap() {
}
void CanvasRenderingContext2DDelegate::fillTextureData() {
}
std::array<float, 2> CanvasRenderingContext2DDelegate::convertDrawPoint(Point point, const std::string &text) {
int font_ascent = 0;
int font_descent = 0;
int direction = 0;
cairo_text_extents_t extents;
cairo_text_extents(_cr, text.c_str(), &extents);
int width = extents.width;
if (_textAlign == CanvasTextAlign::CENTER) {
point[0] -= width / 2.0f;
} else if (_textAlign == CanvasTextAlign::RIGHT) {
point[0] -= width;
}
if (_textBaseLine == CanvasTextBaseline::TOP) {
point[1] += -extents.y_bearing;
} else if (_textBaseLine == CanvasTextBaseline::MIDDLE) {
point[1] += extents.height / 2;
} else if (_textBaseLine == CanvasTextBaseline::BOTTOM) {
point[1] += extents.height;
}
if (text == ".") {
// The calculation of points is not the same as the calculation of numbers,
// which will cause the drawing of points and numbers to be different from the same horizontal line.
// Therefore, here is manually adjusted to calculate the drawing coordinates of
// the point according to the numerical calculation method
cairo_text_extents_t extentNumber;
cairo_text_extents(_cr, "1", &extentNumber);
point[1] += extents.y_bearing - extentNumber.y_bearing;
}
return point;
}
void CanvasRenderingContext2DDelegate::fill() {
}
void CanvasRenderingContext2DDelegate::setLineCap(const std::string &lineCap) {
}
void CanvasRenderingContext2DDelegate::setLineJoin(const std::string &lineJoin) {
}
void CanvasRenderingContext2DDelegate::fillImageData(const Data & /* imageData */,
float /* imageWidth */,
float /* imageHeight */,
float /* offsetX */,
float /* offsetY */) {
}
void CanvasRenderingContext2DDelegate::strokeText(const std::string & /* text */,
float /* x */,
float /* y */,
float /* maxWidth */) {
}
void CanvasRenderingContext2DDelegate::rect(float /* x */,
float /* y */,
float /* w */,
float /* h */) {
}
} // namespace cc
@@ -1,111 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include "platform/interfaces/modules/canvas/ICanvasRenderingContext2D.h"
#include <array>
#include <cstdint>
#include <regex>
#include "base/csscolorparser.h"
#include "cocos/bindings/manual/jsb_platform.h"
#include "math/Math.h"
#include "platform/FileUtils.h"
#include "cairo.h"
namespace cc {
class CC_DLL CanvasRenderingContext2DDelegate : public ICanvasRenderingContext2D::Delegate {
public:
using Point = std::array<float, 2>;
using Vec2 = std::array<float, 2>;
using Size = std::array<float, 2>;
using Color4F = std::array<float, 4>;
CanvasRenderingContext2DDelegate();
~CanvasRenderingContext2DDelegate() override;
void recreateBuffer(float w, float h) override;
void beginPath() override;
void closePath() override;
void moveTo(float x, float y) override;
void lineTo(float x, float y) override;
void stroke() override;
void saveContext() override;
void restoreContext() override;
void clearRect(float /*x*/, float /*y*/, float w, float h) override;
void fillRect(float x, float y, float w, float h) override;
void fillText(const std::string &text, float x, float y, float /*maxWidth*/) override;
void strokeText(const std::string &text, float /*x*/, float /*y*/, float /*maxWidth*/) const;
Size measureText(const std::string &text) override;
void updateFont(const std::string &fontName, float fontSize, bool bold, bool italic, bool oblique, bool smallCaps) override;
void setTextAlign(CanvasTextAlign align) override;
void setTextBaseline(CanvasTextBaseline baseline) override;
void setFillStyle(float r, float g, float b, float a) override;
void setStrokeStyle(float r, float g, float b, float a) override;
void setLineWidth(float lineWidth) override;
const cc::Data &getDataRef() const override;
void fill() override;
void setLineCap(const std::string &lineCap) override;
void setLineJoin(const std::string &lineCap) override;
void fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY) override;
void strokeText(const std::string &text, float /*x*/, float /*y*/, float /*maxWidth*/) override;
void rect(float x, float y, float w, float h) override;
void updateData() override {}
private:
static wchar_t * utf8ToUtf16(const std::string &str, int *pRetLen = nullptr);
void removeCustomFont();
int drawText(const std::string &text, int x, int y);
Size sizeWithText(const wchar_t *pszText, int nLen);
void prepareBitmap(int nWidth, int nHeight);
void deleteBitmap();
void fillTextureData();
std::array<float, 2> convertDrawPoint(Point point, const std::string &text);
public:
cairo_surface_t *_surface{nullptr};
cairo_t * _cr{nullptr};
private:
cc::Data _imageData;
std::string _curFontPath;
int _savedDC{0};
float _lineWidth{0.0F};
float _bufferWidth{0.0F};
float _bufferHeight{0.0F};
std::string _fontName;
int _fontSize{0};
Size _textSize;
CanvasTextAlign _textAlign{CanvasTextAlign::CENTER};
CanvasTextBaseline _textBaseLine{CanvasTextBaseline::TOP};
Color4F _fillStyle;
Color4F _strokeStyle;
};
} // namespace cc
@@ -1,34 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/qnx/modules/Network.h"
namespace cc {
INetwork::NetworkType Network::getNetworkType() const {
return INetwork::NetworkType::LAN;
}
} // namespace cc
@@ -1,37 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include "platform/interfaces/modules/INetwork.h"
namespace cc {
class CC_DLL Network : public INetwork {
public:
NetworkType getNetworkType() const override;
};
} // namespace cc
@@ -1,71 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/qnx/modules/Screen.h"
#include "base/Macros.h"
#include "cocos/bindings/jswrapper/SeApi.h"
namespace cc {
int Screen::getDPI() const {
static int dpi = -1;
if (dpi == -1) {
//screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_DPI, &dpi);
}
return dpi;
}
float Screen::getDevicePixelRatio() const {
return 1;
}
void Screen::setKeepScreenOn(bool value) {
CC_UNUSED_PARAM(value);
}
Screen::Orientation Screen::getDeviceOrientation() const {
return Orientation::PORTRAIT;
}
Vec4 Screen::getSafeAreaEdge() const {
return cc::Vec4();
}
bool Screen::isDisplayStats() {
se::AutoHandleScope hs;
se::Value ret;
char commandBuf[100] = "cc.profiler.isShowingStats();";
se::ScriptEngine::getInstance()->evalString(commandBuf, 100, &ret);
return ret.toBoolean();
}
void Screen::setDisplayStats(bool isShow) {
se::AutoHandleScope hs;
char commandBuf[100] = {0};
sprintf(commandBuf, isShow ? "cc.profiler.showStats();" : "cc.profiler.hideStats();");
se::ScriptEngine::getInstance()->evalString(commandBuf);
}
} // namespace cc
@@ -1,51 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include "platform/interfaces/modules/IScreen.h"
namespace cc {
class CC_DLL Screen : public IScreen {
public:
int getDPI() const override;
float getDevicePixelRatio() const override;
void setKeepScreenOn(bool value) override;
Orientation getDeviceOrientation() const override;
Vec4 getSafeAreaEdge() const override;
/**
@brief Get current display stats.
@return bool, is displaying stats or not.
*/
bool isDisplayStats() override;
/**
@brief set display stats information.
*/
void setDisplayStats(bool isShow) override;
};
} // namespace cc
@@ -1,126 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/qnx/modules/System.h"
#include <string.h>
#include <sys/utsname.h>
namespace cc {
using OSType = System::OSType;
OSType System::getOSType() const {
return OSType::QNX;
}
std::string System::getDeviceModel() const {
return "QNX";
}
System::LanguageType System::getCurrentLanguage() const {
char* pLanguageName = getenv("LANG");
if (!pLanguageName) {
return LanguageType::ENGLISH;
}
strtok(pLanguageName, "_");
if (!pLanguageName) {
return LanguageType::ENGLISH;
}
return getLanguageTypeByISO2(pLanguageName);
}
std::string System::getCurrentLanguageCode() const {
static char code[3] = {0};
char* pLanguageName = getenv("LANG");
if (!pLanguageName) {
return "en";
}
strtok(pLanguageName, "_");
if (!pLanguageName) {
return "en";
}
strncpy(code, pLanguageName, 2);
code[2] = '\0';
return code;
}
std::string System::getSystemVersion() const {
struct utsname u;
uname(&u);
return u.version;
}
bool System::openURL(const std::string& url) {
//std::string op = std::string("xdg-open '").append(url).append("'");
//return system(op.c_str()) == 0;
return false;
}
System::LanguageType System::getLanguageTypeByISO2(const char* code) const {
// this function is used by all platforms to get system language
// except windows: cocos/platform/win32/CCApplication-win32.cpp
LanguageType ret = LanguageType::ENGLISH;
if (strncmp(code, "zh", 2) == 0) {
ret = LanguageType::CHINESE;
} else if (strncmp(code, "ja", 2) == 0) {
ret = LanguageType::JAPANESE;
} else if (strncmp(code, "fr", 2) == 0) {
ret = LanguageType::FRENCH;
} else if (strncmp(code, "it", 2) == 0) {
ret = LanguageType::ITALIAN;
} else if (strncmp(code, "de", 2) == 0) {
ret = LanguageType::GERMAN;
} else if (strncmp(code, "es", 2) == 0) {
ret = LanguageType::SPANISH;
} else if (strncmp(code, "nl", 2) == 0) {
ret = LanguageType::DUTCH;
} else if (strncmp(code, "ru", 2) == 0) {
ret = LanguageType::RUSSIAN;
} else if (strncmp(code, "hu", 2) == 0) {
ret = LanguageType::HUNGARIAN;
} else if (strncmp(code, "pt", 2) == 0) {
ret = LanguageType::PORTUGUESE;
} else if (strncmp(code, "ko", 2) == 0) {
ret = LanguageType::KOREAN;
} else if (strncmp(code, "ar", 2) == 0) {
ret = LanguageType::ARABIC;
} else if (strncmp(code, "nb", 2) == 0) {
ret = LanguageType::NORWEGIAN;
} else if (strncmp(code, "pl", 2) == 0) {
ret = LanguageType::POLISH;
} else if (strncmp(code, "tr", 2) == 0) {
ret = LanguageType::TURKISH;
} else if (strncmp(code, "uk", 2) == 0) {
ret = LanguageType::UKRAINIAN;
} else if (strncmp(code, "ro", 2) == 0) {
ret = LanguageType::ROMANIAN;
} else if (strncmp(code, "bg", 2) == 0) {
ret = LanguageType::BULGARIAN;
}
return ret;
}
} // namespace cc
@@ -1,68 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include "platform/interfaces/modules/ISystem.h"
namespace cc {
class CC_DLL System : public ISystem {
public:
/**
@brief Get target system type.
*/
OSType getOSType() const override;
/**
@brief Get target device model.
*/
std::string getDeviceModel() const override;
/**
@brief Get current language config.
@return Current language config.
*/
LanguageType getCurrentLanguage() const override;
/**
@brief Get current language iso 639-1 code.
@return Current language iso 639-1 code.
*/
std::string getCurrentLanguageCode() const override;
/**
@brief Get system version.
@return system version.
*/
std::string getSystemVersion() const override;
/**
@brief Open url in default browser.
@param String with url to open.
@return True if the resource located by the URL was successfully opened; otherwise false.
*/
bool openURL(const std::string& url) override;
private:
LanguageType getLanguageTypeByISO2(const char* code) const;
};
} // namespace cc
@@ -1,134 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/qnx/modules/SystemWindow.h"
#include "base/Log.h"
#include "base/Macros.h"
// SDL headers
#include <functional>
#include "SDL2/SDL.h"
#include "SDL2/SDL_main.h"
#include "SDL2/SDL_syswm.h"
#include "bindings/event/EventDispatcher.h"
#include "platform/IEventDispatch.h"
#include "platform/qnx/QnxPlatform.h"
namespace cc {
SystemWindow::SystemWindow() {
}
SystemWindow::~SystemWindow() {
if (_screenWin) {
screen_destroy_window(_screenWin);
}
if (_screenCtx) {
screen_destroy_context(_screenCtx);
}
}
bool SystemWindow::createWindow(const char *title,
int w, int h, int flags) {
_width = w;
_height = h;
createWindow(title, 0, 0, w, h, flags);
return true;
}
bool SystemWindow::createWindow(const char *title,
int x, int y, int w,
int h, int flags) {
if (_screenWin) {
return true;
}
_width = w;
_height = h;
//Create the screen context
int rc = screen_create_context(&_screenCtx, SCREEN_APPLICATION_CONTEXT);
if (rc) {
perror("screen_create_window");
return EXIT_FAILURE;
}
//Create the screen window that will be render onto
rc = screen_create_window(&_screenWin, _screenCtx);
if (rc) {
perror("screen_create_window");
return EXIT_FAILURE;
}
screen_set_window_property_iv(_screenWin, SCREEN_PROPERTY_FORMAT, (const int[]){SCREEN_FORMAT_RGBX8888});
#ifdef CC_USE_GLES3
screen_set_window_property_iv(_screenWin, SCREEN_PROPERTY_USAGE, (const int[]){SCREEN_USAGE_OPENGL_ES3});
#elif CC_USE_GLES2
screen_set_window_property_iv(_screenWin, SCREEN_PROPERTY_USAGE, (const int[]){SCREEN_USAGE_OPENGL_ES2});
#endif
int pos[2] = {x, y}; /* size of the window on screen */
rc = screen_set_window_property_iv(_screenWin, SCREEN_PROPERTY_POSITION, pos);
if (rc) {
perror("screen_set_window_property_iv(SCREEN_PROPERTY_SIZE)");
return EXIT_FAILURE;
}
int size[2] = {w, h}; /* size of the window on screen */
rc = screen_set_window_property_iv(_screenWin, SCREEN_PROPERTY_SIZE, size);
if (rc) {
perror("screen_set_window_property_iv(SCREEN_PROPERTY_POSITION)");
return EXIT_FAILURE;
}
int dpi = 0;
screen_get_window_property_iv(_screenWin, SCREEN_PROPERTY_DPI, &dpi);
fprintf(stdout, "[glError] %d\n", dpi);
rc = screen_create_window_buffers(_screenWin, 2);
if (rc) {
perror("screen_create_window_buffers");
return EXIT_FAILURE;
}
// return _sdl->createWindow(title, x, y, w, h, flags);
return true;
}
uintptr_t SystemWindow::getWindowHandler() const {
return reinterpret_cast<uintptr_t>(_screenWin);
}
void SystemWindow::setCursorEnabled(bool value) {
//TODO
}
void SystemWindow::copyTextToClipboard(const std::string &text) {
//TODO
}
SystemWindow::Size SystemWindow::getViewSize() const {
return Size{static_cast<float>(_width), static_cast<float>(_height)};
}
} // namespace cc
@@ -1,62 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include <iostream>
#include "platform/interfaces/modules/ISystemWindow.h"
#include <screen/screen.h>
namespace cc {
class CC_DLL SystemWindow : public ISystemWindow {
public:
explicit SystemWindow();
~SystemWindow() override;
bool createWindow(const char* title,
int w, int h, int flags) override;
bool createWindow(const char* title,
int x, int y, int w,
int h, int flags) override;
uintptr_t getWindowHandler() const override;
Size getViewSize() const override;
/*
@brief enable/disable(lock) the cursor, default is enabled
*/
void setCursorEnabled(bool value) override;
void copyTextToClipboard(const std::string& text) override;
private:
int _width{0};
int _height{0};
// std::unique_ptr<SDLHelper> _sdl;
screen_context_t _screenCtx{nullptr};
screen_window_t _screenWin{nullptr};
};
} // namespace cc
@@ -1,36 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/qnx/modules/Vibrator.h"
#include "base/Macros.h"
namespace cc {
void Vibrator::vibrate(float duration) {
CC_UNUSED_PARAM(duration);
}
} // namespace cc
@@ -1,44 +0,0 @@
/****************************************************************************
Copyright (c) 2021-2022 Xiamen Yaji Software Co., Ltd.
http://www.cocos.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated engine source code (the "Software"), a limited,
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
to use Cocos Creator solely to develop games on your target platforms. You shall
not use Cocos Creator software for developing other software or tools that's
used for developing games. You are not granted to publish, distribute,
sublicense, and/or sell copies of Cocos Creator.
The software or tools in this License Agreement are licensed, not sold.
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
#include "platform/interfaces/modules/IVibrator.h"
namespace cc {
class CC_DLL Vibrator : public IVibrator {
public:
/**
* Vibrator for the specified amount of time.
* If Vibrator is not supported, then invoking this method has no effect.
* Some platforms limit to a maximum duration of 5 seconds.
* Duration is ignored on iOS due to API limitations.
* @param duration The duration in seconds.
*/
void vibrate(float duration) override;
};
} // namespace cc