Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { gameControllerService, GameControllerService, ButtonCode } from '../../service/input/GameControllerService';
import { GamepadManager } from '../../service/input/GamepadManager';
import { UsbDriverService } from '../../service/usbdriver';
import { gcButtonMap, AXIS_MAX, TRIGGER_MAX } from '../../service/input/GamepadTypes';
import { gcButtonMap, AXIS_MAX, TRIGGER_MAX, MoonlightButton } from '../../service/input/GamepadTypes';
import { AppColors } from '../../common/Theme';

// @Builder 按引用传参接口
Expand Down Expand Up @@ -429,6 +429,13 @@ export struct GameControllerTestView {
state.rightStickX = Math.floor(x * AXIS_MAX);
state.rightStickY = Math.floor(-y * AXIS_MAX);
break;
case 2: // D-Pad
state.buttons &= ~MoonlightButton.DPAD_MASK;
if (y < -0.5) state.buttons |= MoonlightButton.UP;
if (y > 0.5) state.buttons |= MoonlightButton.DOWN;
if (x < -0.5) state.buttons |= MoonlightButton.LEFT;
if (x > 0.5) state.buttons |= MoonlightButton.RIGHT;
break;
case 3: // 左扳机
state.leftTrigger = Math.floor(x * TRIGGER_MAX);
break;
Expand Down
4 changes: 2 additions & 2 deletions hvigor/hvigor-config.json5
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"modelVersion": "5.0.0",
"dependencies": {
"@ohos/hvigor": "6.24.1",
"@ohos/hvigor-ohos-plugin": "6.24.1"
"@ohos/hvigor": "6.24.2",
"@ohos/hvigor-ohos-plugin": "6.24.2"
},
"execution": {
"daemon": true,
Expand Down
4 changes: 2 additions & 2 deletions hvigor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"description": "Hvigor dependencies for CI build",
"dependencies": {
"@ohos/hvigor": "6.24.1",
"@ohos/hvigor-ohos-plugin": "6.24.1"
"@ohos/hvigor": "6.24.2",
"@ohos/hvigor-ohos-plugin": "6.24.2"
}
}
23 changes: 21 additions & 2 deletions nativelib/src/main/cpp/game_controller_native.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ static void OnDeviceChanged(const struct GameDevice_DeviceEvent* deviceEvent) {
free(physicalAddress);
}

GameDevice_DeviceType deviceType;
GameDevice_DeviceType deviceType = (GameDevice_DeviceType)0;
OH_GameDevice_DeviceInfo_GetDeviceType(deviceInfo, &deviceType);
info.deviceType = (int32_t)deviceType;

Expand Down Expand Up @@ -1005,6 +1005,25 @@ int GameController_StartMonitor(void) {
strncpy(info.name, name, sizeof(info.name) - 1);
free(name);
}

int product = 0;
OH_GameDevice_DeviceInfo_GetProduct(deviceInfo, &product);
info.product = product;

int version = 0;
OH_GameDevice_DeviceInfo_GetVersion(deviceInfo, &version);
info.version = version;

char* physicalAddress = nullptr;
OH_GameDevice_DeviceInfo_GetPhysicalAddress(deviceInfo, &physicalAddress);
if (physicalAddress) {
strncpy(info.physicalAddress, physicalAddress, sizeof(info.physicalAddress) - 1);
free(physicalAddress);
}

GameDevice_DeviceType deviceType = (GameDevice_DeviceType)0;
OH_GameDevice_DeviceInfo_GetDeviceType(deviceInfo, &deviceType);
info.deviceType = (int32_t)deviceType;

info.isConnected = true;

Expand Down Expand Up @@ -1168,7 +1187,7 @@ int GameController_RefreshDevices(void) {
free(physicalAddress);
}

GameDevice_DeviceType deviceType;
GameDevice_DeviceType deviceType = (GameDevice_DeviceType)0;
OH_GameDevice_DeviceInfo_GetDeviceType(deviceInfo, &deviceType);
info.deviceType = (int32_t)deviceType;

Expand Down
Loading