show mobile controls on a small screen

This commit is contained in:
Corwin 2024-04-09 12:15:11 +01:00
parent abd5e44ede
commit 12316dbe6a
No known key found for this signature in database
2 changed files with 14 additions and 4 deletions

View file

@ -19,6 +19,10 @@ const MobileControls = styled.div`
flex-direction: column;
margin-bottom: 40px;
@media (min-width: 500px) {
display: none;
}
touch-action: none;
img {

View file

@ -63,6 +63,12 @@ const GameSide = styled.div`
}
`;
const ShowOnWideScreen = styled.div`
@media (max-width: 500px) {
display: none;
}
`;
const isTouchScreen = () => navigator.maxTouchPoints > 1;
function shouldStartPlaying(isTouchScreen: boolean | undefined) {
@ -108,9 +114,9 @@ const MgbaWithControllerSides = () => {
</GameSide>
</GamePanelWrapper>
</GameDisplay>
{shouldUseTouchScreenInput ? (
<MobileController mgba={mgbaHandle} />
) : (
<MobileController mgba={mgbaHandle} />
<ShowOnWideScreen>
<CenteredBlock>
<p>
Press escape to open the menu where you can view or change controls
@ -119,7 +125,7 @@ const MgbaWithControllerSides = () => {
on the main menu to switch game.
</p>
</CenteredBlock>
)}
</ShowOnWideScreen>
</>
);
};