type alias refactor
This commit is contained in:
@@ -18,7 +18,7 @@ enum {
|
||||
kVK_ANSI_KeypadEnter = 0x4C,
|
||||
};
|
||||
|
||||
static uint8_t macos_keycode_to_pkey(uint16_t keycode) {
|
||||
static U8 macos_keycode_to_pkey(U16 keycode) {
|
||||
switch (keycode) {
|
||||
case kVK_ANSI_A: return PKEY_A;
|
||||
case kVK_ANSI_C: return PKEY_C;
|
||||
@@ -114,7 +114,7 @@ static PlatformWindow *g_current_window = nullptr;
|
||||
}
|
||||
|
||||
- (void)keyDown:(NSEvent *)event {
|
||||
extern void platform_macos_key_down(uint16_t keycode, NSEventModifierFlags mods);
|
||||
extern void platform_macos_key_down(U16 keycode, NSEventModifierFlags mods);
|
||||
platform_macos_key_down([event keyCode], [event modifierFlags]);
|
||||
|
||||
// Feed into text input system for character generation
|
||||
@@ -142,8 +142,8 @@ static PlatformWindow *g_current_window = nullptr;
|
||||
- (void)mouseDragged:(NSEvent *)event { (void)event; }
|
||||
|
||||
- (void)scrollWheel:(NSEvent *)event {
|
||||
extern void platform_macos_scroll(float dx, float dy);
|
||||
float dy = (float)[event scrollingDeltaY];
|
||||
extern void platform_macos_scroll(F32 dx, F32 dy);
|
||||
F32 dy = (F32)[event scrollingDeltaY];
|
||||
if ([event hasPreciseScrollingDeltas])
|
||||
dy /= 40.0f; // Normalize trackpad deltas to match discrete wheel steps
|
||||
platform_macos_scroll(0, dy);
|
||||
@@ -160,10 +160,10 @@ struct PlatformWindow {
|
||||
NSWindow *ns_window;
|
||||
ASmplView *view;
|
||||
ASmplWindowDelegate *delegate;
|
||||
bool should_close;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
int32_t pending_menu_cmd;
|
||||
B32 should_close;
|
||||
S32 width;
|
||||
S32 height;
|
||||
S32 pending_menu_cmd;
|
||||
PlatformFrameCallback frame_callback;
|
||||
void *frame_callback_user_data;
|
||||
PlatformInput input;
|
||||
@@ -183,8 +183,8 @@ void platform_macos_handle_resize() {
|
||||
if (!g_current_window) return;
|
||||
NSRect frame = [g_current_window->view bounds];
|
||||
F32 scale = g_current_window->backing_scale;
|
||||
g_current_window->width = (int32_t)(frame.size.width * scale);
|
||||
g_current_window->height = (int32_t)(frame.size.height * scale);
|
||||
g_current_window->width = (S32)(frame.size.width * scale);
|
||||
g_current_window->height = (S32)(frame.size.height * scale);
|
||||
if (g_current_window->frame_callback)
|
||||
g_current_window->frame_callback(g_current_window->frame_callback_user_data);
|
||||
}
|
||||
@@ -193,11 +193,11 @@ void platform_macos_insert_text(const char *utf8) {
|
||||
if (!g_current_window || !utf8) return;
|
||||
PlatformInput *ev = &g_current_window->input;
|
||||
while (*utf8 && ev->char_count < PLATFORM_MAX_CHARS_PER_FRAME) {
|
||||
uint8_t c = (uint8_t)*utf8;
|
||||
U8 c = (U8)*utf8;
|
||||
if (c < 32) { utf8++; continue; }
|
||||
// Handle ASCII printable range (single-byte UTF-8)
|
||||
if (c < 0x80) {
|
||||
ev->chars[ev->char_count++] = (uint16_t)c;
|
||||
ev->chars[ev->char_count++] = (U16)c;
|
||||
utf8++;
|
||||
} else {
|
||||
// Skip multi-byte UTF-8 sequences for now (UI only handles ASCII)
|
||||
@@ -208,11 +208,11 @@ void platform_macos_insert_text(const char *utf8) {
|
||||
}
|
||||
}
|
||||
|
||||
void platform_macos_key_down(uint16_t keycode, NSEventModifierFlags mods) {
|
||||
void platform_macos_key_down(U16 keycode, NSEventModifierFlags mods) {
|
||||
if (!g_current_window) return;
|
||||
PlatformInput *ev = &g_current_window->input;
|
||||
|
||||
uint8_t pkey = macos_keycode_to_pkey(keycode);
|
||||
U8 pkey = macos_keycode_to_pkey(keycode);
|
||||
if (pkey && ev->key_count < PLATFORM_MAX_KEYS_PER_FRAME)
|
||||
ev->keys[ev->key_count++] = pkey;
|
||||
|
||||
@@ -229,7 +229,7 @@ void platform_macos_mouse_up() {
|
||||
if (g_current_window) g_current_window->mouse_down_state = 0;
|
||||
}
|
||||
|
||||
void platform_macos_scroll(float dx, float dy) {
|
||||
void platform_macos_scroll(F32 dx, F32 dy) {
|
||||
(void)dx;
|
||||
if (g_current_window) g_current_window->input.scroll_delta.y += dy;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ void platform_macos_scroll(float dx, float dy) {
|
||||
- (void)menuAction:(id)sender {
|
||||
if (!g_current_window) return;
|
||||
NSMenuItem *item = (NSMenuItem *)sender;
|
||||
g_current_window->pending_menu_cmd = (int32_t)[item tag];
|
||||
g_current_window->pending_menu_cmd = (S32)[item tag];
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -288,8 +288,8 @@ PlatformWindow *platform_create_window(PlatformWindowDesc *desc) {
|
||||
window->delegate = delegate;
|
||||
window->should_close = false;
|
||||
window->backing_scale = (F32)[ns_window backingScaleFactor];
|
||||
window->width = (int32_t)(desc->width * window->backing_scale);
|
||||
window->height = (int32_t)(desc->height * window->backing_scale);
|
||||
window->width = (S32)(desc->width * window->backing_scale);
|
||||
window->height = (S32)(desc->height * window->backing_scale);
|
||||
|
||||
g_current_window = window;
|
||||
|
||||
@@ -308,7 +308,7 @@ void platform_destroy_window(PlatformWindow *window) {
|
||||
delete window;
|
||||
}
|
||||
|
||||
bool platform_poll_events(PlatformWindow *window) {
|
||||
B32 platform_poll_events(PlatformWindow *window) {
|
||||
@autoreleasepool {
|
||||
NSEvent *event;
|
||||
while ((event = [NSApp nextEventMatchingMask:NSEventMaskAny
|
||||
@@ -321,7 +321,7 @@ bool platform_poll_events(PlatformWindow *window) {
|
||||
return !window->should_close;
|
||||
}
|
||||
|
||||
void platform_get_size(PlatformWindow *window, int32_t *w, int32_t *h) {
|
||||
void platform_get_size(PlatformWindow *window, S32 *w, S32 *h) {
|
||||
if (w) *w = window->width;
|
||||
if (h) *h = window->height;
|
||||
}
|
||||
@@ -335,7 +335,7 @@ void platform_set_frame_callback(PlatformWindow *window, PlatformFrameCallback c
|
||||
window->frame_callback_user_data = user_data;
|
||||
}
|
||||
|
||||
void platform_set_menu(PlatformWindow *window, PlatformMenu *menus, int32_t menu_count) {
|
||||
void platform_set_menu(PlatformWindow *window, PlatformMenu *menus, S32 menu_count) {
|
||||
(void)window;
|
||||
|
||||
if (!g_menu_target)
|
||||
@@ -352,12 +352,12 @@ void platform_set_menu(PlatformWindow *window, PlatformMenu *menus, int32_t menu
|
||||
[app_menu_item setSubmenu:app_menu];
|
||||
[menu_bar addItem:app_menu_item];
|
||||
|
||||
for (int32_t i = 0; i < menu_count; i++) {
|
||||
for (S32 i = 0; i < menu_count; i++) {
|
||||
NSMenuItem *top_item = [[NSMenuItem alloc] init];
|
||||
NSMenu *submenu = [[NSMenu alloc] initWithTitle:
|
||||
[NSString stringWithUTF8String:menus[i].label]];
|
||||
|
||||
for (int32_t j = 0; j < menus[i].item_count; j++) {
|
||||
for (S32 j = 0; j < menus[i].item_count; j++) {
|
||||
PlatformMenuItem *item = &menus[i].items[j];
|
||||
if (!item->label) {
|
||||
[submenu addItem:[NSMenuItem separatorItem]];
|
||||
@@ -379,8 +379,8 @@ void platform_set_menu(PlatformWindow *window, PlatformMenu *menus, int32_t menu
|
||||
[NSApp setMainMenu:menu_bar];
|
||||
}
|
||||
|
||||
int32_t platform_poll_menu_command(PlatformWindow *window) {
|
||||
int32_t cmd = window->pending_menu_cmd;
|
||||
S32 platform_poll_menu_command(PlatformWindow *window) {
|
||||
S32 cmd = window->pending_menu_cmd;
|
||||
window->pending_menu_cmd = 0;
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user