Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
flycast
Commits
a49c83b2
Commit
a49c83b2
authored
Aug 14, 2015
by
Jan Holthuis
Browse files
linux-dist: Make input devices configurable
parent
d76e605a
Changes
1
Show whitespace changes
Inline
Side-by-side
core/linux-dist/main.cpp
View file @
a49c83b2
...
...
@@ -38,14 +38,6 @@
#include <sys/types.h>
#endif
#if defined(USE_EVDEV)
#ifdef TARGET_PANDORA
#define EVDEV_DEVICE "/dev/input/event4"
#else
#define EVDEV_DEVICE "/dev/event2"
#endif
#endif
#if defined(USE_JOYSTICK)
#include <linux/joystick.h>
#endif
...
...
@@ -127,10 +119,19 @@ void emit_WriteCodeCache();
static
int
evdev_fd
=
-
1
;
#if defined(USE_EVDEV)
#define EVDEV_DEVICE_STRING "/dev/input/event%d"
#ifdef TARGET_PANDORA
#define EVDEV_DEFAULT_DEVICE_ID 4
#else
#define EVDEV_DEFAULT_DEVICE_ID 0
#endif
int
input_evdev_init
(
const
char
*
device
)
{
char
name
[
256
]
=
"Unknown"
;
printf
(
"evdev: Trying to open device at '%s'"
,
device
);
int
fd
=
open
(
device
,
O_RDONLY
);
if
(
fd
>=
0
)
...
...
@@ -237,6 +238,8 @@ static int evdev_fd = -1;
static
int
joystick_fd
=
-
1
;
// Joystick file descriptor
#if defined(USE_JOYSTICK)
#define JOYSTICK_DEVICE_STRING "/dev/input/js%d"
#define JOYSTICK_DEFAULT_DEVICE_ID 0
#define JOYSTICK_MAP_SIZE 32
const
u32
joystick_map_btn_usb
[
JOYSTICK_MAP_SIZE
]
=
{
Btn_Y
,
Btn_B
,
Btn_A
,
Btn_X
,
0
,
0
,
0
,
0
,
0
,
Btn_Start
};
...
...
@@ -254,6 +257,8 @@ static int joystick_fd = -1; // Joystick file descriptor
int
button_count
=
0
;
char
name
[
128
]
=
"Unknown"
;
printf
(
"joystick: Trying to open device at '%s'"
,
device
);
int
fd
=
open
(
device
,
O_RDONLY
);
if
(
fd
>=
0
)
...
...
@@ -274,7 +279,7 @@ static int joystick_fd = -1; // Joystick file descriptor
}
else
{
perror
(
"joystick
:
open"
);
perror
(
"joystick open"
);
}
return
fd
;
...
...
@@ -390,11 +395,33 @@ static int joystick_fd = -1; // Joystick file descriptor
void
SetupInput
()
{
#if defined(USE_EVDEV)
evdev_fd
=
input_evdev_init
(
EVDEV_DEVICE
);
int
evdev_device_id
=
cfgLoadInt
(
"input"
,
"evdev_device_id"
,
EVDEV_DEFAULT_DEVICE_ID
);
if
(
evdev_device_id
<
0
)
{
puts
(
"evdev input disabled by config.
\n
"
);
}
else
{
int
evdev_device_length
=
snprintf
(
NULL
,
0
,
EVDEV_DEVICE_STRING
,
evdev_device_id
);
char
*
evdev_device
=
(
char
*
)
malloc
(
evdev_device_length
+
1
);
sprintf
(
evdev_device
,
EVDEV_DEVICE_STRING
,
evdev_device_id
);
evdev_fd
=
input_evdev_init
(
evdev_device
);
free
(
evdev_device
);
}
#endif
#if defined(USE_JOYSTICK)
joystick_fd
=
input_joystick_init
(
"/dev/input/js0"
);
int
joystick_device_id
=
cfgLoadInt
(
"input"
,
"joystick_device_id"
,
JOYSTICK_DEFAULT_DEVICE_ID
);
if
(
joystick_device_id
<
0
)
{
puts
(
"joystick input disabled by config.
\n
"
);
}
else
{
int
joystick_device_length
=
snprintf
(
NULL
,
0
,
JOYSTICK_DEVICE_STRING
,
joystick_device_id
);
char
*
joystick_device
=
(
char
*
)
malloc
(
joystick_device_length
+
1
);
sprintf
(
joystick_device
,
JOYSTICK_DEVICE_STRING
,
joystick_device_id
);
joystick_fd
=
input_joystick_init
(
joystick_device
);
free
(
joystick_device
);
}
#endif
}
...
...
@@ -860,12 +887,12 @@ int main(int argc, wchar* argv[])
common_linux_setup
();
SetupInput
();
settings
.
profile
.
run_counts
=
0
;
dc_init
(
argc
,
argv
);
SetupInput
();
#if !defined(TARGET_EMSCRIPTEN)
dc_run
();
#else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment