mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 09:06:55 -04:00
3DS: Implement rudimentary controls and support for clicking Singleplayer/Multiplayer from main menu
This commit is contained in:
parent
28aba23a1a
commit
9809e34e78
@ -487,9 +487,9 @@ int Hotkeys_FindPartial(int key) {
|
||||
struct HotkeyData hk;
|
||||
int i, modifiers = 0;
|
||||
|
||||
if (Input_IsCtrlPressed()) modifiers |= HOTIPT_MOD_CTRL;
|
||||
if (Input_IsShiftPressed()) modifiers |= HOTIPT_MOD_SHIFT;
|
||||
if (Input_IsAltPressed()) modifiers |= HOTIPT_MOD_ALT;
|
||||
if (Input_IsCtrlPressed()) modifiers |= HOTKEY_MOD_CTRL;
|
||||
if (Input_IsShiftPressed()) modifiers |= HOTKEY_MOD_SHIFT;
|
||||
if (Input_IsAltPressed()) modifiers |= HOTKEY_MOD_ALT;
|
||||
|
||||
for (i = 0; i < HotkeysText.count; i++) {
|
||||
hk = HotkeysList[i];
|
||||
|
@ -157,14 +157,14 @@ struct HotkeyData {
|
||||
int textIndex; /* contents to copy directly into the input bar */
|
||||
cc_uint8 trigger; /* Member of Key enumeration */
|
||||
cc_uint8 mods; /* HotkeyModifiers bitflags */
|
||||
cc_uint8 flags; /* HOTIPT_FLAG flags */
|
||||
cc_uint8 flags; /* HOTKEY_FLAG flags */
|
||||
};
|
||||
|
||||
#define HOTKEYS_MAX_COUNT 256
|
||||
extern struct HotkeyData HotkeysList[HOTKEYS_MAX_COUNT];
|
||||
extern struct StringsBuffer HotkeysText;
|
||||
enum HotkeyModifiers {
|
||||
HOTIPT_MOD_CTRL = 1, HOTIPT_MOD_SHIFT = 2, HOTIPT_MOD_ALT = 4
|
||||
HOTKEY_MOD_CTRL = 1, HOTKEY_MOD_SHIFT = 2, HOTKEY_MOD_ALT = 4
|
||||
};
|
||||
|
||||
/* Adds or updates a new hotkey. */
|
||||
|
18
src/Menus.c
18
src/Menus.c
@ -879,9 +879,9 @@ static int EditHotkeyScreen_KeyDown(void* screen, int key) {
|
||||
if (s->selectedI == 0) {
|
||||
s->curHotkey.trigger = key;
|
||||
} else if (s->selectedI == 1) {
|
||||
if (key == IPT_LCTRL || key == IPT_RCTRL) s->curHotkey.mods |= HOTIPT_MOD_CTRL;
|
||||
else if (key == IPT_LSHIFT || key == IPT_RSHIFT) s->curHotkey.mods |= HOTIPT_MOD_SHIFT;
|
||||
else if (key == IPT_LALT || key == IPT_RALT) s->curHotkey.mods |= HOTIPT_MOD_ALT;
|
||||
if (key == IPT_LCTRL || key == IPT_RCTRL) s->curHotkey.mods |= HOTKEY_MOD_CTRL;
|
||||
else if (key == IPT_LSHIFT || key == IPT_RSHIFT) s->curHotkey.mods |= HOTKEY_MOD_SHIFT;
|
||||
else if (key == IPT_LALT || key == IPT_RALT) s->curHotkey.mods |= HOTKEY_MOD_ALT;
|
||||
else s->curHotkey.mods = 0;
|
||||
}
|
||||
|
||||
@ -1629,9 +1629,9 @@ static void HotkeyListScreen_EntryClick(void* screen, void* widget) {
|
||||
}
|
||||
|
||||
String_UNSAFE_Separate(&text, '+', &key, &value);
|
||||
if (String_ContainsConst(&value, "Ctrl")) mods |= HOTIPT_MOD_CTRL;
|
||||
if (String_ContainsConst(&value, "Shift")) mods |= HOTIPT_MOD_SHIFT;
|
||||
if (String_ContainsConst(&value, "Alt")) mods |= HOTIPT_MOD_ALT;
|
||||
if (String_ContainsConst(&value, "Ctrl")) mods |= HOTKEY_MOD_CTRL;
|
||||
if (String_ContainsConst(&value, "Shift")) mods |= HOTKEY_MOD_SHIFT;
|
||||
if (String_ContainsConst(&value, "Alt")) mods |= HOTKEY_MOD_ALT;
|
||||
|
||||
trigger = Utils_ParseEnum(&key, IPT_NONE, Input_DisplayNames, INPUT_COUNT);
|
||||
for (i = 0; i < HotkeysText.count; i++) {
|
||||
@ -1643,9 +1643,9 @@ static void HotkeyListScreen_EntryClick(void* screen, void* widget) {
|
||||
}
|
||||
|
||||
static void HotkeyListScreen_MakeFlags(int flags, cc_string* str) {
|
||||
if (flags & HOTIPT_MOD_CTRL) String_AppendConst(str, " Ctrl");
|
||||
if (flags & HOTIPT_MOD_SHIFT) String_AppendConst(str, " Shift");
|
||||
if (flags & HOTIPT_MOD_ALT) String_AppendConst(str, " Alt");
|
||||
if (flags & HOTKEY_MOD_CTRL) String_AppendConst(str, " Ctrl");
|
||||
if (flags & HOTKEY_MOD_SHIFT) String_AppendConst(str, " Shift");
|
||||
if (flags & HOTKEY_MOD_ALT) String_AppendConst(str, " Alt");
|
||||
}
|
||||
|
||||
static void HotkeyListScreen_LoadEntries(struct ListScreen* s) {
|
||||
|
@ -423,9 +423,48 @@ cc_result Socket_CheckWritable(cc_socket s, cc_bool* writable) {
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------Process/Module------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static char gameArgs[GAME_MAX_CMDARGS][STRING_SIZE];
|
||||
static int gameNumArgs;
|
||||
static cc_bool gameHasArgs;
|
||||
cc_result Process_StartGame2(const cc_string* args, int numArgs) {
|
||||
return ERR_NOT_SUPPORTED;
|
||||
for (int i = 0; i < numArgs; i++)
|
||||
{
|
||||
String_CopyToRawArray(gameArgs[i], &args[i]);
|
||||
}
|
||||
Platform_LogConst("START GAME");
|
||||
gameHasArgs = true;
|
||||
gameNumArgs = numArgs;
|
||||
return 0;
|
||||
}
|
||||
static int GetGameArgs(cc_string* args) {
|
||||
int count = gameNumArgs;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
args[i] = String_FromRawArray(gameArgs[i]);
|
||||
}
|
||||
// clear arguments so after game is closed, launcher is started
|
||||
gameNumArgs = 0;
|
||||
return count;
|
||||
}
|
||||
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
|
||||
if (gameHasArgs) return GetGameArgs(args);
|
||||
|
||||
// 3DS *sometimes* doesn't use argv[0] for program name and so argc will be 0
|
||||
// (e.g. when running from Citra)
|
||||
int count = min(argc, GAME_MAX_CMDARGS);
|
||||
Platform_Log1("ARGS: %i", &count);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
args[i] = String_FromReadonly(argv[i]);
|
||||
Platform_Log2(" ARG %i = %c", &i, argv[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Process_Exit(cc_result code) { exit(code); }
|
||||
|
||||
cc_result Process_StartOpen(const cc_string* args) {
|
||||
@ -518,25 +557,4 @@ cc_result Platform_Encrypt(const void* data, int len, cc_string* dst) {
|
||||
cc_result Platform_Decrypt(const void* data, int len, cc_string* dst) {
|
||||
return ERR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------Configuration-------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* args) {
|
||||
// 3DS *sometimes* doesn't use argv[0] for program name and so argc will be 0
|
||||
// (e.g. when running from Citra)
|
||||
int count = min(argc, GAME_MAX_CMDARGS);
|
||||
Platform_Log1("ARGS: %i", &count);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
args[i] = String_FromReadonly(argv[i]);
|
||||
Platform_Log2(" ARG %i = %c", &i, argv[i]);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
|
||||
return 0;
|
||||
}
|
||||
#endif
|
@ -138,6 +138,12 @@ void android_main(void) {
|
||||
SetupProgram(0, NULL);
|
||||
for (;;) { RunProgram(0, NULL); }
|
||||
}
|
||||
#elif defined CC_BUILD_3DS
|
||||
int main(int argc, char** argv) {
|
||||
SetupProgram(argc, argc);
|
||||
for (;;) { RunProgram(argc, argv); }
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
/* NOTE: main_real is used for when compiling with MingW without linking to startup files. */
|
||||
/* Normally, the final code produced for "main" is our "main" combined with crt's main */
|
||||
@ -158,4 +164,4 @@ int main(int argc, char** argv) {
|
||||
Process_Exit(res);
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -6,9 +6,6 @@
|
||||
#include "Bitmap.h"
|
||||
#include "Errors.h"
|
||||
#include <3ds.h>
|
||||
|
||||
#define CC_INPUT_H
|
||||
extern cc_bool Input_RawMode; // Otherwise KEY_ conflicts with 3DS keys
|
||||
#include "_WindowBase.h"
|
||||
|
||||
// Note from https://github.com/devkitPro/libctru/blob/master/libctru/include/3ds/gfx.h
|
||||
@ -64,11 +61,37 @@ void Window_ProcessEvents(void) {
|
||||
hidScanInput();
|
||||
/* TODO implement */
|
||||
|
||||
if (hidKeysDown() & KEY_TOUCH)
|
||||
Input_SetPressed(119); // LMOUSE
|
||||
//u32 m1 = hidKeysDown(), m2 = hidKeysHeld();
|
||||
//Platform_Log2("MODS: %h | %h", &m1, &m2);
|
||||
|
||||
if (hidKeysUp() & KEY_TOUCH)
|
||||
Input_SetReleased(119); // LMOUSE
|
||||
// hidKeysDown hidKeysUp
|
||||
//u32 mods = hidKeysDownRepeat();
|
||||
u32 mods = hidKeysDown() | hidKeysHeld();
|
||||
//Platform_Log1("MODS: %h", &mods);
|
||||
Input_SetNonRepeatable(IPT_LMOUSE, mods & KEY_TOUCH);
|
||||
|
||||
|
||||
Input_SetNonRepeatable(KeyBinds[KEYBIND_PLACE_BLOCK], mods & KEY_L);
|
||||
Input_SetNonRepeatable(KeyBinds[KEYBIND_DELETE_BLOCK], mods & KEY_R);
|
||||
|
||||
Input_SetNonRepeatable(KeyBinds[KEYBIND_JUMP], mods & KEY_A);
|
||||
Input_SetNonRepeatable(KeyBinds[KEYBIND_CHAT], mods & KEY_X);
|
||||
Input_SetNonRepeatable(KeyBinds[KEYBIND_INVENTORY], mods & KEY_Y);
|
||||
|
||||
Input_SetNonRepeatable(IPT_ENTER, mods & KEY_START);
|
||||
Input_SetNonRepeatable(IPT_ESCAPE, mods & KEY_SELECT);
|
||||
// fake tab with down for Launcher
|
||||
Input_SetNonRepeatable(IPT_TAB, mods & KEY_DDOWN);
|
||||
|
||||
Input_SetNonRepeatable(KeyBinds[KEYBIND_LEFT], mods & KEY_DLEFT);
|
||||
Input_SetNonRepeatable(IPT_LEFT, mods & KEY_DLEFT);
|
||||
Input_SetNonRepeatable(KeyBinds[KEYBIND_RIGHT], mods & KEY_DRIGHT);
|
||||
Input_SetNonRepeatable(IPT_RIGHT, mods & KEY_DRIGHT);
|
||||
|
||||
Input_SetNonRepeatable(KeyBinds[KEYBIND_FORWARD], mods & KEY_DUP);
|
||||
Input_SetNonRepeatable(IPT_UP, mods & KEY_DUP);
|
||||
Input_SetNonRepeatable(KeyBinds[KEYBIND_BACK], mods & KEY_DDOWN);
|
||||
Input_SetNonRepeatable(IPT_DOWN, mods & KEY_DDOWN);
|
||||
|
||||
if (hidKeysHeld() & KEY_TOUCH) {
|
||||
int x, y;
|
||||
@ -187,4 +210,4 @@ void Window_CloseKeyboard(void) { /* TODO implement */ }
|
||||
void Window_EnableRawMouse(void) { DefaultEnableRawMouse(); }
|
||||
void Window_UpdateRawMouse(void) { DefaultUpdateRawMouse(); }
|
||||
void Window_DisableRawMouse(void) { DefaultDisableRawMouse(); }
|
||||
#endif
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user