aboutsummaryrefslogtreecommitdiff
path: root/miniLibX/mlx_mouse.m
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-11-15 15:18:38 +0100
committerCharles <sircharlesaze@gmail.com>2019-11-15 15:18:38 +0100
commita4fd7a681376899526cfe38c0449f90feb0f582e (patch)
tree1cf4a074b36903a025652a6ef1ae55e280b6418c /miniLibX/mlx_mouse.m
parent9e1f4605408821b74c9e74216fbf995d29a3921c (diff)
downloadcub3d-a4fd7a681376899526cfe38c0449f90feb0f582e.tar.gz
cub3d-a4fd7a681376899526cfe38c0449f90feb0f582e.tar.bz2
cub3d-a4fd7a681376899526cfe38c0449f90feb0f582e.zip
Added miniLibX man pages
Diffstat (limited to 'miniLibX/mlx_mouse.m')
-rw-r--r--miniLibX/mlx_mouse.m52
1 files changed, 52 insertions, 0 deletions
diff --git a/miniLibX/mlx_mouse.m b/miniLibX/mlx_mouse.m
new file mode 100644
index 0000000..94ce0a9
--- /dev/null
+++ b/miniLibX/mlx_mouse.m
@@ -0,0 +1,52 @@
+#include <stdio.h>
+
+#import <Cocoa/Cocoa.h>
+#import <OpenGL/gl3.h>
+
+#include "mlx_int.h"
+#include "mlx_new_window.h"
+
+int mlx_mouse_hide()
+{
+ // CGDisplayHideCursor(kCGDirectMainDisplay);
+ [NSCursor hide];
+ return (0);
+}
+
+int mlx_mouse_show()
+{
+ // CGDisplayShowCursor(kCGDirectMainDisplay);
+ [NSCursor unhide];
+ return (0);
+}
+
+int mlx_mouse_move(mlx_win_list_t *win, int x, int y)
+{
+ CGPoint point;
+ NSRect pos;
+ id thewin;
+
+ thewin = [(id)(win->winid) win];
+ pos = [thewin frame];
+ // printf("got win pos %f %f\n", pos.origin.x, pos.origin.y);
+ point.x = pos.origin.x + x;
+ point.y = NSHeight([[thewin screen] frame]) - NSHeight([(id)(win->winid) frame]) - pos.origin.y + 1 + y;
+ CGWarpMouseCursorPosition(point);
+ CGAssociateMouseAndMouseCursorPosition(true);
+ return (0);
+}
+
+
+int mlx_mouse_get_pos(mlx_win_list_t *win, int *x, int *y)
+{
+ CGPoint point;
+ id thewin;
+ NSRect pos;
+
+ thewin = [(id)(win->winid) win];
+ pos = [(id)(win->winid) frame];
+ point = [thewin mouseLocationOutsideOfEventStream];
+ *x = point.x;
+ *y = NSHeight(pos) - 1 - point.y;
+ return (0);
+}