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
064b22f2
Commit
064b22f2
authored
Aug 12, 2015
by
Jan Holthuis
Browse files
linux-dist: Harmonize input device fd names
parent
3dc97132
Changes
1
Show whitespace changes
Inline
Side-by-side
core/linux-dist/main.cpp
View file @
064b22f2
...
...
@@ -112,8 +112,8 @@ enum DCPad
void
emit_WriteCodeCache
();
static
int
J
oy
FD
=
-
1
;
// Joystick file descriptor
static
int
kb
fd
=
-
1
;
static
int
j
oy
stick_fd
=
-
1
;
// Joystick file descriptor
static
int
evdev_
fd
=
-
1
;
#define MAP_SIZE 32
...
...
@@ -196,15 +196,15 @@ void SetupInput()
#else
#define EVDEV_DEVICE "/dev/event2"
#endif
kb
fd
=
setup_input_evdev
(
EVDEV_DEVICE
);
J
oy
FD
=
setup_input_joystick
(
"/dev/input/js0"
);
evdev_
fd
=
setup_input_evdev
(
EVDEV_DEVICE
);
j
oy
stick_fd
=
setup_input_joystick
(
"/dev/input/js0"
);
#endif
}
bool
HandleKb
(
u32
port
)
{
#if HOST_OS != OS_DARWIN && !defined(TARGET_EMSCRIPTEN)
if
(
kb
fd
<
0
)
if
(
evdev_
fd
<
0
)
{
return
false
;
}
...
...
@@ -227,7 +227,7 @@ bool HandleKb(u32 port)
#define KEY_LOCK 0x77 // Note that KEY_LOCK is a switch and remains pressed until it's switched back
static
int
keys
[
13
];
while
(
read
(
kb
fd
,
&
ie
,
sizeof
(
ie
))
==
sizeof
(
ie
))
while
(
read
(
evdev_
fd
,
&
ie
,
sizeof
(
ie
))
==
sizeof
(
ie
))
{
//printf("type %i key %i state %i\n", ie.type, ie.code, ie.value);
if
(
ie
.
type
=
EV_KEY
)
...
...
@@ -264,7 +264,7 @@ bool HandleKb(u32 port)
#elif defined(TARGET_PANDORA)
static
int
keys
[
13
];
while
(
read
(
kb
fd
,
&
ie
,
sizeof
(
ie
))
==
sizeof
(
ie
))
while
(
read
(
evdev_
fd
,
&
ie
,
sizeof
(
ie
))
==
sizeof
(
ie
))
{
if
(
ie
.
type
=
EV_KEY
)
//printf("type %i key %i state %i\n", ie.type, ie.code, ie.value);
...
...
@@ -301,7 +301,7 @@ bool HandleKb(u32 port)
return
true
;
#else
while
(
read
(
kb
fd
,
&
ie
,
sizeof
(
ie
))
==
sizeof
(
ie
))
while
(
read
(
evdev_
fd
,
&
ie
,
sizeof
(
ie
))
==
sizeof
(
ie
))
{
printf
(
"type %i key %i state %i
\n
"
,
ie
.
type
,
ie
.
code
,
ie
.
value
);
}
...
...
@@ -314,13 +314,13 @@ bool HandleKb(u32 port)
bool
HandleJoystick
(
u32
port
)
{
// Joystick must be connected
if
(
J
oy
FD
<
0
)
{
if
(
j
oy
stick_fd
<
0
)
{
return
false
;
}
#if HOST_OS != OS_DARWIN && !defined(TARGET_EMSCRIPTEN)
struct
js_event
JE
;
while
(
read
(
J
oy
FD
,
&
JE
,
sizeof
(
JE
))
==
sizeof
(
JE
))
while
(
read
(
j
oy
stick_fd
,
&
JE
,
sizeof
(
JE
))
==
sizeof
(
JE
))
if
(
JE
.
number
<
MAP_SIZE
)
{
switch
(
JE
.
type
&
~
JS_EVENT_INIT
)
...
...
@@ -794,8 +794,8 @@ void dc_run();
size_t
size
;
// close files
if
(
J
oy
FD
>=
0
)
{
close
(
J
oy
FD
);
}
if
(
kb
fd
>=
0
)
{
close
(
kb
fd
);
}
if
(
j
oy
stick_fd
>=
0
)
{
close
(
j
oy
stick_fd
);
}
if
(
evdev_
fd
>=
0
)
{
close
(
evdev_
fd
);
}
// Close EGL context ???
if
(
sig_num
!=
0
)
...
...
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