4 Commits

6 changed files with 41 additions and 19 deletions

View File

@@ -62,20 +62,23 @@ namespace Cryville.Crtr {
GameDataPath = Settings.Default.GameDataPath; GameDataPath = Settings.Default.GameDataPath;
unity::Input.simulateMouseWithTouches = false; unity::Input.simulateMouseWithTouches = false;
InputManager.HandlerRegistries.Add(typeof(AndroidAccelerometerHandler)); var emptyObjectArray = new object[0];
InputManager.HandlerRegistries.Add(typeof(AndroidAccelerometerUncalibratedHandler)); #if UNITY_ANDROID
InputManager.HandlerRegistries.Add(typeof(AndroidGameRotationVectorHandler)); InputManager.HandlerRegistries.Add(typeof(AndroidAccelerometerHandler), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(AndroidGravityHandler)); InputManager.HandlerRegistries.Add(typeof(AndroidAccelerometerUncalibratedHandler), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(AndroidGyroscopeHandler)); InputManager.HandlerRegistries.Add(typeof(AndroidGameRotationVectorHandler), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(AndroidLinearAccelerationHandler)); InputManager.HandlerRegistries.Add(typeof(AndroidGravityHandler), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(AndroidMagneticFieldHandler)); InputManager.HandlerRegistries.Add(typeof(AndroidGyroscopeHandler), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(AndroidMagneticFieldUncalibratedHandler)); InputManager.HandlerRegistries.Add(typeof(AndroidLinearAccelerationHandler), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(AndroidRotationVectorHandler)); InputManager.HandlerRegistries.Add(typeof(AndroidMagneticFieldHandler), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(AndroidTouchHandler)); InputManager.HandlerRegistries.Add(typeof(AndroidMagneticFieldUncalibratedHandler), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(UnityGuiInputHandler<UnityKeyReceiver>)); InputManager.HandlerRegistries.Add(typeof(AndroidRotationVectorHandler), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(UnityGuiInputHandler<UnityMouseReceiver>)); InputManager.HandlerRegistries.Add(typeof(AndroidTouchHandler), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(UnityMouseHandler)); #endif
InputManager.HandlerRegistries.Add(typeof(UnityTouchHandler)); InputManager.HandlerRegistries.Add(typeof(UnityGuiInputHandler<UnityKeyReceiver>), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(UnityGuiInputHandler<UnityMouseReceiver>), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(UnityMouseHandler), emptyObjectArray);
InputManager.HandlerRegistries.Add(typeof(UnityTouchHandler), emptyObjectArray);
InputManager = new InputManager(); InputManager = new InputManager();
#if UNITY_EDITOR_WIN #if UNITY_EDITOR_WIN

View File

@@ -20,6 +20,9 @@ namespace Cryville.Crtr {
else if (a.Remove("score")) { else if (a.Remove("score")) {
return new Score(a, k); return new Score(a, k);
} }
else if (a.Remove("var")) {
return new Variable(a, new Identifier(k));
}
throw new FormatException("Invalid judge action format."); throw new FormatException("Invalid judge action format.");
} }
public readonly HashSet<string> annotations; public readonly HashSet<string> annotations;
@@ -64,5 +67,15 @@ namespace Cryville.Crtr {
return new JudgeActionResult(); return new JudgeActionResult();
} }
} }
public class Variable : JudgeAction {
readonly Identifier _target;
public Variable(IEnumerable<string> a, Identifier k) : base(a) {
_target = k;
}
internal override JudgeActionResult Execute(IJudge judge, JudgeEvent ev, float time, PdtExpression exp, bool onMiss, int depth, int index) {
// throw new NotImplementedException();
return new JudgeActionResult();
}
}
} }
} }

View File

@@ -32,6 +32,8 @@ namespace Cryville.Crtr {
[Binder(typeof(PdtBinder))] [Binder(typeof(PdtBinder))]
public class PdtRuleset { public class PdtRuleset {
public Dictionary<Identifier, ConfigDefinition> configs;
public Dictionary<Identifier, MotionDefinition> motions;
public Dictionary<Identifier, InputDefinition> inputs; public Dictionary<Identifier, InputDefinition> inputs;
public Dictionary<Identifier, PdtExpression> areas; public Dictionary<Identifier, PdtExpression> areas;
public Dictionary<Identifier, JudgeDefinition> judges; public Dictionary<Identifier, JudgeDefinition> judges;
@@ -66,6 +68,12 @@ namespace Cryville.Crtr {
constraints.PrePatch(chart); constraints.PrePatch(chart);
} }
} }
public class ConfigDefinition {
// TODO
}
public class MotionDefinition {
// TODO
}
public class InputDefinition { public class InputDefinition {
public int dim; public int dim;
public string pdim; public string pdim;

View File

@@ -97,11 +97,7 @@ namespace Cryville.Input.Unity {
useGUILayout = false; useGUILayout = false;
} }
void Update() { void Update() {
double time = Time.realtimeSinceStartupAsDouble; Batch(Time.realtimeSinceStartupAsDouble);
foreach (var k in ActiveKeys) {
Feed(k, 0, new InputFrame(time, new InputVector()));
}
Batch(time);
} }
} }

View File

@@ -14,9 +14,11 @@ namespace Cryville.Input.Unity {
/// </summary> /// </summary>
/// <exception cref="NotSupportedException">Unity touch is not supported on the current device.</exception> /// <exception cref="NotSupportedException">Unity touch is not supported on the current device.</exception>
public UnityTouchHandler() { public UnityTouchHandler() {
#if !UNITY_EDITOR // In the simulator, touch works but `touchSupported` returns false (by 2021.3)
if (!unity::Input.touchSupported) { if (!unity::Input.touchSupported) {
throw new NotSupportedException("Unity touch is not supported on this device"); throw new NotSupportedException("Unity touch is not supported on this device");
} }
#endif
} }
/// <inheritdoc /> /// <inheritdoc />

Binary file not shown.