Skip to content

Commit

Permalink
feat: trigger rumble support
Browse files Browse the repository at this point in the history
  • Loading branch information
lijiahao committed Nov 5, 2024
1 parent 483681d commit 22025a8
Show file tree
Hide file tree
Showing 13 changed files with 828 additions and 975 deletions.
7 changes: 5 additions & 2 deletions app/background.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/preload.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

120 changes: 120 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": true,
"name": "xstreaming",
"description": "xstreaming",
"version": "1.1.0",
"version": "1.2.0",
"author": "Geocld <[email protected]>",
"main": "app/background.js",
"scripts": {
Expand Down Expand Up @@ -39,7 +39,7 @@
"uplot": "^1.6.30",
"uuid-1345": "^1.0.2",
"xbox-webapi": "^1.4.1",
"xstreaming-player": "^0.2.4",
"xstreaming-player": "0.2.5",
"xvfb-maybe": "^0.2.1"
},
"devDependencies": {
Expand All @@ -52,7 +52,7 @@
"@typescript-eslint/parser": "^8.6.0",
"autoprefixer": "^10.4.20",
"babel-loader": "^9.1.3",
"electron": "28",
"electron": "33",
"electron-builder": "^24.13.3",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.2",
Expand Down
22 changes: 22 additions & 0 deletions renderer/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ const getSettingsMetas = (t) => {
'Set the cloud streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)',
)
},
{
name: 'audio_bitrate',
type: 'bitrate',
title: t('Audio bitrate'),
description: t(
'Set the streaming audio bitrate',
)
},
],
gamepad: [
{
Expand Down Expand Up @@ -183,6 +191,20 @@ const getSettingsMetas = (t) => {
{value: false, label: t('Disable')},
],
},
{
name: 'force_trigger_rumble',
type: 'radio',
title: t('Trigger rumble'),
description: t(
'trigger_rumble_description',
),
data: [
{value: '', label: t('Disable')},
{value: 'all', label: t('All')},
{value: 'left', label: t('Left trigger')},
{value: 'right', label: t('Right trigger')},
],
},
],
xhome: [
{
Expand Down
3 changes: 3 additions & 0 deletions renderer/context/userContext.defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export const defaultSettings = {
xhome_bitrate: 20,
xcloud_bitrate_mode: "Auto",
xcloud_bitrate: 20,
audio_bitrate_mode: "Auto",
audio_bitrate: 20,
preferred_game_language: "en-US",
force_region_ip: "",
codec: "",
Expand All @@ -14,6 +16,7 @@ export const defaultSettings = {
gamepad_kernal: "Native",
dead_zone: 0.1,
edge_compensation: 0,
force_trigger_rumble: '',
power_on: false,
video_format: "",
virtual_gamepad_opacity: 0.6,
Expand Down
16 changes: 16 additions & 0 deletions renderer/pages/[locale]/stream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ function Stream() {
xPlayer.setGamepadMaping(settings.gamepad_maping)
}

if (settings.force_trigger_rumble) {
xPlayer.setForceTriggerRumble(settings.force_trigger_rumble)
}

// Set bitrate
if (streamType === "cloud") {
if (
Expand All @@ -110,6 +114,18 @@ function Stream() {
}
}

// Set audio bitrate
if (
settings.audio_bitrate_mode === "Custom" &&
settings.audio_bitrate !== 0
) {
console.log(
"setAudioBitrate:",
settings.audio_bitrate + "Mb/s"
);
xPlayer.setAudioBitrate(settings.audio_bitrate);
}

xPlayer.setConnectFailHandler(() => {
// Not connected
if (connectStateRef.current === "") {
Expand Down
30 changes: 29 additions & 1 deletion renderer/pages/[locale]/test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,35 @@ function GamepadTester() {
}
}}
>
Vibration test
Vibration
</Button>

<Button
color="secondary"
onClick={() => {
const gamepads = navigator.getGamepads();
console.log("gamepads:", gamepads);
for (let i = 0; i < gamepads.length; i++) {
const gp = gamepads[i];
if (gp) {
// @ts-ignore
if (gp.vibrationActuator.effects && gp.vibrationActuator.effects.includes('trigger-rumble')) {
gp.vibrationActuator.playEffect('trigger-rumble', {
duration: 255,
leftTrigger: 1,
rightTrigger: 1,
strongMagnitude: 0,
weakMagnitude: 1,
});

} else {
window.alert('trigger rumble is not supported!')
}
}
}
}}
>
Trigger rumble
</Button>
</div>
<div id="gamepads"></div>
Expand Down
7 changes: 7 additions & 0 deletions renderer/public/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,19 @@
"If your device supports newer codecs, it can reduce the video bandwidth requirements": "If your device supports newer codecs, it can reduce the video bandwidth requirements",
"Host stream bitrate": "Host stream bitrate",
"Cloud stream bitrate": "Cloud stream bitrate",
"Audio bitrate": "Audio bitrate",
"Set the streaming audio bitrate": "Set the streaming audio bitrate",
"Set the host streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)": "Set the host streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)",
"Set the cloud streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)": "Set the cloud streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)",
"Joystick dead zone": "Joystick dead zone",
"Config joystick dead zone": "Config joystick dead zone",
"Vibration": "Vibration",
"If your controller supports vibration, you can set whether it vibrates during the game": "If your controller supports vibration, you can set whether it vibrates during the game",
"Trigger rumble": "Trigger rumble",
"trigger_rumble_description": "Force controller trigger rumbled(Only work in Xbox one/s/x controller)",
"All": "All",
"Left trigger": "Left trigger",
"Right trigger": "Right trigger",
"Ipv6": "Ipv6",
"Prioritize using IPv6 connection": "Prioritize using IPv6 connection",
"Signal server": "Signal server",
Expand Down
7 changes: 7 additions & 0 deletions renderer/public/locales/jp/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,19 @@
"If your device supports newer codecs, it can reduce the video bandwidth requirements": "If your device supports newer codecs, it can reduce the video bandwidth requirements",
"Host stream bitrate": "Host stream bitrate",
"Cloud stream bitrate": "Cloud stream bitrate",
"Audio bitrate": "Audio bitrate",
"Set the streaming audio bitrate": "Set the streaming audio bitrate",
"Set the host streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)": "Set the host streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)",
"Set the cloud streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)": "Set the cloud streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)",
"Joystick dead zone": "Joystick dead zone",
"Config joystick dead zone": "Config joystick dead zone",
"Vibration": "Vibration",
"If your controller supports vibration, you can set whether it vibrates during the game": "If your controller supports vibration, you can set whether it vibrates during the game",
"Trigger rumble": "Trigger rumble",
"trigger_rumble_description": "Force controller trigger rumbled(Only work in Xbox one/s/x controller)",
"All": "All",
"Left trigger": "Left trigger",
"Right trigger": "Right trigger",
"Ipv6": "Ipv6",
"Prioritize using IPv6 connection": "Prioritize using IPv6 connection",
"Signal server": "Signal server",
Expand Down
7 changes: 7 additions & 0 deletions renderer/public/locales/zh/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,19 @@
"If your device supports newer codecs, it can reduce the video bandwidth requirements": "如果您的设备支持较新的编解码器,则可以降低视频带宽要求。",
"Host stream bitrate": "主机串流码率",
"Cloud stream bitrate": "云游戏码率",
"Audio bitrate": "声音",
"Set the streaming audio bitrate": "设置声音码率",
"Set the host streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)": "设置主机串流码率(注意:并不是码率越高越好,最终码率以串流协商为准)",
"Set the cloud streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)": "设置主机串流码率(注意:并不是码率越高越好,最终码率以串流协商为准)",
"Joystick dead zone": "摇杆死区",
"Config joystick dead zone": "设置摇杆死区",
"Vibration": "振动",
"If your controller supports vibration, you can set whether it vibrates during the game": "如果手柄支持振动,可以设置游戏中是否振动。",
"Trigger rumble": "扳机振动",
"trigger_rumble_description": "强制扳机振动(只有你的手柄支持扳机振动才生效)",
"All": "全部",
"Left trigger": "左扳机",
"Right trigger": "右扳机",
"Ipv6": "Ipv6",
"Prioritize using IPv6 connection": "优先使用Ipv6连接",
"Signal server": "信令服务器",
Expand Down
7 changes: 7 additions & 0 deletions renderer/public/locales/zht/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,20 @@
"If your device supports newer codecs, it can reduce the video bandwidth requirements": "如果您的設備支持較新的編解碼器,則可以降低視頻帶寬要求。",
"Host stream bitrate": "主機串流碼率",
"Cloud stream bitrate": "雲遊戲碼率",
"Audio bitrate": "声音碼率",
"Set the streaming audio bitrate": "設置主機串流声音碼率",
"Set the host streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)": "設置主機串流碼率(注意:並不是碼率越高越好,最終碼率以串流協商為準)",
"Set the cloud streaming bitrate (Note: Higher bitrate is not always better; the final bitrate will be determined by streaming negotiation)": "設置雲遊戲碼率(注意:並不是碼率越高越好,最終碼率以串流協商為準)",
"Joystick dead zone": "搖桿死區",
"Config joystick dead zone": "設置搖桿死區",
"Vibration": "振動",
"If your controller supports vibration, you can set whether it vibrates during the game": "如果手柄支持振動,可以設置遊戲中是否振動。",
"Trigger rumble": "扳机振動",
"trigger_rumble_description": "强制扳机振動(手柄支持扳机振動才生效)",
"Ipv6": "Ipv6",
"All": "全部",
"Left trigger": "左扳机",
"Right trigger": "右扳机",
"Prioritize using IPv6 connection": "優先使用Ipv6連接",
"Signal server": "信令伺服器",
"The signaling server is a server for stream negotiation. If the host cannot connect, please try modifying this option": "信令伺服器用於串流開始握手階段,如出現無法連接主機/雲遊戲的情況,請嘗試修改此選項(該選項關閉APP後將重置)",
Expand Down
Loading

0 comments on commit 22025a8

Please sign in to comment.