mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 08:43:10 +00:00
Cleanups
This commit is contained in:
parent
08776496ed
commit
a49b5b7129
@ -26,59 +26,53 @@
|
|||||||
#include "linux_common.h"
|
#include "linux_common.h"
|
||||||
|
|
||||||
/* TODO/FIXME - static globals */
|
/* TODO/FIXME - static globals */
|
||||||
static struct termios oldTerm, newTerm;
|
static struct termios old_term, new_term;
|
||||||
static long oldKbmd = 0xffff;
|
static long old_kbmd = 0xffff;
|
||||||
static bool linux_stdin_claimed = false;
|
static bool linux_stdin_claimed = false;
|
||||||
|
|
||||||
void linux_terminal_flush(void)
|
|
||||||
{
|
|
||||||
tcsetattr(0, TCSAFLUSH, &oldTerm);
|
|
||||||
}
|
|
||||||
|
|
||||||
void linux_terminal_restore_input(void)
|
void linux_terminal_restore_input(void)
|
||||||
{
|
{
|
||||||
if (oldKbmd == 0xffff)
|
if (old_kbmd == 0xffff)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (ioctl(0, KDSKBMODE, oldKbmd) < 0)
|
if (ioctl(0, KDSKBMODE, old_kbmd) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
linux_terminal_flush();
|
tcsetattr(0, TCSAFLUSH, &old_term);
|
||||||
oldKbmd = 0xffff;
|
old_kbmd = 0xffff;
|
||||||
|
|
||||||
linux_stdin_claimed = false;
|
linux_stdin_claimed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disables input */
|
/* Disables input */
|
||||||
|
static bool linux_terminal_init(void)
|
||||||
bool linux_terminal_init(void)
|
|
||||||
{
|
{
|
||||||
if (oldKbmd != 0xffff)
|
if (old_kbmd != 0xffff)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (tcgetattr(0, &oldTerm) < 0)
|
if (tcgetattr(0, &old_term) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
newTerm = oldTerm;
|
new_term = old_term;
|
||||||
newTerm.c_lflag &= ~(ECHO | ICANON | ISIG);
|
new_term.c_lflag &= ~(ECHO | ICANON | ISIG);
|
||||||
newTerm.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
|
new_term.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
|
||||||
newTerm.c_cc[VMIN] = 0;
|
new_term.c_cc[VMIN] = 0;
|
||||||
newTerm.c_cc[VTIME] = 0;
|
new_term.c_cc[VTIME] = 0;
|
||||||
|
|
||||||
/* Be careful about recovering the terminal. */
|
/* Be careful about recovering the terminal. */
|
||||||
if (ioctl(0, KDGKBMODE, &oldKbmd) < 0)
|
if (ioctl(0, KDGKBMODE, &old_kbmd) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (tcsetattr(0, TCSAFLUSH, &newTerm) < 0)
|
if (tcsetattr(0, TCSAFLUSH, &new_term) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We need to disable use of stdin command interface if
|
||||||
|
* stdin is supposed to be used for input. */
|
||||||
void linux_terminal_claim_stdin(void)
|
void linux_terminal_claim_stdin(void)
|
||||||
{
|
{
|
||||||
/* We need to disable use of stdin command interface if
|
|
||||||
* stdin is supposed to be used for input. */
|
|
||||||
linux_stdin_claimed = true;
|
linux_stdin_claimed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +100,7 @@ bool linux_terminal_disable_input(void)
|
|||||||
|
|
||||||
if (ioctl(0, KDSKBMODE, K_MEDIUMRAW) < 0)
|
if (ioctl(0, KDSKBMODE, K_MEDIUMRAW) < 0)
|
||||||
{
|
{
|
||||||
linux_terminal_flush();
|
tcsetattr(0, TCSAFLUSH, &old_term);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,12 +19,8 @@
|
|||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
void linux_terminal_flush(void);
|
|
||||||
|
|
||||||
void linux_terminal_restore_input(void);
|
void linux_terminal_restore_input(void);
|
||||||
|
|
||||||
bool linux_terminal_init(void);
|
|
||||||
|
|
||||||
void linux_terminal_claim_stdin(void);
|
void linux_terminal_claim_stdin(void);
|
||||||
|
|
||||||
bool linux_terminal_grab_stdin(void *data);
|
bool linux_terminal_grab_stdin(void *data);
|
||||||
|
@ -32,7 +32,6 @@ static void keyboard_handle_keymap(void* data,
|
|||||||
int fd,
|
int fd,
|
||||||
uint32_t size)
|
uint32_t size)
|
||||||
{
|
{
|
||||||
(void)data;
|
|
||||||
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
|
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
|
||||||
{
|
{
|
||||||
close(fd);
|
close(fd);
|
||||||
@ -74,10 +73,6 @@ static void keyboard_handle_key(void *data,
|
|||||||
uint32_t key,
|
uint32_t key,
|
||||||
uint32_t state)
|
uint32_t state)
|
||||||
{
|
{
|
||||||
(void)serial;
|
|
||||||
(void)time;
|
|
||||||
(void)keyboard;
|
|
||||||
|
|
||||||
int value = 1;
|
int value = 1;
|
||||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||||
|
|
||||||
@ -109,16 +104,8 @@ static void keyboard_handle_modifiers(void *data,
|
|||||||
uint32_t modsLocked,
|
uint32_t modsLocked,
|
||||||
uint32_t group)
|
uint32_t group)
|
||||||
{
|
{
|
||||||
(void)data;
|
|
||||||
(void)keyboard;
|
|
||||||
(void)serial;
|
|
||||||
#ifdef HAVE_XKBCOMMON
|
#ifdef HAVE_XKBCOMMON
|
||||||
handle_xkb_state_mask(modsDepressed, modsLatched, modsLocked, group);
|
handle_xkb_state_mask(modsDepressed, modsLatched, modsLocked, group);
|
||||||
#else
|
|
||||||
(void)modsDepressed;
|
|
||||||
(void)modsLatched;
|
|
||||||
(void)modsLocked;
|
|
||||||
(void)group;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,10 +114,6 @@ void keyboard_handle_repeat_info(void *data,
|
|||||||
int32_t rate,
|
int32_t rate,
|
||||||
int32_t delay)
|
int32_t delay)
|
||||||
{
|
{
|
||||||
(void)data;
|
|
||||||
(void)wl_keyboard;
|
|
||||||
(void)rate;
|
|
||||||
(void)delay;
|
|
||||||
/* TODO: Seems like we'll need this to get
|
/* TODO: Seems like we'll need this to get
|
||||||
* repeat working. We'll have to do it on our own. */
|
* repeat working. We'll have to do it on our own. */
|
||||||
}
|
}
|
||||||
@ -163,9 +146,6 @@ static void pointer_handle_enter(void *data,
|
|||||||
wl_fixed_t sy)
|
wl_fixed_t sy)
|
||||||
{
|
{
|
||||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||||
(void)pointer;
|
|
||||||
(void)serial;
|
|
||||||
(void)surface;
|
|
||||||
|
|
||||||
wl->input.mouse.last_x = wl_fixed_to_int(sx * (wl_fixed_t)wl->buffer_scale);
|
wl->input.mouse.last_x = wl_fixed_to_int(sx * (wl_fixed_t)wl->buffer_scale);
|
||||||
wl->input.mouse.last_y = wl_fixed_to_int(sy * (wl_fixed_t)wl->buffer_scale);
|
wl->input.mouse.last_y = wl_fixed_to_int(sy * (wl_fixed_t)wl->buffer_scale);
|
||||||
@ -184,9 +164,6 @@ static void pointer_handle_leave(void *data,
|
|||||||
{
|
{
|
||||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||||
wl->input.mouse.focus = false;
|
wl->input.mouse.focus = false;
|
||||||
(void)pointer;
|
|
||||||
(void)serial;
|
|
||||||
(void)surface;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pointer_handle_motion(void *data,
|
static void pointer_handle_motion(void *data,
|
||||||
@ -213,31 +190,41 @@ static void pointer_handle_button(void *data,
|
|||||||
|
|
||||||
if (state == WL_POINTER_BUTTON_STATE_PRESSED)
|
if (state == WL_POINTER_BUTTON_STATE_PRESSED)
|
||||||
{
|
{
|
||||||
if (button == BTN_LEFT)
|
switch (button)
|
||||||
{
|
{
|
||||||
wl->input.mouse.left = true;
|
case BTN_LEFT:
|
||||||
|
wl->input.mouse.left = true;
|
||||||
|
|
||||||
if (BIT_GET(wl->input.key_state, KEY_LEFTALT))
|
if (BIT_GET(wl->input.key_state, KEY_LEFTALT))
|
||||||
{
|
{
|
||||||
if (wl->xdg_toplevel)
|
if (wl->xdg_toplevel)
|
||||||
xdg_toplevel_move(wl->xdg_toplevel, wl->seat, serial);
|
xdg_toplevel_move(wl->xdg_toplevel, wl->seat, serial);
|
||||||
else if (wl->zxdg_toplevel)
|
else if (wl->zxdg_toplevel)
|
||||||
zxdg_toplevel_v6_move(wl->zxdg_toplevel, wl->seat, serial);
|
zxdg_toplevel_v6_move(wl->zxdg_toplevel, wl->seat, serial);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case BTN_RIGHT:
|
||||||
|
wl->input.mouse.right = true;
|
||||||
|
break;
|
||||||
|
case BTN_MIDDLE:
|
||||||
|
wl->input.mouse.middle = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (button == BTN_RIGHT)
|
|
||||||
wl->input.mouse.right = true;
|
|
||||||
else if (button == BTN_MIDDLE)
|
|
||||||
wl->input.mouse.middle = true;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (button == BTN_LEFT)
|
switch (button)
|
||||||
wl->input.mouse.left = false;
|
{
|
||||||
else if (button == BTN_RIGHT)
|
case BTN_LEFT:
|
||||||
wl->input.mouse.right = false;
|
wl->input.mouse.left = false;
|
||||||
else if (button == BTN_MIDDLE)
|
break;
|
||||||
wl->input.mouse.middle = false;
|
case BTN_RIGHT:
|
||||||
|
wl->input.mouse.right = false;
|
||||||
|
break;
|
||||||
|
case BTN_MIDDLE:
|
||||||
|
wl->input.mouse.middle = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,14 +232,7 @@ static void pointer_handle_axis(void *data,
|
|||||||
struct wl_pointer *wl_pointer,
|
struct wl_pointer *wl_pointer,
|
||||||
uint32_t time,
|
uint32_t time,
|
||||||
uint32_t axis,
|
uint32_t axis,
|
||||||
wl_fixed_t value)
|
wl_fixed_t value) { }
|
||||||
{
|
|
||||||
(void)data;
|
|
||||||
(void)wl_pointer;
|
|
||||||
(void)time;
|
|
||||||
(void)axis;
|
|
||||||
(void)value;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* TODO: implement check for resize */
|
/* TODO: implement check for resize */
|
||||||
|
|
||||||
@ -368,10 +348,7 @@ static void touch_handle_motion(void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void touch_handle_frame(void *data,
|
static void touch_handle_frame(void *data,
|
||||||
struct wl_touch *wl_touch)
|
struct wl_touch *wl_touch) { }
|
||||||
{
|
|
||||||
/* TODO */
|
|
||||||
}
|
|
||||||
|
|
||||||
static void touch_handle_cancel(void *data,
|
static void touch_handle_cancel(void *data,
|
||||||
struct wl_touch *wl_touch)
|
struct wl_touch *wl_touch)
|
||||||
@ -433,8 +410,6 @@ static void seat_handle_capabilities(void *data,
|
|||||||
static void seat_handle_name(void *data,
|
static void seat_handle_name(void *data,
|
||||||
struct wl_seat *seat, const char *name)
|
struct wl_seat *seat, const char *name)
|
||||||
{
|
{
|
||||||
(void)data;
|
|
||||||
(void)seat;
|
|
||||||
RARCH_LOG("[Wayland]: Seat name: %s.\n", name);
|
RARCH_LOG("[Wayland]: Seat name: %s.\n", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,12 +436,7 @@ static void wl_surface_enter(void *data, struct wl_surface *wl_surface,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static void wl_nop(void *a, struct wl_surface *b, struct wl_output *c)
|
static void wl_nop(void *a, struct wl_surface *b, struct wl_output *c) { }
|
||||||
{
|
|
||||||
(void)a;
|
|
||||||
(void)b;
|
|
||||||
(void)c;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Shell surface callbacks. */
|
/* Shell surface callbacks. */
|
||||||
static void xdg_shell_ping(void *data, struct xdg_wm_base *shell, uint32_t serial)
|
static void xdg_shell_ping(void *data, struct xdg_wm_base *shell, uint32_t serial)
|
||||||
@ -546,11 +516,7 @@ static void display_handle_mode(void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void display_handle_done(void *data,
|
static void display_handle_done(void *data,
|
||||||
struct wl_output *output)
|
struct wl_output *output) { }
|
||||||
{
|
|
||||||
(void)data;
|
|
||||||
(void)output;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void display_handle_scale(void *data,
|
static void display_handle_scale(void *data,
|
||||||
struct wl_output *output,
|
struct wl_output *output,
|
||||||
@ -568,8 +534,6 @@ static void registry_handle_global(void *data, struct wl_registry *reg,
|
|||||||
{
|
{
|
||||||
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data;
|
||||||
|
|
||||||
(void)version;
|
|
||||||
|
|
||||||
if (string_is_equal(interface, "wl_compositor"))
|
if (string_is_equal(interface, "wl_compositor"))
|
||||||
wl->compositor = (struct wl_compositor*)wl_registry_bind(reg,
|
wl->compositor = (struct wl_compositor*)wl_registry_bind(reg,
|
||||||
id, &wl_compositor_interface, 3);
|
id, &wl_compositor_interface, 3);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user