From 4989dba77c0a4760a7056c03eb9b1d7f5294fb37 Mon Sep 17 00:00:00 2001 From: Marcos Diaz Date: Sun, 9 Feb 2025 21:08:58 +0200 Subject: [PATCH 1/5] Added thumbstick DIR8 mode and basic support --- src/components/profile/profile.html | 4 +- src/components/profile/profile.ts | 103 ++++++++++++++++------------ src/components/profile/section.html | 3 +- src/components/profile/section.ts | 42 +++++++----- src/lib/ctrl.ts | 81 +++++++++++----------- src/lib/device.ts | 3 +- src/lib/profile.ts | 45 +++++++----- src/lib/profiles.ts | 46 +++++++------ 8 files changed, 181 insertions(+), 146 deletions(-) diff --git a/src/components/profile/profile.html b/src/components/profile/profile.html index f772e42..78b4810 100644 --- a/src/components/profile/profile.html +++ b/src/components/profile/profile.html @@ -42,7 +42,7 @@
  @@ -52,7 +52,7 @@
  diff --git a/src/components/profile/profile.ts b/src/components/profile/profile.ts index 4464da8..4354609 100644 --- a/src/components/profile/profile.ts +++ b/src/components/profile/profile.ts @@ -13,8 +13,6 @@ import { ThumbstickMode, GyroMode } from 'lib/ctrl' import { sectionIsGyroAxis, sectionIsHome } from 'lib/ctrl' import { SectionIndex } from 'lib/ctrl' import { Device } from 'lib/device' -import { Profiles } from 'lib/profiles' -import { delay } from 'lib/delay' const MAX_FETCH_ATTEMPTS = 3 @@ -101,10 +99,12 @@ export class ProfileComponent { const log = `tryFetchProfile ${this.profileIndex}` console.log(log) let attempts = 0 + let success = false while(true) { try { const profiles = this.webusb.selectedDevice!.profiles await profiles.fetchProfile(this.profileIndex, false) + success = true break } catch(error) { attempts += 1 @@ -115,7 +115,8 @@ export class ProfileComponent { } } } - console.log(log, 'OK') + if (success) console.log(log, 'OK') + else console.log(log, 'FAILED') } getProfile() { @@ -131,11 +132,11 @@ export class ProfileComponent { } setSelectedThumbstick() { - this.selected = this.getProfile().thumbstick + this.selected = this.getProfile().settingsLStick } setSelectedGyro() { - this.selected = this.getProfile().gyro + this.selected = this.getProfile().settingsGyro } getSelected() { @@ -164,8 +165,8 @@ export class ProfileComponent { getMappings() { const profile = this.getProfile() - const thumbstick = profile.thumbstick - const gyro = profile.gyro + const settingsLStick = profile.settingsLStick + const gyro = profile.settingsGyro const rotaryUp = this.getMapping(profile.rotaryUp) const rotaryDown = this.getMapping(profile.rotaryDown) const home = this.getMapping(profile.home) @@ -188,27 +189,34 @@ export class ProfileComponent { this.getMapping(profile.buttonR1), this.getMapping(profile.buttonR2), this.getMapping(profile.buttonR4), - this.getMapping(profile.buttonDhatLeft), - this.getMapping(profile.buttonDhatRight), - this.getMapping(profile.buttonDhatUp), - this.getMapping(profile.buttonDhatDown), - this.getMapping(profile.buttonDhatUL), - this.getMapping(profile.buttonDhatUR), - this.getMapping(profile.buttonDhatDL), - this.getMapping(profile.buttonDhatDR), - this.getMapping(profile.buttonDhatPush), + this.getMapping(profile.buttonRStickLeft), + this.getMapping(profile.buttonRStickRight), + this.getMapping(profile.buttonRStickUp), + this.getMapping(profile.buttonRStickDown), + this.getMapping(profile.buttonRStickUL), + this.getMapping(profile.buttonRStickUR), + this.getMapping(profile.buttonRStickDL), + this.getMapping(profile.buttonRStickDR), + this.getMapping(profile.buttonRStickPush), ] - let buttonsThumbstick: any = [] - if (thumbstick.mode == ThumbstickMode.DIR4) { - buttonsThumbstick = [ - this.getMapping(profile.buttonThumbstickLeft), - this.getMapping(profile.buttonThumbstickRight), - this.getMapping(profile.buttonThumbstickUp), - this.getMapping(profile.buttonThumbstickDown), - this.getMapping(profile.buttonThumbstickPush), - this.getMapping(profile.buttonThumbstickInner), - this.getMapping(profile.buttonThumbstickOuter), - ] + if (settingsLStick.mode==ThumbstickMode.DIR4 || settingsLStick.mode==ThumbstickMode.DIR8) { + buttons.push(...[ + this.getMapping(profile.buttonLStickLeft), + this.getMapping(profile.buttonLStickRight), + this.getMapping(profile.buttonLStickUp), + this.getMapping(profile.buttonLStickDown), + this.getMapping(profile.buttonLStickPush), + this.getMapping(profile.buttonLStickInner), + this.getMapping(profile.buttonLStickOuter), + ]) + } + if (settingsLStick.mode==ThumbstickMode.DIR8) { + buttons.push(...[ + this.getMapping(profile.buttonLStickUL), + this.getMapping(profile.buttonLStickUR), + this.getMapping(profile.buttonLStickDL), + this.getMapping(profile.buttonLStickDR), + ]) } let gyroAxis: any = [] if (gyro.mode != GyroMode.OFF) { @@ -218,7 +226,7 @@ export class ProfileComponent { this.getMapping(profile.gyroZ), ] } - return [...buttons, ...buttonsThumbstick, ...gyroAxis, rotaryUp, rotaryDown, home] + return [...buttons, ...gyroAxis, rotaryUp, rotaryDown, home] } // Required so change detection is working better is scenarios where the @@ -248,24 +256,31 @@ const position = [ {section: SectionIndex.B, column: 17, row: '7/9' }, {section: SectionIndex.A, column: 17, row: 9 }, {section: SectionIndex.R4, column: 17, row: 11 }, - {section: SectionIndex.DHAT_LEFT, column: '12/16', row: 14 }, - {section: SectionIndex.DHAT_RIGHT, column: 17, row: 14 }, - {section: SectionIndex.DHAT_UP, column: 16, row: 13 }, - {section: SectionIndex.DHAT_DOWN, column: 16, row: 15 }, - {section: SectionIndex.DHAT_UL, column: '12/16', row: 13 }, - {section: SectionIndex.DHAT_UR, column: 17, row: 13 }, - {section: SectionIndex.DHAT_DL, column: '12/16', row: 15 }, - {section: SectionIndex.DHAT_DR, column: 17, row: 15 }, - {section: SectionIndex.DHAT_PUSH, column: 16, row: 14 }, + + {section: SectionIndex.LSTICK_UL, column: 1, row: 13 }, + {section: SectionIndex.LSTICK_LEFT, column: 1, row: 14 }, + {section: SectionIndex.LSTICK_DL, column: 1, row: 15 }, + {section: SectionIndex.LSTICK_UP, column: 2, row: 13 }, + {section: SectionIndex.LSTICK_PUSH, column: 2, row: 14 }, + {section: SectionIndex.LSTICK_DOWN, column: 2, row: 15 }, + {section: SectionIndex.LSTICK_UR, column: '3/7', row: 13 }, + {section: SectionIndex.LSTICK_RIGHT, column: '3/7', row: 14 }, + {section: SectionIndex.LSTICK_DR, column: '3/7', row: 15 }, + {section: SectionIndex.LSTICK_INNER, column: 2, row: '18/20' }, + {section: SectionIndex.LSTICK_OUTER, column: 2, row: '20/22' }, + + {section: SectionIndex.RSTICK_LEFT, column: '12/16', row: 14 }, + {section: SectionIndex.RSTICK_RIGHT, column: 17, row: 14 }, + {section: SectionIndex.RSTICK_UP, column: 16, row: 13 }, + {section: SectionIndex.RSTICK_DOWN, column: 16, row: 15 }, + {section: SectionIndex.RSTICK_UL, column: '12/16', row: 13 }, + {section: SectionIndex.RSTICK_UR, column: 17, row: 13 }, + {section: SectionIndex.RSTICK_DL, column: '12/16', row: 15 }, + {section: SectionIndex.RSTICK_DR, column: 17, row: 15 }, + {section: SectionIndex.RSTICK_PUSH, column: 16, row: 14 }, + {section: SectionIndex.ROTARY_UP, column: '16/18', row: '18/20', cls:'wide'}, {section: SectionIndex.ROTARY_DOWN, column: '16/18', row: '20/22', cls:'wide'}, - {section: SectionIndex.THUMBSTICK_LEFT, column: 1, row: 14 }, - {section: SectionIndex.THUMBSTICK_RIGHT, column: '3/7', row: 14 }, - {section: SectionIndex.THUMBSTICK_UP, column: 2, row: 13 }, - {section: SectionIndex.THUMBSTICK_DOWN, column: 2, row: 15 }, - {section: SectionIndex.THUMBSTICK_PUSH, column: 2, row: 14 }, - {section: SectionIndex.THUMBSTICK_INNER, column: 2, row: '18/20' }, - {section: SectionIndex.THUMBSTICK_OUTER, column: 2, row: '20/22' }, {section: SectionIndex.GYRO_X, column: '6/13', row: '17/19', cls:'thin'}, {section: SectionIndex.GYRO_Y, column: '6/13', row: '19/21', cls:'thin'}, {section: SectionIndex.GYRO_Z, column: '6/13', row: '21/23', cls:'thin'}, diff --git a/src/components/profile/section.html b/src/components/profile/section.html index 5b7d7c3..6a411ae 100644 --- a/src/components/profile/section.html +++ b/src/components/profile/section.html @@ -172,6 +172,7 @@

{{getSectionTitle()}}

> +
@@ -198,7 +199,7 @@

{{getSectionTitle()}}

/>
-
+
Deadzone:
diff --git a/src/components/profile/section.ts b/src/components/profile/section.ts index dd7690f..27bf3f1 100644 --- a/src/components/profile/section.ts +++ b/src/components/profile/section.ts @@ -115,7 +115,7 @@ export class SectionComponent { getGyroMode() { const profile = this.profiles.getProfile(this.profileIndex) as Profile - return profile.gyro.mode + return profile.settingsGyro.mode } async profileOverwrite() { @@ -322,26 +322,30 @@ const sectionTitles: SectionTitles = { [SectionIndex.R1]: 'Trigger R1', [SectionIndex.R2]: 'Trigger R2', [SectionIndex.R4]: 'Trigger R4', - [SectionIndex.DHAT_LEFT]: 'DHat Left', - [SectionIndex.DHAT_RIGHT]: 'DHat Right', - [SectionIndex.DHAT_UP]: 'DHat Up', - [SectionIndex.DHAT_DOWN]: 'DHat Down', - [SectionIndex.DHAT_UL]: 'DHat Up-Left', - [SectionIndex.DHAT_UR]: 'DHat Up-Right', - [SectionIndex.DHAT_DL]: 'DHat Down-Left', - [SectionIndex.DHAT_DR]: 'DHat Down-Right', - [SectionIndex.DHAT_PUSH]: 'DHat Push', + [SectionIndex.LSTICK_SETTINGS]: 'LStick Settings', + [SectionIndex.LSTICK_LEFT]: 'LStick Left', + [SectionIndex.LSTICK_RIGHT]: 'LStick Right', + [SectionIndex.LSTICK_UP]: 'LStick Up', + [SectionIndex.LSTICK_DOWN]: 'LStick Down', + [SectionIndex.LSTICK_UL]: 'LStick Up-Left', + [SectionIndex.LSTICK_UR]: 'LStick Up-Right', + [SectionIndex.LSTICK_DL]: 'LStick Down-Left', + [SectionIndex.LSTICK_DR]: 'LStick Down-Right', + [SectionIndex.LSTICK_PUSH]: 'LStick Push', + [SectionIndex.LSTICK_INNER]: 'LStick Inner', + [SectionIndex.LSTICK_OUTER]: 'LStick Outer', + [SectionIndex.RSTICK_LEFT]: 'RStick Left', + [SectionIndex.RSTICK_RIGHT]: 'RStick Right', + [SectionIndex.RSTICK_UP]: 'RStick Up', + [SectionIndex.RSTICK_DOWN]: 'RStick Down', + [SectionIndex.RSTICK_UL]: 'RStick Up-Left', + [SectionIndex.RSTICK_UR]: 'RStick Up-Right', + [SectionIndex.RSTICK_DL]: 'RStick Down-Left', + [SectionIndex.RSTICK_DR]: 'RStick Down-Right', + [SectionIndex.RSTICK_PUSH]: 'RStick Push', [SectionIndex.ROTARY_UP]: 'Rotary up', [SectionIndex.ROTARY_DOWN]: 'Rotary down', - [SectionIndex.THUMBSTICK]: 'Thumbstick settings', - [SectionIndex.THUMBSTICK_LEFT]: 'Thumbstick Left', - [SectionIndex.THUMBSTICK_RIGHT]: 'Thumbstick Right', - [SectionIndex.THUMBSTICK_UP]: 'Thumbstick Up', - [SectionIndex.THUMBSTICK_DOWN]: 'Thumbstick Down', - [SectionIndex.THUMBSTICK_PUSH]: 'Thumbstick Push', - [SectionIndex.THUMBSTICK_INNER]: 'Thumbstick Inner', - [SectionIndex.THUMBSTICK_OUTER]: 'Thumbstick Outer', - [SectionIndex.GYRO]: 'Gyro settings', + [SectionIndex.GYRO_SETTINGS]: 'Gyro settings', [SectionIndex.GYRO_X]: 'Gyro Axis X', [SectionIndex.GYRO_Y]: 'Gyro Axis Y', [SectionIndex.GYRO_Z]: 'Gyro Axis Z', diff --git a/src/lib/ctrl.ts b/src/lib/ctrl.ts index 79f50f1..865b71c 100644 --- a/src/lib/ctrl.ts +++ b/src/lib/ctrl.ts @@ -40,8 +40,8 @@ export enum ConfigIndex { export enum SectionIndex { NONE, - META, - A = 2, + META = 1, + A, B, X, Y, @@ -59,26 +59,33 @@ export enum SectionIndex { R2, L4, R4, - DHAT_LEFT, - DHAT_RIGHT, - DHAT_UP, - DHAT_DOWN, - DHAT_UL, - DHAT_UR, - DHAT_DL, - DHAT_DR, - DHAT_PUSH, - ROTARY_UP, + ROTARY_UP = 29, ROTARY_DOWN, - THUMBSTICK, - THUMBSTICK_LEFT, - THUMBSTICK_RIGHT, - THUMBSTICK_UP, - THUMBSTICK_DOWN, - THUMBSTICK_PUSH, - THUMBSTICK_INNER, - THUMBSTICK_OUTER, - GLYPHS_0, + LSTICK_SETTINGS = 31, + LSTICK_LEFT, + LSTICK_RIGHT, + LSTICK_UP, + LSTICK_DOWN, + LSTICK_UL = 55, + LSTICK_UR, + LSTICK_DL, + LSTICK_DR, + LSTICK_PUSH = 36, + LSTICK_INNER, + LSTICK_OUTER, + RSTICK_SETTINGS = 59, + RSTICK_LEFT = 20, + RSTICK_RIGHT, + RSTICK_UP, + RSTICK_DOWN, + RSTICK_UL, + RSTICK_UR, + RSTICK_DL, + RSTICK_DR, + RSTICK_PUSH, + RSTICK_INNER = 60, + RSTICK_OUTER, + GLYPHS_0 = 39, GLYPHS_1, GLYPHS_2, GLYPHS_3, @@ -86,7 +93,7 @@ export enum SectionIndex { DAISY_1, DAISY_2, DAISY_3, - GYRO, + GYRO_SETTINGS, GYRO_X, GYRO_Y, GYRO_Z, @@ -117,6 +124,7 @@ export enum ThumbstickMode { OFF, DIR4, ALPHANUMERIC, + DIR8, } export enum ThumbstickDistanceMode { @@ -136,31 +144,24 @@ export function sectionIsMeta(section: SectionIndex) { return section == SectionIndex.META } -export function sectionIsButton(section: SectionIndex) { - return ( - (section >= SectionIndex.A && section <= SectionIndex.DHAT_PUSH) || - (section >= SectionIndex.THUMBSTICK_LEFT && section <= SectionIndex.THUMBSTICK_OUTER) - ) -} - export function sectionIsRotary(section: SectionIndex) { return section == SectionIndex.ROTARY_UP || section == SectionIndex.ROTARY_DOWN } export function sectionIsThumbtick(section: SectionIndex) { - return section == SectionIndex.THUMBSTICK + return section == SectionIndex.LSTICK_SETTINGS } export function sectionIsThumbtickDirection(section: SectionIndex) { - return section >= SectionIndex.THUMBSTICK_LEFT && section <= SectionIndex.THUMBSTICK_DOWN + return section >= SectionIndex.LSTICK_LEFT && section <= SectionIndex.LSTICK_DOWN } export function sectionIsThumbtickButton(section: SectionIndex) { - return sectionIsThumbtickDirection(section) || section == SectionIndex.THUMBSTICK_PUSH + return sectionIsThumbtickDirection(section) || section == SectionIndex.LSTICK_PUSH } export function sectionIsGyro(section: SectionIndex) { - return section == SectionIndex.GYRO + return section == SectionIndex.GYRO_SETTINGS } export function sectionIsGyroAxis(section: SectionIndex) { @@ -213,17 +214,17 @@ export class Ctrl { // See: https://github.com/inputlabs/alpakka_firmware/blob/main/docs/ctrl_protocol.md const data = Array.from(buffer) const msgType = data[2] - if (msgType== MessageType.LOG) return CtrlLog.decode(buffer) - if (msgType== MessageType.STATUS_SHARE) return CtrlStatusShare.decode(buffer) + if (msgType == MessageType.LOG) return CtrlLog.decode(buffer) + if (msgType == MessageType.STATUS_SHARE) return CtrlStatusShare.decode(buffer) if (msgType == MessageType.CONFIG_SHARE) return CtrlConfigShare.decode(buffer) if (msgType == MessageType.SECTION_SHARE) { const section = data[5] if (sectionIsMeta(section)) return CtrlSectionMeta.decode(buffer) - if (sectionIsButton(section)) return CtrlButton.decode(buffer) - if (sectionIsRotary(section)) return CtrlRotary.decode(buffer) - if (sectionIsThumbtick(section)) return CtrlThumbstick.decode(buffer) - if (sectionIsGyro(section)) return CtrlGyro.decode(buffer) - if (sectionIsGyroAxis(section)) return CtrlGyroAxis.decode(buffer) + else if (sectionIsRotary(section)) return CtrlRotary.decode(buffer) + else if (sectionIsThumbtick(section)) return CtrlThumbstick.decode(buffer) + else if (sectionIsGyro(section)) return CtrlGyro.decode(buffer) + else if (sectionIsGyroAxis(section)) return CtrlGyroAxis.decode(buffer) + else return CtrlButton.decode(buffer) } return false } diff --git a/src/lib/device.ts b/src/lib/device.ts index e09288c..cf37250 100644 --- a/src/lib/device.ts +++ b/src/lib/device.ts @@ -85,12 +85,11 @@ export class Device { async listen() { this.isListening = true try { - // console.log('Listening...') const response = await this.usbDevice.transferIn(ADDR_IN, PACKAGE_SIZE) let data = response.data as any const array = new Uint8Array(data.buffer) const ctrl = Ctrl.decode(array) - // console.log('received', ctrl) + // console.log('Received', ctrl) if (ctrl instanceof CtrlLog) this.handleCtrlLog(ctrl) if (ctrl instanceof CtrlStatusShare) this.handleCtrlStatusShare(ctrl) if (ctrl instanceof CtrlConfigShare) { diff --git a/src/lib/profile.ts b/src/lib/profile.ts index 52ea31f..012437b 100644 --- a/src/lib/profile.ts +++ b/src/lib/profile.ts @@ -29,26 +29,35 @@ export class Profile { public buttonR1: CtrlButton = new CtrlButton(0, 0, 0), public buttonR2: CtrlButton = new CtrlButton(0, 0, 0), public buttonR4: CtrlButton = new CtrlButton(0, 0, 0), - public buttonDhatLeft: CtrlButton = new CtrlButton(0, 0, 0), - public buttonDhatRight: CtrlButton = new CtrlButton(0, 0, 0), - public buttonDhatUp: CtrlButton = new CtrlButton(0, 0, 0), - public buttonDhatDown: CtrlButton = new CtrlButton(0, 0, 0), - public buttonDhatUL: CtrlButton = new CtrlButton(0, 0, 0), - public buttonDhatUR: CtrlButton = new CtrlButton(0, 0, 0), - public buttonDhatDL: CtrlButton = new CtrlButton(0, 0, 0), - public buttonDhatDR: CtrlButton = new CtrlButton(0, 0, 0), - public buttonDhatPush: CtrlButton = new CtrlButton(0, 0, 0), - public buttonThumbstickLeft: CtrlButton = new CtrlButton(0, 0, 0), - public buttonThumbstickRight: CtrlButton = new CtrlButton(0, 0, 0), - public buttonThumbstickUp: CtrlButton = new CtrlButton(0, 0, 0), - public buttonThumbstickDown: CtrlButton = new CtrlButton(0, 0, 0), - public buttonThumbstickPush: CtrlButton = new CtrlButton(0, 0, 0), - public buttonThumbstickInner: CtrlButton = new CtrlButton(0, 0, 0), - public buttonThumbstickOuter: CtrlButton = new CtrlButton(0, 0, 0), + // Left stick. + public settingsLStick: CtrlThumbstick = new CtrlThumbstick(0, 0, 0, 0, 0, 0, false, 0), + public buttonLStickLeft: CtrlButton = new CtrlButton(0, 0, 0), + public buttonLStickRight: CtrlButton = new CtrlButton(0, 0, 0), + public buttonLStickUp: CtrlButton = new CtrlButton(0, 0, 0), + public buttonLStickDown: CtrlButton = new CtrlButton(0, 0, 0), + public buttonLStickUL: CtrlButton = new CtrlButton(0, 0, 0), + public buttonLStickUR: CtrlButton = new CtrlButton(0, 0, 0), + public buttonLStickDL: CtrlButton = new CtrlButton(0, 0, 0), + public buttonLStickDR: CtrlButton = new CtrlButton(0, 0, 0), + public buttonLStickPush: CtrlButton = new CtrlButton(0, 0, 0), + public buttonLStickInner: CtrlButton = new CtrlButton(0, 0, 0), + public buttonLStickOuter: CtrlButton = new CtrlButton(0, 0, 0), + // Right stick (stick or dhat). + public settingsRStick: CtrlThumbstick = new CtrlThumbstick(0, 0, 0, 0, 0, 0, false, 0), + public buttonRStickLeft: CtrlButton = new CtrlButton(0, 0, 0), + public buttonRStickRight: CtrlButton = new CtrlButton(0, 0, 0), + public buttonRStickUp: CtrlButton = new CtrlButton(0, 0, 0), + public buttonRStickDown: CtrlButton = new CtrlButton(0, 0, 0), + public buttonRStickUL: CtrlButton = new CtrlButton(0, 0, 0), + public buttonRStickUR: CtrlButton = new CtrlButton(0, 0, 0), + public buttonRStickDL: CtrlButton = new CtrlButton(0, 0, 0), + public buttonRStickDR: CtrlButton = new CtrlButton(0, 0, 0), + public buttonRStickPush: CtrlButton = new CtrlButton(0, 0, 0), + // Rotary. public rotaryUp: CtrlRotary = new CtrlRotary(0, 0), public rotaryDown: CtrlRotary = new CtrlRotary(0, 0), - public thumbstick: CtrlThumbstick = new CtrlThumbstick(0, 0, 0, 0, 0, 0, false, 0), - public gyro: CtrlGyro = new CtrlGyro(0, 0, 0, 0), + // Gyro. + public settingsGyro: CtrlGyro = new CtrlGyro(0, 0, 0, 0), public gyroX: CtrlGyroAxis = CtrlGyroAxis.default(), public gyroY: CtrlGyroAxis = CtrlGyroAxis.default(), public gyroZ: CtrlGyroAxis = CtrlGyroAxis.default(), diff --git a/src/lib/profiles.ts b/src/lib/profiles.ts index a43705d..7e922c4 100644 --- a/src/lib/profiles.ts +++ b/src/lib/profiles.ts @@ -71,33 +71,39 @@ export class Profiles { profile.buttonR1 = await getButton(SectionIndex.R1) profile.buttonR2 = await getButton(SectionIndex.R2) profile.buttonR4 = await getButton(SectionIndex.R4) - profile.buttonDhatLeft = await getButton(SectionIndex.DHAT_LEFT) - profile.buttonDhatRight = await getButton(SectionIndex.DHAT_RIGHT) - profile.buttonDhatUp = await getButton(SectionIndex.DHAT_UP) - profile.buttonDhatDown = await getButton(SectionIndex.DHAT_DOWN) - profile.buttonDhatUL = await getButton(SectionIndex.DHAT_UL) - profile.buttonDhatUR = await getButton(SectionIndex.DHAT_UR) - profile.buttonDhatDL = await getButton(SectionIndex.DHAT_DL) - profile.buttonDhatDR = await getButton(SectionIndex.DHAT_DR) - profile.buttonDhatPush = await getButton(SectionIndex.DHAT_PUSH) - profile.buttonThumbstickLeft = await getButton(SectionIndex.THUMBSTICK_LEFT) - profile.buttonThumbstickRight = await getButton(SectionIndex.THUMBSTICK_RIGHT) - profile.buttonThumbstickUp = await getButton(SectionIndex.THUMBSTICK_UP) - profile.buttonThumbstickDown = await getButton(SectionIndex.THUMBSTICK_DOWN) - profile.buttonThumbstickPush = await getButton(SectionIndex.THUMBSTICK_PUSH) - profile.buttonThumbstickInner = await getButton(SectionIndex.THUMBSTICK_INNER) - profile.buttonThumbstickOuter = await getButton(SectionIndex.THUMBSTICK_OUTER) + // Left stick. + profile.buttonLStickLeft = await getButton(SectionIndex.LSTICK_LEFT) + profile.buttonLStickRight = await getButton(SectionIndex.LSTICK_RIGHT) + profile.buttonLStickUp = await getButton(SectionIndex.LSTICK_UP) + profile.buttonLStickDown = await getButton(SectionIndex.LSTICK_DOWN) + profile.buttonLStickUL = await getButton(SectionIndex.LSTICK_UL) + profile.buttonLStickUR = await getButton(SectionIndex.LSTICK_UR) + profile.buttonLStickDL = await getButton(SectionIndex.LSTICK_DL) + profile.buttonLStickDR = await getButton(SectionIndex.LSTICK_DR) + profile.buttonLStickPush = await getButton(SectionIndex.LSTICK_PUSH) + profile.buttonLStickInner = await getButton(SectionIndex.LSTICK_INNER) + profile.buttonLStickOuter = await getButton(SectionIndex.LSTICK_OUTER) + // Right stick (thumbstick or dhat). + profile.buttonRStickLeft = await getButton(SectionIndex.RSTICK_LEFT) + profile.buttonRStickRight = await getButton(SectionIndex.RSTICK_RIGHT) + profile.buttonRStickUp = await getButton(SectionIndex.RSTICK_UP) + profile.buttonRStickDown = await getButton(SectionIndex.RSTICK_DOWN) + profile.buttonRStickUL = await getButton(SectionIndex.RSTICK_UL) + profile.buttonRStickUR = await getButton(SectionIndex.RSTICK_UR) + profile.buttonRStickDL = await getButton(SectionIndex.RSTICK_DL) + profile.buttonRStickDR = await getButton(SectionIndex.RSTICK_DR) + profile.buttonRStickPush = await getButton(SectionIndex.RSTICK_PUSH) // Rotary. const rotaryUp = await this.device.getSection(profileIndex, SectionIndex.ROTARY_UP) as CtrlRotary const rotaryDown = await this.device.getSection(profileIndex, SectionIndex.ROTARY_DOWN) as CtrlRotary profile.rotaryUp = rotaryUp profile.rotaryDown = rotaryDown // Thumbstick mode. - const ts = await this.device.getSection(profileIndex, SectionIndex.THUMBSTICK) as CtrlThumbstick - profile.thumbstick = ts + const ts = await this.device.getSection(profileIndex, SectionIndex.LSTICK_SETTINGS) as CtrlThumbstick + profile.settingsLStick = ts // Gyro mode. - const gyro = await this.device.getSection(profileIndex, SectionIndex.GYRO) as CtrlGyro - profile.gyro = gyro + const gyro = await this.device.getSection(profileIndex, SectionIndex.GYRO_SETTINGS) as CtrlGyro + profile.settingsGyro = gyro // Gyro Axes. profile.gyroX = await this.device.getSection(profileIndex, SectionIndex.GYRO_X) as CtrlGyroAxis profile.gyroY = await this.device.getSection(profileIndex, SectionIndex.GYRO_Y) as CtrlGyroAxis From 89f565ce10abdb8d3cef528d75b2647130658240 Mon Sep 17 00:00:00 2001 From: Marcos Diaz Date: Mon, 10 Feb 2025 00:26:20 +0200 Subject: [PATCH 2/5] Correct analog colors --- src/components/profile/action_preview.ts | 3 ++- src/components/profile/profile.html | 2 ++ src/components/profile/profile.ts | 28 +++++++++++++++++++++++- src/components/profile/section.html | 4 ++-- src/components/profile/section.ts | 5 +++-- src/lib/ctrl.ts | 5 ++++- 6 files changed, 40 insertions(+), 7 deletions(-) diff --git a/src/components/profile/action_preview.ts b/src/components/profile/action_preview.ts index 5ec52e5..0d0b9c6 100644 --- a/src/components/profile/action_preview.ts +++ b/src/components/profile/action_preview.ts @@ -29,6 +29,7 @@ interface Icon { }) export class ButtonComponent { @Input() section: CtrlButton | CtrlRotary | CtrlGyroAxis + @Input() analog: boolean = false constructor( public webusb: WebusbService, @@ -223,7 +224,7 @@ export class ButtonComponent { if (index==1 && this.section.hold) cls += ' hold' if (index==2 && this.section.double) cls += ' double' } - if (sectionIsAnalog(this.section.sectionIndex) && isAxis(action)) { + if (this.analog && sectionIsAnalog(this.section.sectionIndex) && isAxis(action)) { cls += ' analog' } return cls diff --git a/src/components/profile/profile.html b/src/components/profile/profile.html index 78b4810..af37131 100644 --- a/src/components/profile/profile.html +++ b/src/components/profile/profile.html @@ -25,6 +25,7 @@
@@ -66,6 +67,7 @@
diff --git a/src/components/profile/profile.ts b/src/components/profile/profile.ts index 4354609..70fb9aa 100644 --- a/src/components/profile/profile.ts +++ b/src/components/profile/profile.ts @@ -150,15 +150,41 @@ export class ProfileComponent { return cls } - getMapping( section: CtrlButton | CtrlRotary | CtrlGyroAxis) { + sectionCouldBeAnalog(section: CtrlSection) { + const dirLStick= [ + SectionIndex.LSTICK_LEFT, + SectionIndex.LSTICK_RIGHT, + SectionIndex.LSTICK_UP, + SectionIndex.LSTICK_DOWN + ] + const dirRStick= [ + SectionIndex.LSTICK_LEFT, + SectionIndex.LSTICK_RIGHT, + SectionIndex.LSTICK_UP, + SectionIndex.LSTICK_DOWN + ] + if (this.getProfile().settingsLStick.mode == ThumbstickMode.DIR4) { + if (dirLStick.includes(section.sectionIndex)) return true + } + if (this.getProfile().settingsRStick.mode == ThumbstickMode.DIR4) { + if (dirRStick.includes(section.sectionIndex)) return true + } + if (sectionIsGyroAxis(section.sectionIndex)) return true + return false + } + + getMapping(section: CtrlButton | CtrlRotary | CtrlGyroAxis) { const pos = position.filter((x) => x.section==section.sectionIndex)[0] let style = {'grid-column': pos.column, 'grid-row': pos.row} let cls = 'cls' in pos ? pos.cls : '' + let analog = false + if (this.sectionCouldBeAnalog(section)) analog = true if (section.sectionIndex == this.selected?.sectionIndex) cls += ' selected' return { section, cls, style, + analog, click: () => this.setSelected(section), } } diff --git a/src/components/profile/section.html b/src/components/profile/section.html index 6a411ae..4c2a7fc 100644 --- a/src/components/profile/section.html +++ b/src/components/profile/section.html @@ -177,7 +177,7 @@

{{getSectionTitle()}}

-
Distance calculation:
+
Analog distance calculation:
+
+
Saturation:
+
+ +
+
Axis overlap:
@@ -222,7 +235,7 @@

{{getSectionTitle()}}

/>
-
+
Anti-deadzone: