mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
don't typedef key, initial framework for textchanged event
This commit is contained in:
parent
0aaf343ab7
commit
b1ea7243a7
@ -1028,7 +1028,7 @@ static cc_bool LocalPlayer_HandleNoClip(void) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool LocalPlayer_HandlesKey(Key key) {
|
cc_bool LocalPlayer_HandlesKey(int key) {
|
||||||
struct LocalPlayer* p = &LocalPlayer_Instance;
|
struct LocalPlayer* p = &LocalPlayer_Instance;
|
||||||
struct HacksComp* hacks = &p->Hacks;
|
struct HacksComp* hacks = &p->Hacks;
|
||||||
struct PhysicsComp* physics = &p->Physics;
|
struct PhysicsComp* physics = &p->Physics;
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
#include "EntityComponents.h"
|
#include "EntityComponents.h"
|
||||||
#include "Physics.h"
|
#include "Physics.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "Input.h"
|
|
||||||
#include "PackedCol.h"
|
#include "PackedCol.h"
|
||||||
/* Represents an in-game entity.
|
/* Represents an in-game entity.
|
||||||
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
||||||
@ -202,5 +201,5 @@ float LocalPlayer_JumpHeight(void);
|
|||||||
void LocalPlayer_SetInterpPosition(float t);
|
void LocalPlayer_SetInterpPosition(float t);
|
||||||
/* Returns whether local player handles a key being pressed. */
|
/* Returns whether local player handles a key being pressed. */
|
||||||
/* e.g. for respawn, toggle fly, etc. */
|
/* e.g. for respawn, toggle fly, etc. */
|
||||||
cc_bool LocalPlayer_HandlesKey(Key key);
|
cc_bool LocalPlayer_HandlesKey(int key);
|
||||||
#endif
|
#endif
|
||||||
|
12
src/Gui.h
12
src/Gui.h
@ -1,6 +1,5 @@
|
|||||||
#ifndef CC_GUI_H
|
#ifndef CC_GUI_H
|
||||||
#define CC_GUI_H
|
#define CC_GUI_H
|
||||||
#include "Input.h"
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
#include "VertexStructs.h"
|
#include "VertexStructs.h"
|
||||||
/* Describes and manages 2D GUI elements on screen.
|
/* Describes and manages 2D GUI elements on screen.
|
||||||
@ -44,11 +43,14 @@ struct ScreenVTABLE {
|
|||||||
/* Frees/releases persistent state. */
|
/* Frees/releases persistent state. */
|
||||||
void (*Free)(void* elem);
|
void (*Free)(void* elem);
|
||||||
/* Returns non-zero if an input press is handled. */
|
/* Returns non-zero if an input press is handled. */
|
||||||
int (*HandlesKeyDown)(void* elem, Key key);
|
int (*HandlesKeyDown)(void* elem, int key);
|
||||||
/* Returns non-zero if an input release is handled. */
|
/* Returns non-zero if an input release is handled. */
|
||||||
int (*HandlesKeyUp)(void* elem, Key key);
|
int (*HandlesKeyUp)(void* elem, int key);
|
||||||
/* Returns non-zero if a key character press is handled. */
|
/* Returns non-zero if a key character press is handled. */
|
||||||
int (*HandlesKeyPress)(void* elem, char keyChar);
|
int (*HandlesKeyPress)(void* elem, char keyChar);
|
||||||
|
/* Returns non-zero if a key character press is handled. */
|
||||||
|
/* Currently only raised by on-screen keyboard in web client. */
|
||||||
|
int (*HandlesTextChanged)(void* elem, const String* str);
|
||||||
/* Returns non-zero if a pointer press is handled. */
|
/* Returns non-zero if a pointer press is handled. */
|
||||||
int (*HandlesPointerDown)(void* elem, int id, int x, int y);
|
int (*HandlesPointerDown)(void* elem, int id, int x, int y);
|
||||||
/* Returns non-zero if a pointer release is handled. */
|
/* Returns non-zero if a pointer release is handled. */
|
||||||
@ -82,9 +84,9 @@ struct WidgetVTABLE {
|
|||||||
/* Positions this widget on-screen. */
|
/* Positions this widget on-screen. */
|
||||||
void (*Reposition)(void* elem);
|
void (*Reposition)(void* elem);
|
||||||
/* Returns non-zero if an input press is handled. */
|
/* Returns non-zero if an input press is handled. */
|
||||||
int (*HandlesKeyDown)(void* elem, Key key);
|
int (*HandlesKeyDown)(void* elem, int key);
|
||||||
/* Returns non-zero if an input release is handled. */
|
/* Returns non-zero if an input release is handled. */
|
||||||
int (*HandlesKeyUp)(void* elem, Key key);
|
int (*HandlesKeyUp)(void* elem, int key);
|
||||||
/* Returns non-zero if a mouse wheel scroll is handled. */
|
/* Returns non-zero if a mouse wheel scroll is handled. */
|
||||||
int (*HandlesMouseScroll)(void* elem, float delta);
|
int (*HandlesMouseScroll)(void* elem, float delta);
|
||||||
/* Returns non-zero if a pointer press is handled. */
|
/* Returns non-zero if a pointer press is handled. */
|
||||||
|
32
src/Input.c
32
src/Input.c
@ -185,7 +185,7 @@ const char* const Input_Names[INPUT_COUNT] = {
|
|||||||
"XBUTTON1", "XBUTTON2", "MMOUSE"
|
"XBUTTON1", "XBUTTON2", "MMOUSE"
|
||||||
};*/
|
};*/
|
||||||
|
|
||||||
void Input_SetPressed(Key key, cc_bool pressed) {
|
void Input_SetPressed(int key, cc_bool pressed) {
|
||||||
cc_bool wasPressed = Input_Pressed[key];
|
cc_bool wasPressed = Input_Pressed[key];
|
||||||
Input_Pressed[key] = pressed;
|
Input_Pressed[key] = pressed;
|
||||||
|
|
||||||
@ -277,7 +277,7 @@ cc_bool KeyBind_IsPressed(KeyBind binding) { return Input_Pressed[KeyBinds[bindi
|
|||||||
|
|
||||||
static void KeyBind_Load(void) {
|
static void KeyBind_Load(void) {
|
||||||
String name; char nameBuffer[STRING_SIZE + 1];
|
String name; char nameBuffer[STRING_SIZE + 1];
|
||||||
Key mapping;
|
int mapping;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
String_InitArray_NT(name, nameBuffer);
|
String_InitArray_NT(name, nameBuffer);
|
||||||
@ -306,7 +306,7 @@ static void KeyBind_Save(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyBind_Set(KeyBind binding, Key key) {
|
void KeyBind_Set(KeyBind binding, int key) {
|
||||||
KeyBinds[binding] = key;
|
KeyBinds[binding] = key;
|
||||||
KeyBind_Save();
|
KeyBind_Save();
|
||||||
}
|
}
|
||||||
@ -363,7 +363,7 @@ static void Hotkeys_QuickSort(int left, int right) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Hotkeys_AddNewHotkey(Key trigger, cc_uint8 modifiers, const String* text, cc_bool more) {
|
static void Hotkeys_AddNewHotkey(int trigger, cc_uint8 modifiers, const String* text, cc_bool more) {
|
||||||
struct HotkeyData hKey;
|
struct HotkeyData hKey;
|
||||||
hKey.Trigger = trigger;
|
hKey.Trigger = trigger;
|
||||||
hKey.Flags = modifiers;
|
hKey.Flags = modifiers;
|
||||||
@ -392,7 +392,7 @@ static void Hotkeys_RemoveText(int index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Hotkeys_Add(Key trigger, cc_uint8 modifiers, const String* text, cc_bool more) {
|
void Hotkeys_Add(int trigger, cc_uint8 modifiers, const String* text, cc_bool more) {
|
||||||
struct HotkeyData* hk = HotkeysList;
|
struct HotkeyData* hk = HotkeysList;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -408,7 +408,7 @@ void Hotkeys_Add(Key trigger, cc_uint8 modifiers, const String* text, cc_bool mo
|
|||||||
Hotkeys_AddNewHotkey(trigger, modifiers, text, more);
|
Hotkeys_AddNewHotkey(trigger, modifiers, text, more);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Hotkeys_Remove(Key trigger, cc_uint8 modifiers) {
|
cc_bool Hotkeys_Remove(int trigger, cc_uint8 modifiers) {
|
||||||
struct HotkeyData* hk = HotkeysList;
|
struct HotkeyData* hk = HotkeysList;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
@ -424,7 +424,7 @@ cc_bool Hotkeys_Remove(Key trigger, cc_uint8 modifiers) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Hotkeys_FindPartial(Key key) {
|
int Hotkeys_FindPartial(int key) {
|
||||||
struct HotkeyData hk;
|
struct HotkeyData hk;
|
||||||
int i, modifiers = 0;
|
int i, modifiers = 0;
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ static void Hotkeys_Init(void) {
|
|||||||
String entry, key, value;
|
String entry, key, value;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
Key trigger;
|
int trigger;
|
||||||
cc_uint8 modifiers;
|
cc_uint8 modifiers;
|
||||||
cc_bool more;
|
cc_bool more;
|
||||||
|
|
||||||
@ -471,7 +471,7 @@ static void Hotkeys_Init(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hotkeys_UserRemovedHotkey(Key trigger, cc_uint8 modifiers) {
|
void Hotkeys_UserRemovedHotkey(int trigger, cc_uint8 modifiers) {
|
||||||
String key; char keyBuffer[STRING_SIZE];
|
String key; char keyBuffer[STRING_SIZE];
|
||||||
String_InitArray(key, keyBuffer);
|
String_InitArray(key, keyBuffer);
|
||||||
|
|
||||||
@ -479,7 +479,7 @@ void Hotkeys_UserRemovedHotkey(Key trigger, cc_uint8 modifiers) {
|
|||||||
Options_SetString(&key, NULL);
|
Options_SetString(&key, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hotkeys_UserAddedHotkey(Key trigger, cc_uint8 modifiers, cc_bool moreInput, const String* text) {
|
void Hotkeys_UserAddedHotkey(int trigger, cc_uint8 modifiers, cc_bool moreInput, const String* text) {
|
||||||
String key; char keyBuffer[STRING_SIZE];
|
String key; char keyBuffer[STRING_SIZE];
|
||||||
String value; char valueBuffer[STRING_SIZE * 2];
|
String value; char valueBuffer[STRING_SIZE * 2];
|
||||||
String_InitArray(key, keyBuffer);
|
String_InitArray(key, keyBuffer);
|
||||||
@ -728,7 +728,7 @@ void InputHandler_PickBlocks(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*------------------------------------------------------Key helpers--------------------------------------------------------*
|
*------------------------------------------------------Key helpers--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static cc_bool InputHandler_IsShutdown(Key key) {
|
static cc_bool InputHandler_IsShutdown(int key) {
|
||||||
if (key == KEY_F4 && Key_IsAltPressed()) return true;
|
if (key == KEY_F4 && Key_IsAltPressed()) return true;
|
||||||
|
|
||||||
/* On OSX, Cmd+Q should also terminate the process */
|
/* On OSX, Cmd+Q should also terminate the process */
|
||||||
@ -739,7 +739,7 @@ static cc_bool InputHandler_IsShutdown(Key key) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InputHandler_Toggle(Key key, cc_bool* target, const char* enableMsg, const char* disableMsg) {
|
static void InputHandler_Toggle(int key, cc_bool* target, const char* enableMsg, const char* disableMsg) {
|
||||||
*target = !(*target);
|
*target = !(*target);
|
||||||
if (*target) {
|
if (*target) {
|
||||||
Chat_Add2("%c. &ePress &a%c &eto disable.", enableMsg, Input_Names[key]);
|
Chat_Add2("%c. &ePress &a%c &eto disable.", enableMsg, Input_Names[key]);
|
||||||
@ -800,7 +800,7 @@ static void InputHandler_CheckZoomFov(void* obj) {
|
|||||||
if (!h->Enabled || !h->CanUseThirdPersonCamera) Game_SetFov(Game_DefaultFov);
|
if (!h->Enabled || !h->CanUseThirdPersonCamera) Game_SetFov(Game_DefaultFov);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool HandleBlockKey(Key key) {
|
static cc_bool HandleBlockKey(int key) {
|
||||||
if (Gui_GetInputGrab()) return false;
|
if (Gui_GetInputGrab()) return false;
|
||||||
|
|
||||||
if (key == KeyBinds[KEYBIND_DELETE_BLOCK]) {
|
if (key == KeyBinds[KEYBIND_DELETE_BLOCK]) {
|
||||||
@ -818,7 +818,7 @@ static cc_bool HandleBlockKey(Key key) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool HandleNonClassicKey(Key key) {
|
static cc_bool HandleNonClassicKey(int key) {
|
||||||
if (key == KeyBinds[KEYBIND_HIDE_GUI]) {
|
if (key == KeyBinds[KEYBIND_HIDE_GUI]) {
|
||||||
Game_HideGui = !Game_HideGui;
|
Game_HideGui = !Game_HideGui;
|
||||||
} else if (key == KeyBinds[KEYBIND_SMOOTH_CAMERA]) {
|
} else if (key == KeyBinds[KEYBIND_SMOOTH_CAMERA]) {
|
||||||
@ -854,7 +854,7 @@ static cc_bool HandleNonClassicKey(Key key) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool HandleCoreKey(Key key) {
|
static cc_bool HandleCoreKey(int key) {
|
||||||
cc_result res;
|
cc_result res;
|
||||||
|
|
||||||
if (key == KeyBinds[KEYBIND_HIDE_FPS]) {
|
if (key == KeyBinds[KEYBIND_HIDE_FPS]) {
|
||||||
@ -888,7 +888,7 @@ static cc_bool HandleCoreKey(Key key) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HandleHotkeyDown(Key key) {
|
static void HandleHotkeyDown(int key) {
|
||||||
struct HotkeyData* hkey;
|
struct HotkeyData* hkey;
|
||||||
String text;
|
String text;
|
||||||
int i = Hotkeys_FindPartial(key);
|
int i = Hotkeys_FindPartial(key);
|
||||||
|
17
src/Input.h
17
src/Input.h
@ -6,7 +6,7 @@
|
|||||||
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum Key_ {
|
enum Key {
|
||||||
KEY_NONE, /* Unrecognised key */
|
KEY_NONE, /* Unrecognised key */
|
||||||
|
|
||||||
KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10,
|
KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10,
|
||||||
@ -44,7 +44,6 @@ enum Key_ {
|
|||||||
KEY_XBUTTON1, KEY_XBUTTON2, KEY_LMOUSE, KEY_RMOUSE, KEY_MMOUSE,
|
KEY_XBUTTON1, KEY_XBUTTON2, KEY_LMOUSE, KEY_RMOUSE, KEY_MMOUSE,
|
||||||
INPUT_COUNT
|
INPUT_COUNT
|
||||||
};
|
};
|
||||||
typedef int Key;
|
|
||||||
|
|
||||||
/* Simple names for each keyboard button. */
|
/* Simple names for each keyboard button. */
|
||||||
extern const char* const Input_Names[INPUT_COUNT];
|
extern const char* const Input_Names[INPUT_COUNT];
|
||||||
@ -66,7 +65,7 @@ extern cc_bool Input_Pressed[INPUT_COUNT];
|
|||||||
/* Sets the pressed state of a keyboard button. */
|
/* Sets the pressed state of a keyboard button. */
|
||||||
/* Raises InputEvents.Up if not pressed, but was pressed before. */
|
/* Raises InputEvents.Up if not pressed, but was pressed before. */
|
||||||
/* Raises InputEvents.Down if pressed (repeating is whether it was pressed before) */
|
/* Raises InputEvents.Down if pressed (repeating is whether it was pressed before) */
|
||||||
void Input_SetPressed(Key key, cc_bool pressed);
|
void Input_SetPressed(int key, cc_bool pressed);
|
||||||
/* Resets all keyboard keys to released state. */
|
/* Resets all keyboard keys to released state. */
|
||||||
/* Raises InputEvents.Up for each previously pressed key. */
|
/* Raises InputEvents.Up for each previously pressed key. */
|
||||||
void Key_Clear(void);
|
void Key_Clear(void);
|
||||||
@ -125,7 +124,7 @@ extern const cc_uint8 KeyBind_Defaults[KEYBIND_COUNT];
|
|||||||
/* Gets whether the key bound to the given key binding is pressed. */
|
/* Gets whether the key bound to the given key binding is pressed. */
|
||||||
cc_bool KeyBind_IsPressed(KeyBind binding);
|
cc_bool KeyBind_IsPressed(KeyBind binding);
|
||||||
/* Set the key that the given key binding is bound to. (also updates options list) */
|
/* Set the key that the given key binding is bound to. (also updates options list) */
|
||||||
void KeyBind_Set(KeyBind binding, Key key);
|
void KeyBind_Set(KeyBind binding, int key);
|
||||||
|
|
||||||
extern const cc_uint8 Hotkeys_LWJGL[256];
|
extern const cc_uint8 Hotkeys_LWJGL[256];
|
||||||
struct HotkeyData {
|
struct HotkeyData {
|
||||||
@ -143,16 +142,16 @@ enum HotkeyModifiers {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Adds or updates a new hotkey. */
|
/* Adds or updates a new hotkey. */
|
||||||
void Hotkeys_Add(Key trigger, cc_uint8 modifiers, const String* text, cc_bool more);
|
void Hotkeys_Add(int trigger, cc_uint8 modifiers, const String* text, cc_bool more);
|
||||||
/* Removes the given hotkey. */
|
/* Removes the given hotkey. */
|
||||||
cc_bool Hotkeys_Remove(Key trigger, cc_uint8 modifiers);
|
cc_bool Hotkeys_Remove(int trigger, cc_uint8 modifiers);
|
||||||
/* Returns the first hotkey which is bound to the given key and has its modifiers pressed. */
|
/* Returns the first hotkey which is bound to the given key and has its modifiers pressed. */
|
||||||
/* NOTE: The hotkeys list is sorted, so hotkeys with most modifiers are checked first. */
|
/* NOTE: The hotkeys list is sorted, so hotkeys with most modifiers are checked first. */
|
||||||
int Hotkeys_FindPartial(Key key);
|
int Hotkeys_FindPartial(int key);
|
||||||
/* Called when user has removed a hotkey. (removes it from options) */
|
/* Called when user has removed a hotkey. (removes it from options) */
|
||||||
void Hotkeys_UserRemovedHotkey(Key trigger, cc_uint8 modifiers);
|
void Hotkeys_UserRemovedHotkey(int trigger, cc_uint8 modifiers);
|
||||||
/* Called when user has added a hotkey. (Adds it to options) */
|
/* Called when user has added a hotkey. (Adds it to options) */
|
||||||
void Hotkeys_UserAddedHotkey(Key trigger, cc_uint8 modifiers, cc_bool moreInput, const String* text);
|
void Hotkeys_UserAddedHotkey(int trigger, cc_uint8 modifiers, cc_bool moreInput, const String* text);
|
||||||
|
|
||||||
cc_bool InputHandler_SetFOV(int fov);
|
cc_bool InputHandler_SetFOV(int fov);
|
||||||
void InputHandler_PickBlocks(void);
|
void InputHandler_PickBlocks(void);
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "Resources.h"
|
#include "Resources.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
#include "Input.h"
|
||||||
|
|
||||||
#ifndef CC_BUILD_WEB
|
#ifndef CC_BUILD_WEB
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
@ -91,7 +92,7 @@ static void LScreen_HandleTab(struct LScreen* s) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LScreen_KeyDown(struct LScreen* s, Key key, cc_bool was) {
|
static void LScreen_KeyDown(struct LScreen* s, int key, cc_bool was) {
|
||||||
if (key == KEY_TAB) {
|
if (key == KEY_TAB) {
|
||||||
LScreen_HandleTab(s);
|
LScreen_HandleTab(s);
|
||||||
} else if (key == KEY_ENTER) {
|
} else if (key == KEY_ENTER) {
|
||||||
@ -400,7 +401,7 @@ static void ColoursScreen_MouseWheel(struct LScreen* s_, float delta) {
|
|||||||
ColoursScreen_AdjustSelected(s_, steps);
|
ColoursScreen_AdjustSelected(s_, steps);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ColoursScreen_KeyDown(struct LScreen* s, Key key, cc_bool was) {
|
static void ColoursScreen_KeyDown(struct LScreen* s, int key, cc_bool was) {
|
||||||
if (key == KEY_LEFT) {
|
if (key == KEY_LEFT) {
|
||||||
ColoursScreen_AdjustSelected(s, -1);
|
ColoursScreen_AdjustSelected(s, -1);
|
||||||
} else if (key == KEY_RIGHT) {
|
} else if (key == KEY_RIGHT) {
|
||||||
@ -1265,7 +1266,7 @@ static void ServersScreen_MouseWheel(struct LScreen* s_, float delta) {
|
|||||||
s->table.VTABLE->MouseWheel(&s->table, delta);
|
s->table.VTABLE->MouseWheel(&s->table, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ServersScreen_KeyDown(struct LScreen* s_, Key key, cc_bool was) {
|
static void ServersScreen_KeyDown(struct LScreen* s_, int key, cc_bool was) {
|
||||||
struct ServersScreen* s = (struct ServersScreen*)s_;
|
struct ServersScreen* s = (struct ServersScreen*)s_;
|
||||||
if (!LTable_HandlesKey(key)) {
|
if (!LTable_HandlesKey(key)) {
|
||||||
LScreen_KeyDown(s_, key, was);
|
LScreen_KeyDown(s_, key, was);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#ifndef CC_LSCREENS_H
|
#ifndef CC_LSCREENS_H
|
||||||
#define CC_LSCREENS_H
|
#define CC_LSCREENS_H
|
||||||
#include "Input.h"
|
#include "Core.h"
|
||||||
/* Implements screens/menus for the launcher.
|
/* Implements screens/menus for the launcher.
|
||||||
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
||||||
*/
|
*/
|
||||||
@ -17,7 +17,7 @@ typedef void (*LWidget_Func)(struct LScreen* s, struct LWidget* w);
|
|||||||
LScreen_Func Draw; /* Draws all widgets and any other features such as lines/rectangles. */ \
|
LScreen_Func Draw; /* Draws all widgets and any other features such as lines/rectangles. */ \
|
||||||
LScreen_Func Tick; /* Repeatedly called multiple times every second. */ \
|
LScreen_Func Tick; /* Repeatedly called multiple times every second. */ \
|
||||||
LScreen_Func OnDisplay; /* Called when framebuffer is about to be displayed. */ \
|
LScreen_Func OnDisplay; /* Called when framebuffer is about to be displayed. */ \
|
||||||
void (*KeyDown)(struct LScreen* s, Key key, cc_bool wasDown); \
|
void (*KeyDown)(struct LScreen* s, int key, cc_bool wasDown); \
|
||||||
void (*KeyPress)(struct LScreen* s, char c); \
|
void (*KeyPress)(struct LScreen* s, char c); \
|
||||||
void (*MouseDown)(struct LScreen* s, int btn); \
|
void (*MouseDown)(struct LScreen* s, int btn); \
|
||||||
void (*MouseUp)(struct LScreen* s, int btn); \
|
void (*MouseUp)(struct LScreen* s, int btn); \
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "LWeb.h"
|
#include "LWeb.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
#include "LScreens.h"
|
#include "LScreens.h"
|
||||||
|
#include "Input.h"
|
||||||
|
|
||||||
#ifndef CC_BUILD_WEB
|
#ifndef CC_BUILD_WEB
|
||||||
#define BORDER 1
|
#define BORDER 1
|
||||||
@ -404,7 +405,7 @@ static void LInput_CopyFromClipboard(String* text, void* widget) {
|
|||||||
LInput_AppendString(w, text);
|
LInput_AppendString(w, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LInput_KeyDown(void* widget, Key key, cc_bool was) {
|
static void LInput_KeyDown(void* widget, int key, cc_bool was) {
|
||||||
struct LInput* w = (struct LInput*)widget;
|
struct LInput* w = (struct LInput*)widget;
|
||||||
if (key == KEY_BACKSPACE) {
|
if (key == KEY_BACKSPACE) {
|
||||||
LInput_Backspace(w);
|
LInput_Backspace(w);
|
||||||
@ -924,11 +925,11 @@ static void LTable_DrawScrollbar(struct LTable* w) {
|
|||||||
x, w->Y + y, w->ScrollbarWidth, height);
|
x, w->Y + y, w->ScrollbarWidth, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool LTable_HandlesKey(Key key) {
|
cc_bool LTable_HandlesKey(int key) {
|
||||||
return key == KEY_UP || key == KEY_DOWN || key == KEY_PAGEUP || key == KEY_PAGEDOWN;
|
return key == KEY_UP || key == KEY_DOWN || key == KEY_PAGEUP || key == KEY_PAGEDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LTable_KeyDown(void* widget, Key key, cc_bool was) {
|
static void LTable_KeyDown(void* widget, int key, cc_bool was) {
|
||||||
struct LTable* w = (struct LTable*)widget;
|
struct LTable* w = (struct LTable*)widget;
|
||||||
int index = LTable_GetSelectedIndex(w);
|
int index = LTable_GetSelectedIndex(w);
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define CC_LWIDGETS_H
|
#define CC_LWIDGETS_H
|
||||||
#include "Bitmap.h"
|
#include "Bitmap.h"
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "Input.h"
|
#include "String.h"
|
||||||
/* Describes and manages individual 2D GUI elements in the launcher.
|
/* Describes and manages individual 2D GUI elements in the launcher.
|
||||||
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
Copyright 2014-2019 ClassiCube | Licensed under BSD-3
|
||||||
*/
|
*/
|
||||||
@ -15,7 +15,7 @@ struct LWidgetVTABLE {
|
|||||||
/* Called repeatedly to update this widget when selected. */
|
/* Called repeatedly to update this widget when selected. */
|
||||||
void (*Tick)(void* widget);
|
void (*Tick)(void* widget);
|
||||||
/* Called when key is pressed and this widget is selected. */
|
/* Called when key is pressed and this widget is selected. */
|
||||||
void (*KeyDown)(void* widget, Key key, cc_bool wasDown);
|
void (*KeyDown)(void* widget, int key, cc_bool wasDown);
|
||||||
/* Called when key is pressed and this widget is selected. */
|
/* Called when key is pressed and this widget is selected. */
|
||||||
void (*KeyPress)(void* widget, char c);
|
void (*KeyPress)(void* widget, char c);
|
||||||
/* Called when mouse hovers/moves over this widget. */
|
/* Called when mouse hovers/moves over this widget. */
|
||||||
@ -195,7 +195,7 @@ void LTable_Reset(struct LTable* table);
|
|||||||
void LTable_Reposition(struct LTable* table);
|
void LTable_Reposition(struct LTable* table);
|
||||||
/* Whether this table would handle the given key being pressed. */
|
/* Whether this table would handle the given key being pressed. */
|
||||||
/* e.g. used so pressing up/down works even when another widget is selected */
|
/* e.g. used so pressing up/down works even when another widget is selected */
|
||||||
cc_bool LTable_HandlesKey(Key key);
|
cc_bool LTable_HandlesKey(int key);
|
||||||
/* Filters rows to only show those containing 'w->Filter' in the name. */
|
/* Filters rows to only show those containing 'w->Filter' in the name. */
|
||||||
void LTable_ApplyFilter(struct LTable* table);
|
void LTable_ApplyFilter(struct LTable* table);
|
||||||
/* Sorts the rows in the table by current Sorter function of table */
|
/* Sorts the rows in the table by current Sorter function of table */
|
||||||
|
46
src/Menus.c
46
src/Menus.c
@ -371,7 +371,7 @@ static void ListScreen_Select(struct ListScreen* s, const String* str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ListScreen_KeyDown(void* screen, Key key) {
|
static int ListScreen_KeyDown(void* screen, int key) {
|
||||||
struct ListScreen* s = (struct ListScreen*)screen;
|
struct ListScreen* s = (struct ListScreen*)screen;
|
||||||
if (key == KEY_LEFT || key == KEY_PAGEUP) {
|
if (key == KEY_LEFT || key == KEY_PAGEUP) {
|
||||||
ListScreen_PageClick(s, false);
|
ListScreen_PageClick(s, false);
|
||||||
@ -448,7 +448,7 @@ static void ListScreen_ContextRecreated(void* screen) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE ListScreen_VTABLE = {
|
static const struct ScreenVTABLE ListScreen_VTABLE = {
|
||||||
ListScreen_Init, ListScreen_Render, ListScreen_Free,
|
ListScreen_Init, ListScreen_Render, ListScreen_Free,
|
||||||
ListScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
ListScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, ListScreen_MouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, ListScreen_MouseScroll,
|
||||||
Menu_Layout, ListScreen_ContextLost, ListScreen_ContextRecreated
|
Menu_Layout, ListScreen_ContextLost, ListScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -464,7 +464,7 @@ void ListScreen_Show(void) {
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*--------------------------------------------------------MenuScreen-------------------------------------------------------*
|
*--------------------------------------------------------MenuScreen-------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static int MenuScreen_KeyDown(void* screen, Key key) { return key < KEY_F1 || key > KEY_F35; }
|
static int MenuScreen_KeyDown(void* screen, int key) { return key < KEY_F1 || key > KEY_F35; }
|
||||||
|
|
||||||
static void MenuScreen_Render(void* screen, double delta) {
|
static void MenuScreen_Render(void* screen, double delta) {
|
||||||
Menu_RenderBounds();
|
Menu_RenderBounds();
|
||||||
@ -559,7 +559,7 @@ static void PauseScreen_Free(void* screen) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE PauseScreen_VTABLE = {
|
static const struct ScreenVTABLE PauseScreen_VTABLE = {
|
||||||
PauseScreen_Init, MenuScreen_Render, PauseScreen_Free,
|
PauseScreen_Init, MenuScreen_Render, PauseScreen_Free,
|
||||||
MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_Layout, Menu_ContextLost, PauseScreen_ContextRecreated
|
Menu_Layout, Menu_ContextLost, PauseScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -584,7 +584,7 @@ static struct OptionsGroupScreen {
|
|||||||
struct ButtonWidget done;
|
struct ButtonWidget done;
|
||||||
} OptionsGroupScreen;
|
} OptionsGroupScreen;
|
||||||
|
|
||||||
static const char* optsGroup_descs[7] = {
|
static const char* const optsGroup_descs[7] = {
|
||||||
"&eMusic/Sound, view bobbing, and more",
|
"&eMusic/Sound, view bobbing, and more",
|
||||||
"&eChat options, gui scale, font settings, and more",
|
"&eChat options, gui scale, font settings, and more",
|
||||||
"&eFPS limit, view distance, entity names/shadows",
|
"&eFPS limit, view distance, entity names/shadows",
|
||||||
@ -664,7 +664,7 @@ static int OptionsGroupScreen_PointerMove(void* screen, int id, int x, int y) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE OptionsGroupScreen_VTABLE = {
|
static const struct ScreenVTABLE OptionsGroupScreen_VTABLE = {
|
||||||
OptionsGroupScreen_Init, MenuScreen_Render, OptionsGroupScreen_Free,
|
OptionsGroupScreen_Init, MenuScreen_Render, OptionsGroupScreen_Free,
|
||||||
MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
||||||
Menu_PointerDown, Screen_TPointer, OptionsGroupScreen_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, OptionsGroupScreen_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_Layout, OptionsGroupScreen_ContextLost, OptionsGroupScreen_ContextRecreated
|
Menu_Layout, OptionsGroupScreen_ContextLost, OptionsGroupScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -812,7 +812,7 @@ static int EditHotkeyScreen_KeyPress(void* screen, char keyChar) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int EditHotkeyScreen_KeyDown(void* screen, Key key) {
|
static int EditHotkeyScreen_KeyDown(void* screen, int key) {
|
||||||
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
struct EditHotkeyScreen* s = (struct EditHotkeyScreen*)screen;
|
||||||
if (s->selectedI >= 0) {
|
if (s->selectedI >= 0) {
|
||||||
if (s->selectedI == 0) {
|
if (s->selectedI == 0) {
|
||||||
@ -887,7 +887,7 @@ static void EditHotkeyScreen_Init(void* screen) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE EditHotkeyScreen_VTABLE = {
|
static const struct ScreenVTABLE EditHotkeyScreen_VTABLE = {
|
||||||
EditHotkeyScreen_Init, EditHotkeyScreen_Render, Menu_CloseKeyboard,
|
EditHotkeyScreen_Init, EditHotkeyScreen_Render, Menu_CloseKeyboard,
|
||||||
EditHotkeyScreen_KeyDown, Screen_TInput, EditHotkeyScreen_KeyPress,
|
EditHotkeyScreen_KeyDown, Screen_TInput, EditHotkeyScreen_KeyPress, Screen_TText,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_Layout, EditHotkeyScreen_ContextLost, EditHotkeyScreen_ContextRecreated
|
Menu_Layout, EditHotkeyScreen_ContextLost, EditHotkeyScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -981,7 +981,7 @@ static void GenLevelScreen_Make(struct GenLevelScreen* s, int i, int y, int def)
|
|||||||
s->labels[i].col = col;
|
s->labels[i].col = col;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GenLevelScreen_KeyDown(void* screen, Key key) {
|
static int GenLevelScreen_KeyDown(void* screen, int key) {
|
||||||
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
struct GenLevelScreen* s = (struct GenLevelScreen*)screen;
|
||||||
if (s->selected && Elem_HandlesKeyDown(&s->selected->base, key)) return true;
|
if (s->selected && Elem_HandlesKeyDown(&s->selected->base, key)) return true;
|
||||||
return MenuScreen_KeyDown(s, key);
|
return MenuScreen_KeyDown(s, key);
|
||||||
@ -1058,7 +1058,7 @@ static void GenLevelScreen_Init(void* screen) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE GenLevelScreen_VTABLE = {
|
static const struct ScreenVTABLE GenLevelScreen_VTABLE = {
|
||||||
GenLevelScreen_Init, MenuScreen_Render, Menu_CloseKeyboard,
|
GenLevelScreen_Init, MenuScreen_Render, Menu_CloseKeyboard,
|
||||||
GenLevelScreen_KeyDown, Screen_TInput, GenLevelScreen_KeyPress,
|
GenLevelScreen_KeyDown, Screen_TInput, GenLevelScreen_KeyPress, Screen_TText,
|
||||||
GenLevelScreen_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
GenLevelScreen_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_Layout, GenLevelScreen_ContextLost, GenLevelScreen_ContextRecreated
|
Menu_Layout, GenLevelScreen_ContextLost, GenLevelScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -1123,7 +1123,7 @@ static void ClassicGenScreen_Init(void* screen) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE ClassicGenScreen_VTABLE = {
|
static const struct ScreenVTABLE ClassicGenScreen_VTABLE = {
|
||||||
ClassicGenScreen_Init, MenuScreen_Render, Menu_NullFunc,
|
ClassicGenScreen_Init, MenuScreen_Render, Menu_NullFunc,
|
||||||
MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
MenuScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_Layout, Menu_ContextLost, ClassicGenScreen_ContextRecreated
|
Menu_Layout, Menu_ContextLost, ClassicGenScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -1320,7 +1320,7 @@ static int SaveLevelScreen_KeyPress(void* screen, char keyChar) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SaveLevelScreen_KeyDown(void* screen, Key key) {
|
static int SaveLevelScreen_KeyDown(void* screen, int key) {
|
||||||
struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen;
|
struct SaveLevelScreen* s = (struct SaveLevelScreen*)screen;
|
||||||
if (Elem_HandlesKeyDown(&s->input.base, key)) {
|
if (Elem_HandlesKeyDown(&s->input.base, key)) {
|
||||||
SaveLevelScreen_RemoveOverwrites(s);
|
SaveLevelScreen_RemoveOverwrites(s);
|
||||||
@ -1386,7 +1386,7 @@ static void SaveLevelScreen_Init(void* screen) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE SaveLevelScreen_VTABLE = {
|
static const struct ScreenVTABLE SaveLevelScreen_VTABLE = {
|
||||||
SaveLevelScreen_Init, SaveLevelScreen_Render, Menu_CloseKeyboard,
|
SaveLevelScreen_Init, SaveLevelScreen_Render, Menu_CloseKeyboard,
|
||||||
SaveLevelScreen_KeyDown, Screen_TInput, SaveLevelScreen_KeyPress,
|
SaveLevelScreen_KeyDown, Screen_TInput, SaveLevelScreen_KeyPress, Screen_TText,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_Layout, SaveLevelScreen_ContextLost, SaveLevelScreen_ContextRecreated
|
Menu_Layout, SaveLevelScreen_ContextLost, SaveLevelScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -1503,7 +1503,7 @@ static void HotkeyListScreen_EntryClick(void* screen, void* widget) {
|
|||||||
struct ListScreen* s = (struct ListScreen*)screen;
|
struct ListScreen* s = (struct ListScreen*)screen;
|
||||||
struct HotkeyData h, original = { 0 };
|
struct HotkeyData h, original = { 0 };
|
||||||
String text, key, value;
|
String text, key, value;
|
||||||
Key trigger;
|
int trigger;
|
||||||
int i, flags = 0;
|
int i, flags = 0;
|
||||||
|
|
||||||
text = ListScreen_UNSAFE_GetCur(s, widget);
|
text = ListScreen_UNSAFE_GetCur(s, widget);
|
||||||
@ -1650,7 +1650,7 @@ static void KeyBindingsScreen_OnBindingClick(void* screen, void* widget) {
|
|||||||
if (old >= 0) KeyBindingsScreen_Update(s, old);
|
if (old >= 0) KeyBindingsScreen_Update(s, old);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int KeyBindingsScreen_KeyDown(void* screen, Key key) {
|
static int KeyBindingsScreen_KeyDown(void* screen, int key) {
|
||||||
struct KeyBindingsScreen* s = (struct KeyBindingsScreen*)screen;
|
struct KeyBindingsScreen* s = (struct KeyBindingsScreen*)screen;
|
||||||
KeyBind bind;
|
KeyBind bind;
|
||||||
int idx;
|
int idx;
|
||||||
@ -1738,7 +1738,7 @@ static void KeyBindingsScreen_Init(void* screen) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE KeyBindingsScreen_VTABLE = {
|
static const struct ScreenVTABLE KeyBindingsScreen_VTABLE = {
|
||||||
KeyBindingsScreen_Init, MenuScreen_Render, Menu_NullFunc,
|
KeyBindingsScreen_Init, MenuScreen_Render, Menu_NullFunc,
|
||||||
KeyBindingsScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
KeyBindingsScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_Layout, KeyBindingsScreen_ContextLost, KeyBindingsScreen_ContextRecreated
|
Menu_Layout, KeyBindingsScreen_ContextLost, KeyBindingsScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -1984,7 +1984,7 @@ static int MenuOptionsScreen_KeyPress(void* screen, char keyChar) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MenuOptionsScreen_KeyDown(void* screen, Key key) {
|
static int MenuOptionsScreen_KeyDown(void* screen, int key) {
|
||||||
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
struct MenuOptionsScreen* s = (struct MenuOptionsScreen*)screen;
|
||||||
if (s->activeI >= 0) {
|
if (s->activeI >= 0) {
|
||||||
if (Elem_HandlesKeyDown(&s->input.base, key)) return true;
|
if (Elem_HandlesKeyDown(&s->input.base, key)) return true;
|
||||||
@ -2185,7 +2185,7 @@ static void MenuOptionsScreen_ContextRecreated(void* screen) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE MenuOptionsScreen_VTABLE = {
|
static const struct ScreenVTABLE MenuOptionsScreen_VTABLE = {
|
||||||
MenuOptionsScreen_Init, MenuOptionsScreen_Render, MenuOptionsScreen_Free,
|
MenuOptionsScreen_Init, MenuOptionsScreen_Render, MenuOptionsScreen_Free,
|
||||||
MenuOptionsScreen_KeyDown, Screen_TInput, MenuOptionsScreen_KeyPress,
|
MenuOptionsScreen_KeyDown, Screen_TInput, MenuOptionsScreen_KeyPress, Screen_TText,
|
||||||
Menu_PointerDown, Screen_TPointer, MenuOptionsScreen_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, MenuOptionsScreen_PointerMove, Screen_TMouseScroll,
|
||||||
MenuOptionsScreen_Layout, MenuOptionsScreen_ContextLost, MenuOptionsScreen_ContextRecreated
|
MenuOptionsScreen_Layout, MenuOptionsScreen_ContextLost, MenuOptionsScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -3015,7 +3015,7 @@ static void TexIdsOverlay_Render(void* screen, double delta) {
|
|||||||
Gfx_SetTexturing(false);
|
Gfx_SetTexturing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int TexIdsOverlay_KeyDown(void* screen, Key key) {
|
static int TexIdsOverlay_KeyDown(void* screen, int key) {
|
||||||
struct Screen* s = (struct Screen*)screen;
|
struct Screen* s = (struct Screen*)screen;
|
||||||
if (key == KeyBinds[KEYBIND_IDOVERLAY]) { Gui_Remove(s); return true; }
|
if (key == KeyBinds[KEYBIND_IDOVERLAY]) { Gui_Remove(s); return true; }
|
||||||
return false;
|
return false;
|
||||||
@ -3023,7 +3023,7 @@ static int TexIdsOverlay_KeyDown(void* screen, Key key) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE TexIdsOverlay_VTABLE = {
|
static const struct ScreenVTABLE TexIdsOverlay_VTABLE = {
|
||||||
TexIdsOverlay_Init, TexIdsOverlay_Render, Menu_NullFunc,
|
TexIdsOverlay_Init, TexIdsOverlay_Render, Menu_NullFunc,
|
||||||
TexIdsOverlay_KeyDown, Screen_FInput, Screen_FKeyPress,
|
TexIdsOverlay_KeyDown, Screen_FInput, Screen_FKeyPress, Screen_FText,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_Layout, TexIdsOverlay_ContextLost, TexIdsOverlay_ContextRecreated
|
Menu_Layout, TexIdsOverlay_ContextLost, TexIdsOverlay_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -3090,7 +3090,7 @@ static void UrlWarningOverlay_Init(void* screen) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE UrlWarningOverlay_VTABLE = {
|
static const struct ScreenVTABLE UrlWarningOverlay_VTABLE = {
|
||||||
UrlWarningOverlay_Init, MenuScreen_Render, Menu_NullFunc,
|
UrlWarningOverlay_Init, MenuScreen_Render, Menu_NullFunc,
|
||||||
Screen_TInput, Screen_TInput, Screen_TKeyPress,
|
Screen_TInput, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_Layout, Menu_ContextLost, UrlWarningOverlay_ContextRecreated
|
Menu_Layout, Menu_ContextLost, UrlWarningOverlay_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -3239,7 +3239,7 @@ static void TexPackOverlay_Init(void* screen) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE TexPackOverlay_VTABLE = {
|
static const struct ScreenVTABLE TexPackOverlay_VTABLE = {
|
||||||
TexPackOverlay_Init, TexPackOverlay_Render, Menu_NullFunc,
|
TexPackOverlay_Init, TexPackOverlay_Render, Menu_NullFunc,
|
||||||
Screen_TInput, Screen_TInput, Screen_TKeyPress,
|
Screen_TInput, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
||||||
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
Menu_PointerDown, Screen_TPointer, Menu_PointerMove, Screen_TMouseScroll,
|
||||||
Menu_Layout, TexPackOverlay_ContextLost, TexPackOverlay_ContextRecreated
|
Menu_Layout, TexPackOverlay_ContextLost, TexPackOverlay_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -3268,7 +3268,7 @@ static struct TouchMoreOverlay {
|
|||||||
} TouchMoreOverlay_Instance;
|
} TouchMoreOverlay_Instance;
|
||||||
|
|
||||||
static void TouchMore_Toggle(KeyBind bind) {
|
static void TouchMore_Toggle(KeyBind bind) {
|
||||||
Key key = KeyBinds[bind];
|
int key = KeyBinds[bind];
|
||||||
Gui_Remove((struct Screen*)&TouchMoreOverlay_Instance);
|
Gui_Remove((struct Screen*)&TouchMoreOverlay_Instance);
|
||||||
Input_SetPressed(key, !Input_Pressed[key]);
|
Input_SetPressed(key, !Input_Pressed[key]);
|
||||||
}
|
}
|
||||||
|
@ -939,7 +939,7 @@ static void CPE_SetTextHotkey(cc_uint8* data) {
|
|||||||
String action = Protocol_UNSAFE_GetString(&data[64]);
|
String action = Protocol_UNSAFE_GetString(&data[64]);
|
||||||
cc_uint32 keyCode = Stream_GetU32_BE(&data[128]);
|
cc_uint32 keyCode = Stream_GetU32_BE(&data[128]);
|
||||||
cc_uint8 keyMods = data[132];
|
cc_uint8 keyMods = data[132];
|
||||||
Key key;
|
int key;
|
||||||
|
|
||||||
if (keyCode > 255) return;
|
if (keyCode > 255) return;
|
||||||
key = Hotkeys_LWJGL[keyCode];
|
key = Hotkeys_LWJGL[keyCode];
|
||||||
|
@ -26,15 +26,15 @@
|
|||||||
|
|
||||||
int Screen_FInput(void* s, int key) { return false; }
|
int Screen_FInput(void* s, int key) { return false; }
|
||||||
int Screen_FKeyPress(void* s, char keyChar) { return false; }
|
int Screen_FKeyPress(void* s, char keyChar) { return false; }
|
||||||
|
int Screen_FText(void* s, const String* str) { return false; }
|
||||||
int Screen_FMouseScroll(void* s, float delta) { return false; }
|
int Screen_FMouseScroll(void* s, float delta) { return false; }
|
||||||
int Screen_FPointer(void* s, int id, int x, int y) { return false; }
|
int Screen_FPointer(void* s, int id, int x, int y) { return false; }
|
||||||
int Screen_FPointerMove(void* s, int id, int x, int y) { return false; }
|
|
||||||
|
|
||||||
int Screen_TInput(void* s, int key) { return true; }
|
int Screen_TInput(void* s, int key) { return true; }
|
||||||
int Screen_TKeyPress(void* s, char keyChar) { return true; }
|
int Screen_TKeyPress(void* s, char keyChar) { return true; }
|
||||||
|
int Screen_TText(void* s, const String* str) { return false; }
|
||||||
int Screen_TMouseScroll(void* s, float delta) { return true; }
|
int Screen_TMouseScroll(void* s, float delta) { return true; }
|
||||||
int Screen_TPointer(void* s, int id, int x, int y) { return true; }
|
int Screen_TPointer(void* s, int id, int x, int y) { return true; }
|
||||||
int Screen_TPointerMove(void* s, int id, int x, int y) { return true; }
|
|
||||||
static void Screen_NullFunc(void* screen) { }
|
static void Screen_NullFunc(void* screen) { }
|
||||||
|
|
||||||
CC_NOINLINE static cc_bool IsOnlyHudActive(void) {
|
CC_NOINLINE static cc_bool IsOnlyHudActive(void) {
|
||||||
@ -226,8 +226,8 @@ static void HUDScreen_Render(void* screen, double delta) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE HUDScreen_VTABLE = {
|
static const struct ScreenVTABLE HUDScreen_VTABLE = {
|
||||||
Screen_NullFunc, HUDScreen_Render, Screen_NullFunc,
|
Screen_NullFunc, HUDScreen_Render, Screen_NullFunc,
|
||||||
Screen_FInput, Screen_FInput, Screen_FKeyPress,
|
Screen_FInput, Screen_FInput, Screen_FKeyPress, Screen_FText,
|
||||||
Screen_FPointer, Screen_FPointer, Screen_FPointerMove, Screen_FMouseScroll,
|
Screen_FPointer, Screen_FPointer, Screen_FPointer, Screen_FMouseScroll,
|
||||||
Screen_NullFunc, HUDScreen_ContextLost, HUDScreen_ContextRecreated
|
Screen_NullFunc, HUDScreen_ContextLost, HUDScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void HUDScreen_Show(void) {
|
void HUDScreen_Show(void) {
|
||||||
@ -624,10 +624,10 @@ static int ChatScreen_KeyPress(void* screen, char keyChar) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ChatScreen_KeyDown(void* screen, Key key) {
|
static int ChatScreen_KeyDown(void* screen, int key) {
|
||||||
static const String slash = String_FromConst("/");
|
static const String slash = String_FromConst("/");
|
||||||
struct ChatScreen* s = (struct ChatScreen*)screen;
|
struct ChatScreen* s = (struct ChatScreen*)screen;
|
||||||
Key playerListKey = KeyBinds[KEYBIND_PLAYER_LIST];
|
int playerListKey = KeyBinds[KEYBIND_PLAYER_LIST];
|
||||||
cc_bool handlesList = playerListKey != KEY_TAB || !Gui_TabAutocomplete || !s->grabsInput;
|
cc_bool handlesList = playerListKey != KEY_TAB || !Gui_TabAutocomplete || !s->grabsInput;
|
||||||
|
|
||||||
if (key == playerListKey && handlesList) {
|
if (key == playerListKey && handlesList) {
|
||||||
@ -671,7 +671,7 @@ static int ChatScreen_KeyDown(void* screen, Key key) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ChatScreen_KeyUp(void* screen, Key key) {
|
static int ChatScreen_KeyUp(void* screen, int key) {
|
||||||
struct ChatScreen* s = (struct ChatScreen*)screen;
|
struct ChatScreen* s = (struct ChatScreen*)screen;
|
||||||
if (key == KeyBinds[KEYBIND_PLAYER_LIST] && s->showingList) {
|
if (key == KeyBinds[KEYBIND_PLAYER_LIST] && s->showingList) {
|
||||||
s->showingList = false;
|
s->showingList = false;
|
||||||
@ -813,8 +813,8 @@ static void ChatScreen_Free(void* screen) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE ChatScreen_VTABLE = {
|
static const struct ScreenVTABLE ChatScreen_VTABLE = {
|
||||||
ChatScreen_Init, ChatScreen_Render, ChatScreen_Free,
|
ChatScreen_Init, ChatScreen_Render, ChatScreen_Free,
|
||||||
ChatScreen_KeyDown, ChatScreen_KeyUp, ChatScreen_KeyPress,
|
ChatScreen_KeyDown, ChatScreen_KeyUp, ChatScreen_KeyPress, Screen_TText,
|
||||||
ChatScreen_PointerDown, Screen_FPointer, Screen_FPointerMove, ChatScreen_MouseScroll,
|
ChatScreen_PointerDown, Screen_FPointer, Screen_FPointer, ChatScreen_MouseScroll,
|
||||||
ChatScreen_Layout, ChatScreen_ContextLost, ChatScreen_ContextRecreated
|
ChatScreen_Layout, ChatScreen_ContextLost, ChatScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void ChatScreen_Show(void) {
|
void ChatScreen_Show(void) {
|
||||||
@ -935,7 +935,7 @@ static void InventoryScreen_Free(void* screen) {
|
|||||||
Event_UnregisterVoid(&BlockEvents.BlockDefChanged, s, InventoryScreen_OnBlockChanged);
|
Event_UnregisterVoid(&BlockEvents.BlockDefChanged, s, InventoryScreen_OnBlockChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int InventoryScreen_KeyDown(void* screen, Key key) {
|
static int InventoryScreen_KeyDown(void* screen, int key) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
||||||
struct TableWidget* table = &s->table;
|
struct TableWidget* table = &s->table;
|
||||||
|
|
||||||
@ -952,7 +952,7 @@ static int InventoryScreen_KeyDown(void* screen, Key key) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int InventoryScreen_KeyUp(void* screen, Key key) {
|
static int InventoryScreen_KeyUp(void* screen, int key) {
|
||||||
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
struct InventoryScreen* s = (struct InventoryScreen*)screen;
|
||||||
struct ChatScreen* hud;
|
struct ChatScreen* hud;
|
||||||
|
|
||||||
@ -1001,7 +1001,7 @@ static int InventoryScreen_MouseScroll(void* screen, float delta) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE InventoryScreen_VTABLE = {
|
static const struct ScreenVTABLE InventoryScreen_VTABLE = {
|
||||||
InventoryScreen_Init, InventoryScreen_Render, InventoryScreen_Free,
|
InventoryScreen_Init, InventoryScreen_Render, InventoryScreen_Free,
|
||||||
InventoryScreen_KeyDown, InventoryScreen_KeyUp, Screen_TKeyPress,
|
InventoryScreen_KeyDown, InventoryScreen_KeyUp, Screen_TKeyPress, Screen_TText,
|
||||||
InventoryScreen_PointerDown, InventoryScreen_PointerUp, InventoryScreen_PointerMove, InventoryScreen_MouseScroll,
|
InventoryScreen_PointerDown, InventoryScreen_PointerUp, InventoryScreen_PointerMove, InventoryScreen_MouseScroll,
|
||||||
InventoryScreen_Layout, InventoryScreen_ContextLost, InventoryScreen_ContextRecreated
|
InventoryScreen_Layout, InventoryScreen_ContextLost, InventoryScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -1166,8 +1166,8 @@ CC_NOINLINE static void LoadingScreen_ShowCommon(const String* title, const Stri
|
|||||||
|
|
||||||
static const struct ScreenVTABLE LoadingScreen_VTABLE = {
|
static const struct ScreenVTABLE LoadingScreen_VTABLE = {
|
||||||
LoadingScreen_Init, LoadingScreen_Render, LoadingScreen_Free,
|
LoadingScreen_Init, LoadingScreen_Render, LoadingScreen_Free,
|
||||||
Screen_TInput, Screen_TInput, Screen_TKeyPress,
|
Screen_TInput, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
||||||
Screen_TPointer, Screen_TPointer, Screen_TPointerMove, Screen_TMouseScroll,
|
Screen_TPointer, Screen_TPointer, Screen_TPointer, Screen_TMouseScroll,
|
||||||
LoadingScreen_Layout, LoadingScreen_ContextLost, LoadingScreen_ContextRecreated
|
LoadingScreen_Layout, LoadingScreen_ContextLost, LoadingScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void LoadingScreen_Show(const String* title, const String* message) {
|
void LoadingScreen_Show(const String* title, const String* message) {
|
||||||
@ -1236,8 +1236,8 @@ static void GeneratingScreen_Render(void* screen, double delta) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE GeneratingScreen_VTABLE = {
|
static const struct ScreenVTABLE GeneratingScreen_VTABLE = {
|
||||||
GeneratingScreen_Init, GeneratingScreen_Render, LoadingScreen_Free,
|
GeneratingScreen_Init, GeneratingScreen_Render, LoadingScreen_Free,
|
||||||
Screen_TInput, Screen_TInput, Screen_TKeyPress,
|
Screen_TInput, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
||||||
Screen_TPointer, Screen_TPointer, Screen_FPointerMove, Screen_TMouseScroll,
|
Screen_TPointer, Screen_TPointer, Screen_FPointer, Screen_TMouseScroll,
|
||||||
LoadingScreen_Layout, LoadingScreen_ContextLost, LoadingScreen_ContextRecreated
|
LoadingScreen_Layout, LoadingScreen_ContextLost, LoadingScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
void GeneratingScreen_Show(void) {
|
void GeneratingScreen_Show(void) {
|
||||||
@ -1364,7 +1364,7 @@ static void DisconnectScreen_Layout(void* screen) {
|
|||||||
Widget_Layout(&s->reconnect);
|
Widget_Layout(&s->reconnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DisconnectScreen_KeyDown(void* s, Key key) { return key < KEY_F1 || key > KEY_F35; }
|
static int DisconnectScreen_KeyDown(void* s, int key) { return key < KEY_F1 || key > KEY_F35; }
|
||||||
|
|
||||||
static int DisconnectScreen_PointerDown(void* screen, int id, int x, int y) {
|
static int DisconnectScreen_PointerDown(void* screen, int id, int x, int y) {
|
||||||
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
struct DisconnectScreen* s = (struct DisconnectScreen*)screen;
|
||||||
@ -1388,7 +1388,7 @@ static int DisconnectScreen_PointerMove(void* screen, int idx, int x, int y) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE DisconnectScreen_VTABLE = {
|
static const struct ScreenVTABLE DisconnectScreen_VTABLE = {
|
||||||
DisconnectScreen_Init, DisconnectScreen_Render, DisconnectScreen_Free,
|
DisconnectScreen_Init, DisconnectScreen_Render, DisconnectScreen_Free,
|
||||||
DisconnectScreen_KeyDown, Screen_TInput, Screen_TKeyPress,
|
DisconnectScreen_KeyDown, Screen_TInput, Screen_TKeyPress, Screen_TText,
|
||||||
DisconnectScreen_PointerDown, Screen_TPointer, DisconnectScreen_PointerMove, Screen_TMouseScroll,
|
DisconnectScreen_PointerDown, Screen_TPointer, DisconnectScreen_PointerMove, Screen_TMouseScroll,
|
||||||
DisconnectScreen_Layout, DisconnectScreen_ContextLost, DisconnectScreen_ContextRecreated
|
DisconnectScreen_Layout, DisconnectScreen_ContextLost, DisconnectScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
@ -1570,7 +1570,7 @@ static int TouchScreen_PointerUp(void* screen, int id, int x, int y) {
|
|||||||
|
|
||||||
static const struct ScreenVTABLE TouchScreen_VTABLE = {
|
static const struct ScreenVTABLE TouchScreen_VTABLE = {
|
||||||
Screen_NullFunc, TouchScreen_Render, Screen_NullFunc,
|
Screen_NullFunc, TouchScreen_Render, Screen_NullFunc,
|
||||||
Screen_FInput, Screen_FInput, Screen_FKeyPress,
|
Screen_FInput, Screen_FInput, Screen_FKeyPress, Screen_FText,
|
||||||
TouchScreen_PointerDown, TouchScreen_PointerUp, Screen_FPointerMove, Screen_FMouseScroll,
|
TouchScreen_PointerDown, TouchScreen_PointerUp, Screen_FPointerMove, Screen_FMouseScroll,
|
||||||
TouchScreen_Layout, TouchScreen_ContextLost, TouchScreen_ContextRecreated
|
TouchScreen_Layout, TouchScreen_ContextLost, TouchScreen_ContextRecreated
|
||||||
};
|
};
|
||||||
|
@ -10,16 +10,16 @@ struct Widget;
|
|||||||
/* These always return false */
|
/* These always return false */
|
||||||
int Screen_FInput(void* s, int key);
|
int Screen_FInput(void* s, int key);
|
||||||
int Screen_FKeyPress(void* s, char keyChar);
|
int Screen_FKeyPress(void* s, char keyChar);
|
||||||
|
int Screen_FText(void* s, const String* str);
|
||||||
int Screen_FMouseScroll(void* s, float delta);
|
int Screen_FMouseScroll(void* s, float delta);
|
||||||
int Screen_FPointer(void* s, int id, int x, int y);
|
int Screen_FPointer(void* s, int id, int x, int y);
|
||||||
int Screen_FPointerMove(void* s, int id, int x, int y);
|
|
||||||
|
|
||||||
/* These always return true */
|
/* These always return true */
|
||||||
int Screen_TInput(void* s, int key);
|
int Screen_TInput(void* s, int key);
|
||||||
int Screen_TKeyPress(void* s, char keyChar);
|
int Screen_TKeyPress(void* s, char keyChar);
|
||||||
|
int Screen_TText(void* s, const String* str);
|
||||||
int Screen_TMouseScroll(void* s, float delta);
|
int Screen_TMouseScroll(void* s, float delta);
|
||||||
int Screen_TPointer(void* s, int id, int x, int y);
|
int Screen_TPointer(void* s, int id, int x, int y);
|
||||||
int Screen_TPointerMove(void* s, int id, int x, int y);
|
|
||||||
|
|
||||||
void InventoryScreen_Show(void);
|
void InventoryScreen_Show(void);
|
||||||
void HUDScreen_Show(void);
|
void HUDScreen_Show(void);
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define Widget_UV(u1,v1, u2,v2) Tex_UV(u1/256.0f,v1/256.0f, u2/256.0f,v2/256.0f)
|
#define Widget_UV(u1,v1, u2,v2) Tex_UV(u1/256.0f,v1/256.0f, u2/256.0f,v2/256.0f)
|
||||||
static void Widget_NullFunc(void* widget) { }
|
static void Widget_NullFunc(void* widget) { }
|
||||||
static int Widget_Pointer(void* elem, int id, int x, int y) { return false; }
|
static int Widget_Pointer(void* elem, int id, int x, int y) { return false; }
|
||||||
static int Widget_Key(void* elem, Key key) { return false; }
|
static int Widget_Key(void* elem, int key) { return false; }
|
||||||
static int Widget_PointerMove(void* elem, int id, int x, int y) { return false; }
|
static int Widget_PointerMove(void* elem, int id, int x, int y) { return false; }
|
||||||
static int Widget_MouseScroll(void* elem, float delta) { return false; }
|
static int Widget_MouseScroll(void* elem, float delta) { return false; }
|
||||||
|
|
||||||
@ -398,7 +398,7 @@ static void HotbarWidget_Render(void* widget, double delta) {
|
|||||||
HotbarWidget_RenderHotbarBlocks(w);
|
HotbarWidget_RenderHotbarBlocks(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int HotbarWidget_KeyDown(void* widget, Key key) {
|
static int HotbarWidget_KeyDown(void* widget, int key) {
|
||||||
struct HotbarWidget* w = (struct HotbarWidget*)widget;
|
struct HotbarWidget* w = (struct HotbarWidget*)widget;
|
||||||
int index;
|
int index;
|
||||||
if (key < '1' || key > '9') return false;
|
if (key < '1' || key > '9') return false;
|
||||||
@ -414,7 +414,7 @@ static int HotbarWidget_KeyDown(void* widget, Key key) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int HotbarWidget_KeyUp(void* widget, Key key) {
|
static int HotbarWidget_KeyUp(void* widget, int key) {
|
||||||
struct HotbarWidget* w = (struct HotbarWidget*)widget;
|
struct HotbarWidget* w = (struct HotbarWidget*)widget;
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
@ -768,7 +768,7 @@ static int TableWidget_PointerMove(void* widget, int id, int x, int y) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int TableWidget_KeyDown(void* widget, Key key) {
|
static int TableWidget_KeyDown(void* widget, int key) {
|
||||||
struct TableWidget* w = (struct TableWidget*)widget;
|
struct TableWidget* w = (struct TableWidget*)widget;
|
||||||
if (w->selectedIndex == -1) return false;
|
if (w->selectedIndex == -1) return false;
|
||||||
|
|
||||||
@ -1106,7 +1106,7 @@ static void InputWidget_CopyFromClipboard(String* text, void* w) {
|
|||||||
InputWidget_AppendString((struct InputWidget*)w, text);
|
InputWidget_AppendString((struct InputWidget*)w, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static cc_bool InputWidget_OtherKey(struct InputWidget* w, Key key) {
|
static cc_bool InputWidget_OtherKey(struct InputWidget* w, int key) {
|
||||||
int maxChars = w->GetMaxLines() * INPUTWIDGET_LEN;
|
int maxChars = w->GetMaxLines() * INPUTWIDGET_LEN;
|
||||||
if (!Key_IsActionPressed()) return false;
|
if (!Key_IsActionPressed()) return false;
|
||||||
|
|
||||||
@ -1150,7 +1150,7 @@ static void InputWidget_Reposition(void* widget) {
|
|||||||
w->inputTex.X += w->x - oldX; w->inputTex.Y += w->y - oldY;
|
w->inputTex.X += w->x - oldX; w->inputTex.Y += w->y - oldY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int InputWidget_KeyDown(void* widget, Key key) {
|
static int InputWidget_KeyDown(void* widget, int key) {
|
||||||
struct InputWidget* w = (struct InputWidget*)widget;
|
struct InputWidget* w = (struct InputWidget*)widget;
|
||||||
if (key == KEY_LEFT) {
|
if (key == KEY_LEFT) {
|
||||||
InputWidget_LeftKey(w);
|
InputWidget_LeftKey(w);
|
||||||
@ -1170,7 +1170,7 @@ static int InputWidget_KeyDown(void* widget, Key key) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int InputWidget_KeyUp(void* widget, Key key) { return true; }
|
static int InputWidget_KeyUp(void* widget, int key) { return true; }
|
||||||
|
|
||||||
static int InputWidget_PointerDown(void* widget, int id, int x, int y) {
|
static int InputWidget_PointerDown(void* widget, int id, int x, int y) {
|
||||||
String line; char lineBuffer[STRING_SIZE];
|
String line; char lineBuffer[STRING_SIZE];
|
||||||
@ -1666,7 +1666,7 @@ static void ChatInputWidget_TabKey(struct InputWidget* w) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ChatInputWidget_KeyDown(void* widget, Key key) {
|
static int ChatInputWidget_KeyDown(void* widget, int key) {
|
||||||
struct InputWidget* w = (struct InputWidget*)widget;
|
struct InputWidget* w = (struct InputWidget*)widget;
|
||||||
if (key == KEY_TAB) { ChatInputWidget_TabKey(w); return true; }
|
if (key == KEY_TAB) { ChatInputWidget_TabKey(w); return true; }
|
||||||
if (key == KEY_UP) { ChatInputWidget_UpKey(w); return true; }
|
if (key == KEY_UP) { ChatInputWidget_UpKey(w); return true; }
|
||||||
|
22
src/Window.c
22
src/Window.c
@ -166,7 +166,7 @@ static const cc_uint8 key_map[14 * 16] = {
|
|||||||
KEY_TILDE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
KEY_TILDE, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_LBRACKET, KEY_BACKSLASH, KEY_RBRACKET, KEY_QUOTE, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, KEY_LBRACKET, KEY_BACKSLASH, KEY_RBRACKET, KEY_QUOTE, 0,
|
||||||
};
|
};
|
||||||
static Key Window_MapKey(WPARAM key) { return key < Array_Elems(key_map) ? key_map[key] : 0; }
|
static int Window_MapKey(WPARAM key) { return key < Array_Elems(key_map) ? key_map[key] : 0; }
|
||||||
|
|
||||||
static void Window_RefreshBounds(void) {
|
static void Window_RefreshBounds(void) {
|
||||||
RECT rect;
|
RECT rect;
|
||||||
@ -296,7 +296,7 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara
|
|||||||
LPARAM ext = lParam & (1UL << 24);
|
LPARAM ext = lParam & (1UL << 24);
|
||||||
|
|
||||||
cc_bool lShiftDown, rShiftDown;
|
cc_bool lShiftDown, rShiftDown;
|
||||||
Key key;
|
int key;
|
||||||
switch (wParam)
|
switch (wParam)
|
||||||
{
|
{
|
||||||
case VK_SHIFT:
|
case VK_SHIFT:
|
||||||
@ -747,7 +747,7 @@ static long win_eventMask;
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Private details-----------------------------------------------------*
|
*-----------------------------------------------------Private details-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
static Key Window_MapKey(KeySym key) {
|
static int Window_MapKey(KeySym key) {
|
||||||
if (key >= XK_0 && key <= XK_9) { return '0' + (key - XK_0); }
|
if (key >= XK_0 && key <= XK_9) { return '0' + (key - XK_0); }
|
||||||
if (key >= XK_A && key <= XK_Z) { return 'A' + (key - XK_A); }
|
if (key >= XK_A && key <= XK_Z) { return 'A' + (key - XK_A); }
|
||||||
if (key >= XK_a && key <= XK_z) { return 'A' + (key - XK_a); }
|
if (key >= XK_a && key <= XK_z) { return 'A' + (key - XK_a); }
|
||||||
@ -1052,7 +1052,7 @@ static void Window_ToggleKey(XKeyEvent* keyEvent, cc_bool pressed) {
|
|||||||
KeySym keysym1 = XLookupKeysym(keyEvent, 0);
|
KeySym keysym1 = XLookupKeysym(keyEvent, 0);
|
||||||
KeySym keysym2 = XLookupKeysym(keyEvent, 1);
|
KeySym keysym2 = XLookupKeysym(keyEvent, 1);
|
||||||
|
|
||||||
Key key = Window_MapKey(keysym1);
|
int key = Window_MapKey(keysym1);
|
||||||
if (!key) key = Window_MapKey(keysym2);
|
if (!key) key = Window_MapKey(keysym2);
|
||||||
if (key) Input_SetPressed(key, pressed);
|
if (key) Input_SetPressed(key, pressed);
|
||||||
}
|
}
|
||||||
@ -1708,7 +1708,7 @@ static const cc_uint8 key_map[8 * 16] = {
|
|||||||
KEY_F5, KEY_F6, KEY_F7, KEY_F3, KEY_F8, KEY_F9, 0, KEY_F11, 0, KEY_F13, 0, KEY_F14, 0, KEY_F10, 0, KEY_F12,
|
KEY_F5, KEY_F6, KEY_F7, KEY_F3, KEY_F8, KEY_F9, 0, KEY_F11, 0, KEY_F13, 0, KEY_F14, 0, KEY_F10, 0, KEY_F12,
|
||||||
'U', KEY_F15, KEY_INSERT, KEY_HOME, KEY_PAGEUP, KEY_DELETE, KEY_F4, KEY_END, KEY_F2, KEY_PAGEDOWN, KEY_F1, KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0,
|
'U', KEY_F15, KEY_INSERT, KEY_HOME, KEY_PAGEUP, KEY_DELETE, KEY_F4, KEY_END, KEY_F2, KEY_PAGEDOWN, KEY_F1, KEY_LEFT, KEY_RIGHT, KEY_DOWN, KEY_UP, 0,
|
||||||
};
|
};
|
||||||
static Key Window_MapKey(UInt32 key) { return key < Array_Elems(key_map) ? key_map[key] : 0; }
|
static int Window_MapKey(UInt32 key) { return key < Array_Elems(key_map) ? key_map[key] : 0; }
|
||||||
/* TODO: Check these.. */
|
/* TODO: Check these.. */
|
||||||
/* case 0x37: return KEY_LWIN; */
|
/* case 0x37: return KEY_LWIN; */
|
||||||
/* case 0x38: return KEY_LSHIFT; */
|
/* case 0x38: return KEY_LSHIFT; */
|
||||||
@ -1853,7 +1853,7 @@ static void Window_RefreshBounds(void) {
|
|||||||
|
|
||||||
static OSStatus Window_ProcessKeyboardEvent(EventRef inEvent) {
|
static OSStatus Window_ProcessKeyboardEvent(EventRef inEvent) {
|
||||||
UInt32 kind, code;
|
UInt32 kind, code;
|
||||||
Key key;
|
int key;
|
||||||
OSStatus res;
|
OSStatus res;
|
||||||
|
|
||||||
kind = GetEventKind(inEvent);
|
kind = GetEventKind(inEvent);
|
||||||
@ -2524,7 +2524,7 @@ void Window_Close(void) {
|
|||||||
SDL_PushEvent(&e);
|
SDL_PushEvent(&e);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Key Window_MapKey(SDL_Keycode k) {
|
static int Window_MapKey(SDL_Keycode k) {
|
||||||
if (k >= SDLK_0 && k <= SDLK_9) { return '0' + (k - SDLK_0); }
|
if (k >= SDLK_0 && k <= SDLK_9) { return '0' + (k - SDLK_0); }
|
||||||
if (k >= SDLK_a && k <= SDLK_z) { return 'A' + (k - SDLK_a); }
|
if (k >= SDLK_a && k <= SDLK_z) { return 'A' + (k - SDLK_a); }
|
||||||
if (k >= SDLK_F1 && k <= SDLK_F12) { return KEY_F1 + (k - SDLK_F1); }
|
if (k >= SDLK_F1 && k <= SDLK_F12) { return KEY_F1 + (k - SDLK_F1); }
|
||||||
@ -2587,7 +2587,7 @@ static Key Window_MapKey(SDL_Keycode k) {
|
|||||||
|
|
||||||
static void Window_HandleKeyEvent(const SDL_Event* e) {
|
static void Window_HandleKeyEvent(const SDL_Event* e) {
|
||||||
cc_bool pressed = e->key.state == SDL_PRESSED;
|
cc_bool pressed = e->key.state == SDL_PRESSED;
|
||||||
Key key = Window_MapKey(e->key.keysym.sym);
|
int key = Window_MapKey(e->key.keysym.sym);
|
||||||
if (key) Input_SetPressed(key, pressed);
|
if (key) Input_SetPressed(key, pressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2911,7 +2911,7 @@ static const char* Window_BeforeUnload(int type, const void* ev, void *data) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Key Window_MapKey(int k) {
|
static int Window_MapKey(int k) {
|
||||||
if (k >= '0' && k <= '9') return k;
|
if (k >= '0' && k <= '9') return k;
|
||||||
if (k >= 'A' && k <= 'Z') return k;
|
if (k >= 'A' && k <= 'Z') return k;
|
||||||
if (k >= DOM_VK_F1 && k <= DOM_VK_F24) { return KEY_F1 + (k - DOM_VK_F1); }
|
if (k >= DOM_VK_F1 && k <= DOM_VK_F24) { return KEY_F1 + (k - DOM_VK_F1); }
|
||||||
@ -2971,7 +2971,7 @@ static Key Window_MapKey(int k) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static EM_BOOL Window_Key(int type, const EmscriptenKeyboardEvent* ev , void* data) {
|
static EM_BOOL Window_Key(int type, const EmscriptenKeyboardEvent* ev , void* data) {
|
||||||
Key key = Window_MapKey(ev->keyCode);
|
int key = Window_MapKey(ev->keyCode);
|
||||||
Window_CorrectFocus();
|
Window_CorrectFocus();
|
||||||
if (!key) return false;
|
if (!key) return false;
|
||||||
|
|
||||||
@ -3344,7 +3344,7 @@ static void Window_RefreshBounds(void) {
|
|||||||
Event_RaiseVoid(&WindowEvents.Resized);
|
Event_RaiseVoid(&WindowEvents.Resized);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Key Window_MapKey(int code) {
|
static int Window_MapKey(int code) {
|
||||||
if (code >= AKEYCODE_0 && code <= AKEYCODE_9) return (code - AKEYCODE_0) + '0';
|
if (code >= AKEYCODE_0 && code <= AKEYCODE_9) return (code - AKEYCODE_0) + '0';
|
||||||
if (code >= AKEYCODE_A && code <= AKEYCODE_Z) return (code - AKEYCODE_A) + 'A';
|
if (code >= AKEYCODE_A && code <= AKEYCODE_Z) return (code - AKEYCODE_A) + 'A';
|
||||||
if (code >= AKEYCODE_F1 && code <= AKEYCODE_F12) return (code - AKEYCODE_F1) + KEY_F1;
|
if (code >= AKEYCODE_F1 && code <= AKEYCODE_F12) return (code - AKEYCODE_F1) + KEY_F1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user