Skip to content

Commit 32f7130

Browse files
authored
Merge pull request #7 from steffalon/fix/6-unable-to-set-response-curves-stick-sensitivity
Add magic number to joystick preset in order to activate curve values
2 parents 697aaa0 + f4e8828 commit 32f7130

File tree

3 files changed

+55
-29
lines changed

3 files changed

+55
-29
lines changed

src/components/Configuration/StickSensitivity.vue

+28-20
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,30 @@ const changeJoyStickIndex = (joystick: Joystick, event: Event) => {
4141
<template>
4242
<section>
4343
<h3>Left stick</h3>
44-
<select @change="(e: any) => {
45-
leftJoystick.setProfileId(e.target.value);
46-
leftJoystickRange.disabled = Number(leftJoystick.getProfileId()) === JoystickProfileId.DEFAULT
47-
}">
48-
<option :selected="leftJoystick.getProfileId() === JoystickProfileId.DEFAULT" :value="JoystickProfileId.DEFAULT">
44+
<select
45+
v-bind:value="leftJoystick.getProfileId()"
46+
@change="(e: any) => {
47+
leftJoystick.setProfileId(e.target.value);
48+
leftJoystick.setModifier(PS5_JOYSTICK_CURVE[e.target.value].getModifier());
49+
leftJoystickRange.disabled = Number(leftJoystick.getProfileId()) === JoystickProfileId.DEFAULT
50+
}"
51+
>
52+
<option :value="JoystickProfileId.DEFAULT">
4953
Default
5054
</option>
51-
<option :selected="leftJoystick.getProfileId() === JoystickProfileId.QUICK" :value="JoystickProfileId.QUICK">
55+
<option :value="JoystickProfileId.QUICK">
5256
Quick
5357
</option>
54-
<option :selected="leftJoystick.getProfileId() === JoystickProfileId.PRECISE" :value="JoystickProfileId.PRECISE">
58+
<option :value="JoystickProfileId.PRECISE">
5559
Precise
5660
</option>
57-
<option :selected="leftJoystick.getProfileId() === JoystickProfileId.STEADY" :value="JoystickProfileId.STEADY">
61+
<option :value="JoystickProfileId.STEADY">
5862
Steady
5963
</option>
60-
<option :selected="leftJoystick.getProfileId() === JoystickProfileId.DIGITAL" :value="JoystickProfileId.DIGITAL">
64+
<option :value="JoystickProfileId.DIGITAL">
6165
Digital
6266
</option>
63-
<option :selected="leftJoystick.getProfileId() === JoystickProfileId.DYNAMIC" :value="JoystickProfileId.DYNAMIC">
67+
<option :value="JoystickProfileId.DYNAMIC">
6468
Dynamic
6569
</option>
6670
</select>
@@ -75,26 +79,30 @@ const changeJoyStickIndex = (joystick: Joystick, event: Event) => {
7579
</section>
7680
<section>
7781
<h3>Right stick</h3>
78-
<select @change="(e: any) => {
79-
rightJoystick.setProfileId(e.target?.value);
80-
rightJoystickRange.disabled = Number(rightJoystick.getProfileId()) === JoystickProfileId.DEFAULT
81-
}">
82-
<option :selected="rightJoystick.getProfileId() === JoystickProfileId.DEFAULT" :value="JoystickProfileId.DEFAULT">
82+
<select
83+
v-bind:value="rightJoystick.getProfileId()"
84+
@change="(e: any) => {
85+
rightJoystick.setProfileId(e.target.value);
86+
rightJoystick.setModifier(PS5_JOYSTICK_CURVE[e.target.value].getModifier());
87+
rightJoystickRange.disabled = Number(rightJoystick.getProfileId()) === JoystickProfileId.DEFAULT
88+
}"
89+
>
90+
<option :value="JoystickProfileId.DEFAULT">
8391
Default
8492
</option>
85-
<option :selected="rightJoystick.getProfileId() === JoystickProfileId.QUICK" :value="JoystickProfileId.QUICK">
93+
<option :value="JoystickProfileId.QUICK">
8694
Quick
8795
</option>
88-
<option :selected="rightJoystick.getProfileId() === JoystickProfileId.PRECISE" :value="JoystickProfileId.PRECISE">
96+
<option :value="JoystickProfileId.PRECISE">
8997
Precise
9098
</option>
91-
<option :selected="rightJoystick.getProfileId() === JoystickProfileId.STEADY" :value="JoystickProfileId.STEADY">
99+
<option :value="JoystickProfileId.STEADY">
92100
Steady
93101
</option>
94-
<option :selected="rightJoystick.getProfileId() === JoystickProfileId.DIGITAL" :value="JoystickProfileId.DIGITAL">
102+
<option :value="JoystickProfileId.DIGITAL">
95103
Digital
96104
</option>
97-
<option :selected="rightJoystick.getProfileId() === JoystickProfileId.DYNAMIC" :value="JoystickProfileId.DYNAMIC">
105+
<option :value="JoystickProfileId.DYNAMIC">
98106
Dynamic
99107
</option>
100108
</select>

src/helper/bytesToProfile.ts

+16-8
Original file line numberDiff line numberDiff line change
@@ -15,47 +15,47 @@ export const PS5_JOYSTICK_CURVE = [
1515
new JoystickCurve(196),
1616
new JoystickCurve(225),
1717
new JoystickCurve(225)
18-
]),
18+
], 0x03),
1919
new Joystick(JoystickProfileId.QUICK, [
2020
new JoystickCurve(38),
2121
new JoystickCurve(38),
2222
new JoystickCurve(122, -3),
2323
new JoystickCurve(139, [6, 5]),
2424
new JoystickCurve(255),
2525
new JoystickCurve(255)
26-
]),
26+
], 0x03),
2727
new Joystick(JoystickProfileId.PRECISE, [
2828
new JoystickCurve(70, 3),
2929
new JoystickCurve(57, [-3, -4]),
3030
new JoystickCurve(134, 3),
3131
new JoystickCurve(115, [-6, -7]),
3232
new JoystickCurve(196, 2),
3333
new JoystickCurve(177, [-7, -8])
34-
]),
34+
], 0x04),
3535
new Joystick(JoystickProfileId.STEADY, [
3636
new JoystickCurve(62, -1),
3737
new JoystickCurve(62, -1),
3838
new JoystickCurve(120, -4),
3939
new JoystickCurve(129, [0, -1]),
4040
new JoystickCurve(197, [3, 2]),
4141
new JoystickCurve(179, [-5, -6])
42-
]),
42+
], 0x04),
4343
new Joystick(JoystickProfileId.DIGITAL, [
4444
new JoystickCurve(38),
4545
new JoystickCurve(38),
4646
new JoystickCurve(38),
4747
new JoystickCurve(75, 18),
4848
new JoystickCurve(255),
4949
new JoystickCurve(255)
50-
]),
50+
], 0x03),
5151
new Joystick(JoystickProfileId.DYNAMIC, [
5252
new JoystickCurve(69, [3, 2]),
5353
new JoystickCurve(57, [-3, -4]),
5454
new JoystickCurve(183, [-4, -5]),
5555
new JoystickCurve(198, 3),
5656
new JoystickCurve(255),
5757
new JoystickCurve(255)
58-
]),
58+
], 0x03),
5959
];
6060

6161
export function bytesArrayToProfile(bytesArray: Array<Array<number>>): Profile {
@@ -89,6 +89,8 @@ export function bytesArrayToProfile(bytesArray: Array<Array<number>>): Profile {
8989
}
9090
}
9191

92+
console.log(label, bytesArray);
93+
9294
leftJoystickCurrentCurveValues = bytesArray[1].slice(47, 53);
9395

9496
rightJoystickCurrentCurveValues = bytesArray[1].slice(56, 60);
@@ -111,8 +113,8 @@ export function bytesArrayToProfile(bytesArray: Array<Array<number>>): Profile {
111113
const profile = new Profile(
112114
id,
113115
label,
114-
new Joystick(PS5_JOYSTICK_CURVE[bytesArray[2][30]].getProfileId(), PS5_JOYSTICK_CURVE[bytesArray[2][30]].getAdjustments()),
115-
new Joystick(PS5_JOYSTICK_CURVE[bytesArray[2][32]].getProfileId(), PS5_JOYSTICK_CURVE[bytesArray[2][32]].getAdjustments()),
116+
new Joystick(PS5_JOYSTICK_CURVE[bytesArray[2][30]].getProfileId(), PS5_JOYSTICK_CURVE[bytesArray[2][30]].getAdjustments(), PS5_JOYSTICK_CURVE[bytesArray[2][30]].getModifier()),
117+
new Joystick(PS5_JOYSTICK_CURVE[bytesArray[2][32]].getProfileId(), PS5_JOYSTICK_CURVE[bytesArray[2][32]].getAdjustments(), PS5_JOYSTICK_CURVE[bytesArray[2][32]].getModifier()),
116118
new Trigger(bytesArray[2][4], bytesArray[2][5]),
117119
new Trigger(bytesArray[2][6], bytesArray[2][7]),
118120
new ButtonMapping(bytesArray[2].slice(10, 26)),
@@ -161,6 +163,12 @@ export function profileToBytes(profile: Profile): Array<Uint8Array> {
161163
buffers[2][30] = profile.getLeftJoyStick().getProfileId();
162164
buffers[2][32] = profile.getRightJoyStick().getProfileId();
163165

166+
buffers[1][44] = profile.getLeftJoyStick().getModifier();
167+
buffers[1][53] = profile.getRightJoyStick().getModifier();
168+
169+
console.log(profile.getLeftJoyStick().getModifier())
170+
console.log(profile.getRightJoyStick().getModifier())
171+
164172
// Deep copy using JSON
165173
let joyConL = JSON.parse(JSON.stringify(profile.getLeftJoyStick().getCurveValues()));
166174
let joyConR = JSON.parse(JSON.stringify(profile.getRightJoyStick().getCurveValues()));

src/model/Joystick.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ export default class Joystick {
44

55
private profileId: number;
66
private adjustments: Array<JoystickCurve>
7+
private modifier: number;
78

89
private curveValues: Array<number> = [];
910

1011

11-
constructor(id: number, adjustments: Array<JoystickCurve>) {
12+
constructor(id: number, adjustments: Array<JoystickCurve>, modifier: number) {
1213
this.profileId = id;
1314
this.adjustments = adjustments;
15+
this.modifier = modifier; // Unknown? Value set when creating specific joystick profile on console
1416
}
1517

1618
setProfileId(profileId: number): void {
@@ -29,6 +31,14 @@ export default class Joystick {
2931
return this.adjustments;
3032
}
3133

34+
setModifier(modifier: number): void {
35+
this.modifier = modifier
36+
}
37+
38+
getModifier(): number {
39+
return this.modifier;
40+
}
41+
3242
setCurveValues(curveValues: Array<number>) {
3343
this.curveValues = curveValues;
3444
}

0 commit comments

Comments
 (0)