mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
Use RARCH_DEVICE_MOUSE_SCREEN by default now for Zarch, start
setting up cocoa_input.c
This commit is contained in:
parent
704968adca
commit
39189047b4
@ -264,9 +264,6 @@ static void cocoa_input_poll(void *data)
|
||||
{
|
||||
uint32_t i;
|
||||
cocoa_input_data_t *apple = (cocoa_input_data_t*)data;
|
||||
|
||||
if (!apple)
|
||||
return;
|
||||
|
||||
for (i = 0; i < apple->touch_count; i++)
|
||||
input_translate_coord_viewport(
|
||||
@ -282,6 +279,9 @@ static void cocoa_input_poll(void *data)
|
||||
|
||||
if (apple->icade_enabled)
|
||||
BIT32_SET(apple->buttons[0], apple->icade_buttons);
|
||||
|
||||
apple->mouse_x_last = apple->mouse_rel_x;
|
||||
apple->mouse_y_last = apple->mouse_rel_y;
|
||||
}
|
||||
|
||||
static int16_t cocoa_mouse_state(cocoa_input_data_t *apple,
|
||||
@ -290,9 +290,9 @@ static int16_t cocoa_mouse_state(cocoa_input_data_t *apple,
|
||||
switch (id)
|
||||
{
|
||||
case RETRO_DEVICE_ID_MOUSE_X:
|
||||
return apple->mouse_x;
|
||||
return apple->mouse_rel_x - apple->mouse_x_last;
|
||||
case RETRO_DEVICE_ID_MOUSE_Y:
|
||||
return apple->mouse_y;
|
||||
return apple->mouse_rel_y - apple->mouse_y_last;
|
||||
case RETRO_DEVICE_ID_MOUSE_LEFT:
|
||||
return apple->mouse_buttons & 1;
|
||||
case RETRO_DEVICE_ID_MOUSE_RIGHT:
|
||||
@ -306,6 +306,22 @@ static int16_t cocoa_mouse_state(cocoa_input_data_t *apple,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int16_t cocoa_mouse_state_screen(cocoa_input_data_t *apple,
|
||||
unsigned id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case RETRO_DEVICE_ID_MOUSE_X:
|
||||
return apple->window_pos_x;
|
||||
case RETRO_DEVICE_ID_MOUSE_Y:
|
||||
return apple->window_pos_y;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return cocoa_mouse_state(apple, id);
|
||||
}
|
||||
|
||||
static int16_t cocoa_pointer_state(cocoa_input_data_t *apple,
|
||||
unsigned device, unsigned idx, unsigned id)
|
||||
{
|
||||
@ -370,6 +386,8 @@ static int16_t cocoa_input_state(void *data,
|
||||
return cocoa_keyboard_state(apple, id);
|
||||
case RETRO_DEVICE_MOUSE:
|
||||
return cocoa_mouse_state(apple, id);
|
||||
case RARCH_DEVICE_MOUSE_SCREEN:
|
||||
return cocoa_mouse_state_screen(apple, id);
|
||||
case RETRO_DEVICE_POINTER:
|
||||
case RARCH_DEVICE_POINTER_SCREEN:
|
||||
return cocoa_pointer_state(apple, device, idx, id);
|
||||
|
@ -43,8 +43,12 @@ typedef struct
|
||||
uint32_t touch_count;
|
||||
|
||||
uint32_t mouse_buttons;
|
||||
int16_t mouse_x;
|
||||
int16_t mouse_y;
|
||||
int16_t mouse_x_last;
|
||||
int16_t mouse_y_last;
|
||||
int16_t window_pos_x;
|
||||
int16_t window_pos_y;
|
||||
int16_t mouse_rel_x;
|
||||
int16_t mouse_rel_y;
|
||||
int16_t mouse_wu;
|
||||
int16_t mouse_wd;
|
||||
|
||||
|
@ -248,7 +248,7 @@ static void zui_begin(void)
|
||||
zui->mouse.wheel = input_driver_state(binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELDOWN) -
|
||||
input_driver_state(binds, 0, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_WHEELUP);
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
zui->mouse.x = input_driver_state(binds, 0, RARCH_DEVICE_MOUSE_SCREEN, 0, RETRO_DEVICE_ID_MOUSE_X);
|
||||
zui->mouse.y = input_driver_state(binds, 0, RARCH_DEVICE_MOUSE_SCREEN, 0, RETRO_DEVICE_ID_MOUSE_Y);
|
||||
#else
|
||||
|
@ -109,14 +109,26 @@ void apple_rarch_exited(void)
|
||||
case NSOtherMouseDragged:
|
||||
{
|
||||
NSPoint pos;
|
||||
NSPoint mouse_pos;
|
||||
/* Relative */
|
||||
apple->mouse_x = event.deltaX;
|
||||
apple->mouse_y = event.deltaY;
|
||||
apple->mouse_rel_x = event.deltaX;
|
||||
apple->mouse_rel_y = event.deltaY;
|
||||
|
||||
/* Absolute */
|
||||
pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil];
|
||||
apple->touches[0].screen_x = pos.x;
|
||||
apple->touches[0].screen_y = pos.y;
|
||||
|
||||
//window is a variable containing your window
|
||||
//mouse_pos = [self.window mouseLocationOutsideOfEventStream];
|
||||
//convert to screen coordinates
|
||||
//mouse_pos = [[self.window convertBaseToScreen:mouse_pos];
|
||||
|
||||
//mouse_pos = [event locationInWindow];
|
||||
//mouse_pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:[CocoaView get] ];
|
||||
mouse_pos = [[CocoaView get] convertPoint:[event locationInWindow] fromView:nil];
|
||||
apple->window_pos_x = (int16_t)mouse_pos.x;
|
||||
apple->window_pos_y = (int16_t)mouse_pos.y;
|
||||
}
|
||||
break;
|
||||
case NSScrollWheel:
|
||||
@ -191,9 +203,6 @@ static void poll_iteration(void)
|
||||
|
||||
if (!apple)
|
||||
return;
|
||||
|
||||
apple->mouse_x = 0;
|
||||
apple->mouse_y = 0;
|
||||
|
||||
do
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user