Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
fixed button register, probably added comments, changed return types,…
Browse files Browse the repository at this point in the history
… and added genList() which makes an array of uses with their buttons
  • Loading branch information
24cteahan committed Nov 14, 2023
1 parent 87467a5 commit 227f90f
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package org.firstinspires.ftc.teamcode.internals.hardware.accessors

import android.util.Log
import com.michaell.looping.ScriptParameters
import org.firstinspires.ftc.teamcode.internals.hardware.Devices
import org.firstinspires.ftc.teamcode.internals.hardware.HardwareGetter
import org.firstinspires.ftc.teamcode.internals.hardware.data.GamepadRequestInput
import org.firstinspires.ftc.teamcode.internals.misc.RobotRebootException
import org.firstinspires.ftc.teamcode.internals.registration.OperationMode
import org.firstinspires.ftc.teamcode.internals.telemetry.logging.Logging
import java.lang.RuntimeException
import kotlin.jvm.Throws

/**
* A gamepad is simply a controller that a human uses to control the robot.
Expand Down Expand Up @@ -54,15 +49,25 @@ class Gamepad(override var name: String): DeviceAccessor(name) {
* @param act The useage to search for.
* @return The button's value that matches the useage.
*/
fun buttonSearch(act: String): Object {
fun buttonSearch(act: String): Double {
for (i in buttonReg) {
if (i.use.uppercase() == act.uppercase()) {
return HardwareGetter.getGamepadValue(name, i.button) as Object
return HardwareGetter.getGamepadValue(name, i.button)
}
}
org.firstinspires.ftc.teamcode.internals.time.Clock.sleep(3000);
OperationMode.emergencyStop("Button: $act not registered!")
return "" as Object // will never be called, is only to satisfy compiler
return 0.0// will never be called, is only to satisfy compiler
}

fun genList(): Array<String?> {
var temp: Array<String?> = arrayOfNulls<String>(buttonReg.size)
var pos: Int = 0
for (i in buttonReg) {
pos++
temp[pos] = buttonReg.get(pos).button.toString() + ", " + buttonReg.get(pos).use
}
return temp
}

private fun checkCollision(input: GamepadRequestInput) {
Expand Down

0 comments on commit 227f90f

Please sign in to comment.