Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
66428667
Commit
66428667
authored
May 08, 2023
by
AUTOMATIC1111
Committed by
GitHub
May 08, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10146 from missionfloyd/gamepad-option
Fix gamepad navigation
parents
6ac33fe9
85bd9b3d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
32 deletions
+55
-32
javascript/imageviewerGamepad.js
javascript/imageviewerGamepad.js
+53
-32
modules/shared.py
modules/shared.py
+2
-0
No files found.
javascript/imageviewerGamepad.js
View file @
66428667
let
delay
=
350
//ms
window
.
addEventListener
(
'
gamepadconnected
'
,
(
e
)
=>
{
window
.
addEventListener
(
'
gamepadconnected
'
,
(
e
)
=>
{
const
index
=
e
.
gamepad
.
index
;
console
.
log
(
"
Gamepad connected!
"
)
let
isWaiting
=
false
;
const
gamepad
=
e
.
gamepad
;
setInterval
(
async
()
=>
{
setInterval
(()
=>
{
if
(
!
opts
.
js_modal_lightbox_gamepad
||
isWaiting
)
return
;
const
xValue
=
gamepad
.
axes
[
0
].
toFixed
(
2
);
const
gamepad
=
navigator
.
getGamepads
()[
index
];
if
(
xValue
<
-
0.3
)
{
const
xValue
=
gamepad
.
axes
[
0
];
modalPrevImage
(
e
);
if
(
xValue
<=
-
0.3
)
{
}
else
if
(
xValue
>
0.3
)
{
modalNextImage
(
e
);
}
},
delay
);
});
/*
Primarily for vr controller type pointer devices.
I use the wheel event because there's currently no way to do it properly with web xr.
*/
let
isScrolling
=
false
;
window
.
addEventListener
(
'
wheel
'
,
(
e
)
=>
{
if
(
isScrolling
)
return
;
isScrolling
=
true
;
if
(
e
.
deltaX
<=
-
0.6
)
{
modalPrevImage
(
e
);
modalPrevImage
(
e
);
}
else
if
(
e
.
deltaX
>=
0.6
)
{
isWaiting
=
true
;
}
else
if
(
xValue
>=
0.3
)
{
modalNextImage
(
e
);
modalNextImage
(
e
);
isWaiting
=
true
;
}
}
if
(
isWaiting
)
{
await
sleepUntil
(()
=>
{
const
xValue
=
navigator
.
getGamepads
()[
index
].
axes
[
0
]
if
(
xValue
<
0.3
&&
xValue
>
-
0.3
)
{
return
true
;
}
},
opts
.
js_modal_lightbox_gamepad_repeat
);
isWaiting
=
false
;
}
},
10
);
});
/*
Primarily for vr controller type pointer devices.
I use the wheel event because there's currently no way to do it properly with web xr.
*/
let
isScrolling
=
false
;
window
.
addEventListener
(
'
wheel
'
,
(
e
)
=>
{
if
(
!
opts
.
js_modal_lightbox_gamepad
||
isScrolling
)
return
;
isScrolling
=
true
;
if
(
e
.
deltaX
<=
-
0.6
)
{
modalPrevImage
(
e
);
}
else
if
(
e
.
deltaX
>=
0.6
)
{
modalNextImage
(
e
);
}
setTimeout
(()
=>
{
setTimeout
(()
=>
{
isScrolling
=
false
;
isScrolling
=
false
;
},
delay
);
},
opts
.
js_modal_lightbox_gamepad_repeat
);
});
});
\ No newline at end of file
function
sleepUntil
(
f
,
timeout
)
{
return
new
Promise
((
resolve
)
=>
{
const
timeStart
=
new
Date
();
const
wait
=
setInterval
(
function
()
{
if
(
f
()
||
new
Date
()
-
timeStart
>
timeout
)
{
clearInterval
(
wait
);
resolve
();
}
},
20
);
});
}
modules/shared.py
View file @
66428667
...
@@ -400,6 +400,8 @@ options_templates.update(options_section(('ui', "User interface"), {
...
@@ -400,6 +400,8 @@ options_templates.update(options_section(('ui', "User interface"), {
"font"
:
OptionInfo
(
""
,
"Font for image grids that have text"
),
"font"
:
OptionInfo
(
""
,
"Font for image grids that have text"
),
"js_modal_lightbox"
:
OptionInfo
(
True
,
"Enable full page image viewer"
),
"js_modal_lightbox"
:
OptionInfo
(
True
,
"Enable full page image viewer"
),
"js_modal_lightbox_initially_zoomed"
:
OptionInfo
(
True
,
"Show images zoomed in by default in full page image viewer"
),
"js_modal_lightbox_initially_zoomed"
:
OptionInfo
(
True
,
"Show images zoomed in by default in full page image viewer"
),
"js_modal_lightbox_gamepad"
:
OptionInfo
(
True
,
"Navigate image viewer with gamepad"
),
"js_modal_lightbox_gamepad_repeat"
:
OptionInfo
(
250
,
"Gamepad repeat period, in milliseconds"
),
"show_progress_in_title"
:
OptionInfo
(
True
,
"Show generation progress in window title."
),
"show_progress_in_title"
:
OptionInfo
(
True
,
"Show generation progress in window title."
),
"samplers_in_dropdown"
:
OptionInfo
(
True
,
"Use dropdown for sampler selection instead of radio group"
),
"samplers_in_dropdown"
:
OptionInfo
(
True
,
"Use dropdown for sampler selection instead of radio group"
),
"dimensions_and_batch_together"
:
OptionInfo
(
True
,
"Show Width/Height and Batch sliders in same row"
),
"dimensions_and_batch_together"
:
OptionInfo
(
True
,
"Show Width/Height and Batch sliders in same row"
),
...
...
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