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
libretro-minivmac
Commits
a8be2438
Commit
a8be2438
authored
Jan 25, 2022
by
Vladimir Serbinenko
Browse files
Allow using analog to control mouse
parent
c6af4ea7
Changes
2
Hide whitespace changes
Inline
Side-by-side
libretro/libretro-core.c
View file @
a8be2438
...
...
@@ -501,6 +501,8 @@ void retro_init(void)
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_L2
,
"L2"
},
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_R3
,
"R3"
},
{
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_L3
,
"L3"
},
{
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_LEFT
,
RETRO_DEVICE_ID_ANALOG_X
,
"Mouse X"
},
{
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_LEFT
,
RETRO_DEVICE_ID_ANALOG_Y
,
"Mouse Y"
},
{
0
,
0
,
0
,
0
,
NULL
}
};
environ_cb
(
RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS
,
&
inputDescriptors
);
...
...
libretro/retrostubs.c
View file @
a8be2438
...
...
@@ -189,6 +189,17 @@ void Core_Processkey(void)
memcpy
(
Core_old_Key_Sate
,
Core_Key_Sate
,
sizeof
(
Core_Key_Sate
)
);
}
static
int
transform_axis
(
int
val
)
{
int
sign
=
val
>=
0
?
+
1
:
-
1
;
int
absval
=
val
>=
0
?
val
:
-
val
;
int
deadzone_val
=
15
*
0x7fff
/
100
;
if
(
absval
<
deadzone_val
)
return
0
;
return
sign
*
((
absval
-
deadzone_val
)
*
5
*
10
)
/
(
0x7fff
-
deadzone_val
);
}
// Core input (not GUI)
int
Core_PollEvent
(
void
)
{
...
...
@@ -325,6 +336,8 @@ int Core_PollEvent(void)
mouse_y
+=
PAS
;
if
(
input_state_cb
(
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_UP
))
mouse_y
-=
PAS
;
mouse_x
+=
transform_axis
(
input_state_cb
(
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_LEFT
,
RETRO_DEVICE_ID_ANALOG_X
));
mouse_y
+=
transform_axis
(
input_state_cb
(
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_LEFT
,
RETRO_DEVICE_ID_ANALOG_Y
));
mouse_l
=
input_state_cb
(
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_A
);
mouse_r
=
input_state_cb
(
0
,
RETRO_DEVICE_JOYPAD
,
0
,
RETRO_DEVICE_ID_JOYPAD_B
);
}
...
...
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