Merge pull request #273 from FunkinCrew/bugfix/controller-overflow

Gamepad Overflow fix for release builds
This commit is contained in:
Cameron Taylor 2024-01-12 07:48:55 -05:00 committed by GitHub
commit 304cee188a
5 changed files with 39 additions and 27 deletions

View file

@ -111,7 +111,7 @@
<haxelib name="tink_json" /> <!-- JSON parsing (DEPRECATED) --> <haxelib name="tink_json" /> <!-- JSON parsing (DEPRECATED) -->
<haxelib name="thx.semver" /> <!-- Version string handling --> <haxelib name="thx.semver" /> <!-- Version string handling -->
<haxelib name="hmm" if="debug" /> <!-- Read library version data at compile time --> <haxelib name="hmm" /> <!-- Read library version data at compile time so it can be baked into logs -->
<haxelib name="hxcpp-debug-server" if="desktop debug" /> <!-- VSCode debug support --> <haxelib name="hxcpp-debug-server" if="desktop debug" /> <!-- VSCode debug support -->
<!--Disable the Flixel core focus lost screen--> <!--Disable the Flixel core focus lost screen-->
@ -131,8 +131,8 @@
<haxedef name="message.reporting" value="pretty" /> <haxedef name="message.reporting" value="pretty" />
<!-- _________________________________ Custom _______________________________ --> <!-- _________________________________ Custom _______________________________ -->
<!-- Disable trace() calls in release builds to bump up performance. --> <!-- Disable trace() calls in release builds to bump up performance.
<haxeflag name="--no-traces" unless="debug" /> <haxeflag name="- -no-traces" unless="debug" />-->
<!-- HScript relies heavily on Reflection, which means we can't use DCE. --> <!-- HScript relies heavily on Reflection, which means we can't use DCE. -->
<haxeflag name="-dce no" /> <haxeflag name="-dce no" />
<!-- Ensure all Funkin' classes are available at runtime. --> <!-- Ensure all Funkin' classes are available at runtime. -->

View file

@ -107,7 +107,7 @@
"name": "lime", "name": "lime",
"type": "git", "type": "git",
"dir": null, "dir": null,
"ref": "737b86f121cdc90358d59e2e527934f267c94a2c", "ref": "fff39ba6fc64969cd51987ef7491d9345043dc5d",
"url": "https://github.com/FunkinCrew/lime" "url": "https://github.com/FunkinCrew/lime"
}, },
{ {

View file

@ -2270,8 +2270,10 @@ class PlayState extends MusicBeatSubState
vocals.playerVolume = 1; vocals.playerVolume = 1;
// Calculate the input latency (do this as late as possible). // Calculate the input latency (do this as late as possible).
var inputLatencyMs:Float = haxe.Int64.toInt(PreciseInputManager.getCurrentTimestamp() - input.timestamp) / 1000.0 / 1000.0; // trace('Compare: ${PreciseInputManager.getCurrentTimestamp()} - ${input.timestamp}');
trace('Input: ${daNote.noteData.getDirectionName()} pressed ${inputLatencyMs}ms ago!'); var inputLatencyNs:Int64 = PreciseInputManager.getCurrentTimestamp() - input.timestamp;
var inputLatencyMs:Float = inputLatencyNs.toFloat() / Constants.NS_PER_MS;
// trace('Input: ${daNote.noteData.getDirectionName()} pressed ${inputLatencyMs}ms ago!');
// Get the offset and compensate for input latency. // Get the offset and compensate for input latency.
// Round inward (trim remainder) for consistency. // Round inward (trim remainder) for consistency.

View file

@ -11,12 +11,12 @@ class HaxelibVersions
#else #else
// `#if display` is used for code completion. In this case returning an // `#if display` is used for code completion. In this case returning an
// empty string is good enough; We don't want to call functions on every hint. // empty string is good enough; We don't want to call functions on every hint.
var commitHash:String = ""; var commitHash:Array<String> = [];
return macro $v{commitHashSplice}; return macro $v{commitHash};
#end #end
} }
#if (debug && macro) #if (macro)
static function readHmmData():hmm.HmmConfig static function readHmmData():hmm.HmmConfig
{ {
return hmm.HmmConfig.HmmConfigs.readHmmJsonOrThrow(); return hmm.HmmConfig.HmmConfigs.readHmmJsonOrThrow();

View file

@ -1,32 +1,42 @@
package funkin.util.tools; package funkin.util.tools;
import haxe.Int64;
/** /**
* @see https://github.com/fponticelli/thx.core/blob/master/src/thx/Int64s.hx * Why `haxe.Int64` doesn't have a built-in `toFloat` function is beyond me.
*/ */
class Int64Tools class Int64Tools
{ {
static var min = haxe.Int64.make(0x80000000, 0); private inline static var MAX_32_PRECISION:Float = 4294967296.0;
static var one = haxe.Int64.make(0, 1);
static var two = haxe.Int64.ofInt(2);
static var zero = haxe.Int64.make(0, 0);
static var ten = haxe.Int64.ofInt(10);
public static function toFloat(i:haxe.Int64):Float public static function fromFloat(f:Float):Int64
{ {
var isNegative = false; var h = Std.int(f / MAX_32_PRECISION);
if (i < 0) var l = Std.int(f);
return Int64.make(h, l);
}
public static function toFloat(i:Int64):Float
{
var f:Float = Int64.getLow(i);
if (f < 0) f += MAX_32_PRECISION;
return (Int64.getHigh(i) * MAX_32_PRECISION + f);
}
public static function isToIntSafe(i:Int64):Bool
{
return i.high != i.low >> 31;
}
public static function toIntSafe(i:Int64):Int
{
try
{ {
if (i < min) return -9223372036854775808.0; // most -ve value can't be made +ve return Int64.toInt(i);
isNegative = true;
i = -i;
} }
var multiplier = 1.0, ret = 0.0; catch (e:Dynamic)
for (_ in 0...64)
{ {
if (haxe.Int64.and(i, one) != zero) ret += multiplier; throw 'Could not represent value "${Int64.toStr(i)}" as an integer.';
multiplier *= 2.0;
i = haxe.Int64.shr(i, 1);
} }
return (isNegative ? -1 : 1) * ret;
} }
} }