Fix input on linux
This commit is contained in:
@@ -4,7 +4,7 @@ module('scene')
|
||||
module('locale')
|
||||
|
||||
-- Default Input bindings.
|
||||
if PLATFORM == "psp" then
|
||||
if PSP then
|
||||
inputBind("up", INPUT_ACTION_UP)
|
||||
inputBind("down", INPUT_ACTION_DOWN)
|
||||
inputBind("left", INPUT_ACTION_LEFT)
|
||||
@@ -50,6 +50,22 @@ else
|
||||
inputBind("escape", INPUT_ACTION_RAGEQUIT)
|
||||
end
|
||||
|
||||
if INPUT_GAMEPAD then
|
||||
inputBind("gamepad_up", INPUT_ACTION_UP)
|
||||
inputBind("gamepad_down", INPUT_ACTION_DOWN)
|
||||
inputBind("gamepad_left", INPUT_ACTION_LEFT)
|
||||
inputBind("gamepad_right", INPUT_ACTION_RIGHT)
|
||||
|
||||
inputBind("gamepad_a", INPUT_ACTION_ACCEPT)
|
||||
inputBind("gamepad_b", INPUT_ACTION_CANCEL)
|
||||
inputBind("gamepad_back", INPUT_ACTION_RAGEQUIT)
|
||||
|
||||
inputBind("gamepad_lstick_up", INPUT_ACTION_UP)
|
||||
inputBind("gamepad_lstick_down", INPUT_ACTION_DOWN)
|
||||
inputBind("gamepad_lstick_left", INPUT_ACTION_LEFT)
|
||||
inputBind("gamepad_lstick_right", INPUT_ACTION_RIGHT)
|
||||
end
|
||||
|
||||
if INPUT_POINTER then
|
||||
inputBind("mouse_x", INPUT_ACTION_POINTERX)
|
||||
inputBind("mouse_y", INPUT_ACTION_POINTERY)
|
||||
|
||||
@@ -171,12 +171,31 @@ function borderDraw(x, y, innerWidth, innerHeight)
|
||||
)
|
||||
end
|
||||
|
||||
x = 0
|
||||
y = 0
|
||||
|
||||
function sceneDispose()
|
||||
end
|
||||
|
||||
function sceneUpdate()
|
||||
if inputIsDown(INPUT_ACTION_RIGHT) then
|
||||
x = x + 1
|
||||
end
|
||||
|
||||
if inputIsDown(INPUT_ACTION_LEFT) then
|
||||
x = x - 1
|
||||
end
|
||||
|
||||
if inputIsDown(INPUT_ACTION_DOWN) then
|
||||
y = y + 1
|
||||
end
|
||||
|
||||
if inputIsDown(INPUT_ACTION_UP) then
|
||||
y = y - 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function sceneRender()
|
||||
-- Update camera
|
||||
cameraPushMatrix(camera)
|
||||
@@ -185,7 +204,7 @@ function sceneRender()
|
||||
|
||||
spriteBatchPush(
|
||||
nil,
|
||||
0, 0, 32, 32,
|
||||
x, y, x + 32, y + 32,
|
||||
colorBlue()
|
||||
)
|
||||
|
||||
|
||||
@@ -8,18 +8,20 @@
|
||||
#pragma once
|
||||
#include "script/scriptcontext.h"
|
||||
#include "assert/assert.h"
|
||||
#include "script/module/moduleplatformplatform.h"
|
||||
|
||||
#ifndef DUSK_TARGET_SYSTEM
|
||||
#error "DUSK_TARGET_SYSTEM must be defined"
|
||||
#endif
|
||||
|
||||
#define PLATFORM_VALUE "PLATFORM = '" DUSK_TARGET_SYSTEM "'\n"
|
||||
#define MODULE_PLATFORM_VALUE "PLATFORM = '" DUSK_TARGET_SYSTEM "'\n"
|
||||
|
||||
void modulePlatform(scriptcontext_t *ctx) {
|
||||
assertNotNull(ctx, "Script context cannot be NULL");
|
||||
|
||||
scriptContextExec(ctx, PLATFORM_VALUE);
|
||||
#if DOLPHIN
|
||||
scriptContextExec(ctx, "DOLPHIN = true\n");
|
||||
scriptContextExec(ctx, MODULE_PLATFORM_VALUE);
|
||||
|
||||
#ifdef modulePlatformPlatform
|
||||
modulePlatformPlatform(ctx);
|
||||
#endif
|
||||
}
|
||||
13
src/duskdolphin/script/module/moduleplatformdolphin.h
Normal file
13
src/duskdolphin/script/module/moduleplatformdolphin.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "script/scriptcontext.h"
|
||||
|
||||
void modulePlatformDolphin(scriptcontext_t *ctx) {
|
||||
scriptContextExec(ctx, "DOLPHIN = true\n");
|
||||
}
|
||||
11
src/duskdolphin/script/module/moduleplatformplatform.h
Normal file
11
src/duskdolphin/script/module/moduleplatformplatform.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "moduleplatformdolphin.h"
|
||||
|
||||
#define modulePlatformPlatform modulePlatformDolphin
|
||||
@@ -9,30 +9,30 @@
|
||||
|
||||
inputbuttondata_t INPUT_BUTTON_DATA[] = {
|
||||
#ifdef DUSK_INPUT_GAMEPAD
|
||||
{ .name = "a", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } },
|
||||
{ .name = "b", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_B } },
|
||||
{ .name = "x", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_X } },
|
||||
{ .name = "y", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } },
|
||||
{ .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_START } },
|
||||
{ .name = "back", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_BACK } },
|
||||
{ .name = "up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_UP } },
|
||||
{ .name = "down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_DOWN } },
|
||||
{ .name = "left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_LEFT } },
|
||||
{ .name = "right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_RIGHT } },
|
||||
{ .name = "l1", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } },
|
||||
{ .name = "r1", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } },
|
||||
{ .name = "l3", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSTICK } },
|
||||
{ .name = "r3", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSTICK } },
|
||||
{ .name = "lstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = true } } },
|
||||
{ .name = "lstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = false } } },
|
||||
{ .name = "lstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = true } } },
|
||||
{ .name = "lstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = false } } },
|
||||
{ .name = "rstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTY, .positive = true } } },
|
||||
{ .name = "rstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTY, .positive = false } } },
|
||||
{ .name = "rstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTX, .positive = true } } },
|
||||
{ .name = "rstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTX, .positive = false } } },
|
||||
{ .name = "l2", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_TRIGGERLEFT, .positive = true } } },
|
||||
{ .name = "r2", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_TRIGGERRIGHT, .positive = true } } },
|
||||
{ .name = "gamepad_a", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } },
|
||||
{ .name = "gamepad_b", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_B } },
|
||||
{ .name = "gamepad_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_X } },
|
||||
{ .name = "gamepad_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } },
|
||||
{ .name = "gamepad_start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_START } },
|
||||
{ .name = "gamepad_back", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_BACK } },
|
||||
{ .name = "gamepad_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_UP } },
|
||||
{ .name = "gamepad_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_DOWN } },
|
||||
{ .name = "gamepad_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_LEFT } },
|
||||
{ .name = "gamepad_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_RIGHT } },
|
||||
{ .name = "gamepad_l1", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } },
|
||||
{ .name = "gamepad_r1", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } },
|
||||
{ .name = "gamepad_l3", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSTICK } },
|
||||
{ .name = "gamepad_r3", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSTICK } },
|
||||
{ .name = "gamepad_lstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = true } } },
|
||||
{ .name = "gamepad_lstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = false } } },
|
||||
{ .name = "gamepad_lstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = true } } },
|
||||
{ .name = "gamepad_lstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = false } } },
|
||||
{ .name = "gamepad_rstick_down", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTY, .positive = true } } },
|
||||
{ .name = "gamepad_rstick_up", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTY, .positive = false } } },
|
||||
{ .name = "gamepad_rstick_right", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTX, .positive = true } } },
|
||||
{ .name = "gamepad_rstick_left", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_RIGHTX, .positive = false } } },
|
||||
{ .name = "gamepad_l2", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_TRIGGERLEFT, .positive = true } } },
|
||||
{ .name = "gamepad_r2", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_TRIGGERRIGHT, .positive = true } } },
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
13
src/dusklinux/script/module/moduleplatformlinux.h
Normal file
13
src/dusklinux/script/module/moduleplatformlinux.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "script/scriptcontext.h"
|
||||
|
||||
void modulePlatformLinux(scriptcontext_t *ctx) {
|
||||
scriptContextExec(ctx, "LINUX = true\n");
|
||||
}
|
||||
11
src/dusklinux/script/module/moduleplatformplatform.h
Normal file
11
src/dusklinux/script/module/moduleplatformplatform.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "moduleplatformlinux.h"
|
||||
|
||||
#define modulePlatformPlatform modulePlatformLinux
|
||||
11
src/duskpsp/script/module/moduleplatformplatform.h
Normal file
11
src/duskpsp/script/module/moduleplatformplatform.h
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "moduleplatformpsp.h"
|
||||
|
||||
#define modulePlatformPlatform modulePlatformPSP
|
||||
13
src/duskpsp/script/module/moduleplatformpsp.h
Normal file
13
src/duskpsp/script/module/moduleplatformpsp.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) 2026 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "script/scriptcontext.h"
|
||||
|
||||
void modulePlatformPSP(scriptcontext_t *ctx) {
|
||||
scriptContextExec(ctx, "PSP = true\n");
|
||||
}
|
||||
Reference in New Issue
Block a user