Skip to content
Draft
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c220dfb
feat(mac-os): implement Vulkan loader initialization and MoltenVK sur…
pato98115 Dec 8, 2025
c49a1b3
Merge branch 'master' of https://github.com/KaijuEngine/kaiju into fe…
pato98115 Dec 8, 2025
1374ff5
feat(mac-os): Implement macOS Cocoa windowing with mouse input and re…
pato98115 Dec 8, 2025
989f9af
Merge branch 'master' of https://github.com/KaijuEngine/kaiju into fe…
pato98115 Dec 8, 2025
e91b72c
chore: pull from upstream master
pato98115 Dec 8, 2025
9022093
feat(mac-os): implement windowing features and fix keyboard input fo…
pato98115 Dec 8, 2025
efd014b
feat(mac-os): add windowing: borderless, fullscreen, cursor lock/unlo…
pato98115 Dec 9, 2025
a6aa709
Merge branch 'master' of https://github.com/KaijuEngine/kaiju into fe…
pato98115 Dec 9, 2025
e610902
fix: correctly check if android is defined
pato98115 Dec 9, 2025
72970f1
Merge branch 'master' of https://github.com/KaijuEngine/kaiju into fe…
pato98115 Dec 9, 2025
3658f59
fix: expose vulkan sdk path to be set before building and replace old…
pato98115 Dec 10, 2025
2e9b510
Fix environment variables not set when building a project.
pierrec Dec 10, 2025
b05691e
rendering/vulkan: Fix erroneous type declaration
pierrec Dec 10, 2025
36896e0
rendering/vulkan: Fix cgo flags for macos
pierrec Dec 10, 2025
7d9a78e
docs: Update CMake configuration for SoLoud build on macos
pierrec Dec 10, 2025
dfe6c8d
Merge branch 'master' of https://github.com/KaijuEngine/kaiju into fe…
pato98115 Dec 11, 2025
0c0dc8a
Merge pull request #1 from pierrec/feat/mac-os-run
pato98115 Dec 11, 2025
0b10760
Merge branch 'master' of https://github.com/pato98115/kaiju into feat…
pato98115 Dec 11, 2025
a5d9961
fix: use cocoa file only for mac compilation, improve cocoa_poll_even…
pato98115 Dec 11, 2025
6d518fb
feat(mac-os): bullet3 physics, fixes in mouse scrolling and implement…
pato98115 Dec 13, 2025
3f68b98
Merge branch 'master' of https://github.com/KaijuEngine/kaiju into fe…
pato98115 Dec 13, 2025
b948bde
fix: handling toggle keys
pato98115 Dec 13, 2025
4715106
Merge branch 'master' of https://github.com/KaijuEngine/kaiju into fe…
pato98115 Dec 13, 2025
4e0d0b1
Merge branch 'master' of https://github.com/KaijuEngine/kaiju into fe…
pato98115 Dec 13, 2025
f205491
Merge branch 'master' of https://github.com/KaijuEngine/kaiju into fe…
pato98115 Dec 14, 2025
87a2bba
fix: modifying go-cocoa model to avoid crashing and to run the appkit…
pato98115 Dec 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/engine_developers/build_from_source.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,23 @@ Below are instructions on how to build the editor from source
## Prerequisites
To start, make sure you have the [Vulkan SDK](https://vulkan.lunarg.com/sdk/home) installed for your system.

## macOS Development
- Install Xcode Command Line Tools:
- Run `xcode-select --install` in Terminal
- Install the [Vulkan SDK](https://vulkan.lunarg.com/sdk/home#mac) for macOS
- After installation, add the Vulkan library path to your environment:
```sh
export DYLD_LIBRARY_PATH=$HOME/Library/VulkanSDK/1.4.XXX.X/macOS/lib # Replace with your version and your sdk path
```
- Pull the repository
- Go into src: `cd src`
- To build the editor in debug mode, run:
- `CGO_ENABLED=1 go build -tags="debug,editor" -o ../bin/kaiju`
- To build the editor, run:
- `CGO_ENABLED=1 go build -ldflags="-s -w" -tags="editor" -o ../bin/kaiju`

**Note:** On macOS, the engine uses Cocoa/AppKit for windowing and MoltenVK for Vulkan support. Keyboard shortcuts use the Cmd key (not Ctrl) for operations like copy/paste (Cmd+C/Cmd+V).

## Windows Development
- Download mingw into `C:/`
- I use [x86_64-15.2.0-release-win32-seh-msvcrt-rt_v13-rev0.7z](https://github.com/niXman/mingw-builds-binaries/releases)
Expand Down Expand Up @@ -56,6 +73,18 @@ cmake .. -G "Unix Makefiles" -DSOLOUD_BACKEND_SDL2=OFF -DSOLOUD_BACKEND_ALSA=ON
cmake --build . --config Release
```

### Soloud macOS
```sh
git clone https://github.com/jarikomppa/soloud.git
cd soloud/contrib
mkdir build
cd build
cmake .. -G "Unix Makefiles" -DSOLOUD_BACKEND_SDL2=OFF -DSOLOUD_BACKEND_COREAUDIO=ON -DSOLOUD_C_API=ON -DSOLOUD_STATIC=ON
cmake --build . --config Release
# Copy the library to kaiju
cp build/libsoloud.a /path/to/kaiju/src/libs/libsoloud_darwin.a
```

### Soloud Android (on Windows)
```sh
git clone https://github.com/jarikomppa/soloud.git
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ func Show(host *engine.Host, config Config) (*FileBrowser, error) {
} else {
startPath = "/home"
}
case "darwin":
if userHome, err := os.UserHomeDir(); err == nil && userHome != "" {
startPath = userHome
} else {
startPath = "/"
}
default:
slog.Error("unknown platform")
return nil, fmt.Errorf("unknown platform: %s", runtime.GOOS)
Expand Down
64 changes: 55 additions & 9 deletions src/platform/filesystem/directory_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,13 @@ package filesystem

import (
"kaiju/build"
"kaiju/klib"
"os"
"os/exec"
"path/filepath"
"strings"
"unsafe"
)

const macOSSupportIssueID = 485

func knownPaths() map[string]string {
out := map[string]string{
"Root": "/",
Expand Down Expand Up @@ -93,15 +91,63 @@ func openFileBrowserCommand(path string) *exec.Cmd {
}

func openFileDialogWindow(startPath string, extensions []DialogExtension, ok func(path string), cancel func(), windowHandle unsafe.Pointer) error {
// TODO: implement via NSOpenPanel (CGO / Cocoa). For now, don't hang UI.
klib.NotYetImplemented(macOSSupportIssueID)
cancel()
// Use osascript (AppleScript) to show native macOS file picker
script := `POSIX path of (choose file`

if startPath != "" {
script += ` default location "` + startPath + `"`
}

script += `)`

cmd := exec.Command("osascript", "-e", script)
output, err := cmd.Output()

if err != nil {
if cancel != nil {
cancel()
}
return nil
}

path := strings.TrimSpace(string(output))
if path != "" {
ok(path)
} else if cancel != nil {
cancel()
}
return nil
}

func openSaveFileDialogWindow(startPath string, fileName string, extensions []DialogExtension, ok func(path string), cancel func(), windowHandle unsafe.Pointer) error {
// TODO: implement via NSSavePanel (CGO / Cocoa). For now, don't hang UI.
klib.NotYetImplemented(macOSSupportIssueID)
cancel()
// Use osascript (AppleScript) to show native macOS save dialog
script := `POSIX path of (choose file name`

if fileName != "" {
script += ` default name "` + fileName + `"`
}

if startPath != "" {
script += ` default location "` + startPath + `"`
}

script += `)`

cmd := exec.Command("osascript", "-e", script)
output, err := cmd.Output()

if err != nil {
if cancel != nil {
cancel()
}
return nil
}

path := strings.TrimSpace(string(output))
if path != "" {
ok(path)
} else if cancel != nil {
cancel()
}
return nil
}
238 changes: 232 additions & 6 deletions src/platform/hid/keyboard.darwin.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build darwin && !ios

/******************************************************************************/
/* keyboard.win32.go */
/* keyboard.darwin.go */
/******************************************************************************/
/* This file is part of */
/* KAIJU ENGINE */
Expand Down Expand Up @@ -38,11 +38,237 @@

package hid

import "kaiju/klib"
// ToKeyboardKey converts macOS virtual key codes to engine KeyboardKey values.
// macOS key codes are defined in HIToolbox/Events.h (kVK_* constants).
func ToKeyboardKey(nativeKey int) KeyboardKey {
switch nativeKey {
// Letters (QWERTY layout)
case 0x00:
return KeyboardKeyA
case 0x0B:
return KeyboardKeyB
case 0x08:
return KeyboardKeyC
case 0x02:
return KeyboardKeyD
case 0x0E:
return KeyboardKeyE
case 0x03:
return KeyboardKeyF
case 0x05:
return KeyboardKeyG
case 0x04:
return KeyboardKeyH
case 0x22:
return KeyboardKeyI
case 0x26:
return KeyboardKeyJ
case 0x28:
return KeyboardKeyK
case 0x25:
return KeyboardKeyL
case 0x2E:
return KeyboardKeyM
case 0x2D:
return KeyboardKeyN
case 0x1F:
return KeyboardKeyO
case 0x23:
return KeyboardKeyP
case 0x0C:
return KeyboardKeyQ
case 0x0F:
return KeyboardKeyR
case 0x01:
return KeyboardKeyS
case 0x11:
return KeyboardKeyT
case 0x20:
return KeyboardKeyU
case 0x09:
return KeyboardKeyV
case 0x0D:
return KeyboardKeyW
case 0x07:
return KeyboardKeyX
case 0x10:
return KeyboardKeyY
case 0x06:
return KeyboardKeyZ

const macOSSupportIssueID = 485
// Numbers (top row)
case 0x1D:
return KeyboardKey0
case 0x12:
return KeyboardKey1
case 0x13:
return KeyboardKey2
case 0x14:
return KeyboardKey3
case 0x15:
return KeyboardKey4
case 0x17:
return KeyboardKey5
case 0x16:
return KeyboardKey6
case 0x1A:
return KeyboardKey7
case 0x1C:
return KeyboardKey8
case 0x19:
return KeyboardKey9

func ToKeyboardKey(nativeKey int) KeyboardKey {
klib.NotYetImplemented(macOSSupportIssueID)
return KeyBoardKeyInvalid
// Keypad
case 0x52:
return KeyboardNumKey0
case 0x53:
return KeyboardNumKey1
case 0x54:
return KeyboardNumKey2
case 0x55:
return KeyboardNumKey3
case 0x56:
return KeyboardNumKey4
case 0x57:
return KeyboardNumKey5
case 0x58:
return KeyboardNumKey6
case 0x59:
return KeyboardNumKey7
case 0x5B:
return KeyboardNumKey8
case 0x5C:
return KeyboardNumKey9
case 0x43:
return KeyboardNumKeyMultiply
case 0x45:
return KeyboardNumKeyAdd
case 0x4E:
return KeyboardNumKeySubtract
case 0x41:
return KeyboardNumKeyPeriod
case 0x4B:
return KeyboardNumKeyDivide

// Function keys
case 0x7A:
return KeyboardKeyF1
case 0x78:
return KeyboardKeyF2
case 0x63:
return KeyboardKeyF3
case 0x76:
return KeyboardKeyF4
case 0x60:
return KeyboardKeyF5
case 0x61:
return KeyboardKeyF6
case 0x62:
return KeyboardKeyF7
case 0x64:
return KeyboardKeyF8
case 0x65:
return KeyboardKeyF9
case 0x6D:
return KeyboardKeyF10
case 0x67:
return KeyboardKeyF11
case 0x6F:
return KeyboardKeyF12

// Arrow keys
case 0x7B:
return KeyboardKeyLeft
case 0x7C:
return KeyboardKeyRight
case 0x7D:
return KeyboardKeyDown
case 0x7E:
return KeyboardKeyUp

// Control keys
case 0x35:
return KeyboardKeyEscape
case 0x30:
return KeyboardKeyTab
case 0x31:
return KeyboardKeySpace
case 0x24:
return KeyboardKeyReturn
case 0x4C:
return KeyboardKeyEnter // Keypad enter
case 0x33:
return KeyboardKeyBackspace
case 0x75:
return KeyboardKeyDelete
case 0x73:
return KeyboardKeyHome
case 0x77:
return KeyboardKeyEnd
case 0x74:
return KeyboardKeyPageUp
case 0x79:
return KeyboardKeyPageDown

// Modifiers
case 0x38:
return KeyboardKeyLeftShift
case 0x3C:
return KeyboardKeyRightShift
case 0x3B:
return KeyboardKeyLeftCtrl
case 0x3E:
return KeyboardKeyRightCtrl
case 0x3A:
return KeyboardKeyLeftAlt
case 0x3D:
return KeyboardKeyRightAlt
// macOS Command keys map to Ctrl for shortcuts (Cmd+C, Cmd+V, etc.)
// This allows engine's Ctrl+C/V/X clipboard shortcuts to work with Cmd key
case 0x37:
return KeyboardKeyLeftCtrl // Left Command → Left Ctrl
case 0x36:
return KeyboardKeyRightCtrl // Right Command → Right Ctrl

// Special keys
case 0x39:
return KeyboardKeyCapsLock
case 0x47:
return KeyboardKeyNumLock
case 0x6B:
return KeyboardKeyScrollLock
case 0x71:
return KeyboardKeyPrintScreen
case 0x72:
return KeyboardKeyInsert
case 0x7F:
return KeyboardKeyPause

// Punctuation
case 0x32:
return KeyboardKeyBackQuote
case 0x2B:
return KeyboardKeyComma
case 0x2F:
return KeyboardKeyPeriod
case 0x2C:
return KeyboardKeyForwardSlash
case 0x2A:
return KeyboardKeyBackSlash
case 0x21:
return KeyboardKeyOpenBracket
case 0x1E:
return KeyboardKeyCloseBracket
case 0x29:
return KeyboardKeySemicolon
case 0x27:
return KeyboardKeyQuote
case 0x18:
return KeyboardKeyEqual
case 0x1B:
return KeyboardKeyMinus

default:
return KeyBoardKeyInvalid
}
}
Loading
Loading