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
Hide whitespace changes
Inline
Side-by-side
src/citra_libretro/citra_libretro.cpp
View file @
e32cd50c
...
@@ -61,7 +61,7 @@ void LibRetro::OnConfigureEnvironment() {
...
@@ -61,7 +61,7 @@ void LibRetro::OnConfigureEnvironment() {
{
"citra_resolution_factor"
,
{
"citra_resolution_factor"
,
"Resolution scale factor; 1x (Native)|2x|3x|4x|5x|6x|7x|8x|9x|10x"
},
"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 "
{
"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_swap_screen"
,
"Prominent 3DS screen; Top|Bottom"
},
{
"citra_analog_function"
,
{
"citra_analog_function"
,
"Right analog function; C-Stick and Touchscreen Pointer|Touchscreen Pointer|C-Stick"
},
"Right analog function; C-Stick and Touchscreen Pointer|Touchscreen Pointer|C-Stick"
},
...
@@ -161,12 +161,14 @@ void UpdateSettings(bool init) {
...
@@ -161,12 +161,14 @@ void UpdateSettings(bool init) {
auto
layout
=
LibRetro
::
FetchVariable
(
"citra_layout_option"
,
"Default Top-Bottom Screen"
);
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
;
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
;
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
;
Settings
::
values
.
layout_option
=
Settings
::
LayoutOption
::
LargeScreen
;
}
else
if
(
layout
==
"Side by Side"
)
{
Settings
::
values
.
layout_option
=
Settings
::
LayoutOption
::
SideScreen
;
}
else
{
}
else
{
LOG_ERROR
(
Frontend
,
"Unknown layout type: %s."
,
layout
.
c_str
());
LOG_ERROR
(
Frontend
,
"Unknown layout type: %s."
,
layout
.
c_str
());
Settings
::
values
.
layout_option
=
Settings
::
LayoutOption
::
Default
;
Settings
::
values
.
layout_option
=
Settings
::
LayoutOption
::
Default
;
...
@@ -178,11 +180,11 @@ void UpdateSettings(bool init) {
...
@@ -178,11 +180,11 @@ void UpdateSettings(bool init) {
auto
analog_function
=
auto
analog_function
=
LibRetro
::
FetchVariable
(
"citra_analog_function"
,
"C-Stick and Touchscreen Pointer"
);
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
;
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
;
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
;
LibRetro
::
settings
.
analog_function
=
LibRetro
::
CStickFunction
::
Touchscreen
;
}
else
{
}
else
{
LOG_ERROR
(
Frontend
,
"Unknown right analog function: %s."
,
analog_function
.
c_str
());
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) {
...
@@ -158,6 +158,12 @@ void EmuWindow_LibRetro::Prepare(bool hasOGL) {
baseY
*=
scaling
;
baseY
*=
scaling
;
}
}
break
;
break
;
case
Settings
::
LayoutOption
::
SideScreen
:
baseX
=
Core
::
kScreenBottomWidth
+
Core
::
kScreenTopWidth
;
baseY
=
Core
::
kScreenTopHeight
;
baseX
*=
scaling
;
baseY
*=
scaling
;
break
;
case
Settings
::
LayoutOption
::
Default
:
case
Settings
::
LayoutOption
::
Default
:
default:
default:
if
(
swapped
)
{
// Bottom screen on top
if
(
swapped
)
{
// Bottom screen on top
...
...
src/citra_libretro/input/mouse_tracker.cpp
View file @
e32cd50c
...
@@ -74,19 +74,28 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight,
...
@@ -74,19 +74,28 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight,
auto
widthSpeed
=
(
bottomScreen
.
GetWidth
()
/
20.0
);
auto
widthSpeed
=
(
bottomScreen
.
GetWidth
()
/
20.0
);
auto
heightSpeed
=
(
bottomScreen
.
GetHeight
()
/
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
pointerX
=
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_POINTER
,
0
,
RETRO_DEVICE_ID_POINTER_X
);
auto
mouseY
=
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_MOUSE
,
0
,
RETRO_DEVICE_ID_MOUSE_Y
)
*
(
heightSpeed
/
30
);
auto
pointerY
=
LibRetro
::
CheckInput
(
0
,
RETRO_DEVICE_POINTER
,
0
,
RETRO_DEVICE_ID_POINTER_Y
);
OnMouseMove
(
static_cast
<
int
>
(
mouseX
),
static_cast
<
int
>
(
mouseY
));
auto
newX
=
static_cast
<
int
>
((
pointerX
+
0x7fff
)
/
(
float
)(
0x7fff
*
2
)
*
bufferWidth
);
auto
newY
=
static_cast
<
int
>
((
pointerY
+
0x7fff
)
/
(
float
)(
0x7fff
*
2
)
*
bufferHeight
);
if
(
LibRetro
::
settings
.
analog_function
!=
LibRetro
::
CStickFunction
::
CStick
)
{
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
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
)
/
RETRO_DEVICE_ID_ANALOG_X
)
/
INT16_MAX
);
INT16_MAX
);
float
controllerY
=
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
)
/
RETRO_DEVICE_ID_ANALOG_Y
)
/
INT16_MAX
);
INT16_MAX
);
// Deadzone the controller inputs
// Deadzone the controller inputs
if
(
std
::
abs
(
controllerX
)
<
LibRetro
::
settings
.
deadzone
)
{
if
(
std
::
abs
(
controllerX
)
<
LibRetro
::
settings
.
deadzone
)
{
...
@@ -100,23 +109,23 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight,
...
@@ -100,23 +109,23 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight,
static_cast
<
int
>
(
controllerY
*
heightSpeed
));
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
// Make the coordinates 0 -> 1
projectedX
=
(
float
)
x
/
b
uffer
Width
;
projectedX
=
(
float
)
x
/
b
ottomScreen
.
Get
Width
()
;
projectedY
=
(
float
)
y
/
b
uffer
Height
;
projectedY
=
(
float
)
y
/
b
ottomScreen
.
Get
Height
()
;
// Ensure that the projected position doesn't overlap outside the bottom screen framebuffer.
// Ensure that the projected position doesn't overlap outside the bottom screen framebuffer.
// TODO: Provide config option
// TODO: Provide config option
renderRatio
=
(
float
)
(
bottomScreen
.
bottom
-
bottomScreen
.
top
)
/
buffer
Height
/
30
;
renderRatio
=
(
float
)
bottomScreen
.
Get
Height
()
/
30
;
float
renderWidth
=
renderRatio
*
bufferWidth
/
2
;
float
renderWidth
=
renderRatio
/
2
;
float
renderHeight
=
renderRatio
*
bufferHeight
/
2
*
((
float
)
buffer
Width
/
bufferHeight
)
;
float
renderHeight
=
(
float
)
bottomScreen
.
Get
Width
()
/
30
/
2
;
// Map the mouse coord to the bottom screen's position (with a little margin)
// Map the mouse coord to the bottom screen's position (with a little margin)
projectedX
=
bottomScreen
.
left
+
renderWidth
+
projectedX
=
bottomScreen
.
left
+
renderWidth
+
projectedX
*
(
bottomScreen
.
right
-
bottomScreen
.
left
-
renderWidth
*
2
);
projectedX
*
(
bottomScreen
.
GetWidth
()
-
renderWidth
*
2
);
projectedY
=
bottomScreen
.
top
+
renderHeight
+
projectedY
=
bottomScreen
.
top
+
renderHeight
+
projectedY
*
(
bottomScreen
.
bottom
-
bottomScreen
.
top
-
renderHeight
*
2
);
projectedY
*
(
bottomScreen
.
GetHeight
()
-
renderHeight
*
2
);
isPressed
=
state
;
isPressed
=
state
;
...
@@ -124,11 +133,11 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight,
...
@@ -124,11 +133,11 @@ void MouseTracker::Update(int bufferWidth, int bufferHeight,
void
MouseTracker
::
Render
(
int
bufferWidth
,
int
bufferHeight
)
{
void
MouseTracker
::
Render
(
int
bufferWidth
,
int
bufferHeight
)
{
// Convert to OpenGL coordinates
// Convert to OpenGL coordinates
float
centerX
=
(
projectedX
/
bufferWidth
)
*
2
-
1
;
float
centerX
=
(
projectedX
/
bufferWidth
)
*
2
-
1
;
float
centerY
=
-
((
projectedY
/
bufferHeight
)
*
2
-
1
);
float
centerY
=
-
((
projectedY
/
bufferHeight
)
*
2
-
1
);
float
renderWidth
=
renderRatio
;
float
renderWidth
=
renderRatio
/
bufferWidth
;
float
renderHeight
=
renderRatio
*
((
float
)
bufferWidth
/
bufferHeight
)
;
float
renderHeight
=
renderRatio
/
bufferHeight
;
float
projectedLeft
=
centerX
-
renderWidth
;
float
projectedLeft
=
centerX
-
renderWidth
;
float
projectedTop
=
centerY
-
renderHeight
;
float
projectedTop
=
centerY
-
renderHeight
;
...
...
src/citra_libretro/input/mouse_tracker.h
View file @
e32cd50c
...
@@ -43,6 +43,9 @@ private:
...
@@ -43,6 +43,9 @@ private:
int
x
;
int
x
;
int
y
;
int
y
;
float
lastMouseX
;
float
lastMouseY
;
float
projectedX
;
float
projectedX
;
float
projectedY
;
float
projectedY
;
float
renderRatio
;
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