mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 07:59:42 +00:00
Cleanups
This commit is contained in:
parent
08776496ed
commit
a49b5b7129
@ -26,59 +26,53 @@
|
||||
#include "linux_common.h"
|
||||
|
||||
/* TODO/FIXME - static globals */
|
||||
static struct termios oldTerm, newTerm;
|
||||
static long oldKbmd = 0xffff;
|
||||
static struct termios old_term, new_term;
|
||||
static long old_kbmd = 0xffff;
|
||||
static bool linux_stdin_claimed = false;
|
||||
|
||||
void linux_terminal_flush(void)
|
||||
{
|
||||
tcsetattr(0, TCSAFLUSH, &oldTerm);
|
||||
}
|
||||
|
||||
void linux_terminal_restore_input(void)
|
||||
{
|
||||
if (oldKbmd == 0xffff)
|
||||
if (old_kbmd == 0xffff)
|
||||
return;
|
||||
|
||||
if (ioctl(0, KDSKBMODE, oldKbmd) < 0)
|
||||
if (ioctl(0, KDSKBMODE, old_kbmd) < 0)
|
||||
return;
|
||||
|
||||
linux_terminal_flush();
|
||||
oldKbmd = 0xffff;
|
||||
tcsetattr(0, TCSAFLUSH, &old_term);
|
||||
old_kbmd = 0xffff;
|
||||
|
||||
linux_stdin_claimed = false;
|
||||
}
|
||||
|
||||
/* Disables input */
|
||||
|
||||
bool linux_terminal_init(void)
|
||||
static bool linux_terminal_init(void)
|
||||
{
|
||||
if (oldKbmd != 0xffff)
|
||||
if (old_kbmd != 0xffff)
|
||||
return false;
|
||||
|
||||
if (tcgetattr(0, &oldTerm) < 0)
|
||||
if (tcgetattr(0, &old_term) < 0)
|
||||
return false;
|
||||
|
||||
newTerm = oldTerm;
|
||||
newTerm.c_lflag &= ~(ECHO | ICANON | ISIG);
|
||||
newTerm.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
|
||||
newTerm.c_cc[VMIN] = 0;
|
||||
newTerm.c_cc[VTIME] = 0;
|
||||
new_term = old_term;
|
||||
new_term.c_lflag &= ~(ECHO | ICANON | ISIG);
|
||||
new_term.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
|
||||
new_term.c_cc[VMIN] = 0;
|
||||
new_term.c_cc[VTIME] = 0;
|
||||
|
||||
/* Be careful about recovering the terminal. */
|
||||
if (ioctl(0, KDGKBMODE, &oldKbmd) < 0)
|
||||
if (ioctl(0, KDGKBMODE, &old_kbmd) < 0)
|
||||
return false;
|
||||
|
||||
if (tcsetattr(0, TCSAFLUSH, &newTerm) < 0)
|
||||
if (tcsetattr(0, TCSAFLUSH, &new_term) < 0)
|
||||
return false;
|
||||
|
||||
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)
|
||||
{
|
||||
/* We need to disable use of stdin command interface if
|
||||
* stdin is supposed to be used for input. */
|
||||
linux_stdin_claimed = true;
|
||||
}
|
||||
|
||||
@ -106,7 +100,7 @@ bool linux_terminal_disable_input(void)
|
||||
|
||||
if (ioctl(0, KDSKBMODE, K_MEDIUMRAW) < 0)
|
||||
{
|
||||
linux_terminal_flush();
|
||||
tcsetattr(0, TCSAFLUSH, &old_term);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,8 @@
|
||||
|
||||
#include <boolean.h>
|
||||
|
||||
void linux_terminal_flush(void);
|
||||
|
||||
void linux_terminal_restore_input(void);
|
||||
|
||||
bool linux_terminal_init(void);
|
||||
|
||||
void linux_terminal_claim_stdin(void);
|
||||
|
||||
bool linux_terminal_grab_stdin(void *data);
|
||||
|
@ -32,7 +32,6 @@ static void keyboard_handle_keymap(void* data,
|
||||
int fd,
|
||||
uint32_t size)
|
||||
{
|
||||
(void)data;
|
||||
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
|
||||
{
|
||||
close(fd);
|
||||
@ -74,10 +73,6 @@ static void keyboard_handle_key(void *data,
|
||||
uint32_t key,
|
||||
uint32_t state)
|
||||
{
|
||||
(void)serial;
|
||||
(void)time;
|
||||
(void)keyboard;
|
||||
|
||||
int value = 1;
|
||||
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 group)
|
||||
{
|
||||
(void)data;
|
||||
(void)keyboard;
|
||||
(void)serial;
|
||||
#ifdef HAVE_XKBCOMMON
|
||||
handle_xkb_state_mask(modsDepressed, modsLatched, modsLocked, group);
|
||||
#else
|
||||
(void)modsDepressed;
|
||||
(void)modsLatched;
|
||||
(void)modsLocked;
|
||||
(void)group;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -127,10 +114,6 @@ void keyboard_handle_repeat_info(void *data,
|
||||
int32_t rate,
|
||||
int32_t delay)
|
||||
{
|
||||
(void)data;
|
||||
(void)wl_keyboard;
|
||||
(void)rate;
|
||||
(void)delay;
|
||||
/* TODO: Seems like we'll need this to get
|
||||
* 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)
|
||||
{
|
||||
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_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;
|
||||
wl->input.mouse.focus = false;
|
||||
(void)pointer;
|
||||
(void)serial;
|
||||
(void)surface;
|
||||
}
|
||||
|
||||
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 (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 (wl->xdg_toplevel)
|
||||
xdg_toplevel_move(wl->xdg_toplevel, wl->seat, serial);
|
||||
else if (wl->zxdg_toplevel)
|
||||
zxdg_toplevel_v6_move(wl->zxdg_toplevel, wl->seat, serial);
|
||||
}
|
||||
if (BIT_GET(wl->input.key_state, KEY_LEFTALT))
|
||||
{
|
||||
if (wl->xdg_toplevel)
|
||||
xdg_toplevel_move(wl->xdg_toplevel, wl->seat, serial);
|
||||
else if (wl->zxdg_toplevel)
|
||||
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
|
||||
{
|
||||
if (button == BTN_LEFT)
|
||||
wl->input.mouse.left = false;
|
||||
else if (button == BTN_RIGHT)
|
||||
wl->input.mouse.right = false;
|
||||
else if (button == BTN_MIDDLE)
|
||||
wl->input.mouse.middle = false;
|
||||
switch (button)
|
||||
{
|
||||
case BTN_LEFT:
|
||||
wl->input.mouse.left = false;
|
||||
break;
|
||||
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,
|
||||
uint32_t time,
|
||||
uint32_t axis,
|
||||
wl_fixed_t value)
|
||||
{
|
||||
(void)data;
|
||||
(void)wl_pointer;
|
||||
(void)time;
|
||||
(void)axis;
|
||||
(void)value;
|
||||
}
|
||||
wl_fixed_t value) { }
|
||||
|
||||
/* TODO: implement check for resize */
|
||||
|
||||
@ -368,10 +348,7 @@ static void touch_handle_motion(void *data,
|
||||
}
|
||||
|
||||
static void touch_handle_frame(void *data,
|
||||
struct wl_touch *wl_touch)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
struct wl_touch *wl_touch) { }
|
||||
|
||||
static void touch_handle_cancel(void *data,
|
||||
struct wl_touch *wl_touch)
|
||||
@ -433,8 +410,6 @@ static void seat_handle_capabilities(void *data,
|
||||
static void seat_handle_name(void *data,
|
||||
struct wl_seat *seat, const char *name)
|
||||
{
|
||||
(void)data;
|
||||
(void)seat;
|
||||
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)
|
||||
{
|
||||
(void)a;
|
||||
(void)b;
|
||||
(void)c;
|
||||
}
|
||||
static void wl_nop(void *a, struct wl_surface *b, struct wl_output *c) { }
|
||||
|
||||
/* Shell surface callbacks. */
|
||||
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,
|
||||
struct wl_output *output)
|
||||
{
|
||||
(void)data;
|
||||
(void)output;
|
||||
}
|
||||
struct wl_output *output) { }
|
||||
|
||||
static void display_handle_scale(void *data,
|
||||
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;
|
||||
|
||||
(void)version;
|
||||
|
||||
if (string_is_equal(interface, "wl_compositor"))
|
||||
wl->compositor = (struct wl_compositor*)wl_registry_bind(reg,
|
||||
id, &wl_compositor_interface, 3);
|
||||
|
Loading…
Reference in New Issue
Block a user