mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-24 02:55:45 +00:00
Keyboard and mouse controls will now work if you use the kbMouseSupport parameter in the config for Libretro cores. Be aware that capturing mouse and keyboard controls properly is only possible in fullscreen mode. Note: In the case of DOSBox, a virtual filesystem handler is not yet implemented, thus each game state will be shared between all rooms (DOS game instances) of CloudRetro.
56 lines
1.1 KiB
JavaScript
56 lines
1.1 KiB
JavaScript
import {
|
|
REFRESH_INPUT,
|
|
KB_MOUSE_FLAG,
|
|
pub,
|
|
sub
|
|
} from 'event';
|
|
|
|
export {KEY} from './keys.js?v=3';
|
|
|
|
import {joystick} from './joystick.js?v=3';
|
|
import {keyboard} from './keyboard.js?v=3'
|
|
import {pointer} from './pointer.js?v=3';
|
|
import {retropad} from './retropad.js?v=3';
|
|
import {touch} from './touch.js?v=3';
|
|
|
|
export {joystick, keyboard, pointer, retropad, touch};
|
|
|
|
const input_state = {
|
|
joystick: true,
|
|
keyboard: false,
|
|
pointer: true, // aka mouse
|
|
retropad: true,
|
|
touch: true,
|
|
|
|
kbm: false,
|
|
}
|
|
|
|
const init = () => {
|
|
keyboard.init()
|
|
joystick.init()
|
|
touch.init()
|
|
}
|
|
|
|
sub(KB_MOUSE_FLAG, () => {
|
|
input_state.kbm = true
|
|
pub(REFRESH_INPUT)
|
|
})
|
|
|
|
export const input = {
|
|
state: input_state,
|
|
init,
|
|
retropad: {
|
|
...retropad,
|
|
toggle(on = true) {
|
|
if (on === input_state.retropad) return
|
|
input_state.retropad = on
|
|
on ? retropad.enable() : retropad.disable()
|
|
}
|
|
},
|
|
set kbm(v) {
|
|
input_state.kbm = v
|
|
},
|
|
get kbm() {
|
|
return input_state.kbm
|
|
}
|
|
}
|