Skip to content

Commit

Permalink
1.Fix the problem of incorrect rotation direction of openharmony screen
Browse files Browse the repository at this point in the history
2.Remove redundant files

# Conflicts:
#	templates/harmonyos-next/entry/src/main/ets/cocos/jsb-adapter/sys-ability-polyfill.js
  • Loading branch information
qiuguohua committed Dec 13, 2024
1 parent c2882db commit e4ac5b3
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 249 deletions.
2 changes: 1 addition & 1 deletion native/cocos/audio/openharmony/PcmAudioService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ void PcmAudioService::resume() {
OH_AudioRenderer_Start(_audioRenderer);
}
}
} // namespace cocos2d
} // namespace cc
4 changes: 2 additions & 2 deletions native/cocos/platform/openharmony/modules/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ Screen::Orientation Screen::getDeviceOrientation() const {
if(value == 0) {
return Orientation::PORTRAIT;
} else if(value == 1) {
return Orientation::LANDSCAPE_RIGHT;
return Orientation::LANDSCAPE_LEFT;
} else if(value == 2) {
return Orientation::PORTRAIT_UPSIDE_DOWN;
} else if(value == 3) {
return Orientation::LANDSCAPE_LEFT;
return Orientation::LANDSCAPE_RIGHT;
}
CC_ASSERT(false);
return Orientation::PORTRAIT;
Expand Down
5 changes: 2 additions & 3 deletions native/cocos/platform/openharmony/napi/NapiHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ enum ContextType {
ENGINE_UTILS,
EDITBOX_UTILS,
WEBVIEW_UTILS,
SYSTEM_UTILS,
DISPLAY_UTILS,
UV_ASYNC_SEND,
VIDEO_UTILS
Expand Down Expand Up @@ -226,13 +225,13 @@ static void napiOnDisplayChange(const Napi::CallbackInfo &info) {
orientation = static_cast<int>(cc::IScreen::Orientation::PORTRAIT);
break;
case 1: // ROTATION_90
orientation = static_cast<int>(cc::IScreen::Orientation::LANDSCAPE_RIGHT);
orientation = static_cast<int>(cc::IScreen::Orientation::LANDSCAPE_LEFT);
break;
case 2: // ROTATION_180
orientation = static_cast<int>(cc::IScreen::Orientation::PORTRAIT_UPSIDE_DOWN);
break;
case 3: // ROTATION_270
orientation = static_cast<int>(cc::IScreen::Orientation::LANDSCAPE_LEFT);
orientation = static_cast<int>(cc::IScreen::Orientation::LANDSCAPE_RIGHT);
break;
}
cc::events::Orientation::broadcast(orientation);
Expand Down
6 changes: 0 additions & 6 deletions platforms/native/builtin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,6 @@ for (const key in jsbWindow) {
}
}

// In the openharmony platform, XMLHttpRequest is not undefined, but there are problems to using it.
// So the native implementation is forced to be used.
if (window.oh && typeof globalThis.XMLHttpRequest !== 'undefined') {
globalThis.XMLHttpRequest = jsbWindow.XMLHttpRequest;
}

if (typeof globalThis.window === 'undefined') {
globalThis.window = globalThis;
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/native-pack-tool/source/platforms/harmonyos-next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ export class HarmonyOSNextPackTool extends NativePackTool {
moduleJSON.module.abilities[0].orientation = 'auto_rotation';
}
else if (cfg.landscapeRight && !cfg.landscapeLeft) {
moduleJSON.module.abilities[0].orientation = 'landscape';
moduleJSON.module.abilities[0].orientation = 'landscape_inverted';
}
else if (!cfg.landscapeRight && cfg.landscapeLeft) {
moduleJSON.module.abilities[0].orientation = 'landscape_inverted';
moduleJSON.module.abilities[0].orientation = 'landscape';
}
else if (cfg.landscapeRight && cfg.landscapeLeft) {
moduleJSON.module.abilities[0].orientation = 'auto_rotation_landscape';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libcocos.so",
"types": "./index.d.ts",
"version": "",
"version": "1.0.0",
"description": "Please describe the basic information."
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,11 @@ globalThis.initScreenInfo = function () {
if (data.boundingRects.length == 0) {
return;
}
const rc = data.boundingRects[0];
cutout.left = rc.left;
cutout.top = rc.top;
cutout.width = rc.width;
cutout.height = rc.height;

cutout.left = data.boundingRects[0].left;
cutout.top = data.boundingRects[0].top;
cutout.width = data.boundingRects[0].width;
cutout.height = data.boundingRects[0].height;
}).catch((err) => {
console.log("get cutout info error!");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export enum ContextType {
ENGINE_UTILS,
EDITBOX_UTILS,
WEBVIEW_UTILS,
SYSTEM_UTILS,
DISPLAY_UTILS,
UV_ASYNC_SEND,
VIDEO_UTILS
Expand Down

0 comments on commit e4ac5b3

Please sign in to comment.