Added PSP Accept/Cance
This commit is contained in:
+2
-2
@@ -9,8 +9,8 @@ if PSP then
|
||||
inputBind("down", INPUT_ACTION_DOWN)
|
||||
inputBind("left", INPUT_ACTION_LEFT)
|
||||
inputBind("right", INPUT_ACTION_RIGHT)
|
||||
inputBind("circle", INPUT_ACTION_CANCEL)
|
||||
inputBind("cross", INPUT_ACTION_ACCEPT)
|
||||
inputBind("accept", INPUT_ACTION_ACCEPT)
|
||||
inputBind("cancel", INPUT_ACTION_CANCEL)
|
||||
inputBind("select", INPUT_ACTION_RAGEQUIT)
|
||||
inputBind("lstick_up", INPUT_ACTION_UP)
|
||||
inputBind("lstick_down", INPUT_ACTION_DOWN)
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "game/game.h"
|
||||
#include "physics/physicsmanager.h"
|
||||
#include "network/network.h"
|
||||
#include "system/system.h"
|
||||
|
||||
#include "display/mesh/cube.h"
|
||||
#include "display/mesh/plane.h"
|
||||
@@ -62,6 +63,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
|
||||
ENGINE.argv = argv;
|
||||
|
||||
// Init systems. Order is important.
|
||||
errorChain(systemInit());
|
||||
timeInit();
|
||||
errorChain(inputInit());
|
||||
errorChain(assetInit());
|
||||
|
||||
@@ -12,6 +12,14 @@
|
||||
#error "systemGetActiveDialogTypePlatform is not defined"
|
||||
#endif
|
||||
|
||||
#ifndef systemInitPlatform
|
||||
#error "systemInitPlatform is not defined"
|
||||
#endif
|
||||
|
||||
errorret_t systemInit() {
|
||||
return systemInitPlatform();
|
||||
}
|
||||
|
||||
systemdialogtype_t systemGetActiveDialogType() {
|
||||
return systemGetActiveDialogTypePlatform();
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
#include "error/error.h"
|
||||
|
||||
typedef enum {
|
||||
SYSTEM_DIALOG_TYPE_NONE,
|
||||
@@ -14,6 +14,14 @@ typedef enum {
|
||||
SYSTEM_DIALOG_TYPE_TICK_BLOCKING
|
||||
} systemdialogtype_t;
|
||||
|
||||
/**
|
||||
* Initializes the system module. This is called really early in the init
|
||||
* process of the engine.
|
||||
*
|
||||
* @return Error code indicating success or failure.
|
||||
*/
|
||||
errorret_t systemInit(void);
|
||||
|
||||
/**
|
||||
* Basically this is only used on a few system types, it is to ask the plaform,
|
||||
* e.g. PSP "What dialog is currently open?" and then the engine will change the
|
||||
|
||||
@@ -7,6 +7,10 @@
|
||||
|
||||
#include "systemlinux.h"
|
||||
|
||||
errorret_t systemInitLinux() {
|
||||
errorOk();
|
||||
}
|
||||
|
||||
systemdialogtype_t systemGetActiveDialogTypeLinux() {
|
||||
return SYSTEM_DIALOG_TYPE_NONE;
|
||||
}
|
||||
@@ -8,6 +8,11 @@
|
||||
#pragma once
|
||||
#include "system/system.h"
|
||||
|
||||
/**
|
||||
* Initializes the Linux system module.
|
||||
*/
|
||||
errorret_t systemInitLinux(void);
|
||||
|
||||
/**
|
||||
* Currently just returns SYSTEM_DIALOG_TYPE_NONE.
|
||||
*
|
||||
|
||||
@@ -8,4 +8,5 @@
|
||||
#pragma once
|
||||
#include "system/systemlinux.h"
|
||||
|
||||
#define systemInitPlatform systemInitLinux
|
||||
#define systemGetActiveDialogTypePlatform systemGetActiveDialogTypeLinux
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
#include "input/input.h"
|
||||
|
||||
// #define INPUT_PSP_GAMEPAD_BUTTON_ACCEPT INPUT_SDL2_GAMEPAD_BUTTON_CUSTOM
|
||||
// #define INPUT_PSP_GAMEPAD_BUTTON_CANCEL INPUT_SDL2_GAMEPAD_BUTTON_CUSTOM
|
||||
|
||||
inputbuttondata_t INPUT_BUTTON_DATA[] = {
|
||||
{ .name = "triangle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } },
|
||||
{ .name = "cross", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } },
|
||||
@@ -21,6 +24,10 @@ inputbuttondata_t INPUT_BUTTON_DATA[] = {
|
||||
{ .name = "l", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } },
|
||||
{ .name = "r", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } },
|
||||
|
||||
// Refer to systempsp.c for some extra info.
|
||||
{ .name = "accept", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } },
|
||||
{ .name = "cancel", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_B } },
|
||||
|
||||
{ .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 } } },
|
||||
|
||||
@@ -36,7 +36,7 @@ typedef struct {
|
||||
void (*onFailed)(errorret_t error, void *user);
|
||||
|
||||
// Used during disconnecting
|
||||
void *onCompelteUser;
|
||||
void *onCompleteUser;
|
||||
void (*onComplete)(void *user);
|
||||
} networkpsp_t;
|
||||
|
||||
|
||||
@@ -8,4 +8,5 @@
|
||||
#pragma once
|
||||
#include "system/systempsp.h"
|
||||
|
||||
#define systemInitPlatform systemInitPSP
|
||||
#define systemGetActiveDialogTypePlatform systemGetActiveDialogTypePSP
|
||||
@@ -6,10 +6,45 @@
|
||||
*/
|
||||
|
||||
#include "systempsp.h"
|
||||
#include "input/input.h"
|
||||
#include "util/string.h"
|
||||
#include "assert/assert.h"
|
||||
|
||||
errorret_t systemInitPSP() {
|
||||
// Bind ACCEPT and CANCEL binds.
|
||||
inputbuttondata_t *buttonCross, *buttonCircle, *buttonAccept, *buttonCancel;
|
||||
|
||||
inputbuttondata_t *i = INPUT_BUTTON_DATA;
|
||||
while(i->name) {
|
||||
if(stringCompare(i->name, "cross")) {
|
||||
buttonCross = i;
|
||||
} else if(stringCompare(i->name, "circle")) {
|
||||
buttonCircle = i;
|
||||
} else if(stringCompare(i->name, "accept")) {
|
||||
buttonAccept = i;
|
||||
} else if(stringCompare(i->name, "cancel")) {
|
||||
buttonCancel = i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
assertNotNull(buttonCross, "Cross button not found!");
|
||||
assertNotNull(buttonCircle, "Circle button not found!");
|
||||
assertNotNull(buttonAccept, "Accept button not found!");
|
||||
assertNotNull(buttonCancel, "Cancel button not found!");
|
||||
|
||||
if(systemPSPGetCrossButtonSetting() == PSP_UTILITY_ACCEPT_CROSS) {
|
||||
buttonAccept->button.gpButton = buttonCross->button.gpButton;
|
||||
buttonCancel->button.gpButton = buttonCircle->button.gpButton;
|
||||
} else {
|
||||
buttonAccept->button.gpButton = buttonCircle->button.gpButton;
|
||||
buttonCancel->button.gpButton = buttonCross->button.gpButton;
|
||||
}
|
||||
|
||||
errorOk();
|
||||
}
|
||||
|
||||
systemdialogtype_t systemGetActiveDialogTypePSP() {
|
||||
|
||||
|
||||
return SYSTEM_DIALOG_TYPE_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,13 @@
|
||||
#include "system/system.h"
|
||||
#include <psputility.h>
|
||||
|
||||
/**
|
||||
* Initializes the PSP system module.
|
||||
*
|
||||
* @return Error code indicating success or failure.
|
||||
*/
|
||||
errorret_t systemInitPSP(void);
|
||||
|
||||
/**
|
||||
* Returns which PSP system dialog is currently open (if any).
|
||||
*
|
||||
|
||||
@@ -73,6 +73,11 @@ float_t inputButtonGetValueSDL2(const inputbutton_t button) {
|
||||
|
||||
#ifdef DUSK_INPUT_GAMEPAD
|
||||
case INPUT_BUTTON_TYPE_GAMEPAD: {
|
||||
assertTrue(
|
||||
button.gpButton < SDL_CONTROLLER_BUTTON_MAX,
|
||||
"Gamepad button out of range"
|
||||
);
|
||||
|
||||
if(SDL_GameControllerGetButton(
|
||||
INPUT.platform.controller, button.gpButton
|
||||
)) {
|
||||
|
||||
Reference in New Issue
Block a user