Files
kryon/runtime/input.kry
T

70 lines
1.9 KiB
Plaintext

#module "input"
InputScalarStep :: struct {
value: float
changed: bool
}
InputWholeStep :: struct {
value: i32
changed: bool
}
InputDoubleStep :: struct {
value: f64
changed: bool
}
InputScalarEffectiveStep :: (step: float, step_fast: float, fast: bool) -> float #export {
if fast && step_fast != 0.0 { return step_fast }
return step
}
InputWholeEffectiveStep :: (step: i32, step_fast: i32, fast: bool) -> i32 #export {
if fast && step_fast != 0 { return step_fast }
return step
}
InputDoubleEffectiveStep :: (step: f64, step_fast: f64, fast: bool) -> f64 #export {
if fast && step_fast != 0.0 { return step_fast }
return step
}
InputScalarStepValue :: (value: float, step: float, step_fast: float,
direction: i32, fast: bool) -> InputScalarStep #export {
result: InputScalarStep
result.value = value
result.changed = false
if direction == 0 || step == 0.0 { return result }
next: float = value + (float)direction *
InputScalarEffectiveStep(step, step_fast, fast)
result.value = next
result.changed = next != value
return result
}
InputWholeStepValue :: (value: i32, step: i32, step_fast: i32,
direction: i32, fast: bool) -> InputWholeStep #export {
result: InputWholeStep
result.value = value
result.changed = false
if direction == 0 || step == 0 { return result }
next: i32 = value + direction * InputWholeEffectiveStep(step, step_fast, fast)
result.value = next
result.changed = next != value
return result
}
InputDoubleStepValue :: (value: f64, step: f64, step_fast: f64,
direction: i32, fast: bool) -> InputDoubleStep #export {
result: InputDoubleStep
result.value = value
result.changed = false
if direction == 0 || step == 0.0 { return result }
next: f64 = value + (f64)direction *
InputDoubleEffectiveStep(step, step_fast, fast)
result.value = next
result.changed = next != value
return result
}