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
@@ -1,7 +1,7 @@
import { execute } from "./PlayerGamepadConnectService";
import { $gamepadButtonStates, $gamepadAxisStates } from "../../GamepadState";
import { stage } from "@next2d/display";
import { GamepadEvent } from "@next2d/events";
import { GamepadEvent as Next2DGamepadEvent } from "@next2d/events";
import { describe, expect, it, vi, beforeEach } from "vitest";

describe("PlayerGamepadConnectService.js test", () =>
Expand Down Expand Up @@ -51,7 +51,7 @@ describe("PlayerGamepadConnectService.js test", () =>
let result = "";
let gamepadIndex = -1;
stage.hasEventListener = vi.fn().mockReturnValue(true);
stage.dispatchEvent = vi.fn((event: GamepadEvent) =>
stage.dispatchEvent = vi.fn((event: Next2DGamepadEvent) =>
{
result = event.type;
gamepadIndex = event.gamepadIndex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { $gamepadButtonStates, $gamepadAxisStates } from "../../GamepadState";
import { stage } from "@next2d/display";
import { GamepadEvent } from "@next2d/events";
import { GamepadEvent as Next2DGamepadEvent } from "@next2d/events";

/**
* @description ゲームパッド接続イベントを実行する
Expand All @@ -27,11 +27,11 @@ export const execute = (event: GamepadEvent): void =>
Array.from({ "length": gamepad.axes.length }, () => 0)
);

if (!stage.hasEventListener(GamepadEvent.GAMEPAD_CONNECTED)) {
if (!stage.hasEventListener(Next2DGamepadEvent.GAMEPAD_CONNECTED)) {
return ;
}

const gamepadEvent = new GamepadEvent(GamepadEvent.GAMEPAD_CONNECTED);
const gamepadEvent = new Next2DGamepadEvent(Next2DGamepadEvent.GAMEPAD_CONNECTED);
gamepadEvent.gamepadIndex = gamepad.index;
stage.dispatchEvent(gamepadEvent);
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { execute } from "./PlayerGamepadDisconnectService";
import { $gamepadButtonStates, $gamepadAxisStates } from "../../GamepadState";
import { stage } from "@next2d/display";
import { GamepadEvent } from "@next2d/events";
import { GamepadEvent as Next2DGamepadEvent } from "@next2d/events";
import { describe, expect, it, vi, beforeEach } from "vitest";

describe("PlayerGamepadDisconnectService.js test", () =>
Expand Down Expand Up @@ -57,7 +57,7 @@ describe("PlayerGamepadDisconnectService.js test", () =>
let result = "";
let gamepadIndex = -1;
stage.hasEventListener = vi.fn().mockReturnValue(true);
stage.dispatchEvent = vi.fn((event: GamepadEvent) =>
stage.dispatchEvent = vi.fn((event: Next2DGamepadEvent) =>
{
result = event.type;
gamepadIndex = event.gamepadIndex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { $gamepadButtonStates, $gamepadAxisStates } from "../../GamepadState";
import { stage } from "@next2d/display";
import { GamepadEvent } from "@next2d/events";
import { GamepadEvent as Next2DGamepadEvent } from "@next2d/events";

/**
* @description ゲームパッド切断イベントを実行する
Expand All @@ -21,11 +21,11 @@ export const execute = (event: GamepadEvent): void =>
$gamepadButtonStates.delete(gamepad.index);
$gamepadAxisStates.delete(gamepad.index);

if (!stage.hasEventListener(GamepadEvent.GAMEPAD_DISCONNECTED)) {
if (!stage.hasEventListener(Next2DGamepadEvent.GAMEPAD_DISCONNECTED)) {
return ;
}

const gamepadEvent = new GamepadEvent(GamepadEvent.GAMEPAD_DISCONNECTED);
const gamepadEvent = new Next2DGamepadEvent(Next2DGamepadEvent.GAMEPAD_DISCONNECTED);
gamepadEvent.gamepadIndex = gamepad.index;
stage.dispatchEvent(gamepadEvent);
};
Loading