mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Virtual keyboard: X for backspace, Y for space
This commit is contained in:
parent
82529852f4
commit
7af80a9223
@ -291,6 +291,15 @@ void Input_Clear(void) {
|
||||
ClearTouches();
|
||||
}
|
||||
|
||||
int Input_CalcDelta(int key, int horDelta, int verDelta) {
|
||||
if (Input_IsLeftButton(key) || key == CCKEY_KP4) return -horDelta;
|
||||
if (Input_IsRightButton(key) || key == CCKEY_KP6) return +horDelta;
|
||||
if (Input_IsUpButton(key) || key == CCKEY_KP8) return -verDelta;
|
||||
if (Input_IsDownButton(key) || key == CCKEY_KP2) return +verDelta;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*----------------------------------------------------------Mouse----------------------------------------------------------*
|
||||
|
@ -106,6 +106,7 @@ void Input_Clear(void);
|
||||
#else
|
||||
#define Input_IsActionPressed() Input_IsCtrlPressed()
|
||||
#endif
|
||||
int Input_CalcDelta(int btn, int horDelta, int verDelta);
|
||||
|
||||
|
||||
#ifdef CC_BUILD_TOUCH
|
||||
|
@ -380,14 +380,9 @@ static void ColoursScreen_MouseWheel(struct LScreen* s_, float delta) {
|
||||
}
|
||||
|
||||
static void ColoursScreen_KeyDown(struct LScreen* s, int key, cc_bool was) {
|
||||
if (Input_IsLeftButton(key)) {
|
||||
ColoursScreen_AdjustSelected(s, -1);
|
||||
} else if (Input_IsRightButton(key)) {
|
||||
ColoursScreen_AdjustSelected(s, +1);
|
||||
} else if (Input_IsUpButton(key)) {
|
||||
ColoursScreen_AdjustSelected(s, +10);
|
||||
} else if (Input_IsDownButton(key)) {
|
||||
ColoursScreen_AdjustSelected(s, -10);
|
||||
int delta = Input_CalcDelta(key, 1, 10);
|
||||
if (delta) {
|
||||
ColoursScreen_AdjustSelected(s, delta);
|
||||
} else {
|
||||
LScreen_KeyDown(s, key, was);
|
||||
}
|
||||
|
@ -154,6 +154,12 @@ static void VirtualKeyboard_AppendChar(char c) {
|
||||
if (kb_shift) { VirtualKeyboard_ToggleTable(); kb_shift = false; }
|
||||
}
|
||||
|
||||
static void VirtualKeyboard_Backspace(void) {
|
||||
if (kb_str.length) kb_str.length--;
|
||||
Event_RaiseString(&InputEvents.TextChanged, &kb_str);
|
||||
KB_MarkDirty();
|
||||
}
|
||||
|
||||
static void VirtualKeyboard_ClickSelected(void) {
|
||||
int selected = VirtualKeyboard_GetSelected();
|
||||
if (selected < 0) return;
|
||||
@ -161,9 +167,7 @@ static void VirtualKeyboard_ClickSelected(void) {
|
||||
/* TODO kinda hacky, redo this */
|
||||
switch (selected) {
|
||||
case KB_INDEX(KB_LAST_CELL, 0):
|
||||
if (kb_str.length) kb_str.length--;
|
||||
Event_RaiseString(&InputEvents.TextChanged, &kb_str);
|
||||
KB_MarkDirty();
|
||||
VirtualKeyboard_Backspace();
|
||||
break;
|
||||
case KB_INDEX(KB_LAST_CELL, 2):
|
||||
OnscreenKeyboard_Close();
|
||||
@ -192,20 +196,20 @@ static void VirtualKeyboard_ClickSelected(void) {
|
||||
}
|
||||
|
||||
static void VirtualKeyboard_ProcessDown(void* obj, int key, cc_bool was) {
|
||||
if (Input_IsLeftButton(key)) {
|
||||
VirtualKeyboard_Scroll(-1);
|
||||
} else if (Input_IsRightButton(key)) {
|
||||
VirtualKeyboard_Scroll(+1);
|
||||
} else if (Input_IsUpButton(key)) {
|
||||
VirtualKeyboard_Scroll(-KB_CELLS_PER_ROW);
|
||||
} else if (Input_IsDownButton(key)) {
|
||||
VirtualKeyboard_Scroll(+KB_CELLS_PER_ROW);
|
||||
} else if (Input_IsEnterButton(key) || key == CCPAD_A) {
|
||||
int delta = Input_CalcDelta(key, 1, KB_CELLS_PER_ROW);
|
||||
if (delta) {
|
||||
VirtualKeyboard_Scroll(delta);
|
||||
} else if (key == CCPAD_START || key == CCPAD_A) {
|
||||
VirtualKeyboard_ClickSelected();
|
||||
} else if (Input_IsEscapeButton(key) || key == CCPAD_B) {
|
||||
} else if (key == CCPAD_SELECT || key == CCPAD_B) {
|
||||
VirtualKeyboard_Close();
|
||||
} else if (key == CCPAD_X) {
|
||||
VirtualKeyboard_Backspace();
|
||||
} else if (key == CCPAD_Y) {
|
||||
VirtualKeyboard_AppendChar(' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void VirtualKeyboard_PadAxis(void* obj, int port, int axis, float x, float y) {
|
||||
int xSteps, ySteps;
|
||||
|
@ -975,20 +975,15 @@ static int TableWidget_PointerMove(void* widget, int id, int x, int y) {
|
||||
|
||||
static int TableWidget_KeyDown(void* widget, int key) {
|
||||
struct TableWidget* w = (struct TableWidget*)widget;
|
||||
int delta;
|
||||
if (w->selectedIndex == -1) return false;
|
||||
|
||||
if (Input_IsLeftButton(key) || key == CCKEY_KP4) {
|
||||
TableWidget_ScrollRelative(w, -1);
|
||||
} else if (Input_IsRightButton(key) || key == CCKEY_KP6) {
|
||||
TableWidget_ScrollRelative(w, 1);
|
||||
} else if (Input_IsUpButton(key) || key == CCKEY_KP8) {
|
||||
TableWidget_ScrollRelative(w, -w->blocksPerRow);
|
||||
} else if (Input_IsDownButton(key) || key == CCKEY_KP2) {
|
||||
TableWidget_ScrollRelative(w, w->blocksPerRow);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
delta = Input_CalcDelta(key, 1, w->blocksPerRow);
|
||||
if (delta) {
|
||||
TableWidget_ScrollRelative(w, delta);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int TableWidget_PadAxis(void* widget, int axis, float x, float y) {
|
||||
|
@ -53,7 +53,7 @@ static cc_bool is_ansiWindow, grabCursor;
|
||||
static int windowX, windowY;
|
||||
|
||||
static const cc_uint8 key_map[14 * 16] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, CCKEY_BACKSPACE, CCKEY_TAB, 0, 0, 0, CCKEY_ENTER, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, CCKEY_BACKSPACE, CCKEY_TAB, 0, 0, CCKEY_F5, CCKEY_ENTER, 0, 0,
|
||||
0, 0, 0, CCKEY_PAUSE, CCKEY_CAPSLOCK, 0, 0, 0, 0, 0, 0, CCKEY_ESCAPE, 0, 0, 0, 0,
|
||||
CCKEY_SPACE, CCKEY_PAGEUP, CCKEY_PAGEDOWN, CCKEY_END, CCKEY_HOME, CCKEY_LEFT, CCKEY_UP, CCKEY_RIGHT, CCKEY_DOWN, 0, CCKEY_PRINTSCREEN, 0, CCKEY_PRINTSCREEN, CCKEY_INSERT, CCKEY_DELETE, 0,
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 0, 0, 0, 0, 0, 0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user