Skip to content
This repository has been archived by the owner on Dec 24, 2018. It is now read-only.

Commit

Permalink
Support customizable control modes from prefs
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX committed Jan 30, 2018
1 parent eca2ef7 commit 7926039
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/org/sert2521/powerup/util/Oi.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.sert2521.powerup.util

import edu.wpi.first.wpilibj.Joystick
import edu.wpi.first.wpilibj.Preferences
import edu.wpi.first.wpilibj.XboxController

val leftJoystick = Joystick(LEFT_STICK_PORT)
Expand All @@ -9,8 +10,16 @@ val secondaryJoystick = Joystick(SECONDARY_STICK_PORT)

val controller = XboxController(CONTROLLER_PORT)

var controlMode = Control.Controller
var controlMode
get() = Preferences.getInstance().getString("control_mode", null).let {
when (it) {
"arcade" -> Control.Arcade
"controller" -> Control.Controller
else -> Control.Tank
}
}
set(value) = Unit // Needed so Kotlin doesn't create a field

enum class Control {
Arcade, Tank, Controller
Tank, Arcade, Controller
}

0 comments on commit 7926039

Please sign in to comment.