Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ingame
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vladislav
ingame
Commits
4b5a7b32
Commit
4b5a7b32
authored
Jun 02, 2024
by
Georgiy Yankovskiy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gamepad up/down handler
parent
ac8c42df
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
71 additions
and
9 deletions
+71
-9
App.py
ingame/models/App.py
+4
-0
Gamepad.py
ingame/models/Gamepad.py
+24
-0
Tabs.qml
qml/components/Tabs.qml
+17
-6
qml.qml
qml/qml.qml
+8
-0
GameInfoScene.qml
qml/scenes/GameInfoScene.qml
+10
-3
HomeScene.qml
qml/scenes/HomeScene.qml
+8
-0
No files found.
ingame/models/App.py
View file @
4b5a7b32
...
...
@@ -31,6 +31,8 @@ class App(QtCore.QObject):
gamepad_clicked_RB
=
Signal
(
bool
,
name
=
"gamepadClickedRB"
)
gamepad_clicked_apply
=
Signal
(
bool
,
name
=
"gamepadClickedApply"
)
gamepad_clicked_back
=
Signal
(
bool
,
name
=
"gamepadClickedBack"
)
gamepad_axis_up
=
Signal
(
bool
,
name
=
"gamepadAxisUp"
)
gamepad_axis_down
=
Signal
(
bool
,
name
=
"gamepadAxisDown"
)
gamepad_axis_left
=
Signal
(
bool
,
name
=
"gamepadAxisLeft"
)
gamepad_axis_right
=
Signal
(
bool
,
name
=
"gamepadAxisRight"
)
...
...
@@ -48,6 +50,8 @@ class App(QtCore.QObject):
self
.
gamepad
.
apply_clicked
=
lambda
:
self
.
gamepad_clicked_apply
.
emit
(
True
)
self
.
gamepad
.
l_clicked
=
lambda
:
self
.
gamepad_axis_left
.
emit
(
True
)
self
.
gamepad
.
r_clicked
=
lambda
:
self
.
gamepad_axis_right
.
emit
(
True
)
self
.
gamepad
.
u_clicked
=
lambda
:
self
.
gamepad_axis_up
.
emit
(
True
)
self
.
gamepad
.
d_clicked
=
lambda
:
self
.
gamepad_axis_down
.
emit
(
True
)
self
.
gamepad
.
back_clicked
=
lambda
:
self
.
gamepad_clicked_back
.
emit
(
True
)
self
.
agent
=
GameAgent
()
...
...
ingame/models/Gamepad.py
View file @
4b5a7b32
...
...
@@ -11,6 +11,8 @@ class Gamepad:
RB_BUTTON
=
5
LEFT_RIGHT_AXIS
=
0
LEFT_RIGHT_AXIS_SENSITIVITY
=
0.7
UP_DOWN_AXIS
=
1
UP_DOWN_AXIS_SENSITIVITY
=
0.7
APPLY_BUTTON
=
0
BACK_BUTTON
=
1
...
...
@@ -23,12 +25,16 @@ class Gamepad:
self
.
last_apply_clicked
:
bool
=
False
self
.
last_left_clicked
:
bool
=
False
self
.
last_right_clicked
:
bool
=
False
self
.
last_up_clicked
:
bool
=
False
self
.
last_down_clicked
:
bool
=
False
self
.
last_back_clicked
:
bool
=
False
self
.
lb_clicked
:
()
=
lambda
:
None
self
.
rb_clicked
:
()
=
lambda
:
None
self
.
l_clicked
:
()
=
lambda
:
None
self
.
r_clicked
:
()
=
lambda
:
None
self
.
u_clicked
:
()
=
lambda
:
None
self
.
d_clicked
:
()
=
lambda
:
None
self
.
back_clicked
:
()
=
lambda
:
None
self
.
apply_clicked
:
()
=
lambda
:
None
...
...
@@ -64,6 +70,7 @@ class Gamepad:
rb_button
=
self
.
joystick
.
get_button
(
self
.
RB_BUTTON
)
apply_button
=
self
.
joystick
.
get_button
(
self
.
APPLY_BUTTON
)
left_right_axis
=
self
.
joystick
.
get_axis
(
self
.
LEFT_RIGHT_AXIS
)
up_down_axis
=
self
.
joystick
.
get_axis
(
self
.
UP_DOWN_AXIS
)
back_button
=
self
.
joystick
.
get_button
(
self
.
BACK_BUTTON
)
# LB
...
...
@@ -110,6 +117,23 @@ class Gamepad:
if
(
not
left_right_axis
>=
self
.
LEFT_RIGHT_AXIS_SENSITIVITY
)
and
self
.
last_right_clicked
:
self
.
last_right_clicked
=
not
self
.
last_right_clicked
# UP
if
(
up_down_axis
<=
-
self
.
UP_DOWN_AXIS_SENSITIVITY
)
and
not
self
.
last_up_clicked
:
self
.
last_up_clicked
=
not
self
.
last_up_clicked
self
.
u_clicked
()
if
not
(
up_down_axis
<=
-
self
.
UP_DOWN_AXIS_SENSITIVITY
)
and
self
.
last_up_clicked
:
self
.
last_up_clicked
=
not
self
.
last_up_clicked
# DOWN
if
(
up_down_axis
>=
self
.
UP_DOWN_AXIS_SENSITIVITY
)
and
not
self
.
last_down_clicked
:
self
.
last_down_clicked
=
not
self
.
last_down_clicked
self
.
d_clicked
()
if
(
not
up_down_axis
>=
self
.
UP_DOWN_AXIS_SENSITIVITY
)
and
self
.
last_down_clicked
:
self
.
last_down_clicked
=
not
self
.
last_down_clicked
# BACK
if
back_button
and
not
self
.
last_back_clicked
:
self
.
last_back_clicked
=
not
self
.
last_back_clicked
...
...
qml/components/Tabs.qml
View file @
4b5a7b32
...
...
@@ -380,14 +380,17 @@ Rectangle {
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
let
c
=
gamesGrid
.
children
;
let
l
=
c
.
length
-
1
;
// exclude QQuickRepeater
tabs
.
focusedItems
+=
inc
;
if
(
tabs
.
focusedItems
>=
c
.
length
)
tabs
.
focusedItems
=
0
;
if
(
tabs
.
focusedItems
<
0
)
tabs
.
focusedItems
=
c
.
length
-
1
;
console
.
log
(
tabs
.
focusedItems
);
if
(
tabs
.
focusedItems
+
inc
>=
l
)
{
tabs
.
focusedItems
=
(
c
.
focusedItems
+
inc
===
l
-
1
)
?
0
:
l
-
1
;
}
else
if
(
tabs
.
focusedItems
+
inc
<
0
)
{
tabs
.
focusedItems
=
(
c
.
focusedItems
+
inc
===
0
)
?
l
-
1
:
0
;
//;
}
else
{
tabs
.
focusedItems
+=
inc
;
}
c
[
tabs
.
focusedItems
].
forceActiveFocus
();
// gamesScroller.contentY = c[tabs.focusedItems].y; // not working
// c[tabs.focusedItems].clicked();
...
...
@@ -401,6 +404,14 @@ Rectangle {
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
tabs
.
applyTabsFocus
(
1
)
}
function
onGamepadAxisUp
(
done
){
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
tabs
.
applyItemsFocus
(
-
gamesGrid
.
columns
)
}
function
onGamepadAxisDown
(
done
){
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
tabs
.
applyItemsFocus
(
gamesGrid
.
columns
)
}
function
onGamepadAxisLeft
(
done
){
if
(
window
.
scene
!==
S
.
homeScene
)
return
;
tabs
.
applyItemsFocus
(
-
1
)
...
...
qml/qml.qml
View file @
4b5a7b32
...
...
@@ -40,6 +40,12 @@ Window {
function
onGamepadAxisRight
(
done
){
window
.
_trigger
(
"onGamepadAxisRight"
,
done
);
}
function
onGamepadAxisUp
(
done
){
window
.
_trigger
(
"onGamepadAxisUp"
,
done
);
}
function
onGamepadAxisDown
(
done
){
window
.
_trigger
(
"onGamepadAxisDown"
,
done
);
}
function
onGamepadClickedApply
(
done
){
window
.
_trigger
(
"onGamepadClickedApply"
,
done
);
}
...
...
@@ -56,6 +62,8 @@ Window {
let
d
=
scenes
[
scene
];
// console.log("CALLUP " + _method);
if
(
d
!==
null
&&
d
[
_method
]
!==
undefined
&&
d
[
_method
]
!==
null
)
d
[
_method
](
args
);
}
...
...
qml/scenes/GameInfoScene.qml
View file @
4b5a7b32
...
...
@@ -95,7 +95,7 @@ Rectangle {
}
ColumnLayout
{
ColumnLayout
{
// anchors.fill:parent
anchors.left
:
parent
.
left
anchors.top
:
parent
.
top
...
...
@@ -107,7 +107,7 @@ Rectangle {
anchors.topMargin
:
parent
.
height
/
100
*
3
spacing
:
6
ItemGroup
{
ItemGroup
{
id
:
topPanel
Button
{
id
:
back
...
...
@@ -178,7 +178,7 @@ Rectangle {
}
}
}
Rectangle
{
Rectangle
{
// Start pos
Layout.fillWidth
:
true
Layout.fillHeight
:
true
...
...
@@ -387,6 +387,13 @@ Rectangle {
}
function
onGamepadAxisUp
(
done
){
root
.
onGamepadAxisLeft
(
done
);
}
function
onGamepadAxisDown
(
done
){
root
.
onGamepadAxisRight
(
done
);
}
function
onGamepadAxisLeft
(
done
){
if
(
window
.
scene
!==
S
.
gameInfoScene
)
return
;
root
.
applyItemsFocus
(
-
1
)
...
...
qml/scenes/HomeScene.qml
View file @
4b5a7b32
...
...
@@ -54,6 +54,14 @@ Rectangle {
function
onGamepadAxisRight
(
done
){
tabs
.
onGamepadAxisRight
(
done
)
}
function
onGamepadAxisUp
(
done
){
tabs
.
onGamepadAxisUp
(
done
)
}
function
onGamepadAxisDown
(
done
){
tabs
.
onGamepadAxisDown
(
done
)
}
function
onGamepadClickedApply
(
done
){
tabs
.
onGamepadClickedApply
(
done
)
}
...
...
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