mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 12:05:14 -04:00
Fix alt+keypad 1+keypad 2 not working in C client
This commit is contained in:
parent
5aba50620a
commit
0086f047f8
@ -26,6 +26,7 @@ extern ReturnCode ReturnCode_NotSupported;
|
|||||||
extern ReturnCode ReturnCode_SocketInProgess;
|
extern ReturnCode ReturnCode_SocketInProgess;
|
||||||
extern ReturnCode ReturnCode_SocketWouldBlock;
|
extern ReturnCode ReturnCode_SocketWouldBlock;
|
||||||
|
|
||||||
|
void Platform_UnicodeExpand(void* dstPtr, STRING_PURE String* src);
|
||||||
void Platform_Init(void);
|
void Platform_Init(void);
|
||||||
void Platform_Free(void);
|
void Platform_Free(void);
|
||||||
void Platform_Exit(ReturnCode code);
|
void Platform_Exit(ReturnCode code);
|
||||||
|
@ -31,8 +31,9 @@ ReturnCode ReturnCode_FileShareViolation = ERROR_SHARING_VIOLATION;
|
|||||||
ReturnCode ReturnCode_FileNotFound = ERROR_FILE_NOT_FOUND;
|
ReturnCode ReturnCode_FileNotFound = ERROR_FILE_NOT_FOUND;
|
||||||
ReturnCode ReturnCode_NotSupported = ERROR_NOT_SUPPORTED;
|
ReturnCode ReturnCode_NotSupported = ERROR_NOT_SUPPORTED;
|
||||||
|
|
||||||
static void Platform_UnicodeExpand(WCHAR* dst, STRING_PURE String* src) {
|
void Platform_UnicodeExpand(void* dstPtr, STRING_PURE String* src) {
|
||||||
if (src->length > FILENAME_SIZE) ErrorHandler_Fail("String too long to expand");
|
if (src->length > FILENAME_SIZE) ErrorHandler_Fail("String too long to expand");
|
||||||
|
WCHAR* dst = dstPtr;
|
||||||
|
|
||||||
Int32 i;
|
Int32 i;
|
||||||
for (i = 0; i < src->length; i++) {
|
for (i = 0; i < src->length; i++) {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#define win_Style WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN
|
#define win_Style WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN
|
||||||
#define win_ClassName "ClassiCube_Window"
|
#define win_ClassName L"ClassiCube_Window"
|
||||||
#define RECT_WIDTH(rect) (rect.right - rect.left)
|
#define RECT_WIDTH(rect) (rect.right - rect.left)
|
||||||
#define RECT_HEIGHT(rect) (rect.bottom - rect.top)
|
#define RECT_HEIGHT(rect) (rect.bottom - rect.top)
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ static void Window_DoSetHiddenBorder(bool value) {
|
|||||||
/* This avoids leaving garbage on the background window. */
|
/* This avoids leaving garbage on the background window. */
|
||||||
if (was_visible) Window_SetVisible(false);
|
if (was_visible) Window_SetVisible(false);
|
||||||
|
|
||||||
SetWindowLongA(win_Handle, GWL_STYLE, style);
|
SetWindowLongW(win_Handle, GWL_STYLE, style);
|
||||||
SetWindowPos(win_Handle, NULL, 0, 0, RECT_WIDTH(rect), RECT_HEIGHT(rect),
|
SetWindowPos(win_Handle, NULL, 0, 0, RECT_WIDTH(rect), RECT_HEIGHT(rect),
|
||||||
SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
|
||||||
|
|
||||||
@ -379,18 +379,18 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara
|
|||||||
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
Window_Exists = false;
|
Window_Exists = false;
|
||||||
UnregisterClassA(win_ClassName, win_Instance);
|
UnregisterClassW(win_ClassName, win_Instance);
|
||||||
if (win_DC) ReleaseDC(win_Handle, win_DC);
|
if (win_DC) ReleaseDC(win_Handle, win_DC);
|
||||||
Event_RaiseVoid(&WindowEvents_Closed);
|
Event_RaiseVoid(&WindowEvents_Closed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return DefWindowProcA(handle, message, wParam, lParam);
|
return DefWindowProcW(handle, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_REF String* title,
|
void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_REF String* title,
|
||||||
struct GraphicsMode* mode, struct DisplayDevice* device) {
|
struct GraphicsMode* mode, struct DisplayDevice* device) {
|
||||||
win_Instance = GetModuleHandleA(NULL);
|
win_Instance = GetModuleHandleW(NULL);
|
||||||
/* TODO: UngroupFromTaskbar(); */
|
/* TODO: UngroupFromTaskbar(); */
|
||||||
|
|
||||||
/* Find out the final window rectangle, after the WM has added its chrome (titlebar, sidebars etc). */
|
/* Find out the final window rectangle, after the WM has added its chrome (titlebar, sidebars etc). */
|
||||||
@ -398,21 +398,22 @@ void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_REF Strin
|
|||||||
rect.right = x + width; rect.bottom = y + height;
|
rect.right = x + width; rect.bottom = y + height;
|
||||||
AdjustWindowRect(&rect, win_Style, false);
|
AdjustWindowRect(&rect, win_Style, false);
|
||||||
|
|
||||||
WNDCLASSEXA wc = { 0 };
|
WNDCLASSEXW wc = { 0 };
|
||||||
wc.cbSize = sizeof(WNDCLASSEXA);
|
wc.cbSize = sizeof(WNDCLASSEXW);
|
||||||
wc.style = CS_OWNDC;
|
wc.style = CS_OWNDC;
|
||||||
wc.hInstance = win_Instance;
|
wc.hInstance = win_Instance;
|
||||||
wc.lpfnWndProc = Window_Procedure;
|
wc.lpfnWndProc = Window_Procedure;
|
||||||
wc.lpszClassName = win_ClassName;
|
wc.lpszClassName = win_ClassName;
|
||||||
/* TODO: Set window icons here */
|
/* TODO: Set window icons here */
|
||||||
wc.hCursor = LoadCursorA(NULL, IDC_ARROW);
|
wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
|
||||||
|
|
||||||
ATOM atom = RegisterClassExA(&wc);
|
ATOM atom = RegisterClassExW(&wc);
|
||||||
if (atom == 0) {
|
if (atom == 0) {
|
||||||
ErrorHandler_FailWithCode(GetLastError(), "Failed to register window class");
|
ErrorHandler_FailWithCode(GetLastError(), "Failed to register window class");
|
||||||
}
|
}
|
||||||
win_Handle = CreateWindowExA(
|
WCHAR data[512]; Platform_UnicodeExpand(data, title);
|
||||||
0, atom, title->buffer, win_Style,
|
|
||||||
|
win_Handle = CreateWindowExW(0, atom, data, win_Style,
|
||||||
rect.left, rect.top, RECT_WIDTH(rect), RECT_HEIGHT(rect),
|
rect.left, rect.top, RECT_WIDTH(rect), RECT_HEIGHT(rect),
|
||||||
NULL, NULL, win_Instance, NULL);
|
NULL, NULL, win_Instance, NULL);
|
||||||
|
|
||||||
@ -507,7 +508,7 @@ void Window_SetSize(struct Size2D size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Window_SetClientSize(struct Size2D size) {
|
void Window_SetClientSize(struct Size2D size) {
|
||||||
DWORD style = GetWindowLongA(win_Handle, GWL_STYLE);
|
DWORD style = GetWindowLongW(win_Handle, GWL_STYLE);
|
||||||
RECT rect; rect.left = 0; rect.top = 0;
|
RECT rect; rect.left = 0; rect.top = 0;
|
||||||
rect.right = size.Width; rect.bottom = size.Height;
|
rect.right = size.Width; rect.bottom = size.Height;
|
||||||
|
|
||||||
@ -533,7 +534,7 @@ void Window_SetVisible(bool visible) {
|
|||||||
|
|
||||||
|
|
||||||
void Window_Close(void) {
|
void Window_Close(void) {
|
||||||
PostMessageA(win_Handle, WM_CLOSE, NULL, NULL);
|
PostMessageW(win_Handle, WM_CLOSE, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
UInt8 Window_GetWindowState(void) { return win_State; }
|
UInt8 Window_GetWindowState(void) { return win_State; }
|
||||||
@ -605,9 +606,9 @@ struct Point2D Window_PointToScreen(struct Point2D point) {
|
|||||||
|
|
||||||
void Window_ProcessEvents(void) {
|
void Window_ProcessEvents(void) {
|
||||||
MSG msg;
|
MSG msg;
|
||||||
while (PeekMessageA(&msg, NULL, 0, 0, 1)) {
|
while (PeekMessageW(&msg, NULL, 0, 0, 1)) {
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessageA(&msg);
|
DispatchMessageW(&msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
HWND foreground = GetForegroundWindow();
|
HWND foreground = GetForegroundWindow();
|
||||||
|
@ -25,8 +25,9 @@ ReturnCode ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparen
|
|||||||
ReturnCode ReturnCode_FileNotFound = ENOENT;
|
ReturnCode ReturnCode_FileNotFound = ENOENT;
|
||||||
ReturnCode ReturnCode_NotSupported = EPERM;
|
ReturnCode ReturnCode_NotSupported = EPERM;
|
||||||
|
|
||||||
static void Platform_UnicodeExpand(UInt8* dst, STRING_PURE String* src) {
|
void Platform_UnicodeExpand(void* dstPtr, STRING_PURE String* src) {
|
||||||
if (src->length > FILENAME_SIZE) ErrorHandler_Fail("String too long to expand");
|
if (src->length > FILENAME_SIZE) ErrorHandler_Fail("String too long to expand");
|
||||||
|
UInt8* dst = dstPtr;
|
||||||
|
|
||||||
Int32 i;
|
Int32 i;
|
||||||
for (i = 0; i < src->length; i++) {
|
for (i = 0; i < src->length; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user