Closed asdf23 closed 1 year ago
You'll also need to re-work drawKey
as that references the center
display:
https://github.com/foxxyz/loupedeck/blob/7c5d99b9d659af6b6bf7c79da6fb6f43c8724693/device.js#L130
The button count is also different, and you don't have the "side" screens (so you need to allow for 15 pixels of padding on either side) - so you'll probably need to adjust things based on the productId
of the device (which looks like it's already being captured for devices using the latest serial firmware?).
For example, I made these quick and dirty tweaks to make it draw correct using the simple
example:
// Draw to a specific key index (0-12)
drawKey(index, cb) {
// Get offset x/y for key index
const width = 90
const height = 90
const x = (30/2) + index % 5 * width
const y = Math.floor(index / 5) * height
return this[cb instanceof Buffer ? 'drawBuffer' : 'drawCanvas']({ id: 'main', x, y, width, height }, cb)
}
You'll also need to update onTouch
with similar maths. For example:
onTouch(event, buff) {
const x = buff.readUInt16BE(1)
const y = buff.readUInt16BE(3)
const id = buff[5]
// Determine target
const screen = 'main'
let key
if (screen === 'main') {
const column = Math.floor(((x + 15) - 60) / 90)
const row = Math.floor(y / 90)
key = row * 5 + column
}
// Create touch
const touch = { x, y, id, target: { screen, key } }
// End touch, remove from local cache
if (event === 'touchend') {
delete this.touches[touch.id]
} else {
// First time seeing this touch, emit touchstart instead of touchmove
if (!this.touches[touch.id]) event = 'touchstart'
this.touches[touch.id] = touch
}
this.emit(event, { touches: Object.values(this.touches), changedTouches: [touch] })
}
I'm also not sure that the bottom left button should be labelled "circle" - it probably makes more sense for the Loupedeck Live-S if the bottom left is button 1, then the top right is button 2, etc.
Again, obviously you need to tweak things so that it's a per-device thing, so you don't break Loupedeck Live support. Once this is done however, it should be pretty easy to add Loupedeck CT, and Razer Stream Controller support.
Hope this helps!
Also, getInfo
seems to work fine here. Here's the output from the simple
example with those above tweaks:
✅ Connected to Loupedeck at /dev/tty.usbmodem32101
Device serial number LDD2201010022300100020B1001, software version 0.1.1
Knob knobTL rotated left
Testing vibration #0
Knob knobTL rotated right
Testing vibration #1
Knob knobCL rotated left
Knob knobCL rotated right
Button circle pressed
Button circle released
Button 1 pressed
Button 1 released
Button 2 pressed
Button 2 released
Button 3 pressed
Button 3 released
Touch #21 started: x: 69, y: 47
Touch #21 ended: x: 69, y: 47
Touch #18 started: x: 160, y: 52
Touch #18 ended: x: 160, y: 52
Touch #15 started: x: 250, y: 48
Touch #15 ended: x: 250, y: 48
Touch #17 started: x: 338, y: 30
Touch #17 ended: x: 338, y: 30
Touch #17 started: x: 443, y: 41
Touch #17 ended: x: 443, y: 41
Touch #20 started: x: 70, y: 129
Touch #20 ended: x: 70, y: 129
Touch #19 started: x: 168, y: 120
Touch #19 ended: x: 168, y: 120
Touch #20 started: x: 258, y: 131
Touch #20 ended: x: 258, y: 131
Touch #20 started: x: 331, y: 129
Touch #20 ended: x: 331, y: 129
Touch #15 started: x: 429, y: 129
Touch #15 ended: x: 429, y: 129
Touch #19 started: x: 69, y: 221
Touch #19 ended: x: 69, y: 221
Touch #20 started: x: 147, y: 210
Touch #20 ended: x: 147, y: 210
Touch #19 started: x: 253, y: 225
Touch #19 ended: x: 253, y: 225
Touch #18 started: x: 344, y: 221
Touch #18 ended: x: 344, y: 221
Touch #16 started: x: 440, y: 223
Touch #16 ended: x: 440, y: 223
Thank you @latenitefilms! This is really useful, and it looks this PR likely requires a bit more work.
If I had access to a device I'd definitely add all the support for it.
Are you able to confirm what firmware version is running on the device?
Sorry I've never done a pull request on github, I didnt' see these suggestions until just now. I do have an update that I think addresses these issues.
Closing this in favor of the simpler and tested implementation in #21.
Thank you for all your hard work @asdf23!
Adds support for Live S