no message

This commit is contained in:
gem
2025-02-18 15:21:31 +08:00
commit 2d133e56d7
1980 changed files with 465595 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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/empty/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

View File

@@ -0,0 +1,49 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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

View File

@@ -0,0 +1,32 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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/empty/modules/Battery.h"
namespace cc {
float Battery::getBatteryLevel() const {
return 1.0F;
}
} // namespace cc

View File

@@ -0,0 +1,36 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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

View File

@@ -0,0 +1,143 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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/empty/modules/CanvasRenderingContext2DDelegate.h"
#include "platform/empty/EmptyPlatform.h"
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 cc {
CanvasRenderingContext2DDelegate::CanvasRenderingContext2DDelegate() {
}
CanvasRenderingContext2DDelegate::~CanvasRenderingContext2DDelegate() {
}
void CanvasRenderingContext2DDelegate::recreateBuffer(float w, float h) {
}
void CanvasRenderingContext2DDelegate::beginPath() {
}
void CanvasRenderingContext2DDelegate::closePath() {
}
void CanvasRenderingContext2DDelegate::moveTo(float x, float y) {
//
}
void CanvasRenderingContext2DDelegate::lineTo(float x, float y) {
}
void CanvasRenderingContext2DDelegate::stroke() {
}
void CanvasRenderingContext2DDelegate::saveContext() {
}
void CanvasRenderingContext2DDelegate::restoreContext() {
}
void CanvasRenderingContext2DDelegate::clearRect(float x, float y, float w, float h) {
}
void CanvasRenderingContext2DDelegate::fillRect(float x, float y, float w, float h) {
}
void CanvasRenderingContext2DDelegate::fillText(const ccstd::string &text, float x, float y, float /*maxWidth*/) {
}
void CanvasRenderingContext2DDelegate::strokeText(const ccstd::string &text, float /*x*/, float /*y*/, float /*maxWidth*/) const {
}
CanvasRenderingContext2DDelegate::Size CanvasRenderingContext2DDelegate::measureText(const ccstd::string &text) {
return Size{0, 0};
}
void CanvasRenderingContext2DDelegate::updateFont(const ccstd::string &fontName,
float fontSize,
bool bold,
bool italic,
bool oblique,
bool /* smallCaps */) {
}
void CanvasRenderingContext2DDelegate::setTextAlign(TextAlign align) {
}
void CanvasRenderingContext2DDelegate::setTextBaseline(TextBaseline baseline) {
//
}
void CanvasRenderingContext2DDelegate::setFillStyle(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
//
}
void CanvasRenderingContext2DDelegate::setStrokeStyle(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {
//
}
void CanvasRenderingContext2DDelegate::setLineWidth(float lineWidth) {
//
}
const cc::Data &CanvasRenderingContext2DDelegate::getDataRef() const {
return _imageData;
}
void CanvasRenderingContext2DDelegate::fill() {
}
void CanvasRenderingContext2DDelegate::setLineCap(const ccstd::string &lineCap) {
}
void CanvasRenderingContext2DDelegate::setLineJoin(const ccstd::string &lineJoin) {
}
void CanvasRenderingContext2DDelegate::fillImageData(const Data & /* imageData */,
float /* imageWidth */,
float /* imageHeight */,
float /* offsetX */,
float /* offsetY */) {
//XCreateImage(display, visual, DefaultDepth(display,DefaultScreen(display)), ZPixmap, 0, image32, width, height, 32, 0);
//XPutImage(dpy, w, gc, image, 0, 0, 50, 60, 40, 30);
}
void CanvasRenderingContext2DDelegate::strokeText(const ccstd::string & /* text */,
float /* x */,
float /* y */,
float /* maxWidth */) {
}
void CanvasRenderingContext2DDelegate::rect(float /* x */,
float /* y */,
float /* w */,
float /* h */) {
}
} // namespace cc

View File

@@ -0,0 +1,86 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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 <cstdint>
#include <regex>
#include "base/csscolorparser.h"
#include "base/std/container/array.h"
#include "cocos/bindings/manual/jsb_platform.h"
#include "math/Math.h"
#include "platform/FileUtils.h"
namespace cc {
class CC_DLL CanvasRenderingContext2DDelegate : public ICanvasRenderingContext2D::Delegate {
public:
using Point = ccstd::array<float, 2>;
using Vec2 = ccstd::array<float, 2>;
using Size = ccstd::array<float, 2>;
using Color4F = ccstd::array<float, 4>;
using TextAlign = ICanvasRenderingContext2D::TextAlign;
using TextBaseline = ICanvasRenderingContext2D::TextBaseline;
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 ccstd::string &text, float x, float y, float /*maxWidth*/) override;
void strokeText(const ccstd::string &text, float /*x*/, float /*y*/, float /*maxWidth*/) const;
Size measureText(const ccstd::string &text) override;
void updateFont(const ccstd::string &fontName, float fontSize, bool bold, bool italic, bool oblique, bool smallCaps) override;
void setTextAlign(TextAlign align) override;
void setTextBaseline(TextBaseline baseline) override;
void setFillStyle(uint8_t r, uint8_t g, uint8_t b, uint8_t a) override;
void setStrokeStyle(uint8_t r, uint8_t g, uint8_t b, uint8_t a) override;
void setLineWidth(float lineWidth) override;
const cc::Data &getDataRef() const override;
void fill() override;
void setLineCap(const ccstd::string &lineCap) override;
void setLineJoin(const ccstd::string &lineCap) override;
void fillImageData(const Data &imageData, float imageWidth, float imageHeight, float offsetX, float offsetY) override;
void strokeText(const ccstd::string &text, float /*x*/, float /*y*/, float /*maxWidth*/) override;
void rect(float x, float y, float w, float h) override;
void updateData() override {}
void setShadowBlur(float blur) override {}
void setShadowColor(uint8_t r, uint8_t g, uint8_t b, uint8_t a) override {}
void setShadowOffsetX(float offsetX) override {}
void setShadowOffsetY(float offsetY) override {}
private:
cc::Data _imageData;
};
} // namespace cc

View File

@@ -0,0 +1,32 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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/empty/modules/Network.h"
namespace cc {
INetwork::NetworkType Network::getNetworkType() const {
return INetwork::NetworkType::LAN;
}
} // namespace cc

View File

@@ -0,0 +1,36 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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

View File

@@ -0,0 +1,67 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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/empty/modules/Screen.h"
#include "base/Macros.h"
#include "cocos/bindings/jswrapper/SeApi.h"
namespace cc {
int Screen::getDPI() const {
static int dpi = -1;
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

View File

@@ -0,0 +1,50 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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

View File

@@ -0,0 +1,66 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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/empty/modules/System.h"
#include <string.h>
namespace cc {
using OSType = System::OSType;
OSType System::getOSType() const {
return OSType::LINUX;
}
ccstd::string System::getDeviceModel() const {
return "Empty";
}
System::LanguageType System::getCurrentLanguage() const {
return LanguageType::ENGLISH;
}
ccstd::string System::getCurrentLanguageCode() const {
return "en";
}
ccstd::string System::getSystemVersion() const {
return "empty";
}
bool System::openURL(const ccstd::string &url) {
return true;
}
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;
return ret;
}
void System::copyTextToClipboard(const ccstd::string &text) {
// TODO
}
} // namespace cc

View File

@@ -0,0 +1,68 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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.
*/
ccstd::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.
*/
ccstd::string getCurrentLanguageCode() const override;
/**
@brief Get system version.
@return system version.
*/
ccstd::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 ccstd::string &url) override;
void copyTextToClipboard(const ccstd::string &text) override;
private:
LanguageType getLanguageTypeByISO2(const char *code) const;
};
} // namespace cc

View File

@@ -0,0 +1,69 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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/empty/modules/SystemWindow.h"
#include <functional>
#include "base/Log.h"
#include "base/Macros.h"
#include "engine/EngineEvents.h"
#include "platform/empty/EmptyPlatform.h"
namespace {
} // namespace
namespace cc {
SystemWindow::SystemWindow(uint32_t windowId, void* externalHandle)
: _windowId(windowId) {
if (externalHandle) {
_windowHandle = reinterpret_cast<uintptr_t>(externalHandle);
}
}
SystemWindow::~SystemWindow() = default;
uintptr_t SystemWindow::getWindowHandle() const {
return _windowHandle;
}
uint32_t SystemWindow::getWindowId() const {
return _windowId;
}
void SystemWindow::setCursorEnabled(bool value) {
}
int SystemWindow::init() {
return 0;
}
void SystemWindow::pollEvent(bool* quit) {
return;
}
SystemWindow::Size SystemWindow::getViewSize() const {
return Size{static_cast<float>(_width), static_cast<float>(_height)};
}
} // namespace cc

View File

@@ -0,0 +1,58 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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"
namespace cc {
class CC_DLL SystemWindow : public ISystemWindow {
public:
explicit SystemWindow(uint32_t windowId, void* externalHandle);
~SystemWindow() override;
uintptr_t getWindowHandle() const override;
uint32_t getWindowId() const override;
Size getViewSize() const override;
/*
@brief enable/disable(lock) the cursor, default is enabled
*/
void setCursorEnabled(bool value) override;
int init();
void pollEvent(bool* quit);
private:
int _width{0};
int _height{0};
uint32_t _windowId{0};
uintptr_t _windowHandle{0};
};
} // namespace cc

View File

@@ -0,0 +1,63 @@
/****************************************************************************
Copyright (c) 2021-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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 "SystemWindowManager.h"
#include "platform/BasePlatform.h"
#include "platform/empty/modules/SystemWindow.h"
#include "platform/interfaces/modules/ISystemWindowManager.h"
namespace cc {
int SystemWindowManager::init() {
return 0;
}
void SystemWindowManager::processEvent() {
}
ISystemWindow *SystemWindowManager::getWindow(uint32_t windowId) const {
if (windowId == 0) {
return nullptr;
}
auto iter = _windows.find(windowId);
if (iter != _windows.end()) {
return iter->second.get();
}
return nullptr;
}
ISystemWindow *SystemWindowManager::createWindow(const cc::ISystemWindowInfo &info) {
ISystemWindow *window = BasePlatform::getPlatform()->createNativeWindow(_nextWindowId, info.externalHandle);
if (window) {
if (!info.externalHandle) {
window->createWindow(info.title.c_str(), info.x, info.y, info.width, info.height, info.flags);
}
_windows[_nextWindowId] = std::shared_ptr<ISystemWindow>(window);
_nextWindowId++;
}
return window;
}
} // namespace cc

View File

@@ -0,0 +1,49 @@
/****************************************************************************
Copyright (c) 2021-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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 "base/std/container/unordered_map.h"
#include "platform/interfaces/modules/ISystemWindowManager.h"
namespace cc {
class ISystemWindow;
class SystemWindowManager : public ISystemWindowManager {
public:
explicit SystemWindowManager() = default;
int init() override;
void processEvent() override;
ISystemWindow *createWindow(const ISystemWindowInfo &info) override;
ISystemWindow *getWindow(uint32_t windowId) const override;
const SystemWindowMap &getWindows() const override { return _windows; }
private:
uint32_t _nextWindowId{1}; // start from 1, 0 means an invalid ID
SystemWindowMap _windows;
};
} // namespace cc

View File

@@ -0,0 +1,35 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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/empty/modules/Vibrator.h"
#include "base/Macros.h"
namespace cc {
void Vibrator::vibrate(float duration) {
CC_UNUSED_PARAM(duration);
}
} // namespace cc

View File

@@ -0,0 +1,43 @@
/****************************************************************************
Copyright (c) 2022-2023 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 documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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