Added PSP Accept/Cance
This commit is contained in:
+2
-2
@@ -9,8 +9,8 @@ if PSP then
|
|||||||
inputBind("down", INPUT_ACTION_DOWN)
|
inputBind("down", INPUT_ACTION_DOWN)
|
||||||
inputBind("left", INPUT_ACTION_LEFT)
|
inputBind("left", INPUT_ACTION_LEFT)
|
||||||
inputBind("right", INPUT_ACTION_RIGHT)
|
inputBind("right", INPUT_ACTION_RIGHT)
|
||||||
inputBind("circle", INPUT_ACTION_CANCEL)
|
inputBind("accept", INPUT_ACTION_ACCEPT)
|
||||||
inputBind("cross", INPUT_ACTION_ACCEPT)
|
inputBind("cancel", INPUT_ACTION_CANCEL)
|
||||||
inputBind("select", INPUT_ACTION_RAGEQUIT)
|
inputBind("select", INPUT_ACTION_RAGEQUIT)
|
||||||
inputBind("lstick_up", INPUT_ACTION_UP)
|
inputBind("lstick_up", INPUT_ACTION_UP)
|
||||||
inputBind("lstick_down", INPUT_ACTION_DOWN)
|
inputBind("lstick_down", INPUT_ACTION_DOWN)
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "game/game.h"
|
#include "game/game.h"
|
||||||
#include "physics/physicsmanager.h"
|
#include "physics/physicsmanager.h"
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
|
#include "system/system.h"
|
||||||
|
|
||||||
#include "display/mesh/cube.h"
|
#include "display/mesh/cube.h"
|
||||||
#include "display/mesh/plane.h"
|
#include "display/mesh/plane.h"
|
||||||
@@ -62,6 +63,7 @@ errorret_t engineInit(const int32_t argc, const char_t **argv) {
|
|||||||
ENGINE.argv = argv;
|
ENGINE.argv = argv;
|
||||||
|
|
||||||
// Init systems. Order is important.
|
// Init systems. Order is important.
|
||||||
|
errorChain(systemInit());
|
||||||
timeInit();
|
timeInit();
|
||||||
errorChain(inputInit());
|
errorChain(inputInit());
|
||||||
errorChain(assetInit());
|
errorChain(assetInit());
|
||||||
|
|||||||
@@ -12,6 +12,14 @@
|
|||||||
#error "systemGetActiveDialogTypePlatform is not defined"
|
#error "systemGetActiveDialogTypePlatform is not defined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef systemInitPlatform
|
||||||
|
#error "systemInitPlatform is not defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
errorret_t systemInit() {
|
||||||
|
return systemInitPlatform();
|
||||||
|
}
|
||||||
|
|
||||||
systemdialogtype_t systemGetActiveDialogType() {
|
systemdialogtype_t systemGetActiveDialogType() {
|
||||||
return systemGetActiveDialogTypePlatform();
|
return systemGetActiveDialogTypePlatform();
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "dusk.h"
|
#include "error/error.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
SYSTEM_DIALOG_TYPE_NONE,
|
SYSTEM_DIALOG_TYPE_NONE,
|
||||||
@@ -14,6 +14,14 @@ typedef enum {
|
|||||||
SYSTEM_DIALOG_TYPE_TICK_BLOCKING
|
SYSTEM_DIALOG_TYPE_TICK_BLOCKING
|
||||||
} systemdialogtype_t;
|
} 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,
|
* 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
|
* e.g. PSP "What dialog is currently open?" and then the engine will change the
|
||||||
|
|||||||
@@ -7,6 +7,10 @@
|
|||||||
|
|
||||||
#include "systemlinux.h"
|
#include "systemlinux.h"
|
||||||
|
|
||||||
|
errorret_t systemInitLinux() {
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
systemdialogtype_t systemGetActiveDialogTypeLinux() {
|
systemdialogtype_t systemGetActiveDialogTypeLinux() {
|
||||||
return SYSTEM_DIALOG_TYPE_NONE;
|
return SYSTEM_DIALOG_TYPE_NONE;
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "system/system.h"
|
#include "system/system.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the Linux system module.
|
||||||
|
*/
|
||||||
|
errorret_t systemInitLinux(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currently just returns SYSTEM_DIALOG_TYPE_NONE.
|
* Currently just returns SYSTEM_DIALOG_TYPE_NONE.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -8,4 +8,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "system/systemlinux.h"
|
#include "system/systemlinux.h"
|
||||||
|
|
||||||
|
#define systemInitPlatform systemInitLinux
|
||||||
#define systemGetActiveDialogTypePlatform systemGetActiveDialogTypeLinux
|
#define systemGetActiveDialogTypePlatform systemGetActiveDialogTypeLinux
|
||||||
@@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
#include "input/input.h"
|
#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[] = {
|
inputbuttondata_t INPUT_BUTTON_DATA[] = {
|
||||||
{ .name = "triangle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } },
|
{ .name = "triangle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } },
|
||||||
{ .name = "cross", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } },
|
{ .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 = "l", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } },
|
||||||
{ .name = "r", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } },
|
{ .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_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_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_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);
|
void (*onFailed)(errorret_t error, void *user);
|
||||||
|
|
||||||
// Used during disconnecting
|
// Used during disconnecting
|
||||||
void *onCompelteUser;
|
void *onCompleteUser;
|
||||||
void (*onComplete)(void *user);
|
void (*onComplete)(void *user);
|
||||||
} networkpsp_t;
|
} networkpsp_t;
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "system/systempsp.h"
|
#include "system/systempsp.h"
|
||||||
|
|
||||||
|
#define systemInitPlatform systemInitPSP
|
||||||
#define systemGetActiveDialogTypePlatform systemGetActiveDialogTypePSP
|
#define systemGetActiveDialogTypePlatform systemGetActiveDialogTypePSP
|
||||||
@@ -6,10 +6,45 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "systempsp.h"
|
#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() {
|
systemdialogtype_t systemGetActiveDialogTypePSP() {
|
||||||
|
|
||||||
|
|
||||||
return SYSTEM_DIALOG_TYPE_NONE;
|
return SYSTEM_DIALOG_TYPE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,13 @@
|
|||||||
#include "system/system.h"
|
#include "system/system.h"
|
||||||
#include <psputility.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).
|
* 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
|
#ifdef DUSK_INPUT_GAMEPAD
|
||||||
case INPUT_BUTTON_TYPE_GAMEPAD: {
|
case INPUT_BUTTON_TYPE_GAMEPAD: {
|
||||||
|
assertTrue(
|
||||||
|
button.gpButton < SDL_CONTROLLER_BUTTON_MAX,
|
||||||
|
"Gamepad button out of range"
|
||||||
|
);
|
||||||
|
|
||||||
if(SDL_GameControllerGetButton(
|
if(SDL_GameControllerGetButton(
|
||||||
INPUT.platform.controller, button.gpButton
|
INPUT.platform.controller, button.gpButton
|
||||||
)) {
|
)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user