Skip to content

Commit 3255691

Browse files
committed
[virtual keyboard] fix gamepad input on keyboard
[version] set version to 0.0.5
1 parent 0ad52ab commit 3255691

5 files changed

Lines changed: 74 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lantern-bloodborne-launcher",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"productName": "LanternLauncher",
55
"description": "LanternLauncher for Bloodborne shadPS4 emu.",
66
"author": "par274",

src/lib/components/gamepad.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export type GamepadState = {
1313
buttonHeldB: boolean;
1414
buttonHeldX: boolean;
1515
buttonHeldY: boolean;
16+
buttonHeldLeftShoulder: boolean;
17+
buttonHeldRightShoulder: boolean;
1618
inputMode: InputMode;
1719
isXboxControllerConnected: boolean;
1820
isDualSenseControllerConnected: boolean;
@@ -27,6 +29,8 @@ type ControllerActions = {
2729
goBack: () => void;
2830
deleteText: () => void;
2931
confirmText: () => void;
32+
insertSpace: () => void;
33+
clearText: () => void;
3034
};
3135

3236
const AXIS_DEADZONE = 0.55;
@@ -48,6 +52,8 @@ export function createGamepadState(): GamepadState {
4852
buttonHeldB: false,
4953
buttonHeldX: false,
5054
buttonHeldY: false,
55+
buttonHeldLeftShoulder: false,
56+
buttonHeldRightShoulder: false,
5157
inputMode: 'keyboard',
5258
isXboxControllerConnected: false,
5359
isDualSenseControllerConnected: false
@@ -181,6 +187,8 @@ export function handleControllerInput(state: GamepadState, actions: ControllerAc
181187
state.buttonHeldB = false;
182188
state.buttonHeldX = false;
183189
state.buttonHeldY = false;
190+
state.buttonHeldLeftShoulder = false;
191+
state.buttonHeldRightShoulder = false;
184192

185193
if (state.inputMode !== 'keyboard') {
186194
state.inputMode = 'keyboard';
@@ -274,6 +282,20 @@ export function handleControllerInput(state: GamepadState, actions: ControllerAc
274282
actions.confirmText();
275283
}
276284
state.buttonHeldY = yPressed;
285+
286+
const leftShoulderPressed = !!controller.buttons[4]?.pressed;
287+
if (leftShoulderPressed && !state.buttonHeldLeftShoulder) {
288+
setDetectedControllerInputMode(state);
289+
actions.insertSpace();
290+
}
291+
state.buttonHeldLeftShoulder = leftShoulderPressed;
292+
293+
const rightShoulderPressed = !!controller.buttons[5]?.pressed;
294+
if (rightShoulderPressed && !state.buttonHeldRightShoulder) {
295+
setDetectedControllerInputMode(state);
296+
actions.clearText();
297+
}
298+
state.buttonHeldRightShoulder = rightShoulderPressed;
277299
}
278300

279301
export function createControllerTick(state: GamepadState, actions: ControllerActions) {

src/lib/components/patches/PatchModal.svelte

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
goBack: () => void;
99
deleteText: () => void;
1010
confirmText: () => void;
11+
insertSpace: () => void;
12+
clearText: () => void;
1113
};
1214
</script>
1315

@@ -597,6 +599,32 @@
597599
void updateBloodbornePatches();
598600
}
599601
602+
export function insertSpace() {
603+
if (!isVirtualKeyboardOpen && !isPatchSearchFocused) {
604+
return;
605+
}
606+
607+
playEnterSound();
608+
setPatchSearchQuery(`${patchSearchQuery} `);
609+
610+
requestAnimationFrame(() => {
611+
patchSearchInput?.focus({ preventScroll: true });
612+
});
613+
}
614+
615+
export function clearText() {
616+
if (!isVirtualKeyboardOpen && !isPatchSearchFocused) {
617+
return;
618+
}
619+
620+
playEnterSound();
621+
setPatchSearchQuery('');
622+
623+
requestAnimationFrame(() => {
624+
patchSearchInput?.focus({ preventScroll: true });
625+
});
626+
}
627+
600628
onMount(() => {
601629
void refreshPatchCatalog();
602630
void refreshPatchEnablement();

src/platform/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const app: App = {
1616
name: 'lantern-bloodborne-launcher',
1717
appShortTitle: 'LanternLauncher',
1818
appTitle: 'LanternLauncher for Bloodborne shadPS4 emu.',
19-
appVer: '0.0.4',
19+
appVer: '0.0.5',
2020
buildTitle: 'Early Access Build',
2121
copyright: 'Copyright (c) 2026 par274',
2222
license: 'GPL-2.0',

src/routes/+page.svelte

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,28 @@
11401140
if (isLauncherInfoPromptVisible) {
11411141
openLauncherInfoModal();
11421142
}
1143+
},
1144+
insertSpace: () => {
1145+
if (activeInputDropdown) {
1146+
playEnterSound();
1147+
activeInputDropdown.onInput(`${activeInputDropdown.value} `);
1148+
return;
1149+
}
1150+
1151+
if (isPatchModalOpen) {
1152+
patchModal?.insertSpace();
1153+
}
1154+
},
1155+
clearText: () => {
1156+
if (activeInputDropdown) {
1157+
playEnterSound();
1158+
activeInputDropdown.onInput('');
1159+
return;
1160+
}
1161+
1162+
if (isPatchModalOpen) {
1163+
patchModal?.clearText();
1164+
}
11431165
}
11441166
});
11451167
const handleControllerChange = createControllerChangeHandler(gamepad);

0 commit comments

Comments
 (0)