Wii/Gamecube now show dialogs

This commit is contained in:
UnknownShadow200 2025-11-08 18:39:20 +11:00
parent 45ec826517
commit b40eb663a7
41 changed files with 145 additions and 92 deletions

View File

@ -110,6 +110,8 @@ static const BindMapping pad_defaults[BIND_COUNT] = {
[BIND_HOTBAR_RIGHT] = { CCPAD_4, CCPAD_RIGHT } [BIND_HOTBAR_RIGHT] = { CCPAD_4, CCPAD_RIGHT }
}; };
void Gamepads_PreInit(void) { }
void Gamepads_Init(void) { void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD; Input.Sources |= INPUT_SOURCE_GAMEPAD;
} }

View File

@ -153,10 +153,12 @@ static const BindMapping defaults_3ds[BIND_COUNT] = {
}; };
static Result irrst_result; static Result irrst_result;
void Gamepads_PreInit(void) {
irrst_result = irrstInit();
}
void Gamepads_Init(void) { void Gamepads_Init(void) {
Input.Sources = INPUT_SOURCE_GAMEPAD; Input.Sources = INPUT_SOURCE_GAMEPAD;
irrst_result = irrstInit();
} }
static void HandleButtons(int port, u32 mods) { static void HandleButtons(int port, u32 mods) {

View File

@ -116,9 +116,9 @@ void Window_ProcessEvents(float delta) {
dispatcher.ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent); dispatcher.ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) { }
} void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -11,12 +11,12 @@ static cc_bool dlg_close;
static cc_bool VirtualDialog_InputHook(int key, struct InputDevice* device) { return true; } static cc_bool VirtualDialog_InputHook(int key, struct InputDevice* device) { return true; }
static void VirtualDialog_OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* device) { static void VirtualDialog_OnInputDown(void* obj, int key, cc_bool was, struct InputDevice* device) {
Platform_LogConst("AAAA");
dlg_close = true; dlg_close = true;
} }
struct LogPosition { struct Bitmap* bmp; int x, y; }; struct LogPosition { struct Bitmap* bmp; int x, y; };
#define BEG_X 10 #define VD_BEG_X 10
#define VD_LINE_SPACE 20
static void PlotOnscreen(int x, int y, void* ctx) { static void PlotOnscreen(int x, int y, void* ctx) {
struct LogPosition* pos = ctx; struct LogPosition* pos = ctx;
@ -31,30 +31,33 @@ static void PlotOnscreen(int x, int y, void* ctx) {
static int DrawText(const char* msg, struct Bitmap* bmp, int y) { static int DrawText(const char* msg, struct Bitmap* bmp, int y) {
struct LogPosition pos; struct LogPosition pos;
pos.bmp = bmp; pos.bmp = bmp;
pos.x = BEG_X; pos.x = VD_BEG_X;
pos.y = y; pos.y = y;
while (*msg) while (*msg)
{ {
if (pos.x + 20 >= bmp->width) { char c = *msg;
pos.x = BEG_X; if (pos.x + 20 >= bmp->width || c == '\n') {
pos.y += 20; pos.x = VD_BEG_X;
pos.y += VD_LINE_SPACE;
} }
pos.x += FallbackFont_Plot((cc_uint8)*msg, PlotOnscreen, 1, &pos); if (c != '\n') { pos.x += FallbackFont_Plot((cc_uint8)c, PlotOnscreen, 1, &pos); }
msg++; msg++;
} }
return pos.y; return pos.y;
} }
#define DLG_TICK_INTERVAL 50 #define VD_TICK_INTERVAL 50
#define VD_MAX_ITERS (5000 / VD_TICK_INTERVAL)
static void VirtualDialog_Show(const char* title, const char* msg) { static void VirtualDialog_Show(const char* title, const char* msg) {
struct Bitmap bmp; struct Bitmap bmp;
Platform_LogConst(title); Platform_LogConst(title);
Platform_LogConst(msg); Platform_LogConst(msg);
if (!LBackend_FB.bmp.scan0) { if (!LBackend_FB.bmp.scan0) {
Window_AllocFramebuffer(&bmp, Window_Main.Width, Window_Main.Height); Window_AllocFramebuffer(&bmp, DisplayInfo.Width, DisplayInfo.Height);
} else { } else {
bmp = LBackend_FB.bmp; bmp = LBackend_FB.bmp;
} }
@ -64,9 +67,9 @@ static void VirtualDialog_Show(const char* title, const char* msg) {
Context2D_Clear(&ctx, BitmapCol_Make(50, 50, 50, 255), Context2D_Clear(&ctx, BitmapCol_Make(50, 50, 50, 255),
0, 0, bmp.width, bmp.height); 0, 0, bmp.width, bmp.height);
const char* ipt_msg = "Press any button to continue"; const char* ipt_msg = "Press any button to continue (or wait 5 seconds)";
dlg_close = false; dlg_close = false;
int y = 30; int y = max(30, bmp.height / 2 - 50);
y = DrawText(title, &bmp, y); y = DrawText(title, &bmp, y);
y = DrawText(msg, &bmp, y + 20); y = DrawText(msg, &bmp, y + 20);
@ -77,14 +80,18 @@ static void VirtualDialog_Show(const char* title, const char* msg) {
Event_Register_(&InputEvents.Down2, NULL, VirtualDialog_OnInputDown); Event_Register_(&InputEvents.Down2, NULL, VirtualDialog_OnInputDown);
Rect2D rect = { 0, 0, bmp.width, bmp.height }; Rect2D rect = { 0, 0, bmp.width, bmp.height };
cc_bool has_window = Window_Main.Exists;
while (Window_Main.Exists && !dlg_close) for (int i = 0; !dlg_close && i < VD_MAX_ITERS; i++)
{ {
Window_ProcessEvents(1.0f / DLG_TICK_INTERVAL); Window_ProcessEvents(1.0f / VD_TICK_INTERVAL);
Gamepads_Process( 1.0f / DLG_TICK_INTERVAL); Gamepads_Process( 1.0f / VD_TICK_INTERVAL);
Window_DrawFramebuffer(rect, &bmp); Window_DrawFramebuffer(rect, &bmp);
Thread_Sleep(DLG_TICK_INTERVAL); Thread_Sleep(VD_TICK_INTERVAL);
// Window_ProcessEvents processed an app exit event
if (has_window && !Window_Main.Exists) break;
} }
Context2D_Clear(&ctx, BitmapCol_Make(40, 40, 40, 255), Context2D_Clear(&ctx, BitmapCol_Make(40, 40, 40, 255),

View File

@ -139,6 +139,8 @@ void Window_RequestClose(void);
/* Processes all pending window messages/events. */ /* Processes all pending window messages/events. */
void Window_ProcessEvents(float delta); void Window_ProcessEvents(float delta);
/* Initialises necessary state before initing platform and loading options */
void Gamepads_PreInit(void);
/* Initialises state for gamepad/joystick input. */ /* Initialises state for gamepad/joystick input. */
void Gamepads_Init(void); void Gamepads_Init(void);
/* Processes all pending gamepad/joystick input. */ /* Processes all pending gamepad/joystick input. */

View File

@ -549,9 +549,9 @@ void Window_ProcessEvents(float delta) {
} }
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) { }
} void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -386,9 +386,9 @@ void Window_ProcessEvents(float delta) {
} }
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) { }
} void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -120,9 +120,12 @@ static const BindMapping defaults_n64[BIND_COUNT] = {
[BIND_SET_SPAWN] = { CCPAD_START }, [BIND_SET_SPAWN] = { CCPAD_START },
}; };
void Gamepads_PreInit(void) {
joypad_init();
}
void Gamepads_Init(void) { void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD; Input.Sources |= INPUT_SOURCE_GAMEPAD;
joypad_init();
} }
static void HandleButtons(int port, joypad_buttons_t btns) { static void HandleButtons(int port, joypad_buttons_t btns) {

View File

@ -604,6 +604,8 @@ void Window_DisableRawMouse(void) {
DefaultDisableRawMouse(); DefaultDisableRawMouse();
} }
void Gamepads_PreInit(void) { }
void Gamepads_Init(void) { } void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -473,7 +473,9 @@ void Window_DisableRawMouse(void) {
#include "ExtMath.h" #include "ExtMath.h"
static SDL_GameController* controllers[INPUT_MAX_GAMEPADS]; static SDL_GameController* controllers[INPUT_MAX_GAMEPADS];
static void LoadControllers(void) { void Gamepads_PreInit(void) { }
void Gamepads_Init(void) {
for (int i = 0, port = 0; i < SDL_NumJoysticks() && port < INPUT_MAX_GAMEPADS; i++) for (int i = 0, port = 0; i < SDL_NumJoysticks() && port < INPUT_MAX_GAMEPADS; i++)
{ {
if (!SDL_IsGameController(i)) continue; if (!SDL_IsGameController(i)) continue;
@ -484,10 +486,6 @@ static void LoadControllers(void) {
} }
} }
void Gamepads_Init(void) {
LoadControllers();
}
static void ProcessGamepadButtons(int port, SDL_GameController* gp) { static void ProcessGamepadButtons(int port, SDL_GameController* gp) {
Gamepad_SetButton(port, CCPAD_1, SDL_GameControllerGetButton(gp, SDL_CONTROLLER_BUTTON_A)); Gamepad_SetButton(port, CCPAD_1, SDL_GameControllerGetButton(gp, SDL_CONTROLLER_BUTTON_A));
Gamepad_SetButton(port, CCPAD_2, SDL_GameControllerGetButton(gp, SDL_CONTROLLER_BUTTON_B)); Gamepad_SetButton(port, CCPAD_2, SDL_GameControllerGetButton(gp, SDL_CONTROLLER_BUTTON_B));

View File

@ -502,7 +502,9 @@ void Window_DisableRawMouse(void) {
#include "ExtMath.h" #include "ExtMath.h"
static SDL_Gamepad* controllers[INPUT_MAX_GAMEPADS]; static SDL_Gamepad* controllers[INPUT_MAX_GAMEPADS];
static void LoadControllers(void) { void Gamepads_PreInit(void) { }
void Gamepads_Init(void) {
int count = 0; int count = 0;
SDL_JoystickID* joysticks = SDL_GetGamepads(&count); SDL_JoystickID* joysticks = SDL_GetGamepads(&count);
@ -514,10 +516,6 @@ static void LoadControllers(void) {
SDL_free(joysticks); SDL_free(joysticks);
} }
void Gamepads_Init(void) {
LoadControllers();
}
static void ProcessGamepadButtons(int port, SDL_Gamepad* gp) { static void ProcessGamepadButtons(int port, SDL_Gamepad* gp) {
Gamepad_SetButton(port, CCPAD_1, SDL_GetGamepadButton(gp, SDL_GAMEPAD_BUTTON_SOUTH)); Gamepad_SetButton(port, CCPAD_1, SDL_GetGamepadButton(gp, SDL_GAMEPAD_BUTTON_SOUTH));
Gamepad_SetButton(port, CCPAD_2, SDL_GetGamepadButton(gp, SDL_GAMEPAD_BUTTON_EAST)); Gamepad_SetButton(port, CCPAD_2, SDL_GetGamepadButton(gp, SDL_GAMEPAD_BUTTON_EAST));

View File

@ -490,9 +490,9 @@ void Window_ProcessEvents(float delta) {
ProcessConsoleEvents(delta); ProcessConsoleEvents(delta);
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) { }
} void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -602,9 +602,9 @@ void Window_ProcessEvents(float delta) {
} }
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) { }
} void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -550,9 +550,9 @@ void Window_ProcessEvents(float delta) {
} }
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) { }
} void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -851,9 +851,9 @@ void Window_ProcessEvents(float delta) {
} }
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) { }
} void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -606,9 +606,9 @@ void Window_ProcessEvents(float delta) {
} }
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) { }
} void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -333,9 +333,9 @@ void Window_ProcessEvents(float delta) {
} while (res == kCFRunLoopRunHandledSource); } while (res == kCFRunLoopRunHandledSource);
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) { }
} void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -83,9 +83,10 @@ void Window_RequestClose(void) {
void Window_ProcessEvents(float delta) { void Window_ProcessEvents(float delta) {
} }
void Gamepads_Init(void) {
} void Gamepads_PreInit(void) { }
void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -361,9 +361,9 @@ void Window_ProcessEvents(float delta) {
Java_ICall_Void(env, JAVA_processEvents, NULL); Java_ICall_Void(env, JAVA_processEvents, NULL);
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) { }
} void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -94,7 +94,9 @@ void Window_UpdateRawMouse(void) { }
/*########################################################################################################################* /*########################################################################################################################*
*-------------------------------------------------------Gamepads----------------------------------------------------------* *-------------------------------------------------------Gamepads----------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Gamepads_PreInit(void) { }
void Gamepads_Init(void) { } void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -245,6 +245,8 @@ static const BindMapping defaults_dc[BIND_COUNT] = {
[BIND_SCREENSHOT] = { CCPAD_3 }, [BIND_SCREENSHOT] = { CCPAD_3 },
}; };
void Gamepads_PreInit(void) { }
void Gamepads_Init(void) { void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD; Input.Sources |= INPUT_SOURCE_GAMEPAD;
} }

View File

@ -102,6 +102,8 @@ static const BindMapping pad_defaults[BIND_COUNT] = {
[BIND_HOTBAR_RIGHT] = { CCPAD_L, CCPAD_RIGHT } [BIND_HOTBAR_RIGHT] = { CCPAD_L, CCPAD_RIGHT }
}; };
void Gamepads_PreInit(void) { }
void Gamepads_Init(void) { void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD; Input.Sources |= INPUT_SOURCE_GAMEPAD;
} }

View File

@ -101,7 +101,7 @@ static void InitSockets(void) {
if (ret >= 0) { if (ret >= 0) {
Platform_Log3("Network ip: %c, gw: %c, mask %c", localip, gateway, netmask); Platform_Log3("Network ip: %c, gw: %c, mask %c", localip, gateway, netmask);
} else { } else {
Platform_Log1("Network setup failed: %i", &ret); Logger_SimpleWarn(ret, "setting up network");
net_supported = false; net_supported = false;
} }
} }

View File

@ -97,7 +97,7 @@ cc_result Socket_GetLastError(cc_socket s) {
static void InitSockets(void) { static void InitSockets(void) {
int ret = net_init(); int ret = net_init();
Platform_Log1("Network setup result: %i", &ret); if (ret) Logger_SimpleWarn(ret, "setting up network");
} }

View File

@ -11,6 +11,7 @@
#include "../Graphics.h" #include "../Graphics.h"
#include "../Options.h" #include "../Options.h"
#include "../VirtualKeyboard.h" #include "../VirtualKeyboard.h"
#include "../VirtualDialog.h"
#include <gccore.h> #include <gccore.h>
#if defined HW_RVL #if defined HW_RVL
@ -62,16 +63,16 @@ void Window_PreInit(void) {
SYS_SetPowerCallback(OnPowerOff); SYS_SetPowerCallback(OnPowerOff);
#endif #endif
InitVideo(); InitVideo();
}
void Window_Init(void) {
DisplayInfo.Width = cur_mode->fbWidth; DisplayInfo.Width = cur_mode->fbWidth;
DisplayInfo.Height = cur_mode->xfbHeight; DisplayInfo.Height = cur_mode->xfbHeight;
DisplayInfo.ScaleX = 1; DisplayInfo.ScaleX = 1;
DisplayInfo.ScaleY = 1; DisplayInfo.ScaleY = 1;
}
Window_Main.Width = cur_mode->fbWidth;
Window_Main.Height = cur_mode->xfbHeight; void Window_Init(void) {
Window_Main.Width = DisplayInfo.Width;
Window_Main.Height = DisplayInfo.Height;
Window_Main.Focused = true; Window_Main.Focused = true;
Window_Main.Exists = true; Window_Main.Exists = true;
@ -91,7 +92,6 @@ void Window_Init(void) {
void Window_Free(void) { } void Window_Free(void) { }
void Window_Create2D(int width, int height) { void Window_Create2D(int width, int height) {
needsFBUpdate = true;
Window_Main.Is3D = false; Window_Main.Is3D = false;
} }
@ -358,9 +358,7 @@ void Window_DisableRawMouse(void) { Input.RawMode = false; }
/*########################################################################################################################* /*########################################################################################################################*
*-------------------------------------------------------Gamepads----------------------------------------------------------* *-------------------------------------------------------Gamepads----------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Gamepads_Init(void) { void Gamepads_PreInit(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
#if defined HW_RVL #if defined HW_RVL
WPAD_Init(); WPAD_Init();
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
@ -369,6 +367,10 @@ void Gamepads_Init(void) {
PAD_Init(); PAD_Init();
} }
void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
}
#if defined HW_RVL #if defined HW_RVL
static const BindMapping default_nunchuck[BIND_COUNT] = { static const BindMapping default_nunchuck[BIND_COUNT] = {
[BIND_FORWARD] = { CCPAD_CUP, 0 }, [BIND_FORWARD] = { CCPAD_CUP, 0 },
@ -522,6 +524,8 @@ void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) {
bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels"); bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "window pixels");
bmp->width = width; bmp->width = width;
bmp->height = height; bmp->height = height;
needsFBUpdate = true;
} }
// TODO: Get rid of this complexity and use the 3D API instead.. // TODO: Get rid of this complexity and use the 3D API instead..
@ -608,11 +612,8 @@ int Window_IsObscured(void) { return 0; }
void Window_Show(void) { } void Window_Show(void) { }
void Window_SetSize(int width, int height) { } void Window_SetSize(int width, int height) { }
void Window_ShowDialog(const char* title, const char* msg) { void Window_ShowDialog(const char* title, const char* msg) {
/* TODO implement */ VirtualDialog_Show(title, msg);
Platform_LogConst(title);
Platform_LogConst(msg);
} }
cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) { cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {

View File

@ -126,6 +126,7 @@ static void SetupProgram(int argc, char** argv) {
CrashHandler_Install(); CrashHandler_Install();
Logger_Hook(); Logger_Hook();
Window_PreInit(); Window_PreInit();
Gamepads_PreInit();
Platform_Init(); Platform_Init();
res = Platform_SetDefaultCurrentDirectory(argc, argv); res = Platform_SetDefaultCurrentDirectory(argc, argv);

View File

@ -255,9 +255,9 @@ void Window_ProcessEvents(float delta) {
Keyboard_UpdateState(delta); Keyboard_UpdateState(delta);
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) { }
} void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -170,14 +170,14 @@ void Window_PreInit(void) {
Window_Main.Is3D = 210; // So SetupVideo still runs Window_Main.Is3D = 210; // So SetupVideo still runs
SetupVideo(false); SetupVideo(false);
setBrightness(2, 0); setBrightness(2, 0);
}
void Window_Init(void) {
DisplayInfo.Width = SCREEN_WIDTH; DisplayInfo.Width = SCREEN_WIDTH;
DisplayInfo.Height = SCREEN_HEIGHT; DisplayInfo.Height = SCREEN_HEIGHT;
DisplayInfo.ScaleX = 0.5f; DisplayInfo.ScaleX = 0.5f;
DisplayInfo.ScaleY = 0.5f; DisplayInfo.ScaleY = 0.5f;
}
void Window_Init(void) {
Window_Main.Width = DisplayInfo.Width; Window_Main.Width = DisplayInfo.Width;
Window_Main.Height = DisplayInfo.Height; Window_Main.Height = DisplayInfo.Height;
Window_Main.Focused = true; Window_Main.Focused = true;
@ -274,6 +274,8 @@ static const BindMapping defaults_nds[BIND_COUNT] = {
[BIND_HOTBAR_LEFT] = { CCPAD_2, CCPAD_LEFT }, [BIND_HOTBAR_LEFT] = { CCPAD_2, CCPAD_LEFT },
[BIND_HOTBAR_RIGHT] = { CCPAD_2, CCPAD_RIGHT } [BIND_HOTBAR_RIGHT] = { CCPAD_2, CCPAD_RIGHT }
}; };
void Gamepads_PreInit(void) { }
void Gamepads_Init(void) { void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD; Input.Sources |= INPUT_SOURCE_GAMEPAD;

View File

@ -162,15 +162,17 @@ static const BindMapping pad_defaults[BIND_COUNT] = {
static char pad_buff[2][34]; static char pad_buff[2][34];
void Gamepads_Init(void) { void Gamepads_PreInit(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
// http://lameguy64.net/tutorials/pstutorials/chapter1/4-controllers.html // http://lameguy64.net/tutorials/pstutorials/chapter1/4-controllers.html
InitPAD(&pad_buff[0][0], 34, &pad_buff[1][0], 34); InitPAD(&pad_buff[0][0], 34, &pad_buff[1][0], 34);
pad_buff[0][0] = pad_buff[0][1] = 0xff; pad_buff[0][0] = pad_buff[0][1] = 0xff;
pad_buff[1][0] = pad_buff[1][1] = 0xff; pad_buff[1][0] = pad_buff[1][1] = 0xff;
StartPAD(); StartPAD();
ChangeClearPAD(0); ChangeClearPAD(0);
}
void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
Input_DisplayNames[CCPAD_1] = "CIRCLE"; Input_DisplayNames[CCPAD_1] = "CIRCLE";
Input_DisplayNames[CCPAD_2] = "CROSS"; Input_DisplayNames[CCPAD_2] = "CROSS";

View File

@ -252,12 +252,14 @@ static const BindMapping defaults_ps2[BIND_COUNT] = {
static char padBuf0[256] __attribute__((aligned(64))); static char padBuf0[256] __attribute__((aligned(64)));
static char padBuf1[256] __attribute__((aligned(64))); static char padBuf1[256] __attribute__((aligned(64)));
void Gamepads_Init(void) { void Gamepads_PreInit(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
padInit(0); padInit(0);
padPortOpen(0, 0, padBuf0); padPortOpen(0, 0, padBuf0);
padPortOpen(1, 0, padBuf1); padPortOpen(1, 0, padBuf1);
}
void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
Input_DisplayNames[CCPAD_1] = "CIRCLE"; Input_DisplayNames[CCPAD_1] = "CIRCLE";
Input_DisplayNames[CCPAD_2] = "CROSS"; Input_DisplayNames[CCPAD_2] = "CROSS";

View File

@ -296,9 +296,12 @@ static padInfo pad_info;
static padData pad_data[MAX_PORT_NUM]; static padData pad_data[MAX_PORT_NUM];
static cc_bool circle_main; static cc_bool circle_main;
void Gamepads_PreInit(void) {
ioPadInit(MAX_PORT_NUM);
}
void Gamepads_Init(void) { void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD; Input.Sources |= INPUT_SOURCE_GAMEPAD;
ioPadInit(MAX_PORT_NUM);
int ret = 0; int ret = 0;
sysUtilGetSystemParamInt(SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &ret); sysUtilGetSystemParamInt(SYSUTIL_SYSTEMPARAM_ID_ENTER_BUTTON_ASSIGN, &ret);

View File

@ -88,6 +88,8 @@ void Window_DisableRawMouse(void) { Input.RawMode = false; }
/*########################################################################################################################* /*########################################################################################################################*
*-------------------------------------------------------Gamepads----------------------------------------------------------* *-------------------------------------------------------Gamepads----------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Gamepads_PreInit(void) { }
void Gamepads_Init(void) { void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD; Input.Sources |= INPUT_SOURCE_GAMEPAD;
} }

View File

@ -103,11 +103,13 @@ static const BindMapping defaults_psp[BIND_COUNT] = {
[BIND_HOTBAR_RIGHT] = { CCPAD_ZR } [BIND_HOTBAR_RIGHT] = { CCPAD_ZR }
}; };
void Gamepads_Init(void) { void Gamepads_PreInit(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
}
void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
Input_DisplayNames[CCPAD_1] = "CIRCLE"; Input_DisplayNames[CCPAD_1] = "CIRCLE";
Input_DisplayNames[CCPAD_2] = "CROSS"; Input_DisplayNames[CCPAD_2] = "CROSS";

View File

@ -159,11 +159,13 @@ static const BindMapping defaults_vita[BIND_COUNT] = {
}; };
static cc_bool circle_main; static cc_bool circle_main;
void Gamepads_PreInit(void) {
sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG);
}
void Gamepads_Init(void) { void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD; Input.Sources |= INPUT_SOURCE_GAMEPAD;
sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG);
SceAppUtilInitParam init_param = { 0 }; SceAppUtilInitParam init_param = { 0 };
SceAppUtilBootParam boot_param = { 0 }; SceAppUtilBootParam boot_param = { 0 };
sceAppUtilInit(&init_param, &boot_param); sceAppUtilInit(&init_param, &boot_param);

View File

@ -112,9 +112,12 @@ static const BindMapping saturn_defaults[BIND_COUNT] = {
[BIND_DELETE_BLOCK] = { CCPAD_R }, [BIND_DELETE_BLOCK] = { CCPAD_R },
}; };
void Gamepads_PreInit(void) {
smpc_peripheral_init();
}
void Gamepads_Init(void) { void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD; Input.Sources |= INPUT_SOURCE_GAMEPAD;
smpc_peripheral_init();
Input_DisplayNames[CCPAD_1] = "A"; Input_DisplayNames[CCPAD_1] = "A";
Input_DisplayNames[CCPAD_2] = "B"; Input_DisplayNames[CCPAD_2] = "B";

View File

@ -167,6 +167,8 @@ static const BindMapping defaults_switch[BIND_COUNT] = {
[BIND_HOTBAR_RIGHT] = { CCPAD_ZR } [BIND_HOTBAR_RIGHT] = { CCPAD_ZR }
}; };
void Gamepads_PreInit(void) { }
void Gamepads_Init(void) { void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD; Input.Sources |= INPUT_SOURCE_GAMEPAD;
} }

View File

@ -905,6 +905,8 @@ void Window_DisableRawMouse(void) {
Input.RawMode = false; Input.RawMode = false;
} }
void Gamepads_PreInit(void) { }
void Gamepads_Init(void) { } void Gamepads_Init(void) { }
void Gamepads_Process(float delta) { } void Gamepads_Process(float delta) { }

View File

@ -568,6 +568,8 @@ static void Cursor_DoSetVisible(cc_bool visible) {
/*########################################################################################################################* /*########################################################################################################################*
*-------------------------------------------------------Gamepads----------------------------------------------------------* *-------------------------------------------------------Gamepads----------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
void Gamepads_PreInit(void) { }
void Gamepads_Init(void) { void Gamepads_Init(void) {
/* Devices can't be detected until first time a button is pressed */ /* Devices can't be detected until first time a button is pressed */
} }

View File

@ -156,13 +156,15 @@ void Window_DisableRawMouse(void) { Input.RawMode = false; }
static VPADStatus vpadStatus; static VPADStatus vpadStatus;
static KPADStatus kpads[4]; static KPADStatus kpads[4];
void Gamepads_Init(void) { void Gamepads_PreInit(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
KPADInit(); KPADInit();
VPADInit(); VPADInit();
} }
void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
}
static void ProcessKPadButtons(int port, int mods) { static void ProcessKPadButtons(int port, int mods) {
Gamepad_SetButton(port, CCPAD_L, mods & WPAD_BUTTON_1); Gamepad_SetButton(port, CCPAD_L, mods & WPAD_BUTTON_1);
Gamepad_SetButton(port, CCPAD_R, mods & WPAD_BUTTON_2); Gamepad_SetButton(port, CCPAD_R, mods & WPAD_BUTTON_2);

View File

@ -146,9 +146,7 @@ static void OnDeviceChanged(xid_dev_t *xid_dev__, int status__) {
xid_ctrl = NULL; xid_ctrl = NULL;
} }
void Gamepads_Init(void) { void Gamepads_PreInit(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
#ifndef CC_BUILD_CXBX #ifndef CC_BUILD_CXBX
usbh_core_init(); usbh_core_init();
usbh_xid_init(); usbh_xid_init();
@ -158,6 +156,10 @@ void Gamepads_Init(void) {
#endif #endif
} }
void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
}
// https://docs.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_gamepad // https://docs.microsoft.com/en-us/windows/win32/api/xinput/ns-xinput-xinput_gamepad
// NOTE: Analog buttons use dedicated field rather than being part of dButtons // NOTE: Analog buttons use dedicated field rather than being part of dButtons
#define XINPUT_GAMEPAD_DPAD_UP 0x0001 #define XINPUT_GAMEPAD_DPAD_UP 0x0001

View File

@ -104,12 +104,14 @@ static const BindMapping defaults_xbox360[BIND_COUNT] = {
[BIND_HOTBAR_RIGHT] = { CCPAD_ZR } [BIND_HOTBAR_RIGHT] = { CCPAD_ZR }
}; };
void Gamepads_Init(void) { void Gamepads_PreInit(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
usb_init(); usb_init();
usb_do_poll(); usb_do_poll();
} }
void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
}
/* /*
struct controller_data_s struct controller_data_s
{ {