all: add files for PlayStation 5

The implementation is WIP.

Updates #2799
This commit is contained in:
Hajime Hoshi 2023-10-01 23:14:47 +09:00
parent bdd68ca01a
commit 630789757f
29 changed files with 334 additions and 33 deletions

View File

@ -112,6 +112,11 @@ jobs:
run: |
go build -tags=nintendosdk -v ./...
- name: go build (PlayStation 5)
if: runner.os == 'Linux'
run: |
go build -tags=playstation5 -v ./...
- name: go mod vendor
run: |
mkdir /tmp/vendoring

3
doc.go
View File

@ -74,6 +74,7 @@
// "opengl": OpenGL, OpenGL ES, or WebGL.
// "directx": DirectX. This works only on Windows.
// "metal": Metal. This works only on macOS or iOS.
// "playstation5": PlayStation 5. This works only on PlayStation 5.
//
// `EBITENGINE_DIRECTX` environment variable specifies various parameters for DirectX.
// You can specify multiple values separated by a comma. The default value is empty (i.e. no parameters).
@ -115,4 +116,6 @@
// `nintendosdk` is for NintendoSDK (e.g. Nintendo Switch).
//
// `nintendosdkprofile` enables a profiler for NintendoSDK.
//
// `playstation5` is for PlayStation 5.
package ebiten

View File

@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build microsoftgdk || nintendosdk
//go:build microsoftgdk || nintendosdk || playstation5
// This file is for some special environments using 'microsoftgdk' or 'nintendosdk'.
// This file is for some special environments.
// You usually don't have to care about this file.
// Actually this example works without this file in usual cases.

View File

@ -878,7 +878,7 @@ func main() {
case filepath.Join("internal", "ui", "keys_mobile.go"):
buildTag = "//go:build android || ios"
case filepath.Join("internal", "ui", "keys_glfw.go"):
buildTag = "//go:build !android && !ios && !js && !nintendosdk"
buildTag = "//go:build !android && !ios && !js && !nintendosdk && !playstation5"
}
// NOTE: According to godoc, maps are automatically sorted by key.
if err := tmpl.Execute(f, struct {

View File

@ -34,6 +34,7 @@ const (
type GraphicsLibrary int
const (
// GraphicsLibraryAuto represents the automatic choose of graphics library by Ebitengine.
GraphicsLibraryAuto GraphicsLibrary = GraphicsLibrary(ui.GraphicsLibraryAuto)
// GraphicsLibraryUnknown represents the state at which graphics library cannot be determined,
@ -48,6 +49,9 @@ const (
// GraphicsLibraryMetal represents the graphics library Apple's Metal.
GraphicsLibraryMetal GraphicsLibrary = GraphicsLibrary(ui.GraphicsLibraryMetal)
// GraphicsLibraryMetal represents the graphics library PlayStation 5.
GraphicsLibraryPlayStation5 GraphicsLibrary = GraphicsLibrary(ui.GraphicsLibraryPlayStation5)
)
// String returns a string representing the graphics library.

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !nintendosdk
//go:build !android && !nintendosdk && !playstation5
package gamepad

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !nintendosdk
//go:build !android && !nintendosdk && !playstation5
package gamepad

View File

@ -0,0 +1,32 @@
// Copyright 2023 The Ebitengine Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build playstation5
package gamepad
type nativeGamepadsImpl struct {
}
func newNativeGamepadsImpl() nativeGamepads {
return &nativeGamepadsImpl{}
}
func (g *nativeGamepadsImpl) init(gamepads *gamepads) error {
return nil
}
func (g *nativeGamepadsImpl) update(gamepads *gamepads) error {
return nil
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build (freebsd || linux || netbsd || openbsd) && !nintendosdk
//go:build (freebsd || linux || netbsd || openbsd) && !nintendosdk && !playstation5
package gl

View File

@ -0,0 +1,29 @@
// Copyright 2023 The Ebitengine Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build playstation5
package gl
import (
"errors"
)
func (c *defaultContext) init() error {
return errors.New("gl: defaultContext is not implemented")
}
func (c *defaultContext) getProcAddress(name string) (uintptr, error) {
return 0, errors.New("gl: defaultContext is not implemented")
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !ios && !js && !nintendosdk
//go:build !android && !ios && !js && !nintendosdk && !playstation5
package opengl

View File

@ -26,6 +26,7 @@ type graphicsDriverCreator interface {
newOpenGL() (graphicsdriver.Graphics, error)
newDirectX() (graphicsdriver.Graphics, error)
newMetal() (graphicsdriver.Graphics, error)
newPlayStation5() (graphicsdriver.Graphics, error)
}
func newGraphicsDriver(creator graphicsDriverCreator, graphicsLibrary GraphicsLibrary) (graphicsdriver.Graphics, GraphicsLibrary, error) {
@ -47,6 +48,8 @@ func newGraphicsDriver(creator graphicsDriverCreator, graphicsLibrary GraphicsLi
graphicsLibrary = GraphicsLibraryDirectX
case "metal":
graphicsLibrary = GraphicsLibraryMetal
case "playstation5":
graphicsLibrary = GraphicsLibraryPlayStation5
default:
return nil, 0, fmt.Errorf("ui: an unsupported graphics library is specified by the environment variable: %s", env)
}
@ -80,6 +83,12 @@ func newGraphicsDriver(creator graphicsDriverCreator, graphicsLibrary GraphicsLi
return nil, 0, err
}
return g, GraphicsLibraryMetal, nil
case GraphicsLibraryPlayStation5:
g, err := creator.newPlayStation5()
if err != nil {
return nil, 0, err
}
return g, GraphicsLibraryPlayStation5, nil
default:
return nil, 0, fmt.Errorf("ui: an unsupported graphics library is specified: %d", graphicsLibrary)
}
@ -93,24 +102,27 @@ type GraphicsLibrary int
const (
GraphicsLibraryAuto GraphicsLibrary = iota
GraphicsLibraryUnknown
GraphicsLibraryOpenGL
GraphicsLibraryDirectX
GraphicsLibraryMetal
GraphicsLibraryUnknown
GraphicsLibraryPlayStation5
)
func (g GraphicsLibrary) String() string {
switch g {
case GraphicsLibraryAuto:
return "Auto"
case GraphicsLibraryUnknown:
return "Unknown"
case GraphicsLibraryOpenGL:
return "OpenGL"
case GraphicsLibraryDirectX:
return "DirectX"
case GraphicsLibraryMetal:
return "Metal"
case GraphicsLibraryUnknown:
return "Unknown"
case GraphicsLibraryPlayStation5:
return "PlayStation 5"
default:
return fmt.Sprintf("GraphicsLibrary(%d)", g)
}

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !ios && !js && !nintendosdk
//go:build !android && !ios && !js && !nintendosdk && !playstation5
package ui

View File

@ -0,0 +1,26 @@
// Copyright 2023 The Ebitengine Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build playstation5
package ui
func (u *UserInterface) updateInputState() error {
// TODO: Implement this
return nil
}
func (u *UserInterface) KeyName(key Key) string {
return ""
}

View File

@ -14,7 +14,7 @@
// Code generated by genkeys.go using 'go generate'. DO NOT EDIT.
//go:build !android && !ios && !js && !nintendosdk
//go:build !android && !ios && !js && !nintendosdk && !playstation5
package ui

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !ios && !js && !nintendosdk
//go:build !android && !ios && !js && !nintendosdk && !playstation5
package ui

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !ios && !js && !nintendosdk && !ebitenginesinglethread && !ebitensinglethread
//go:build !android && !ios && !js && !nintendosdk && !playstation5 && !ebitenginesinglethread && !ebitensinglethread
package ui

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !ios && !js && !nintendosdk && (ebitenginesinglethread || ebitensinglethread)
//go:build !android && !ios && !js && !nintendosdk && !playstation5 && (ebitenginesinglethread || ebitensinglethread)
package ui

View File

@ -116,6 +116,10 @@ func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: Metal is not supported in this environment")
}
func (*graphicsDriverCreatorImpl) newPlayStation5() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: PlayStation 5 is not supported in this environment")
}
func deviceScaleFactorImpl() float64 {
var s float64
if err := app.RunOnJVM(func(vm, env, ctx uintptr) error {

View File

@ -193,6 +193,10 @@ func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
return metal.NewGraphics()
}
func (*graphicsDriverCreatorImpl) newPlayStation5() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: PlayStation 5 is not supported in this environment")
}
// glfwMonitorSizeInGLFWPixels must be called from the main thread.
func glfwMonitorSizeInGLFWPixels(m *glfw.Monitor) (int, int, error) {
vm, err := m.GetVideoMode()

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !ios && !js && !nintendosdk
//go:build !android && !ios && !js && !nintendosdk && !playstation5
package ui

View File

@ -66,6 +66,10 @@ func (g *graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error)
return metal.NewGraphics()
}
func (*graphicsDriverCreatorImpl) newPlayStation5() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: PlayStation 5 is not supported in this environment")
}
func (u *UserInterface) SetUIView(uiview uintptr) error {
select {
case err := <-u.errCh:

View File

@ -50,6 +50,10 @@ func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: Metal is not supported in this environment")
}
func (*graphicsDriverCreatorImpl) newPlayStation5() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: PlayStation 5 is not supported in this environment")
}
var (
stringNone = js.ValueOf("none")
stringTransparent = js.ValueOf("transparent")

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build (freebsd || (linux && !android) || netbsd || openbsd) && !nintendosdk
//go:build (freebsd || (linux && !android) || netbsd || openbsd) && !nintendosdk && !playstation5
package ui
@ -55,6 +55,10 @@ func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: Metal is not supported in this environment")
}
func (*graphicsDriverCreatorImpl) newPlayStation5() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: PlayStation 5 is not supported in this environment")
}
// glfwMonitorSizeInGLFWPixels must be called from the main thread.
func glfwMonitorSizeInGLFWPixels(m *glfw.Monitor) (int, int, error) {
vm, err := m.GetVideoMode()

View File

@ -54,6 +54,10 @@ func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: Metal is not supported in this environment")
}
func (*graphicsDriverCreatorImpl) newPlayStation5() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: PlayStation 5 is not supported in this environment")
}
const deviceScaleFactor = 1
func init() {
@ -198,6 +202,16 @@ func (*UserInterface) Window() Window {
return &nullWindow{}
}
func (u *UserInterface) beginFrame() {
}
func (u *UserInterface) endFrame() {
}
func (u *UserInterface) updateIconIfNeeded() error {
return nil
}
type Monitor struct{}
var theMonitor = &Monitor{}
@ -219,16 +233,6 @@ func (u *UserInterface) Monitor() *Monitor {
return theMonitor
}
func (u *UserInterface) beginFrame() {
}
func (u *UserInterface) endFrame() {
}
func (u *UserInterface) updateIconIfNeeded() error {
return nil
}
func IsScreenTransparentAvailable() bool {
return false
}

View File

@ -0,0 +1,162 @@
// Copyright 2023 The Ebitengine Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build playstation5
package ui
import (
"errors"
"image"
"runtime"
"github.com/hajimehoshi/ebiten/v2/internal/graphicsdriver"
)
type graphicsDriverCreatorImpl struct{}
func (g *graphicsDriverCreatorImpl) newAuto() (graphicsdriver.Graphics, GraphicsLibrary, error) {
graphics, err := g.newPlayStation5()
return graphics, GraphicsLibraryPlayStation5, err
}
func (*graphicsDriverCreatorImpl) newOpenGL() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: OpenGL is not supported in this environment")
}
func (*graphicsDriverCreatorImpl) newDirectX() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: DirectX is not supported in this environment")
}
func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: Metal is not supported in this environment")
}
func (*graphicsDriverCreatorImpl) newPlayStation5() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: not implemented yet")
}
const deviceScaleFactor = 1
func init() {
runtime.LockOSThread()
}
type userInterfaceImpl struct {
graphicsDriver graphicsdriver.Graphics
context *context
}
func (u *UserInterface) init() error {
return nil
}
func (u *UserInterface) Run(game Game, options *RunOptions) error {
// TODO: Implement this.
return nil
}
func (*UserInterface) DeviceScaleFactor() float64 {
return deviceScaleFactor
}
func (*UserInterface) IsFocused() bool {
return true
}
func (*UserInterface) ScreenSizeInFullscreen() (int, int) {
return 0, 0
}
func (u *UserInterface) readInputState(inputState *InputState) {
// TODO: Implement this.
}
func (*UserInterface) CursorMode() CursorMode {
return CursorModeHidden
}
func (*UserInterface) SetCursorMode(mode CursorMode) {
}
func (*UserInterface) CursorShape() CursorShape {
return CursorShapeDefault
}
func (*UserInterface) SetCursorShape(shape CursorShape) {
}
func (*UserInterface) IsFullscreen() bool {
return false
}
func (*UserInterface) SetFullscreen(fullscreen bool) {
}
func (*UserInterface) IsRunnableOnUnfocused() bool {
return false
}
func (*UserInterface) SetRunnableOnUnfocused(runnableOnUnfocused bool) {
}
func (*UserInterface) FPSMode() FPSModeType {
return FPSModeVsyncOn
}
func (*UserInterface) SetFPSMode(mode FPSModeType) {
}
func (*UserInterface) ScheduleFrame() {
}
func (*UserInterface) Window() Window {
return &nullWindow{}
}
func (u *UserInterface) beginFrame() {
}
func (u *UserInterface) endFrame() {
}
func (u *UserInterface) updateIconIfNeeded() error {
return nil
}
type Monitor struct{}
var theMonitor = &Monitor{}
func (m *Monitor) Bounds() image.Rectangle {
// TODO: This should return the available viewport dimensions.
return image.Rectangle{}
}
func (m *Monitor) Name() string {
return ""
}
func (u *UserInterface) AppendMonitors(mons []*Monitor) []*Monitor {
return append(mons, theMonitor)
}
func (u *UserInterface) Monitor() *Monitor {
return theMonitor
}
func IsScreenTransparentAvailable() bool {
return false
}

View File

@ -89,6 +89,10 @@ func (*graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: Metal is not supported in this environment")
}
func (*graphicsDriverCreatorImpl) newPlayStation5() (graphicsdriver.Graphics, error) {
return nil, errors.New("ui: PlayStation 5 is not supported in this environment")
}
// glfwMonitorSizeInGLFWPixels must be called from the main thread.
func glfwMonitorSizeInGLFWPixels(m *glfw.Monitor) (int, int, error) {
vm, err := m.GetVideoMode()

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build !android && !ios && !js && !nintendosdk
//go:build !android && !ios && !js && !nintendosdk && !playstation5
package ui

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//go:build (!android && !ios && !js) || nintendosdk
//go:build (!android && !ios && !js) || nintendosdk || playstation5
package vibrate