Compare commits
2 Commits
145bf4d7b1
...
265efd1db0
| Author | SHA1 | Date | |
|---|---|---|---|
| 265efd1db0 | |||
| e0838be9b8 |
15
README.md
15
README.md
@@ -2,12 +2,21 @@
|
||||
|
||||
OBS control from D-Bus messages
|
||||
|
||||
Send a D-Bus signal to perform an operation with `src/obsdc-signal`, which takes a single operation name
|
||||
as an argument.
|
||||
Send a D-Bus signal to perform an operation with `src/obsdc-signal`, which takes a single operation command
|
||||
as an argument, and performs an action in OBS.
|
||||
|
||||
## Operations
|
||||
|
||||
See [Op](src/main/kotlin/net/eksb/obsdc/Op.kt) for a list of operations.
|
||||
* `SCENE_NEXT` - switch to the next scene
|
||||
* `SCENE_PREV` - switch to the previous scene
|
||||
* `SCENE_#` - switch to the indicated scene
|
||||
* replace `#` with scene index, starting with 1.
|
||||
* `STUDIO_TRANSITION` - transition the studio preview and program
|
||||
* `STUDIO_MODE_TOGGLE` - toggle studio mode
|
||||
* `PAN_UP` - move the top unlocked source up 50px
|
||||
* `PAN_DOWN` - move the top unlocked source down 50px
|
||||
* `PAN_LEFT` - move the top unlocked source left 50px
|
||||
* `PAN_RIGHT` - move the top unlocked source right 50pxt
|
||||
|
||||
## Configuration
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package net.eksb.obsdc
|
||||
|
||||
class Backoff {
|
||||
fun backoff() {
|
||||
// TODO: actual bakoff
|
||||
Thread.sleep(5_000)
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory
|
||||
*
|
||||
* `src/scripts/obsdc-signal` takes an [Op] name and sends the signal.
|
||||
*/
|
||||
class DBus(private val opRunner:OpRunner): AutoCloseable {
|
||||
class DBus(private val opHandler:(String)->Unit): AutoCloseable {
|
||||
|
||||
// To monitor DBUS: `dbus-monitor`
|
||||
// To see what is registered: `qdbus net.eksb.obsdc /`
|
||||
@@ -37,9 +37,7 @@ class DBus(private val opRunner:OpRunner): AutoCloseable {
|
||||
|
||||
dbus.addSigHandler<ObsdcDBusInterface.Signal> { signal ->
|
||||
log.debug("signal: ${signal.op}")
|
||||
val op = Op.valueOf(signal.op)
|
||||
log.debug("op: ${op}")
|
||||
opRunner.run(op)
|
||||
opHandler.invoke(signal.op)
|
||||
}
|
||||
log.debug("DBUS initialized")
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package net.eksb.obsdc
|
||||
|
||||
enum class Op {
|
||||
/** If in studio mode, transition between scenes. */
|
||||
STUDIO_TRANSITION,
|
||||
/** Enable/disable studio mode. */
|
||||
STUDIO_MODE_TOGGLE,
|
||||
/** Activate the previous scene. */
|
||||
SCENE_PREV,
|
||||
/** Activate the next scene. */
|
||||
SCENE_NEXT,
|
||||
/** Activate the first scene. */
|
||||
SCENE_1,
|
||||
/** Activate the second scene. */
|
||||
SCENE_2,
|
||||
/** Activate the third scene. */
|
||||
SCENE_3,
|
||||
/** Move the bottom-most unlocked source in the active scene up. */
|
||||
PAN_UP,
|
||||
/** Move the bottom-most unlocked source in the active scene down. */
|
||||
PAN_DOWN,
|
||||
/** Move the bottom-most unlocked source in the active scene left. */
|
||||
PAN_LEFT,
|
||||
/** Move the bottom-most unlocked source in the active scene right. */
|
||||
PAN_RIGHT,
|
||||
;
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import org.slf4j.LoggerFactory
|
||||
*
|
||||
* Call [run] to run an OBS operation.
|
||||
*/
|
||||
class OpRunner(private val obs:Obs) {
|
||||
class OpRunner(private val obs:Obs): (String)->Unit {
|
||||
|
||||
/** How much to pan. */
|
||||
private val panAmount = 50F
|
||||
@@ -23,10 +23,10 @@ class OpRunner(private val obs:Obs) {
|
||||
/**
|
||||
* Run the specified [Op].
|
||||
*/
|
||||
fun run(op:Op) {
|
||||
override fun invoke(op:String) {
|
||||
obs.submit { controller ->
|
||||
when(op) {
|
||||
Op.SCENE_NEXT -> scene { scenes, current ->
|
||||
when {
|
||||
op == "SCENE_NEXT" -> scene { scenes, current ->
|
||||
if (current != null) {
|
||||
scenes.asSequence()
|
||||
.dropWhile { scene -> scene != current }
|
||||
@@ -37,7 +37,7 @@ class OpRunner(private val obs:Obs) {
|
||||
null
|
||||
}
|
||||
}
|
||||
Op.SCENE_PREV -> scene { scenes, current ->
|
||||
op == "SCENE_PREV" -> scene { scenes, current ->
|
||||
if (current != null) {
|
||||
scenes.reversed().asSequence()
|
||||
.dropWhile { scene -> scene != current }
|
||||
@@ -48,19 +48,21 @@ class OpRunner(private val obs:Obs) {
|
||||
null
|
||||
}
|
||||
}
|
||||
Op.SCENE_1 -> scene { scenes, current -> scenes.firstOrNull() }
|
||||
Op.SCENE_2 -> scene { scenes, current -> scenes.asSequence().drop(1).firstOrNull() }
|
||||
Op.SCENE_3 -> scene { scenes, current -> scenes.asSequence().drop(2).firstOrNull() }
|
||||
Op.STUDIO_TRANSITION -> {
|
||||
op.startsWith("SCENE_") -> scene { scenes, current ->
|
||||
val drop = op.drop("SCENE_".length).toInt() - 1
|
||||
scenes.asSequence().drop(drop).firstOrNull()
|
||||
}
|
||||
op == "STUDIO_TRANSITION" -> {
|
||||
controller.triggerStudioModeTransition { response ->
|
||||
log.debug("studio transitioned: ${response.isSuccessful}")
|
||||
}
|
||||
}
|
||||
Op.STUDIO_MODE_TOGGLE -> studioModeToggle()
|
||||
Op.PAN_UP -> transform { old -> positionY(old.positionY - panAmount ) }
|
||||
Op.PAN_DOWN -> transform { old -> positionY(old.positionY + panAmount ) }
|
||||
Op.PAN_LEFT -> transform { old -> positionX(old.positionX - panAmount ) }
|
||||
Op.PAN_RIGHT -> transform { old -> positionX(old.positionX + panAmount ) }
|
||||
op == "STUDIO_MODE_TOGGLE" -> studioModeToggle()
|
||||
op == "PAN_UP" -> transform { old -> positionY(old.positionY - panAmount ) }
|
||||
op == "PAN_DOWN" -> transform { old -> positionY(old.positionY + panAmount ) }
|
||||
op == "PAN_LEFT" -> transform { old -> positionX(old.positionX - panAmount ) }
|
||||
op == "PAN_RIGHT" -> transform { old -> positionX(old.positionX + panAmount ) }
|
||||
else -> log.error("Unhandled op \"${op}\"")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user