Skip to content

Commit 8d256a4

Browse files
committed
Added a commandline option to set the port on launch via (--port=N or --port N)
1 parent 61c50de commit 8d256a4

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ You can download that [here](https://github.com/bkacjios/m-overlay/releases/tag/
1616

1717
- **You can change which controller port is displayed by using the scrollwheel or pressing 1-4 on the keyboard.**
1818
- Access a settings menu by pressing the escape key
19+
- Set what port you are using on launch via commandline (--port=N or --port N)
20+
21+
![Port Commandline](https://i.imgur.com/f9AkS2q.png)
1922

2023
To use with OBS, add a "Game Capture" source and use "capture specific window" select "[M'Overlay.exe]"
2124
and be sure to check "Allow Transparency"

source/main.lua

+21-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ local DEBUG_FONT = graphics.newFont("fonts/melee-bold.otf", 12)
1818

1919
local PANEL_SETTINGS
2020

21-
function love.load()
21+
local MAX_PORTS = 4
22+
local PORT = 0
23+
local CONTROLLER_PORT_DISPLAY = 0
24+
25+
function love.load(args, unfilteredArg)
2226
if watcher.hasPermissions() then
2327
love.window.setTitle("M'Overlay - Waiting for Dolphin...")
2428
else
@@ -31,6 +35,22 @@ function love.load()
3135
PANEL_SETTINGS = gui.create("Settings")
3236
PANEL_SETTINGS:LoadSettings()
3337
PANEL_SETTINGS:SetVisible(false)
38+
39+
-- Loop through all the commandline arguments
40+
for n, arg in pairs(args) do
41+
-- Check for '--port=N' first..
42+
local portn = tonumber(string.match(arg, "%-%-port=(%d+)"))
43+
44+
if arg == "--port" then -- Alternative '--port N'
45+
portn = tonumber(args[n+1]) -- Convert the next argument in the commandline to a number
46+
end
47+
48+
if portn then -- A port number was specified..
49+
PORT = (portn - 1) % MAX_PORTS -- Clamp the number between 0-3
50+
CONTROLLER_PORT_DISPLAY = love.timer.getTime() + 3 -- Show the port display number for 3 seconds
51+
break -- Done
52+
end
53+
end
3454
end
3555

3656
function love.update(dt)
@@ -62,10 +82,6 @@ function love.joystickreleased(joy, but)
6282
gui.joyReleased(joy, but)
6383
end
6484

65-
local MAX_PORTS = 4
66-
local PORT = 0
67-
local CONTROLLER_PORT_DISPLAY = 0
68-
6985
function love.keypressed(key, scancode, isrepeat)
7086
if key == "escape" and not isrepeat then
7187
PANEL_SETTINGS:Toggle()

0 commit comments

Comments
 (0)