Fix HTML typing issue

This commit is contained in:
EliteMasterEric 2023-08-03 12:41:54 -04:00
parent 29466af4b7
commit 5590331e10

View file

@ -28,10 +28,6 @@ class PreciseInputManager extends FlxKeyManager<FlxKey, PreciseInputList>
return instance ?? (instance = new PreciseInputManager());
}
static final MS_TO_US:Int64 = 1000;
static final US_TO_NS:Int64 = 1000;
static final MS_TO_NS:Int64 = MS_TO_US * US_TO_NS;
static final DIRECTIONS:Array<NoteDirection> = [NoteDirection.LEFT, NoteDirection.DOWN, NoteDirection.UP, NoteDirection.RIGHT];
public var onInputPressed:FlxTypedSignal<PreciseInputEvent->Void>;
@ -101,11 +97,11 @@ class PreciseInputManager extends FlxKeyManager<FlxKey, PreciseInputList>
// NOTE: This timestamp isn't that precise on standard HTML5 builds.
// This is because of browser safeguards against timing attacks.
// See https://web.dev/coop-coep to enable headers which allow for more precise timestamps.
return js.Browser.window.performance.now() * MS_TO_NS;
return haxe.Int64.fromFloat(js.Browser.window.performance.now() * Constants.NS_PER_MS);
#elseif cpp
// NOTE: If the game hard crashes on this line, rebuild Lime!
// `lime rebuild windows -clean`
return lime._internal.backend.native.NativeCFFI.lime_sdl_get_ticks() * MS_TO_NS;
return lime._internal.backend.native.NativeCFFI.lime_sdl_get_ticks() * Constants.NS_PER_MS;
#else
throw "Eric didn't implement precise timestamps on this platform!";
#end
@ -176,7 +172,7 @@ class PreciseInputManager extends FlxKeyManager<FlxKey, PreciseInputList>
// TODO: Remove this line with SDL3 when timestamps change meaning.
// This is because SDL3's timestamps are measured in nanoseconds, not milliseconds.
timestamp *= MS_TO_NS;
timestamp *= Constants.NS_PER_MS;
updateKeyStates(key, true);
@ -198,7 +194,7 @@ class PreciseInputManager extends FlxKeyManager<FlxKey, PreciseInputList>
// TODO: Remove this line with SDL3 when timestamps change meaning.
// This is because SDL3's timestamps are measured in nanoseconds, not milliseconds.
timestamp *= MS_TO_NS;
timestamp *= Constants.NS_PER_MS;
updateKeyStates(key, false);