@@ -2,7 +2,12 @@ import React, { useEffect, useRef, useState } from 'react'
22import type { FrameInfo , KeyInfo , MonochromeBitmap } from '@lib/bitmap'
33import { useAppDispatch , useAppSelector , type RootState } from '../store'
44import { togglePause , showMap , hideMap , pause , unpause } from '../gameSlice'
5- import { getControls , type ControlMatrix } from '@core/controls'
5+ import {
6+ getControls ,
7+ mergeControls ,
8+ blankControls ,
9+ type ControlMatrix
10+ } from '@core/controls'
611import { Map } from './Map'
712import { bitmapToCollisionItem , type CollisionService } from '@/core/collision'
813import { Collision } from '@/core/collision/constants'
@@ -136,37 +141,14 @@ const GameRenderer: React.FC<GameRendererProps> = ({
136141 const keyboardControls = getControls ( keyInfo , bindings )
137142
138143 // Merge keyboard and touch controls (OR logic for each control)
139- const mergedControls : ControlMatrix = {
140- thrust : keyboardControls . thrust || touchControls . thrust ,
141- left : keyboardControls . left || touchControls . left ,
142- right : keyboardControls . right || touchControls . right ,
143- fire : keyboardControls . fire || touchControls . fire ,
144- shield : keyboardControls . shield || touchControls . shield ,
145- selfDestruct :
146- keyboardControls . selfDestruct || touchControls . selfDestruct ,
147- pause : keyboardControls . pause || touchControls . pause ,
148- quit : keyboardControls . quit || touchControls . quit ,
149- nextLevel : keyboardControls . nextLevel || touchControls . nextLevel ,
150- extraLife : keyboardControls . extraLife || touchControls . extraLife ,
151- map : keyboardControls . map || touchControls . map
152- }
144+ const mergedControls = mergeControls ( keyboardControls , touchControls )
153145
154146 // If map is showing, use blank controls (all false) to prevent game input
155147 const controls = showMapState
156- ? {
157- thrust : false ,
158- left : false ,
159- right : false ,
160- fire : false ,
161- shield : false ,
162- selfDestruct : false ,
163- pause : false ,
164- quit : false ,
165- nextLevel : false ,
166- extraLife : false ,
148+ ? blankControls ( mergedControls , {
167149 // need to still detect the map key
168150 map : mergedControls . map
169- }
151+ } )
170152 : mergedControls
171153
172154 if ( controls . map ) {
0 commit comments