Skip to content

Commit

Permalink
wip: fixing loupedeck CT
Browse files Browse the repository at this point in the history
  • Loading branch information
dnmeid committed Jul 9, 2023
1 parent afcfede commit c222b3c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
18 changes: 11 additions & 7 deletions lib/Surface/Handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,18 @@ class SurfaceHandler extends CoreBase {
} else if (this.#xkeysPageCount > 0) {
this.#xkeysDrawPages()
} else if (this.panel.info.type === 'Loupedeck CT') {
for (let y = 0; y < 7; y++) {
for (let x = 0; x < this.panel.info.keysPerRow; x++) {
for (let y = 0; y < 7; y += 1) {
let pageNumber = this.currentPage
if (y > 3) pageNumber += 1
if (pageNumber > 99) pageNumber = 1
for (let x = 0; x < this.panel.info.keysPerRow; x += 1) {
const image = this.graphics.getBank({
pageNumber: this.currentPage + Math.floor(row / 4),
pageNumber,
column: x,
row: y % 4,
})

this.panel.draw(x + xOffset, y + yOffset, image.buffer, image.style)
this.panel.draw(x, y, image.buffer, image.style)
}
}
} else {
Expand Down Expand Up @@ -304,6 +307,7 @@ class SurfaceHandler extends CoreBase {
onButtonDrawn(location, render) {
// If device is locked ignore updates. pincode updates are handled separately
if (this.isSurfaceLocked) return
console.log('button drawn', location);

if (this.#xkeysPageCount > 0) {
// xkeys mode
Expand All @@ -314,10 +318,10 @@ class SurfaceHandler extends CoreBase {
} else if (
this.panel.info.type === 'Loupedeck CT' &&
(location.pageNumber - this.currentPage == 1 || (location.pageNumber == 1 && this.currentPage == 99)) &&
bank <= location.row <= 2
location.row < 3 // lower half of CT has only 3 rows, zero based
) {
// Loupdeck CT lower half, draw buttun with number offset by 32
this.panel.draw(location.column - xOffset, location.row - yOffset + 4, render.buffer, render.style)
// Loupdeck CT lower half, draw button with row offset by 4
this.panel.draw(location.column, location.row + 4, render.buffer, render.style)
} else if (location.pageNumber == this.currentPage) {
// normal mode
const xOffset = Math.min(Math.max(this.panelconfig.config.xOffset || 0, 0), this.panelInfo.xOffsetMax)
Expand Down
18 changes: 9 additions & 9 deletions lib/Surface/USB/LoupedeckCt.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import { EventEmitter } from 'events'
import { LoupedeckBufferFormat, LoupedeckDisplayId, openLoupedeck } from '@loupedeck/node'
import { convertPanelIndexToXY } from '../Util.js'
import ImageWriteQueue from '../../Resources/ImageWriteQueue.js'
import imageRs from '@julusian/image-rs'
import LogController from '../../Log/Controller.js'
Expand Down Expand Up @@ -288,7 +289,7 @@ class SurfaceUSBLoupedeckCt extends EventEmitter {
[2, 4],
],
buttons: [
// row
// row 1-8
[0, 3],
[1, 3],
[2, 3],
Expand All @@ -297,19 +298,19 @@ class SurfaceUSBLoupedeckCt extends EventEmitter {
[5, 3],
[6, 3],
[7, 3],

// home, undo, keyboard
[0, 4],
[0, 5],
[0, 6],

// return, save, left fn
[1, 4],
[1, 5],
[1, 6],

// up, left, right fn
[6, 4],
[6, 5],
[6, 6],

// down, right, E
[7, 4],
[7, 5],
[7, 6],
Expand Down Expand Up @@ -352,12 +353,11 @@ class SurfaceUSBLoupedeckCt extends EventEmitter {
let screen = this.modelInfo.displays.center
const lcdX = x - screen.lcdXOffset

if (lcdX >= 0 && lcdX < screen.lcdCols && y >= 0 && y < screen.lcdRows) {
if (x === 3 && y === 4) {
this.key_write_queue.queue(35, buffer)
} else if (lcdX >= 0 && lcdX < screen.lcdCols && y >= 0 && y < screen.lcdRows) {
const button = lcdX + y * screen.lcdCols

this.key_write_queue.queue(button, buffer)
} else if (x === 2 && y === 4) {
this.key_write_queue.queue(35, buffer)
}

const buttonIndex = this.modelInfo.buttons.findIndex((btn) => btn[0] == x && btn[1] == y)
Expand Down

0 comments on commit c222b3c

Please sign in to comment.