mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-08-04 11:17:14 -04:00
Separate gamepad Start/Select from Enter/Escape keys
This commit is contained in:
parent
ed67758d79
commit
8406571804
@ -446,8 +446,10 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Animations.c" />
|
<ClCompile Include="Animations.c" />
|
||||||
<ClCompile Include="GameVersion.c" />
|
<ClCompile Include="GameVersion.c" />
|
||||||
|
<ClCompile Include="Graphics_3DS.c" />
|
||||||
<ClCompile Include="Graphics_D3D11.c" />
|
<ClCompile Include="Graphics_D3D11.c" />
|
||||||
<ClCompile Include="Graphics_D3D9.c" />
|
<ClCompile Include="Graphics_D3D9.c" />
|
||||||
|
<ClCompile Include="Graphics_GCWii.c" />
|
||||||
<ClCompile Include="Graphics_GL1.c" />
|
<ClCompile Include="Graphics_GL1.c" />
|
||||||
<ClCompile Include="Audio.c" />
|
<ClCompile Include="Audio.c" />
|
||||||
<ClCompile Include="Camera.c" />
|
<ClCompile Include="Camera.c" />
|
||||||
@ -465,6 +467,7 @@
|
|||||||
<ClCompile Include="Formats.c" />
|
<ClCompile Include="Formats.c" />
|
||||||
<ClCompile Include="Game.c" />
|
<ClCompile Include="Game.c" />
|
||||||
<ClCompile Include="Graphics_GL2.c" />
|
<ClCompile Include="Graphics_GL2.c" />
|
||||||
|
<ClCompile Include="Graphics_PSP.c" />
|
||||||
<ClCompile Include="Gui.c" />
|
<ClCompile Include="Gui.c" />
|
||||||
<ClCompile Include="HeldBlockRenderer.c" />
|
<ClCompile Include="HeldBlockRenderer.c" />
|
||||||
<ClCompile Include="Http_Web.c" />
|
<ClCompile Include="Http_Web.c" />
|
||||||
|
@ -620,6 +620,15 @@
|
|||||||
<ClCompile Include="Platform_WinApi.c">
|
<ClCompile Include="Platform_WinApi.c">
|
||||||
<Filter>Source Files\Platform</Filter>
|
<Filter>Source Files\Platform</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Graphics_3DS.c">
|
||||||
|
<Filter>Source Files\Graphics</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Graphics_PSP.c">
|
||||||
|
<Filter>Source Files\Graphics</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Graphics_GCWii.c">
|
||||||
|
<Filter>Source Files\Graphics</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="..\misc\CCicon.rc">
|
<ResourceCompile Include="..\misc\CCicon.rc">
|
||||||
|
41
src/Input.c
41
src/Input.c
@ -25,6 +25,7 @@
|
|||||||
#include "AxisLinesRenderer.h"
|
#include "AxisLinesRenderer.h"
|
||||||
#include "Picking.h"
|
#include "Picking.h"
|
||||||
|
|
||||||
|
struct _InputState Input;
|
||||||
static cc_bool input_buttonsDown[3];
|
static cc_bool input_buttonsDown[3];
|
||||||
static int input_pickingId = -1;
|
static int input_pickingId = -1;
|
||||||
static TimeMS input_lastClick;
|
static TimeMS input_lastClick;
|
||||||
@ -88,7 +89,7 @@ static cc_bool TryUpdateTouch(long id, int x, int y) {
|
|||||||
for (i = 0; i < Pointers_Count; i++) {
|
for (i = 0; i < Pointers_Count; i++) {
|
||||||
if (touches[i].id != id || !touches[i].type) continue;
|
if (touches[i].id != id || !touches[i].type) continue;
|
||||||
|
|
||||||
if (Input_RawMode && (touches[i].type & TOUCH_TYPE_CAMERA)) {
|
if (Input.RawMode && (touches[i].type & TOUCH_TYPE_CAMERA)) {
|
||||||
/* If the pointer hasn't been locked to gui or block yet, moving a bit */
|
/* If the pointer hasn't been locked to gui or block yet, moving a bit */
|
||||||
/* should cause the pointer to get locked to camera movement. */
|
/* should cause the pointer to get locked to camera movement. */
|
||||||
if (touches[i].type == TOUCH_TYPE_ALL && MovedFromBeg(i, x, y)) {
|
if (touches[i].type == TOUCH_TYPE_ALL && MovedFromBeg(i, x, y)) {
|
||||||
@ -179,8 +180,6 @@ static void ClearTouches(void) { }
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------------Key-----------------------------------------------------------*
|
*-----------------------------------------------------------Key-----------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
cc_bool Input_Pressed[INPUT_COUNT];
|
|
||||||
|
|
||||||
#define Key_Function_Names \
|
#define Key_Function_Names \
|
||||||
"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",\
|
"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",\
|
||||||
"F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20",\
|
"F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", "F19", "F20",\
|
||||||
@ -191,9 +190,11 @@ cc_bool Input_Pressed[INPUT_COUNT];
|
|||||||
"U", "V", "W", "X", "Y", "Z"
|
"U", "V", "W", "X", "Y", "Z"
|
||||||
#define Pad_Names \
|
#define Pad_Names \
|
||||||
"PAD_A", "PAD_B", "PAD_X", "PAD_Y", "PAD_L", "PAD_R", \
|
"PAD_A", "PAD_B", "PAD_X", "PAD_Y", "PAD_L", "PAD_R", \
|
||||||
"PAD_LEFT", "PAD_RIGHT", "PAD_UP", "PAD_DOWN",
|
"PAD_LEFT", "PAD_RIGHT", "PAD_UP", "PAD_DOWN", \
|
||||||
|
"PAD_START", "PAD_SELECT"
|
||||||
|
|
||||||
const char* const Input_StorageNames[INPUT_COUNT] = {
|
/* Names for each input button when stored to disc */
|
||||||
|
static const char* const storageNames[INPUT_COUNT] = {
|
||||||
"None",
|
"None",
|
||||||
Key_Function_Names,
|
Key_Function_Names,
|
||||||
"Tilde", "Minus", "Plus", "BracketLeft", "BracketRight", "Slash",
|
"Tilde", "Minus", "Plus", "BracketLeft", "BracketRight", "Slash",
|
||||||
@ -240,8 +241,8 @@ const char* const Input_DisplayNames[INPUT_COUNT] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void Input_SetPressed(int key) {
|
void Input_SetPressed(int key) {
|
||||||
cc_bool wasPressed = Input_Pressed[key];
|
cc_bool wasPressed = Input.Pressed[key];
|
||||||
Input_Pressed[key] = true;
|
Input.Pressed[key] = true;
|
||||||
Event_RaiseInput(&InputEvents.Down, key, wasPressed);
|
Event_RaiseInput(&InputEvents.Down, key, wasPressed);
|
||||||
|
|
||||||
if (key == 'C' && Input_IsActionPressed()) Event_RaiseInput(&InputEvents.Down, INPUT_CLIPBOARD_COPY, 0);
|
if (key == 'C' && Input_IsActionPressed()) Event_RaiseInput(&InputEvents.Down, INPUT_CLIPBOARD_COPY, 0);
|
||||||
@ -253,8 +254,8 @@ void Input_SetPressed(int key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Input_SetReleased(int key) {
|
void Input_SetReleased(int key) {
|
||||||
if (!Input_Pressed[key]) return;
|
if (!Input.Pressed[key]) return;
|
||||||
Input_Pressed[key] = false;
|
Input.Pressed[key] = false;
|
||||||
|
|
||||||
Event_RaiseInt(&InputEvents.Up, key);
|
Event_RaiseInt(&InputEvents.Up, key);
|
||||||
if (key == CCMOUSE_L) Pointer_SetPressed(0, false);
|
if (key == CCMOUSE_L) Pointer_SetPressed(0, false);
|
||||||
@ -270,7 +271,7 @@ void Input_Set(int key, int pressed) {
|
|||||||
|
|
||||||
void Input_SetNonRepeatable(int key, int pressed) {
|
void Input_SetNonRepeatable(int key, int pressed) {
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
if (Input_Pressed[key]) return;
|
if (Input.Pressed[key]) return;
|
||||||
Input_SetPressed(key);
|
Input_SetPressed(key);
|
||||||
} else {
|
} else {
|
||||||
Input_SetReleased(key);
|
Input_SetReleased(key);
|
||||||
@ -279,8 +280,9 @@ void Input_SetNonRepeatable(int key, int pressed) {
|
|||||||
|
|
||||||
void Input_Clear(void) {
|
void Input_Clear(void) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < INPUT_COUNT; i++) {
|
for (i = 0; i < INPUT_COUNT; i++)
|
||||||
if (Input_Pressed[i]) Input_SetReleased(i);
|
{
|
||||||
|
if (Input.Pressed[i]) Input_SetReleased(i);
|
||||||
}
|
}
|
||||||
/* TODO: Properly release instead of just clearing */
|
/* TODO: Properly release instead of just clearing */
|
||||||
ClearTouches();
|
ClearTouches();
|
||||||
@ -291,7 +293,6 @@ void Input_Clear(void) {
|
|||||||
*----------------------------------------------------------Mouse----------------------------------------------------------*
|
*----------------------------------------------------------Mouse----------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
struct Pointer Pointers[INPUT_MAX_POINTERS];
|
struct Pointer Pointers[INPUT_MAX_POINTERS];
|
||||||
cc_bool Input_RawMode;
|
|
||||||
|
|
||||||
void Pointer_SetPressed(int idx, cc_bool pressed) {
|
void Pointer_SetPressed(int idx, cc_bool pressed) {
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
@ -350,7 +351,7 @@ static const char* const keybindNames[KEYBIND_COUNT] = {
|
|||||||
"Hotbar7", "Hotbar8", "Hotbar9"
|
"Hotbar7", "Hotbar8", "Hotbar9"
|
||||||
};
|
};
|
||||||
|
|
||||||
cc_bool KeyBind_IsPressed(KeyBind binding) { return Input_Pressed[KeyBinds[binding]]; }
|
cc_bool KeyBind_IsPressed(KeyBind binding) { return Input.Pressed[KeyBinds[binding]]; }
|
||||||
|
|
||||||
static void KeyBind_Load(void) {
|
static void KeyBind_Load(void) {
|
||||||
cc_string name; char nameBuffer[STRING_SIZE + 1];
|
cc_string name; char nameBuffer[STRING_SIZE + 1];
|
||||||
@ -363,7 +364,7 @@ static void KeyBind_Load(void) {
|
|||||||
String_Format1(&name, "key-%c", keybindNames[i]);
|
String_Format1(&name, "key-%c", keybindNames[i]);
|
||||||
name.buffer[name.length] = '\0';
|
name.buffer[name.length] = '\0';
|
||||||
|
|
||||||
mapping = Options_GetEnum(name.buffer, KeyBind_Defaults[i], Input_StorageNames, INPUT_COUNT);
|
mapping = Options_GetEnum(name.buffer, KeyBind_Defaults[i], storageNames, INPUT_COUNT);
|
||||||
if (mapping != CCKEY_ESCAPE) KeyBinds[i] = mapping;
|
if (mapping != CCKEY_ESCAPE) KeyBinds[i] = mapping;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -374,7 +375,7 @@ void KeyBind_Set(KeyBind binding, int key) {
|
|||||||
String_InitArray(name, nameBuffer);
|
String_InitArray(name, nameBuffer);
|
||||||
|
|
||||||
String_Format1(&name, "key-%c", keybindNames[binding]);
|
String_Format1(&name, "key-%c", keybindNames[binding]);
|
||||||
value = String_FromReadonly(Input_StorageNames[key]);
|
value = String_FromReadonly(storageNames[key]);
|
||||||
Options_SetString(&name, &value);
|
Options_SetString(&name, &value);
|
||||||
KeyBinds[binding] = key;
|
KeyBinds[binding] = key;
|
||||||
}
|
}
|
||||||
@ -521,7 +522,7 @@ static void StoredHotkey_Parse(cc_string* key, cc_string* value) {
|
|||||||
if (!String_UNSAFE_Separate(key, '&', &strKey, &strMods)) return;
|
if (!String_UNSAFE_Separate(key, '&', &strKey, &strMods)) return;
|
||||||
if (!String_UNSAFE_Separate(value, '&', &strMore, &strText)) return;
|
if (!String_UNSAFE_Separate(value, '&', &strMore, &strText)) return;
|
||||||
|
|
||||||
trigger = Utils_ParseEnum(&strKey, INPUT_NONE, Input_StorageNames, INPUT_COUNT);
|
trigger = Utils_ParseEnum(&strKey, INPUT_NONE, storageNames, INPUT_COUNT);
|
||||||
if (trigger == INPUT_NONE) return;
|
if (trigger == INPUT_NONE) return;
|
||||||
if (!Convert_ParseUInt8(&strMods, &modifiers)) return;
|
if (!Convert_ParseUInt8(&strMods, &modifiers)) return;
|
||||||
if (!Convert_ParseBool(&strMore, &more)) return;
|
if (!Convert_ParseBool(&strMore, &more)) return;
|
||||||
@ -546,7 +547,7 @@ void StoredHotkeys_Load(int trigger, cc_uint8 modifiers) {
|
|||||||
cc_string key, value; char keyBuffer[STRING_SIZE];
|
cc_string key, value; char keyBuffer[STRING_SIZE];
|
||||||
String_InitArray(key, keyBuffer);
|
String_InitArray(key, keyBuffer);
|
||||||
|
|
||||||
String_Format2(&key, "hotkey-%c&%b", Input_StorageNames[trigger], &modifiers);
|
String_Format2(&key, "hotkey-%c&%b", storageNames[trigger], &modifiers);
|
||||||
key.buffer[key.length] = '\0'; /* TODO: Avoid this null terminator */
|
key.buffer[key.length] = '\0'; /* TODO: Avoid this null terminator */
|
||||||
|
|
||||||
Options_UNSAFE_Get(key.buffer, &value);
|
Options_UNSAFE_Get(key.buffer, &value);
|
||||||
@ -557,7 +558,7 @@ void StoredHotkeys_Remove(int trigger, cc_uint8 modifiers) {
|
|||||||
cc_string key; char keyBuffer[STRING_SIZE];
|
cc_string key; char keyBuffer[STRING_SIZE];
|
||||||
String_InitArray(key, keyBuffer);
|
String_InitArray(key, keyBuffer);
|
||||||
|
|
||||||
String_Format2(&key, "hotkey-%c&%b", Input_StorageNames[trigger], &modifiers);
|
String_Format2(&key, "hotkey-%c&%b", storageNames[trigger], &modifiers);
|
||||||
Options_SetString(&key, NULL);
|
Options_SetString(&key, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,7 +568,7 @@ void StoredHotkeys_Add(int trigger, cc_uint8 modifiers, cc_bool moreInput, const
|
|||||||
String_InitArray(key, keyBuffer);
|
String_InitArray(key, keyBuffer);
|
||||||
String_InitArray(value, valueBuffer);
|
String_InitArray(value, valueBuffer);
|
||||||
|
|
||||||
String_Format2(&key, "hotkey-%c&%b", Input_StorageNames[trigger], &modifiers);
|
String_Format2(&key, "hotkey-%c&%b", storageNames[trigger], &modifiers);
|
||||||
String_Format2(&value, "%t&%s", &moreInput, text);
|
String_Format2(&value, "%t&%s", &moreInput, text);
|
||||||
Options_SetString(&key, &value);
|
Options_SetString(&key, &value);
|
||||||
}
|
}
|
||||||
|
55
src/Input.h
55
src/Input.h
@ -47,6 +47,7 @@ enum InputButtons {
|
|||||||
|
|
||||||
CCPAD_A, CCPAD_B, CCPAD_X, CCPAD_Y, CCPAD_L, CCPAD_R,
|
CCPAD_A, CCPAD_B, CCPAD_X, CCPAD_Y, CCPAD_L, CCPAD_R,
|
||||||
CCPAD_LEFT, CCPAD_RIGHT, CCPAD_UP, CCPAD_DOWN,
|
CCPAD_LEFT, CCPAD_RIGHT, CCPAD_UP, CCPAD_DOWN,
|
||||||
|
CCPAD_START, CCPAD_SELECT,
|
||||||
|
|
||||||
INPUT_COUNT,
|
INPUT_COUNT,
|
||||||
|
|
||||||
@ -54,33 +55,15 @@ enum InputButtons {
|
|||||||
INPUT_CLIPBOARD_PASTE = 1002
|
INPUT_CLIPBOARD_PASTE = 1002
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Names for each input button when stored to disc */
|
|
||||||
extern const char* const Input_StorageNames[INPUT_COUNT];
|
|
||||||
/* Simple display names for each input button */
|
|
||||||
extern const char* const Input_DisplayNames[INPUT_COUNT];
|
extern const char* const Input_DisplayNames[INPUT_COUNT];
|
||||||
|
|
||||||
#define Input_IsWinPressed() (Input_Pressed[CCKEY_LWIN] || Input_Pressed[CCKEY_RWIN])
|
extern struct _InputState {
|
||||||
#define Input_IsAltPressed() (Input_Pressed[CCKEY_LALT] || Input_Pressed[CCKEY_RALT])
|
/* Pressed state of each input button. Use Input_Set to change */
|
||||||
#define Input_IsCtrlPressed() (Input_Pressed[CCKEY_LCTRL] || Input_Pressed[CCKEY_RCTRL])
|
cc_bool Pressed[INPUT_COUNT];
|
||||||
#define Input_IsShiftPressed() (Input_Pressed[CCKEY_LSHIFT] || Input_Pressed[CCKEY_RSHIFT])
|
/* Whether raw mouse/touch input is currently being listened for */
|
||||||
|
cc_bool RawMode;
|
||||||
|
} Input;
|
||||||
|
|
||||||
#define Input_IsUpButton(btn) ((btn) == CCKEY_UP || (btn) == CCPAD_UP)
|
|
||||||
#define Input_IsDownButton(btn) ((btn) == CCKEY_DOWN || (btn) == CCPAD_DOWN)
|
|
||||||
#define Input_IsLeftButton(btn) ((btn) == CCKEY_LEFT || (btn) == CCPAD_LEFT)
|
|
||||||
#define Input_IsRightButton(btn) ((btn) == CCKEY_RIGHT || (btn) == CCPAD_RIGHT)
|
|
||||||
|
|
||||||
#if defined CC_BUILD_HAIKU
|
|
||||||
/* Haiku uses ALT instead of CTRL for clipboard and stuff */
|
|
||||||
#define Input_IsActionPressed() Input_IsAltPressed()
|
|
||||||
#elif defined CC_BUILD_DARWIN
|
|
||||||
/* macOS uses CMD instead of CTRL for clipboard and stuff */
|
|
||||||
#define Input_IsActionPressed() Input_IsWinPressed()
|
|
||||||
#else
|
|
||||||
#define Input_IsActionPressed() Input_IsCtrlPressed()
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Pressed state of each input button. Use Input_Set to change. */
|
|
||||||
extern cc_bool Input_Pressed[INPUT_COUNT];
|
|
||||||
/* Sets Input_Pressed[key] to true and raises InputEvents.Down */
|
/* Sets Input_Pressed[key] to true and raises InputEvents.Down */
|
||||||
void Input_SetPressed(int key);
|
void Input_SetPressed(int key);
|
||||||
/* Sets Input_Pressed[key] to false and raises InputEvents.Up */
|
/* Sets Input_Pressed[key] to false and raises InputEvents.Up */
|
||||||
@ -91,8 +74,28 @@ void Input_SetNonRepeatable(int key, int pressed);
|
|||||||
/* Resets all input buttons to released state. (Input_SetReleased) */
|
/* Resets all input buttons to released state. (Input_SetReleased) */
|
||||||
void Input_Clear(void);
|
void Input_Clear(void);
|
||||||
|
|
||||||
/* Whether raw mouse/touch input is currently being listened for. */
|
|
||||||
extern cc_bool Input_RawMode;
|
#define Input_IsWinPressed() (Input.Pressed[CCKEY_LWIN] || Input.Pressed[CCKEY_RWIN])
|
||||||
|
#define Input_IsAltPressed() (Input.Pressed[CCKEY_LALT] || Input.Pressed[CCKEY_RALT])
|
||||||
|
#define Input_IsCtrlPressed() (Input.Pressed[CCKEY_LCTRL] || Input.Pressed[CCKEY_RCTRL])
|
||||||
|
#define Input_IsShiftPressed() (Input.Pressed[CCKEY_LSHIFT] || Input.Pressed[CCKEY_RSHIFT])
|
||||||
|
|
||||||
|
#define Input_IsUpButton(btn) ((btn) == CCKEY_UP || (btn) == CCPAD_UP)
|
||||||
|
#define Input_IsDownButton(btn) ((btn) == CCKEY_DOWN || (btn) == CCPAD_DOWN)
|
||||||
|
#define Input_IsLeftButton(btn) ((btn) == CCKEY_LEFT || (btn) == CCPAD_LEFT)
|
||||||
|
#define Input_IsRightButton(btn) ((btn) == CCKEY_RIGHT || (btn) == CCPAD_RIGHT)
|
||||||
|
#define Input_IsEnterButton(btn) ((btn) == CCKEY_ENTER || (btn) == CCPAD_START || (btn) == CCKEY_KP_ENTER)
|
||||||
|
#define Input_IsEscapeButton(btn) ((btn) == CCKEY_ESCAPE || (btn) == CCPAD_SELECT)
|
||||||
|
|
||||||
|
#if defined CC_BUILD_HAIKU
|
||||||
|
/* Haiku uses ALT instead of CTRL for clipboard and stuff */
|
||||||
|
#define Input_IsActionPressed() Input_IsAltPressed()
|
||||||
|
#elif defined CC_BUILD_DARWIN
|
||||||
|
/* macOS uses CMD instead of CTRL for clipboard and stuff */
|
||||||
|
#define Input_IsActionPressed() Input_IsWinPressed()
|
||||||
|
#else
|
||||||
|
#define Input_IsActionPressed() Input_IsCtrlPressed()
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CC_BUILD_TOUCH
|
#ifdef CC_BUILD_TOUCH
|
||||||
#define INPUT_MAX_POINTERS 32
|
#define INPUT_MAX_POINTERS 32
|
||||||
|
@ -81,7 +81,7 @@ static void LScreen_CycleSelected(struct LScreen* s, int dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void LScreen_KeyDown(struct LScreen* s, int key, cc_bool was) {
|
static void LScreen_KeyDown(struct LScreen* s, int key, cc_bool was) {
|
||||||
if (key == CCKEY_ENTER || key == CCKEY_KP_ENTER) {
|
if (Input_IsEnterButton(key)) {
|
||||||
/* Shouldn't multi click when holding down Enter */
|
/* Shouldn't multi click when holding down Enter */
|
||||||
if (was) return;
|
if (was) return;
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ static void LScreen_KeyDown(struct LScreen* s, int key, cc_bool was) {
|
|||||||
LScreen_CycleSelected(s, -1);
|
LScreen_CycleSelected(s, -1);
|
||||||
} else if (Input_IsDownButton(key)) {
|
} else if (Input_IsDownButton(key)) {
|
||||||
LScreen_CycleSelected(s, 1);
|
LScreen_CycleSelected(s, 1);
|
||||||
} else if (key == CCKEY_ESCAPE && s->onEscapeWidget) {
|
} else if (Input_IsEscapeButton(key) && s->onEscapeWidget) {
|
||||||
s->onEscapeWidget->OnClick(s->onEscapeWidget);
|
s->onEscapeWidget->OnClick(s->onEscapeWidget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,7 +257,7 @@ static cc_bool LInput_KeyDown(void* widget, int key, cc_bool was) {
|
|||||||
if (w->text.length) Clipboard_SetText(&w->text);
|
if (w->text.length) Clipboard_SetText(&w->text);
|
||||||
} else if (key == INPUT_CLIPBOARD_PASTE) {
|
} else if (key == INPUT_CLIPBOARD_PASTE) {
|
||||||
LInput_CopyFromClipboard(w);
|
LInput_CopyFromClipboard(w);
|
||||||
} else if (key == CCKEY_ESCAPE) {
|
} else if (Input_IsEscapeButton(key)) {
|
||||||
if (w->text.length) LInput_SetString(w, &String_Empty);
|
if (w->text.length) LInput_SetString(w, &String_Empty);
|
||||||
} else if (Input_IsLeftButton(key)) {
|
} else if (Input_IsLeftButton(key)) {
|
||||||
LInput_AdvanceCaretPos(w, false);
|
LInput_AdvanceCaretPos(w, false);
|
||||||
|
@ -166,7 +166,7 @@ static int Menu_InputDown(void* screen, int key) {
|
|||||||
Menu_CycleSelected(s, -1);
|
Menu_CycleSelected(s, -1);
|
||||||
} else if (Input_IsDownButton(key)) {
|
} else if (Input_IsDownButton(key)) {
|
||||||
Menu_CycleSelected(s, +1);
|
Menu_CycleSelected(s, +1);
|
||||||
} else if (key == CCKEY_ENTER) {
|
} else if (Input_IsEnterButton(key)) {
|
||||||
Menu_ClickSelected(s);
|
Menu_ClickSelected(s);
|
||||||
}
|
}
|
||||||
return Screen_InputDown(screen, key);
|
return Screen_InputDown(screen, key);
|
||||||
@ -1876,7 +1876,7 @@ static int KeyBindsScreen_KeyDown(void* screen, int key) {
|
|||||||
|
|
||||||
if (s->curI == -1) return Menu_InputDown(s, key);
|
if (s->curI == -1) return Menu_InputDown(s, key);
|
||||||
bind = s->binds[s->curI];
|
bind = s->binds[s->curI];
|
||||||
if (key == CCKEY_ESCAPE) key = KeyBind_Defaults[bind];
|
if (Input_IsEscapeButton(key)) key = KeyBind_Defaults[bind];
|
||||||
KeyBind_Set(bind, key);
|
KeyBind_Set(bind, key);
|
||||||
|
|
||||||
idx = s->curI;
|
idx = s->curI;
|
||||||
@ -2144,7 +2144,7 @@ static int MenuInputOverlay_KeyDown(void* screen, int key) {
|
|||||||
struct MenuInputOverlay* s = (struct MenuInputOverlay*)screen;
|
struct MenuInputOverlay* s = (struct MenuInputOverlay*)screen;
|
||||||
if (Elem_HandlesKeyDown(&s->input.base, key)) return true;
|
if (Elem_HandlesKeyDown(&s->input.base, key)) return true;
|
||||||
|
|
||||||
if (key == CCKEY_ENTER || key == CCKEY_KP_ENTER) {
|
if (Input_IsEnterButton(key)) {
|
||||||
MenuInputOverlay_EnterInput(s); return true;
|
MenuInputOverlay_EnterInput(s); return true;
|
||||||
}
|
}
|
||||||
return Menu_InputDown(screen, key);
|
return Menu_InputDown(screen, key);
|
||||||
|
@ -1228,8 +1228,8 @@ static int ChatScreen_KeyDown(void* screen, int key) {
|
|||||||
if (key == KeyBinds[KEYBIND_SEND_CHAT] || key == CCKEY_KP_ENTER) {
|
if (key == KeyBinds[KEYBIND_SEND_CHAT] || key == CCKEY_KP_ENTER) {
|
||||||
ChatScreen_EnterChatInput(s, false);
|
ChatScreen_EnterChatInput(s, false);
|
||||||
#else
|
#else
|
||||||
if (key == KeyBinds[KEYBIND_SEND_CHAT] || key == CCKEY_KP_ENTER || key == CCKEY_ESCAPE) {
|
if (key == KeyBinds[KEYBIND_SEND_CHAT] || key == CCKEY_KP_ENTER || Input_IsEscapeButton(key)) {
|
||||||
ChatScreen_EnterChatInput(s, key == CCKEY_ESCAPE);
|
ChatScreen_EnterChatInput(s, Input_IsEscapeButton(key));
|
||||||
#endif
|
#endif
|
||||||
} else if (key == CCKEY_PAGEUP) {
|
} else if (key == CCKEY_PAGEUP) {
|
||||||
ChatScreen_ScrollChatBy(s, -Gui.Chatlines);
|
ChatScreen_ScrollChatBy(s, -Gui.Chatlines);
|
||||||
@ -1597,7 +1597,7 @@ static int InventoryScreen_KeyDown(void* screen, int key) {
|
|||||||
|
|
||||||
if (key == KeyBinds[KEYBIND_INVENTORY] && s->releasedInv) {
|
if (key == KeyBinds[KEYBIND_INVENTORY] && s->releasedInv) {
|
||||||
Gui_Remove((struct Screen*)s);
|
Gui_Remove((struct Screen*)s);
|
||||||
} else if (key == CCKEY_ENTER && table->selectedIndex != -1) {
|
} else if (Input_IsEnterButton(key) && table->selectedIndex != -1) {
|
||||||
Inventory_SetSelectedBlock(table->blocks[table->selectedIndex]);
|
Inventory_SetSelectedBlock(table->blocks[table->selectedIndex]);
|
||||||
Gui_Remove((struct Screen*)s);
|
Gui_Remove((struct Screen*)s);
|
||||||
} else if (Elem_HandlesKeyDown(table, key)) {
|
} else if (Elem_HandlesKeyDown(table, key)) {
|
||||||
|
@ -155,13 +155,13 @@ void Window_ProcessEvents(double delta) {
|
|||||||
touchBegY = touch.py;
|
touchBegY = touch.py;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input_RawMode) {
|
if (Input.RawMode) {
|
||||||
circlePosition pos;
|
circlePosition pos;
|
||||||
hidCircleRead(&pos);
|
hidCircleRead(&pos);
|
||||||
ProcessJoystickInput(&pos);
|
ProcessJoystickInput(&pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input_RawMode && irrst_result == 0) {
|
if (Input.RawMode && irrst_result == 0) {
|
||||||
circlePosition pos;
|
circlePosition pos;
|
||||||
irrstScanInput();
|
irrstScanInput();
|
||||||
irrstCstickRead(&pos);
|
irrstCstickRead(&pos);
|
||||||
@ -171,8 +171,8 @@ void Window_ProcessEvents(double delta) {
|
|||||||
|
|
||||||
void Cursor_SetPosition(int x, int y) { } // Makes no sense for 3DS
|
void Cursor_SetPosition(int x, int y) { } // Makes no sense for 3DS
|
||||||
|
|
||||||
void Window_EnableRawMouse(void) { Input_RawMode = true; }
|
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||||
void Window_DisableRawMouse(void) { Input_RawMode = false; }
|
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||||
|
|
||||||
void Window_UpdateRawMouse(void) {
|
void Window_UpdateRawMouse(void) {
|
||||||
if (!touchActive) return;
|
if (!touchActive) return;
|
||||||
|
@ -270,7 +270,7 @@ static OSStatus Window_ProcessMouseEvent(EventRef inEvent) {
|
|||||||
Logger_Abort2(res, "Getting mouse position");
|
Logger_Abort2(res, "Getting mouse position");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input_RawMode) {
|
if (Input.RawMode) {
|
||||||
raw.x = 0; raw.y = 0;
|
raw.x = 0; raw.y = 0;
|
||||||
GetEventParameter(inEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(HIPoint), NULL, &raw);
|
GetEventParameter(inEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(HIPoint), NULL, &raw);
|
||||||
Event_RaiseRawMove(&PointerEvents.RawMoved, raw.x, raw.y);
|
Event_RaiseRawMove(&PointerEvents.RawMoved, raw.x, raw.y);
|
||||||
|
@ -110,7 +110,7 @@ static void ProcessPAD_Game(PADStatus* pad) {
|
|||||||
int dx = pad->substickX;
|
int dx = pad->substickX;
|
||||||
int dy = pad->substickY;
|
int dy = pad->substickY;
|
||||||
|
|
||||||
if (Input_RawMode) {
|
if (Input.RawMode) {
|
||||||
// May not be exactly 0 on actual hardware
|
// May not be exactly 0 on actual hardware
|
||||||
if (Math_AbsI(dx) <= 8) dx = 0;
|
if (Math_AbsI(dx) <= 8) dx = 0;
|
||||||
if (Math_AbsI(dy) <= 8) dy = 0;
|
if (Math_AbsI(dy) <= 8) dy = 0;
|
||||||
@ -270,7 +270,7 @@ static void ProcessClassic_Game(void) {
|
|||||||
Input_SetNonRepeatable(KeyBinds[KEYBIND_BACK], mods & CLASSIC_CTRL_BUTTON_DOWN);
|
Input_SetNonRepeatable(KeyBinds[KEYBIND_BACK], mods & CLASSIC_CTRL_BUTTON_DOWN);
|
||||||
Input_SetNonRepeatable(CCPAD_DOWN, mods & CLASSIC_CTRL_BUTTON_DOWN);
|
Input_SetNonRepeatable(CCPAD_DOWN, mods & CLASSIC_CTRL_BUTTON_DOWN);
|
||||||
|
|
||||||
if (Input_RawMode) {
|
if (Input.RawMode) {
|
||||||
ProcessClassic_Joystick(&ctrls.ljs);
|
ProcessClassic_Joystick(&ctrls.ljs);
|
||||||
ProcessClassic_Joystick(&ctrls.rjs);
|
ProcessClassic_Joystick(&ctrls.rjs);
|
||||||
}
|
}
|
||||||
@ -368,8 +368,8 @@ void Window_UpdateRawMouse(void) { }
|
|||||||
|
|
||||||
void Cursor_SetPosition(int x, int y) { } // No point in GameCube/Wii
|
void Cursor_SetPosition(int x, int y) { } // No point in GameCube/Wii
|
||||||
// TODO: Display cursor on Wii when not raw mode
|
// TODO: Display cursor on Wii when not raw mode
|
||||||
void Window_EnableRawMouse(void) { Input_RawMode = true; }
|
void Window_EnableRawMouse(void) { Input.RawMode = true; }
|
||||||
void Window_DisableRawMouse(void) { Input_RawMode = false; }
|
void Window_DisableRawMouse(void) { Input.RawMode = false; }
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
|
@ -60,7 +60,7 @@ void Window_ProcessEvents(double delta) {
|
|||||||
|
|
||||||
int dx = pad.Lx - 127;
|
int dx = pad.Lx - 127;
|
||||||
int dy = pad.Ly - 127;
|
int dy = pad.Ly - 127;
|
||||||
if (Input_RawMode && (Math_AbsI(dx) > 1 || Math_AbsI(dy) > 1)) {
|
if (Input.RawMode && (Math_AbsI(dx) > 1 || Math_AbsI(dy) > 1)) {
|
||||||
//Platform_Log2("RAW: %i, %i", &dx, &dy);
|
//Platform_Log2("RAW: %i, %i", &dx, &dy);
|
||||||
Event_RaiseRawMove(&PointerEvents.RawMoved, dx / 32.0f, dy / 32.0f);
|
Event_RaiseRawMove(&PointerEvents.RawMoved, dx / 32.0f, dy / 32.0f);
|
||||||
}
|
}
|
||||||
@ -162,12 +162,12 @@ void Window_CloseKeyboard(void) { /* TODO implement */ }
|
|||||||
|
|
||||||
void Window_EnableRawMouse(void) {
|
void Window_EnableRawMouse(void) {
|
||||||
RegrabMouse();
|
RegrabMouse();
|
||||||
Input_RawMode = true;
|
Input.RawMode = true;
|
||||||
}
|
}
|
||||||
void Window_UpdateRawMouse(void) { CentreMousePosition(); }
|
void Window_UpdateRawMouse(void) { CentreMousePosition(); }
|
||||||
|
|
||||||
void Window_DisableRawMouse(void) {
|
void Window_DisableRawMouse(void) {
|
||||||
RegrabMouse();
|
RegrabMouse();
|
||||||
Input_RawMode = false;
|
Input.RawMode = false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -243,7 +243,7 @@ void Window_ProcessEvents(double delta) {
|
|||||||
break;
|
break;
|
||||||
case SDL_MOUSEMOTION:
|
case SDL_MOUSEMOTION:
|
||||||
Pointer_SetPosition(0, e.motion.x, e.motion.y);
|
Pointer_SetPosition(0, e.motion.x, e.motion.y);
|
||||||
if (Input_RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, e.motion.xrel, e.motion.yrel);
|
if (Input.RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, e.motion.xrel, e.motion.yrel);
|
||||||
break;
|
break;
|
||||||
case SDL_TEXTINPUT:
|
case SDL_TEXTINPUT:
|
||||||
OnTextEvent(&e); break;
|
OnTextEvent(&e); break;
|
||||||
@ -339,14 +339,14 @@ void Window_CloseKeyboard(void) { SDL_StopTextInput(); }
|
|||||||
void Window_EnableRawMouse(void) {
|
void Window_EnableRawMouse(void) {
|
||||||
RegrabMouse();
|
RegrabMouse();
|
||||||
SDL_SetRelativeMouseMode(true);
|
SDL_SetRelativeMouseMode(true);
|
||||||
Input_RawMode = true;
|
Input.RawMode = true;
|
||||||
}
|
}
|
||||||
void Window_UpdateRawMouse(void) { CentreMousePosition(); }
|
void Window_UpdateRawMouse(void) { CentreMousePosition(); }
|
||||||
|
|
||||||
void Window_DisableRawMouse(void) {
|
void Window_DisableRawMouse(void) {
|
||||||
RegrabMouse();
|
RegrabMouse();
|
||||||
SDL_SetRelativeMouseMode(false);
|
SDL_SetRelativeMouseMode(false);
|
||||||
Input_RawMode = false;
|
Input.RawMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ static void SetFullscreenBounds(void) {
|
|||||||
/* Browser only allows pointer lock requests in response to user input */
|
/* Browser only allows pointer lock requests in response to user input */
|
||||||
static void DeferredEnableRawMouse(void) {
|
static void DeferredEnableRawMouse(void) {
|
||||||
EmscriptenPointerlockChangeEvent status;
|
EmscriptenPointerlockChangeEvent status;
|
||||||
if (!Input_RawMode) return;
|
if (!Input.RawMode) return;
|
||||||
|
|
||||||
status.isActive = false;
|
status.isActive = false;
|
||||||
emscripten_get_pointerlock_status(&status);
|
emscripten_get_pointerlock_status(&status);
|
||||||
@ -92,7 +92,7 @@ static EM_BOOL OnMouseMove(int type, const EmscriptenMouseEvent* ev, void* data)
|
|||||||
x = ev->targetX; y = ev->targetY;
|
x = ev->targetX; y = ev->targetY;
|
||||||
RescaleXY(&x, &y);
|
RescaleXY(&x, &y);
|
||||||
Pointer_SetPosition(0, x, y);
|
Pointer_SetPosition(0, x, y);
|
||||||
if (Input_RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, ev->movementX, ev->movementY);
|
if (Input.RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, ev->movementX, ev->movementY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -632,14 +632,14 @@ void Window_CloseKeyboard(void) {
|
|||||||
void Window_EnableRawMouse(void) {
|
void Window_EnableRawMouse(void) {
|
||||||
RegrabMouse();
|
RegrabMouse();
|
||||||
/* defer pointerlock request until next user input */
|
/* defer pointerlock request until next user input */
|
||||||
Input_RawMode = true;
|
Input.RawMode = true;
|
||||||
}
|
}
|
||||||
void Window_UpdateRawMouse(void) { }
|
void Window_UpdateRawMouse(void) { }
|
||||||
|
|
||||||
void Window_DisableRawMouse(void) {
|
void Window_DisableRawMouse(void) {
|
||||||
RegrabMouse();
|
RegrabMouse();
|
||||||
emscripten_exit_pointerlock();
|
emscripten_exit_pointerlock();
|
||||||
Input_RawMode = false;
|
Input.RawMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ static void RefreshWindowBounds(void) {
|
|||||||
|
|
||||||
static void GrabCursor(void) {
|
static void GrabCursor(void) {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
if (!grabCursor || !Input_RawMode) return;
|
if (!grabCursor || !Input.RawMode) return;
|
||||||
|
|
||||||
GetWindowRect(win_handle, &rect);
|
GetWindowRect(win_handle, &rect);
|
||||||
ClipCursor(&rect);
|
ClipCursor(&rect);
|
||||||
@ -209,7 +209,7 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara
|
|||||||
dy = absY - prevPosY; prevPosY = absY;
|
dy = absY - prevPosY; prevPosY = absY;
|
||||||
} else { break; }
|
} else { break; }
|
||||||
|
|
||||||
if (Input_RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, (float)dx, (float)dy);
|
if (Input.RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, (float)dx, (float)dy);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case WM_KEYDOWN:
|
case WM_KEYDOWN:
|
||||||
|
@ -1161,7 +1161,7 @@ static void HandleGenericEvent(XEvent* e) {
|
|||||||
if (!rawMouseSupported || e->xcookie.extension != xiOpcode) return;
|
if (!rawMouseSupported || e->xcookie.extension != xiOpcode) return;
|
||||||
if (!XGetEventData(win_display, &e->xcookie)) return;
|
if (!XGetEventData(win_display, &e->xcookie)) return;
|
||||||
|
|
||||||
if (e->xcookie.evtype == XI_RawMotion && Input_RawMode) {
|
if (e->xcookie.evtype == XI_RawMotion && Input.RawMode) {
|
||||||
ev = (XIRawEvent*)e->xcookie.data;
|
ev = (XIRawEvent*)e->xcookie.data;
|
||||||
values = ev->raw_values;
|
values = ev->raw_values;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ static void RegrabMouse(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void DefaultEnableRawMouse(void) {
|
static void DefaultEnableRawMouse(void) {
|
||||||
Input_RawMode = true;
|
Input.RawMode = true;
|
||||||
RegrabMouse();
|
RegrabMouse();
|
||||||
Cursor_SetVisible(false);
|
Cursor_SetVisible(false);
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ static void DefaultUpdateRawMouse(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void DefaultDisableRawMouse(void) {
|
static void DefaultDisableRawMouse(void) {
|
||||||
Input_RawMode = false;
|
Input.RawMode = false;
|
||||||
RegrabMouse();
|
RegrabMouse();
|
||||||
Cursor_SetVisible(true);
|
Cursor_SetVisible(true);
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ static void DefaultDisableRawMouse(void) {
|
|||||||
static void ShowDialogCore(const char* title, const char* msg);
|
static void ShowDialogCore(const char* title, const char* msg);
|
||||||
void Window_ShowDialog(const char* title, const char* msg) {
|
void Window_ShowDialog(const char* title, const char* msg) {
|
||||||
/* Ensure cursor is usable while showing message box */
|
/* Ensure cursor is usable while showing message box */
|
||||||
cc_bool rawMode = Input_RawMode;
|
cc_bool rawMode = Input.RawMode;
|
||||||
|
|
||||||
if (rawMode) Window_DisableRawMouse();
|
if (rawMode) Window_DisableRawMouse();
|
||||||
ShowDialogCore(title, msg);
|
ShowDialogCore(title, msg);
|
||||||
|
@ -527,7 +527,7 @@ void Window_ProcessEvents(double delta) {
|
|||||||
case 27: // NSOtherMouseDragged
|
case 27: // NSOtherMouseDragged
|
||||||
if (GetMouseCoords(&x, &y)) Pointer_SetPosition(0, x, y);
|
if (GetMouseCoords(&x, &y)) Pointer_SetPosition(0, x, y);
|
||||||
|
|
||||||
if (Input_RawMode) {
|
if (Input.RawMode) {
|
||||||
dx = [ev deltaX];
|
dx = [ev deltaX];
|
||||||
dy = [ev deltaY];
|
dy = [ev deltaY];
|
||||||
Event_RaiseRawMove(&PointerEvents.RawMoved, dx, dy);
|
Event_RaiseRawMove(&PointerEvents.RawMoved, dx, dy);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user