Skip to content

Commit

Permalink
cmd/ebitenmobile: update gomobile version (reland)
Browse files Browse the repository at this point in the history
This switches from .framework to .xcframwork for iOS.

Closes hajimehoshi#1922
  • Loading branch information
hajimehoshi committed Jan 5, 2022
1 parent c67e438 commit 116203c
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,4 @@ jobs:
if: ${{ startsWith(matrix.os, 'macos-') && !startsWith(matrix.go, '1.15.') && !startsWith(matrix.go, '1.16.') }}
run: |
cd /tmp/go-inovation
ebitenmobile bind -target ios -o Inovation.framework -v github.com/hajimehoshi/go-inovation/mobile
ebitenmobile bind -target ios -o Inovation.xcframework -v github.com/hajimehoshi/go-inovation/mobile
2 changes: 1 addition & 1 deletion cmd/ebitenmobile/gomobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"runtime"
)

const gomobileHash = "5d9a33257ab559d10fa8c96087aed99bf8b6d868"
const gomobileHash = "4a8be17bd2e3f4793a871839e766cbea7e999464"

func runCommand(command string, args []string, env []string) error {
if buildX || buildN {
Expand Down
73 changes: 46 additions & 27 deletions cmd/ebitenmobile/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,42 +221,61 @@ func doBind(args []string, flagset *flag.FlagSet, buildOS string) error {
}

if buildOS == "darwin" {
dir := filepath.Join(buildO, "Versions", "A")

if err := ioutil.WriteFile(filepath.Join(dir, "Headers", prefixUpper+"EbitenViewController.h"), []byte(replacePrefixes(objcH)), 0644); err != nil {
// TODO: Use os.ReadDir after Ebiten stops supporting Go 1.15.
f, err := os.Open(buildO)
if err != nil {
return err
}
// TODO: Remove 'Ebitenmobileview.objc.h' here. Now it is hard since there is a header file importing
// that header file.
defer f.Close()

fs, err := ioutil.ReadDir(filepath.Join(dir, "Headers"))
names, err := f.Readdirnames(-1)
if err != nil {
return err
}
var headerFiles []string
for _, f := range fs {
if strings.HasSuffix(f.Name(), ".h") {
headerFiles = append(headerFiles, f.Name())

for _, name := range names {
if name == "Info.plist" {
continue
}
}
frameworkName := filepath.Base(buildO)
frameworkName = frameworkName[:len(frameworkName)-len(".xcframework")] + ".framework"
dir := filepath.Join(buildO, name, frameworkName, "Versions", "A")

w, err := os.OpenFile(filepath.Join(dir, "Modules", "module.modulemap"), os.O_WRONLY, 0644)
if err != nil {
return err
}
defer w.Close()
var mmVals = struct {
Module string
Headers []string
}{
Module: prefixUpper,
Headers: headerFiles,
}
if err := iosModuleMapTmpl.Execute(w, mmVals); err != nil {
return err
}
if err := ioutil.WriteFile(filepath.Join(dir, "Headers", prefixUpper+"EbitenViewController.h"), []byte(replacePrefixes(objcH)), 0644); err != nil {
return err
}
// TODO: Remove 'Ebitenmobileview.objc.h' here. Now it is hard since there is a header file importing
// that header file.

// TODO: Remove Ebitenmobileview.objc.h?
fs, err := ioutil.ReadDir(filepath.Join(dir, "Headers"))
if err != nil {
return err
}
var headerFiles []string
for _, f := range fs {
if strings.HasSuffix(f.Name(), ".h") {
headerFiles = append(headerFiles, f.Name())
}
}

w, err := os.OpenFile(filepath.Join(dir, "Modules", "module.modulemap"), os.O_WRONLY, 0644)
if err != nil {
return err
}
defer w.Close()
var mmVals = struct {
Module string
Headers []string
}{
Module: prefixUpper,
Headers: headerFiles,
}
if err := iosModuleMapTmpl.Execute(w, mmVals); err != nil {
return err
}

// TODO: Remove Ebitenmobileview.objc.h?
}
}

return nil
Expand Down
32 changes: 1 addition & 31 deletions internal/uidriver/mobile/gamepad_ios.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,22 +240,6 @@ package mobile
//
// property->nAxes = 6;
// property->nHats = 1;
// } else if (controller.gamepad) {
// property->buttonMask |= (1 << kControllerButtonA);
// property->buttonMask |= (1 << kControllerButtonB);
// property->buttonMask |= (1 << kControllerButtonX);
// property->buttonMask |= (1 << kControllerButtonY);
// property->buttonMask |= (1 << kControllerButtonLeftShoulder);
// property->buttonMask |= (1 << kControllerButtonRightShoulder);
// // This button's detection actually does not happen.
// property->buttonMask |= (1 << kControllerButtonStart);
// property->nButtons += 7;
//
// vendor = kUSBVendorApple;
// product = 2;
// subtype = 2;
// property->nAxes = 0;
// property->nHats = 1;
// }
//
// const int kSDLHardwareBusBluetooth = 0x05;
Expand Down Expand Up @@ -284,7 +268,7 @@ package mobile
//
// static void addController(GCController* controller) {
// // Ignore if the controller is not an actual controller.
// if (!controller.extendedGamepad && !controller.gamepad && controller.microGamepad) {
// if (!controller.extendedGamepad && controller.microGamepad) {
// return;
// }
//
Expand Down Expand Up @@ -399,20 +383,6 @@ package mobile
// if (property.nHats) {
// controllerState->hat = getHatState(gamepad.dpad);
// }
// } else if (controller.gamepad) {
// GCGamepad* gamepad = controller.gamepad;
//
// int buttonCount = 0;
// controllerState->buttons[buttonCount++] = gamepad.buttonA.isPressed;
// controllerState->buttons[buttonCount++] = gamepad.buttonB.isPressed;
// controllerState->buttons[buttonCount++] = gamepad.buttonX.isPressed;
// controllerState->buttons[buttonCount++] = gamepad.buttonY.isPressed;
// controllerState->buttons[buttonCount++] = gamepad.leftShoulder.isPressed;
// controllerState->buttons[buttonCount++] = gamepad.rightShoulder.isPressed;
//
// if (property.nHats) {
// controllerState->hat = getHatState(gamepad.dpad);
// }
// }
// }
// }
Expand Down

0 comments on commit 116203c

Please sign in to comment.