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
Citra2018
Commits
e32cd50c
Commit
e32cd50c
authored
Nov 11, 2017
by
James
Browse files
Use pointer rather than mouse for receiving events
parent
b43d6618
Changes
4
Show whitespace changes
Inline
Side-by-side
src/citra_libretro/citra_libretro.cpp
View file @
e32cd50c
...
...
@@ -61,7 +61,7 @@ void LibRetro::OnConfigureEnvironment() {
{
"citra_resolution_factor"
,
"Resolution scale factor; 1x (Native)|2x|3x|4x|5x|6x|7x|8x|9x|10x"
},
{
"citra_layout_option"
,
"Screen layout positioning; Default Top-Bottom Screen|Single "
"Screen Only|Large Screen, Small Screen"
},
"Screen Only|Large Screen, Small Screen
|Side by Side
"
},
{
"citra_swap_screen"
,
"Prominent 3DS screen; Top|Bottom"
},
{
"citra_analog_function"
,
"Right analog function; C-Stick and Touchscreen Pointer|Touchscreen Pointer|C-Stick"
},
...
...
@@ -161,12 +161,14 @@ void UpdateSettings(bool init) {
auto
layout
=
LibRetro
::
FetchVariable
(
"citra_layout_option"
,
"Default Top-Bottom Screen"
);
if
(
layout
.
compare
(
"Default Top-Bottom Screen"
)
==
0
)
{
if
(
layout
==
"Default Top-Bottom Screen"
)
{
Settings
::
values
.
layout_option
=
Settings
::
LayoutOption
::
Default
;
}
else
if
(
layout
.
compare
(
"Single Screen Only"
)
==
0
)
{
}
else
if
(
layout
==
"Single Screen Only"
)
{
Settings
::
values
.
layout_option
=
Settings
::
LayoutOption
::
SingleScreen
;
}
else
if
(
layout
.
compare
(
"Large Screen, Small Screen"
)
==
0
)
{
}
else
if
(
layout
==
"Large Screen, Small Screen"
)
{
Settings
::
values
.
layout_option
=
Settings
::
LayoutOption
::
LargeScreen
;
}
else
if
(
layout
==
"Side by Side"
)
{
Settings
::
values
.
layout_option
=
Settings
::
LayoutOption
::
SideScreen
;
}
else
{
LOG_ERROR
(
Frontend
,
"Unknown layout type: %s."
,
layout
.
c_str
());
Settings
::
values
.
layout_option
=
Settings
::
LayoutOption
::
Default
;
...
...
@@ -178,11 +180,11 @@ void UpdateSettings(bool init) {
auto
analog_function
=
LibRetro
::
FetchVariable
(
"citra_analog_function"
,
"C-Stick and Touchscreen Pointer"
);
if
(
analog_function
.
compare
(
"C-Stick and Touchscreen Pointer"
)
==
0
)
{
if
(
analog_function
==
"C-Stick and Touchscreen Pointer"
)
{
LibRetro
::
settings
.
analog_function
=
LibRetro
::
CStickFunction
::
Both
;
}
else
if
(
analog_function
.
compare
(
"C-Stick"
)
==
0
)
{
}
else
if
(
analog_function
==
"C-Stick"
)
{
LibRetro
::
settings
.
analog_function
=
LibRetro
::
CStickFunction
::
CStick
;
}
else
if
(
analog_function
.
compare
(
"Touchscreen Pointer"
)
==
0
)
{
}
else
if
(
analog_function
==
"Touchscreen Pointer"
)
{
LibRetro
::
settings
.
analog_function
=
LibRetro
::
CStickFunction
::
Touchscreen
;
}
else
{
LOG_ERROR
(
Frontend
,
"Unknown right analog function: %s."
,
analog_function
.
c_str
());
...
...
src/citra_libretro/emu_window/libretro_window.cpp
View file @
e32cd50c
...
...
@@ -158,6 +158,12 @@ void EmuWindow_LibRetro::Prepare(bool hasOGL) {
baseY
*=
scaling
;
}
break
;
case
Settings
::
LayoutOption
::
SideScreen
:
baseX
=
Core
::
kScreenBottomWidth
+
Core
::
kScreenTopWidth
;
baseY
=
Core
::
kScreenTopHeight
;
baseX
*=
scaling
;
baseY
*=
scaling
;
break
;
case
Settings
::
LayoutOption
::
Default
:
default:
if
(
swapped
)
{
// Bottom screen on top
...
...
src/citra_libretro/input/mouse_tracker.cpp
View file @
e32cd50c
...
...
@@ -74,17 +74,26 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight,
auto
widthSpeed
=
(
bottomScreen
.
GetWidth
()
/
20.0
);
auto
heightSpeed
=
(
bottomScreen
.
GetHeight
()
/
20.0
);
auto
mouseX
=
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_MOUSE
,
0
,
RETRO_DEVICE_ID_MOUSE_X
)
*
(
widthSpeed
/
30
);
auto
mouseY
=
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_MOUSE
,
0
,
RETRO_DEVICE_ID_MOUSE_Y
)
*
(
heightSpeed
/
30
);
OnMouseMove
(
static_cast
<
int
>
(
mouseX
),
static_cast
<
int
>
(
mouseY
));
if
(
LibRetro
::
settings
.
analog_function
!=
LibRetro
::
CStickFunction
::
CStick
)
{
auto
pointerX
=
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_POINTER
,
0
,
RETRO_DEVICE_ID_POINTER_X
);
auto
pointerY
=
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_POINTER
,
0
,
RETRO_DEVICE_ID_POINTER_Y
);
auto
newX
=
static_cast
<
int
>
((
pointerX
+
0x7fff
)
/
(
float
)(
0x7fff
*
2
)
*
bufferWidth
);
auto
newY
=
static_cast
<
int
>
((
pointerY
+
0x7fff
)
/
(
float
)(
0x7fff
*
2
)
*
bufferHeight
);
if
((
pointerX
!=
0
||
pointerY
!=
0
)
&&
(
newX
!=
lastMouseX
||
newY
!=
lastMouseY
))
{
lastMouseX
=
newX
;
lastMouseY
=
newY
;
x
=
std
::
max
(
static_cast
<
int
>
(
bottomScreen
.
left
),
std
::
min
(
newX
,
static_cast
<
int
>
(
bottomScreen
.
right
)))
-
bottomScreen
.
left
;
y
=
std
::
max
(
static_cast
<
int
>
(
bottomScreen
.
top
),
std
::
min
(
newY
,
static_cast
<
int
>
(
bottomScreen
.
bottom
)))
-
bottomScreen
.
top
;
}
else
if
(
LibRetro
::
settings
.
analog_function
!=
LibRetro
::
CStickFunction
::
CStick
)
{
float
controllerX
=
((
float
)
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_RIGHT
,
((
float
)
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_RIGHT
,
RETRO_DEVICE_ID_ANALOG_X
)
/
INT16_MAX
);
float
controllerY
=
((
float
)
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_RIGHT
,
((
float
)
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_ANALOG
,
RETRO_DEVICE_INDEX_ANALOG_RIGHT
,
RETRO_DEVICE_ID_ANALOG_Y
)
/
INT16_MAX
);
...
...
@@ -100,23 +109,23 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight,
static_cast
<
int
>
(
controllerY
*
heightSpeed
));
}
Restrict
(
0
,
0
,
b
uffer
Width
,
b
uffer
Height
);
Restrict
(
0
,
0
,
b
ottomScreen
.
Get
Width
()
,
b
ottomScreen
.
Get
Height
()
);
// Make the coordinates 0 -> 1
projectedX
=
(
float
)
x
/
b
uffer
Width
;
projectedY
=
(
float
)
y
/
b
uffer
Height
;
projectedX
=
(
float
)
x
/
b
ottomScreen
.
Get
Width
()
;
projectedY
=
(
float
)
y
/
b
ottomScreen
.
Get
Height
()
;
// Ensure that the projected position doesn't overlap outside the bottom screen framebuffer.
// TODO: Provide config option
renderRatio
=
(
float
)
(
bottomScreen
.
bottom
-
bottomScreen
.
top
)
/
buffer
Height
/
30
;
float
renderWidth
=
renderRatio
*
bufferWidth
/
2
;
float
renderHeight
=
renderRatio
*
bufferHeight
/
2
*
((
float
)
buffer
Width
/
bufferHeight
)
;
renderRatio
=
(
float
)
bottomScreen
.
Get
Height
()
/
30
;
float
renderWidth
=
renderRatio
/
2
;
float
renderHeight
=
(
float
)
bottomScreen
.
Get
Width
()
/
30
/
2
;
// Map the mouse coord to the bottom screen's position (with a little margin)
projectedX
=
bottomScreen
.
left
+
renderWidth
+
projectedX
*
(
bottomScreen
.
right
-
bottomScreen
.
left
-
renderWidth
*
2
);
projectedX
*
(
bottomScreen
.
GetWidth
()
-
renderWidth
*
2
);
projectedY
=
bottomScreen
.
top
+
renderHeight
+
projectedY
*
(
bottomScreen
.
bottom
-
bottomScreen
.
top
-
renderHeight
*
2
);
projectedY
*
(
bottomScreen
.
GetHeight
()
-
renderHeight
*
2
);
isPressed
=
state
;
...
...
@@ -127,8 +136,8 @@ void MouseTracker::Render(int bufferWidth, int bufferHeight) {
float
centerX
=
(
projectedX
/
bufferWidth
)
*
2
-
1
;
float
centerY
=
-
((
projectedY
/
bufferHeight
)
*
2
-
1
);
float
renderWidth
=
renderRatio
;
float
renderHeight
=
renderRatio
*
((
float
)
bufferWidth
/
bufferHeight
)
;
float
renderWidth
=
renderRatio
/
bufferWidth
;
float
renderHeight
=
renderRatio
/
bufferHeight
;
float
projectedLeft
=
centerX
-
renderWidth
;
float
projectedTop
=
centerY
-
renderHeight
;
...
...
src/citra_libretro/input/mouse_tracker.h
View file @
e32cd50c
...
...
@@ -43,6 +43,9 @@ private:
int
x
;
int
y
;
float
lastMouseX
;
float
lastMouseY
;
float
projectedX
;
float
projectedY
;
float
renderRatio
;
...
...
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