Skip to content

Commit

Permalink
Add support for XKE-124 T-bar
Browse files Browse the repository at this point in the history
  • Loading branch information
cyraxx committed Dec 27, 2020
1 parent b9eb6a8 commit 1757637
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ if (connectedXKeys.length) {
* 'jog': Triggered when the jog wheel is moved. Emitted with (jogValue)
* 'shuttle': Triggered when the shuttle is moved. Emitted with (shuttleValue)
* 'joystick': Triggered when the joystick is moved. Emitted with ({x, y, z})
* 'tbar': Triggered when the T-bar is moved. Emitted with (tbarPosition, rawPosition)

* 'error': Triggered on error. Emitted with (error).

Expand Down Expand Up @@ -165,6 +166,7 @@ These devices have been tested to work:
* XK-80
* XK-68 Jog + Shuttle
* XK-12 Jog
* XKE-124 T-bar

### Not tested devices (yet)

Expand All @@ -175,7 +177,7 @@ Support for these devices is implemented, but not tested:
* XK-16: Not tested
* XK-12 Joystick: Not tested
* XR-32: Not tested
* XKE-28: Not tested
* XKE-128: Not tested

If you have access to any of the untested devices listed above, it would be very nice if you could provide some data to add to the tests!
Just do
Expand Down
4 changes: 4 additions & 0 deletions examples/xkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ myXkeysPanel.on('shuttle', shuttlePos => {
myXkeysPanel.on('joystick', position => {
console.log('Joystick has changed:' + position) // {x, y, z}
})
// Listen to t-bar changes:
myXkeysPanel.on('tbar', (position, rawPosition) => {
console.log('T-bar position has changed: ' + position + ' (uncalibrated: ' + rawPosition + ')')
})
5 changes: 4 additions & 1 deletion examples/xkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ myXkeysPanel.on('up', keyIndex => {

// Turn off button light when released:
myXkeysPanel.setBacklight(keyIndex, false)
myXkeysPanel.setBacklight(keyIndex, false)
})

// Listen to jog wheel changes:
Expand All @@ -31,3 +30,7 @@ myXkeysPanel.on('shuttle', shuttlePos => {
myXkeysPanel.on('joystick', position => {
console.log('Joystick has changed:' + position) // {x, y, z}
})
// Listen to t-bar changes:
myXkeysPanel.on('tbar', (position, rawPosition) => {
console.log('T-bar position has changed: ' + position + ' (uncalibrated: ' + rawPosition + ')')
})
23 changes: 22 additions & 1 deletion src/products.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export interface ProductBase {
jogByte?: number
hasShuttle?: true
shuttleByte?: number
hasTbar?: true
tbarByte?: number
tbarByteRaw?: number
}
export interface ProductJog extends ProductBase {
hasJog: true
Expand All @@ -26,7 +29,12 @@ export interface ProductShuttle extends ProductBase {
hasShuttle: true
shuttleByte: number
}
export type Product = ProductBase | ProductJog | ProductShuttle
export interface ProductTbar extends ProductBase {
hasTbar: true
tbarByte: number
tbarByteRaw: number
}
export type Product = ProductBase | ProductJog | ProductShuttle | ProductTbar

export const PRODUCTS: {[name: string]: Product} = {
XK24: {
Expand Down Expand Up @@ -114,6 +122,19 @@ export const PRODUCTS: {[name: string]: Product} = {
banks: 2,
bankSize: 80
},
XKE124TBAR: {
identifier: 'XKE-124 T-bar',
productId: [1275,1276,1277,1278],
columns: 16,
rows: 8,
hasPS: false,
hasTbar: true,
tbarByte: 30,
tbarByteRaw: 31,
banks: 2,
bankSize: 128,
disableKeys: [108,109,110,111]
},
XKE128: { // This has not been tested
identifier: 'XKE-128',
productId: [1227,1228,1229,1230],
Expand Down
19 changes: 18 additions & 1 deletion src/xkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export interface AnalogStates {
joystick_y?: number
/** -127 to 127 */
joystick_z?: number
/** 0 to 255 */
tbar?: number
/** 0 to 4096 */
tbar_raw?: number
}
type Message = (string | number)[]

Expand Down Expand Up @@ -167,6 +171,13 @@ export class XKeys extends EventEmitter {
analogStates.joystick_z = (d < 128 ? d : d - 256)

}
if (this.deviceType.hasTbar) {
let d = data[(this.deviceType.tbarByte || 0) - 2] // T-bar (calibrated)
analogStates.tbar = d

d = data.readUInt16BE((this.deviceType.tbarByteRaw || 0) - 2) // T-bar (uncalibrated)
analogStates.tbar_raw = d
}

// Disabled/nonexisting keys:
if (this.deviceType.disableKeys) {
Expand Down Expand Up @@ -209,6 +220,10 @@ export class XKeys extends EventEmitter {
analogStateKey === 'shuttle'
) {
this.emit(analogStateKey , analogStates[analogStateKey])
} else if (
analogStateKey === 'tbar_raw'
) {
this.emit('tbar', analogStates.tbar, analogStates.tbar_raw)
} else if (
analogStateKey === 'joystick_x' ||
analogStateKey === 'joystick_y' ||
Expand All @@ -219,7 +234,9 @@ export class XKeys extends EventEmitter {
y: analogStates.joystick_y,
z: analogStates.joystick_z
})
} else {
} else if (
analogStateKey !== 'tbar' // ignore tbar updates because event is emitted on tbar_raw update
) {
throw new Error(`Internal error: Unknown analogStateKey: "${analogStateKey}"`)
}

Expand Down

6 comments on commit 1757637

@whitebalanceinc
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

Are there any bits of code in this that could get the xKey 124 T-bar to automate this in DaVinci Resolve application:

https://drive.google.com/file/d/1W7xLKw4FsEekt6M_v2bCRBTV4Pu5a21Z/view?usp=sharing

Resolve's wipe function places two images over each other in the exact same spot in the GUI.  You can then “switch” between the two images just like you would “switch” between two live video feeds in a control room.  Just inside the app.  This is also output through video hardware to your broadcast monitor.

When you initiate the wipe function, a visible line appears, splitting the two images in half.  You can then click, hold, and drag a mouse or pen tablet, and drag either way to reveal more or less of each image.  Effectively cropping the image your are dragging over and revealing more of the image you are dragging from.

If you have BM's $30k Black Magic Advanced panel T-bar, you can use it's T-bar to wipe between the images.  I'm assuming BM's DaVinci Resolve uses the same code for their Advanced Panel T-bar, as BM's ATEM uses for the a T-bar on an external controller.  So technically Resolve should be "listening" for a T-bar

The physical wiping of the line itself could be a "left mouse button down and hold" but assigned to the T-bar instead of the mouse.

I see the code above. It seems like it will tell a listening app or device that the T-bar has moved, and the position it's in. But is there anything that will then connect it to an action like the wipe in the video above?

Is it somewhere in here:

XKE124TBAR: {
identifier: 'XKE-124 T-bar',
productId: [1275,1276,1277,1278],
columns: 16,
rows: 8,
hasPS: false,
hasTbar: true,
tbarByte: 30,
tbarByteRaw: 31,
banks: 2,
bankSize: 128,
disableKeys: [108,109,110,111]

Do I have to assign something from the PI engineering doc to the "tbarByte" or another line?:

file:///Users/ernestsavage/Downloads/non-PC/xke124Tbarreport.htm

Thanks. Sorry I'm such a noob, I just need this one command that I thought I could just copy and paste code for.

@nytamin
Copy link
Member

@nytamin nytamin commented on 1757637 Jan 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi!
I'm afraid it's not that simple, unfortunately. But hey, asking questions is the only way from noob to pro! 🙂

Resolve has a (closed) API that can be used to communicate with it, from a quick Google I found this and this unofficial api documentation. I haven't looked if any of them mentions the wipe functionality though.

This library doesn't provide any functionality that can be used directly in an existing application. Instead, if you create an application yourself that supports an xkeys, you can use this library to communicate with the xkeys panel.

@whitebalanceinc
Copy link

@whitebalanceinc whitebalanceinc commented on 1757637 Jan 16, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@whitebalanceinc
Copy link

@whitebalanceinc whitebalanceinc commented on 1757637 Jan 16, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cyraxx
Copy link
Contributor Author

@cyraxx cyraxx commented on 1757637 Jan 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be code for that very shortly in my project (where you have opened an issue).

@whitebalanceinc
Copy link

@whitebalanceinc whitebalanceinc commented on 1757637 Jan 16, 2021 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.