Skip to content

Commit 760fc3a

Browse files
authored
Merge pull request #53 from PiterWeb/main
Linux support for Gamepad
2 parents e895143 + a80d91a commit 760fc3a

35 files changed

+1026
-182
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@
3030

3131
1. Fork this repository
3232
2. Clone it
33-
3. Work on your translations (located in frontend/src/lib/i18n)
34-
4. When you have finished make a pull request to merge it with the main branch
35-
5. Wait for merge
36-
6. Done
33+
3. Work on your translations (located in frontend/src/lib/i18n):
34+
- Create a JSON file of the language and register the language in the i18n.ts file (all of this if the language is not added already)
35+
- Add the entries (you can do manually or using [i18n Ally extension](https://marketplace.visualstudio.com/items?itemName=Lokalise.i18n-ally))
36+
5. When you have finished make a pull request to merge it with the main branch
37+
6. Wait for merge
38+
7. Done
3739

3840

39-
## Thank you for reading this & also for your interest on contributing
41+
## Thank you for reading this & also for your interest on contributing

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
## Download 📦
1919

20-
- https://remote-controller.vercel.app/download/
20+
- (Website) https://remote-controller.vercel.app/download/
21+
- (Github) https://github.com/PiterWeb/RemoteController/releases/latest
2122

2223
## Guides 📘
2324

@@ -27,6 +28,7 @@
2728
## Resources 📚
2829

2930
- [Docs](./docs/) 📘
31+
- [Linux Docs](./docs/LINUX.md) 📘
3032
- [FAQ](https://remote-controller.vercel.app/info/resources/faq/) 💬
3133
- [Security](https://remote-controller.vercel.app/info/resources/security/) 🔐
3234

@@ -41,7 +43,7 @@
4143
- [x] P2P "Decentralized" (WebRTC)
4244
- [x] Remote Streaming
4345
- [x] Browser Client
44-
- [x] Support for keyboard
46+
- [x] Support for keyboard (very experimental)
4547
- [x] ViGEmBus Setup (Windows)
4648
- [x] Localization (translation to multiple languages)
4749
- [x] Support for STUN & TURN
@@ -50,13 +52,13 @@
5052

5153
| Windows | Linux | MacOS | Browser (Only Client) |
5254
|--------- |------- |------- |--------- |
53-
|| (Only keyboard)⌛ Looking for contributions for Gamepad | (In theory keyboard works)⌛ Looking for contributions for Gamepad | ✔ (Known Issues with Safari) |
55+
|| ✔ Gamepad support (❌ Keyboard/Streaming for the moment) | ❌ (No MacOS to test) | ✔ (Known Issues with Safari) |
5456

5557
### Native Gamepad Support 🎮
5658

5759
| PC Controller (XInput/DirectInput) | Xbox Controller (XInput) | PlayStation Controler
5860
|--------- |------- |------- |
59-
||| ❌ (You can achieve emulating a Xbox Controller) |
61+
||| ❌ (But you can achieve [emulating a Xbox Controller](https://github.com/Ryochan7/DS4Windows)) |
6062

6163
### Translations 🔠
6264

@@ -70,13 +72,13 @@ There is no way to self-host the infrastructure of RemoteController because it h
7072

7173
- If you want to self-host a TURN/STUN server you can [try Coturn](https://github.com/coturn/coturn). (This is only an example, you can choose other STUN/TURN implementations)
7274

73-
- Also you can host the Web version (but it is only frontend) to make like a network of Remote Controller web clients
75+
- Also you can host the Web version (but it is only frontend, so is not very usefull)
7476

7577
## Run Dev
7678

7779
### Prerequisites
7880

79-
You must have Task CLI, Wails CLI, NodeJS, pnpm and Golang installed.
81+
You must have [Task CLI](https://taskfile.dev/installation/), [Wails CLI](https://wails.io/docs/gettingstarted/installation#installing-wails), [NodeJS (~v20.x.x)](https://nodejs.org/en/download), [pnpm](https://pnpm.io/es/installation) and [Golang (min v1.22.4)](https://go.dev/doc/install) installed.
8082

8183
### How to
8284

@@ -94,7 +96,7 @@ Go to the root project folder and run
9496

9597
### Prerequisites
9698

97-
You must have Task CLI, Wails CLI, NodeJS, pnpm and Golang installed.
99+
You must have [Task CLI](https://taskfile.dev/installation/), [Wails CLI](https://wails.io/docs/gettingstarted/installation#installing-wails), [NodeJS (~v20.x.x)](https://nodejs.org/en/download), [pnpm](https://pnpm.io/es/installation) and [Golang (min v1.22.4)](https://go.dev/doc/install) installed.
98100

99101
### How to
100102

Taskfile.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ tasks:
1010
build:
1111
deps: [build-front]
1212
cmds:
13-
- wails build -platform=windows/amd64,windows/arm64,linux/amd64,linux/arm64
13+
- wails build -s -platform=windows/amd64,windows/arm64,linux/amd64,linux/arm64
1414
desc: Build the application for all platforms
1515
build-win:
1616
deps: [build-front]
1717
cmds:
18-
- wails build -platform=windows/amd64,windows/arm64
18+
- wails build -s -platform=windows/amd64,windows/arm64
1919
desc: Build the application for Windows
2020
build-linux:
2121
deps: [build-front]
2222
cmds:
23-
- wails build -platform=linux/amd64,linux/arm64
23+
- wails build -s -platform=linux/amd64,linux/arm64
2424
desc: Build the application for Linux
2525
build-wasm-front-linux:
2626
dir: frontend/static/wasm
@@ -37,7 +37,6 @@ tasks:
3737
cmds:
3838
- wails dev
3939
desc: Run the application in development mode
40-
4140
dev-front:
4241
dir: frontend
4342
deps: [build-front]

docs/GamepadConversionTable.xlsx

10.9 KB
Binary file not shown.

docs/LINUX.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Linux
2+
3+
## Execute in Linux
4+
5+
When you run RemoteController you will need to be sure to:
6+
7+
- Your user has read/write permissions for /dev/input/event/* and uinput devices
8+
- Example in Debian: sudo usermod -aG input $USER
9+
- Uinput module enabled
10+
- Example in Debian: sudo modprobe uinput

docs/Xinput to GamepadAPI.xlsx

-11.2 KB
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script lang="ts">
2+
import { isLinux } from '$lib/detection/detect_os';
3+
import type { Snippet } from 'svelte';
4+
let { children, not = false }: {children?: Snippet, not?: boolean} = $props();
5+
</script>
6+
7+
{#await isLinux() then bool}
8+
{#if bool}
9+
{#if !not}
10+
{@render children?.()}
11+
{/if}
12+
{:else if not}
13+
{@render children?.()}
14+
{/if}
15+
{/await}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
<script>
1+
<script lang="ts">
22
import { isWindows } from '$lib/detection/detect_os';
3-
/** @type {{children?: import('svelte').Snippet}} */
4-
let { children } = $props();
3+
import type { Snippet } from 'svelte';
4+
let { children, not = false }: {children?: Snippet, not?: boolean} = $props();
55
</script>
66

77
{#await isWindows() then bool}
88
{#if bool}
9+
{#if !not}
10+
{@render children?.()}
11+
{/if}
12+
{:else if not}
913
{@render children?.()}
1014
{/if}
1115
{/await}

frontend/src/lib/detection/detect_os.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,28 @@ import { GetCurrentOS } from '$lib/wailsjs/go/desktop/App';
44
type OS = 'WINDOWS' | 'LINUX' | 'MACOS';
55

66
export async function isWindows() {
7-
if (onwebsite) return false;
8-
else return ((await GetCurrentOS()) as OS) === 'WINDOWS';
7+
try {
8+
if (onwebsite) return false;
9+
else return ((await GetCurrentOS()) as OS) === 'WINDOWS';
10+
} catch {
11+
return false
12+
}
913
}
1014

1115
export async function isLinux() {
12-
if (onwebsite) return false;
13-
else return ((await GetCurrentOS()) as OS) === 'LINUX';
16+
try {
17+
if (onwebsite) return false;
18+
else return ((await GetCurrentOS()) as OS) === 'LINUX';
19+
} catch {
20+
return false
21+
}
1422
}
1523

1624
export async function isMacOS() {
17-
if (onwebsite) return false;
18-
else return ((await GetCurrentOS()) as OS) === 'MACOS';
25+
try {
26+
if (onwebsite) return false;
27+
else return ((await GetCurrentOS()) as OS) === 'MACOS';
28+
} catch {
29+
return false
30+
}
1931
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
// This file is used to determine if the app is running on the website(client only) or not.
22
const onwebsite = import.meta.env?.VITE_ON_WEBSITE === 'true';
33

4+
// This will be true if using the linux client when browser opens
5+
const IS_RUNNING_EXTERNAL = window.location.port === "8080";
6+
7+
export {IS_RUNNING_EXTERNAL}
8+
49
export default onwebsite;

frontend/src/lib/webrtc/host_webrtc_hook.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import {
33
TryClosePeerConnection as closeConnectionFn
44
} from '$lib/wailsjs/go/desktop/App';
55

6-
import { EventsOff, EventsOn, EventsOnce } from '$lib/wailsjs/runtime/runtime';
7-
86
import { _ } from 'svelte-i18n'
97
import { get } from 'svelte/store';
108
import { showToast, ToastType } from '$lib/toast/toast_hook';
@@ -14,6 +12,10 @@ import { StopStreaming } from '$lib/webrtc/stream/host_stream_hook';
1412
import type { ICEServer } from '$lib/webrtc/ice';
1513
import { exportStunServers } from './stun_servers';
1614
import { exportTurnServers } from './turn_servers';
15+
import { isLinux } from '$lib/detection/detect_os';
16+
import { IS_RUNNING_EXTERNAL } from '$lib/detection/onwebsite';
17+
18+
const BROWSER_BASE_URL = "http://localhost:8080/mode/host/connection";
1719

1820
let host: boolean = false;
1921

@@ -50,13 +52,19 @@ export async function CreateHost(client: string) {
5052
setLoadingMessage(get(_)('waiting-for-client-to-connect'));
5153
setLoadingTitle(get(_)('make-sure-to-pass-the-code-to-the-client'));
5254

53-
EventsOnce('connection_state', (state: ConnectionState) => {
55+
const {EventsOnce} = await import("$lib/wailsjs/runtime/runtime")
56+
57+
EventsOnce('connection_state', async (state: ConnectionState) => {
5458
toogleLoading();
5559

5660
switch (state.toUpperCase()) {
5761
case ConnectionState.Connected:
5862
showToast(get(_)('connected'), ToastType.SUCCESS);
5963
host = true;
64+
if (await isLinux()) {
65+
const {BrowserOpenURL} = await import("$lib/wailsjs/runtime/runtime")
66+
BrowserOpenURL(BROWSER_BASE_URL);
67+
}
6068
goto('/mode/host/connection');
6169
break;
6270
case ConnectionState.Failed:
@@ -85,7 +93,12 @@ export function CloseHostConnection(fn?: () => void) {
8593
StopStreaming();
8694
}
8795

88-
export function ListenForConnectionChanges() {
96+
export async function ListenForConnectionChanges() {
97+
98+
if (IS_RUNNING_EXTERNAL) return;
99+
100+
const {EventsOn, EventsOff} = await import("$lib/wailsjs/runtime/runtime")
101+
89102
const connectionStateCancelEventListener = EventsOn(
90103
'connection_state',
91104
(state: ConnectionState) => {

0 commit comments

Comments
 (0)