Skip to content

Commit

Permalink
Clear or suppress some easy lint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AbandonedCart authored and nickbeth committed Mar 18, 2023
1 parent 94459e0 commit 0949d51
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 24 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/emu/skyline/data/DataItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ data class AppItem(private val meta : AppEntry) : DataItem() {
/**
* The name and author is used as the key
*/
fun key() = meta.name + if (meta.author != null) " ${meta.author}" else ""
fun key() = "${meta.name}${meta.author.let { it ?: "" }}"
}
26 changes: 21 additions & 5 deletions app/src/main/java/emu/skyline/input/Controller.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ open class Controller(val id : Int, var type : ControllerType, var rumbleDeviceD
*/
companion object {
@JvmStatic
private val serialVersionUID = 6529685098267757690L
val serialVersionUID = 6529685098267757690L

/**
* The value of [rumbleDeviceDescriptor] when the built-in Vibrator should be utilized
Expand All @@ -60,23 +60,39 @@ open class Controller(val id : Int, var type : ControllerType, var rumbleDeviceD
/**
* This Controller class is for the Handheld-ProCon controller that change based on the operation mode
*/
class HandheldController(id : Int) : Controller(id, ControllerType.HandheldProController)
class HandheldController(id : Int) : Controller(id, ControllerType.HandheldProController) {
companion object {
private val serialVersionUID = Controller.serialVersionUID
}
}

/**
* This Controller class is for the Pro Controller (ProCon)
*/
class ProController(id : Int) : Controller(id, ControllerType.ProController)
class ProController(id : Int) : Controller(id, ControllerType.ProController) {
companion object {
private val serialVersionUID = Controller.serialVersionUID
}
}

/**
* This Controller class is for the left Joy-Con controller
*
* @param partnerId The ID of the corresponding right Joy-Con if this is a pair
*/
class JoyConLeftController(id : Int, var partnerId : Int? = null) : Controller(id, ControllerType.JoyConLeft)
class JoyConLeftController(id : Int, var partnerId : Int? = null) : Controller(id, ControllerType.JoyConLeft) {
companion object {
private val serialVersionUID = Controller.serialVersionUID
}
}

/**
* This Controller class is for the right Joy-Con controller
*
* @param partnerId The ID of the corresponding left Joy-Con if this is a pair
*/
class JoyConRightController(id : Int, var partnerId : Int? = null) : Controller(id, ControllerType.JoyConRight)
class JoyConRightController(id : Int, var partnerId : Int? = null) : Controller(id, ControllerType.JoyConRight) {
companion object {
private val serialVersionUID = Controller.serialVersionUID
}
}
6 changes: 4 additions & 2 deletions app/src/main/java/emu/skyline/input/ControllerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ class ControllerActivity : AppCompatActivity() {
*/
val axisMap = mutableMapOf<AxisId, ControllerStickViewItem>()

@Suppress("WeakerAccess")
val stickItems = mutableListOf<ControllerStickViewItem>()

@Suppress("WeakerAccess")
val buttonItems = mutableListOf<ControllerButtonViewItem>()

@Inject
Expand Down Expand Up @@ -191,7 +193,7 @@ class ControllerActivity : AppCompatActivity() {

var layoutDone = false // Tracks if the layout is complete to avoid retrieving invalid attributes
binding.coordinatorLayout.viewTreeObserver.addOnTouchModeChangeListener { isTouchMode ->
val layoutUpdate = { ->
val layoutUpdate = {
val params = binding.controllerList.layoutParams as CoordinatorLayout.LayoutParams
if (!isTouchMode) {
binding.titlebar.appBarLayout.setExpanded(true)
Expand All @@ -218,7 +220,7 @@ class ControllerActivity : AppCompatActivity() {
}
}

val dividerItemDecoration = object : DividerItemDecoration(this, DividerItemDecoration.VERTICAL) {
val dividerItemDecoration = object : DividerItemDecoration(this, VERTICAL) {
override fun onDraw(canvas : Canvas, parent : RecyclerView, state : RecyclerView.State) {
val divider = drawable!!
for (i in 0 until parent.childCount) {
Expand Down
33 changes: 17 additions & 16 deletions app/src/main/java/emu/skyline/input/InputHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class InputHandler(private val inputManager : InputManager, private val emulatio
external fun setTouchState(points : IntArray)
}

@Suppress("ArrayInDataClass")
data class MotionSensorInput(
var timestamp : u64 = 0uL,
var deltaTimestamp : u64 = 0uL,
Expand All @@ -100,10 +101,10 @@ class InputHandler(private val inputManager : InputManager, private val emulatio
* Used for adjusting motion to phone orientation
*/
private val motionRotationMatrix = FloatArray(9)
private val motionGyroOrientation : FloatArray = FloatArray(3);
private val motionAcelOrientation : FloatArray = FloatArray(3);
private var motionAxisOrientationX = SensorManager.AXIS_Y;
private var motionAxisOrientationY = SensorManager.AXIS_X;
private val motionGyroOrientation : FloatArray = FloatArray(3)
private val motionAcelOrientation : FloatArray = FloatArray(3)
private var motionAxisOrientationX = SensorManager.AXIS_Y
private var motionAxisOrientationY = SensorManager.AXIS_X

/**
* Initializes all of the controllers from [InputManager] on the guest
Expand Down Expand Up @@ -151,15 +152,15 @@ class InputHandler(private val inputManager : InputManager, private val emulatio
}
}

setMotionOrientation90();
setMotionOrientation90()
val orientationEventListener = object : OrientationEventListener(context) {
override fun onOrientationChanged(orientation : Int) {
when {
isWithinOrientationRange(orientation, 270) -> {
setMotionOrientation270();
setMotionOrientation270()
}
isWithinOrientationRange(orientation, 90) -> {
setMotionOrientation90();
setMotionOrientation90()
}
}
}
Expand All @@ -184,8 +185,8 @@ class InputHandler(private val inputManager : InputManager, private val emulatio
motionAcelOrientation[0] = -1.0f
motionAcelOrientation[1] = 1.0f
motionAcelOrientation[2] = -1.0f
motionAxisOrientationX = SensorManager.AXIS_Y;
motionAxisOrientationY = SensorManager.AXIS_X;
motionAxisOrientationX = SensorManager.AXIS_Y
motionAxisOrientationY = SensorManager.AXIS_X
}

/**
Expand All @@ -200,8 +201,8 @@ class InputHandler(private val inputManager : InputManager, private val emulatio
motionAcelOrientation[2] = -1.0f

// TODO: Find the correct configuration here
motionAxisOrientationX = SensorManager.AXIS_Y;
motionAxisOrientationY = SensorManager.AXIS_X;
motionAxisOrientationX = SensorManager.AXIS_Y
motionAxisOrientationY = SensorManager.AXIS_X
}

/**
Expand Down Expand Up @@ -320,7 +321,7 @@ class InputHandler(private val inputManager : InputManager, private val emulatio
motionSensor.quaternion[2] = event.values[2]
motionSensor.quaternion[3] = event.values[3]
SensorManager.getRotationMatrixFromVector(motionRotationMatrix, motionSensor.quaternion)
SensorManager.remapCoordinateSystem(motionRotationMatrix, motionAxisOrientationX, motionAxisOrientationY, motionSensor.orientationMatrix);
SensorManager.remapCoordinateSystem(motionRotationMatrix, motionAxisOrientationX, motionAxisOrientationY, motionSensor.orientationMatrix)
}

Sensor.TYPE_GAME_ROTATION_VECTOR -> {
Expand All @@ -329,7 +330,7 @@ class InputHandler(private val inputManager : InputManager, private val emulatio
motionSensor.quaternion[2] = event.values[2]
motionSensor.quaternion[3] = event.values[3]
SensorManager.getRotationMatrixFromVector(motionRotationMatrix, motionSensor.quaternion)
SensorManager.remapCoordinateSystem(motionRotationMatrix, motionAxisOrientationX, motionAxisOrientationY, motionSensor.orientationMatrix);
SensorManager.remapCoordinateSystem(motionRotationMatrix, motionAxisOrientationX, motionAxisOrientationY, motionSensor.orientationMatrix)
}

else -> {}
Expand All @@ -341,11 +342,11 @@ class InputHandler(private val inputManager : InputManager, private val emulatio

motionSensor.deltaTimestamp = event.timestamp.toULong() - motionSensor.timestamp
motionSensor.timestamp = event.timestamp.toULong()
motionDataBuffer.clear();
motionDataBuffer.clear()
setMotionState(0, 0, motionSensor.writeToByteBuffer(motionDataBuffer))
motionDataBuffer.clear();
motionDataBuffer.clear()
setMotionState(0, 1, motionSensor.writeToByteBuffer(motionDataBuffer))
motionDataBuffer.clear();
motionDataBuffer.clear()
setMotionState(0, 2, motionSensor.writeToByteBuffer(motionDataBuffer))
}

Expand Down

0 comments on commit 0949d51

Please sign in to comment.