mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 10:35:44 +00:00
Add L R
This commit is contained in:
parent
57ba14a3e6
commit
8484eca293
5 changed files with 20 additions and 12 deletions
|
|
@ -74,12 +74,14 @@ var bindKeysMap = map[int]int{
|
|||
C.RETRO_DEVICE_ID_JOYPAD_B: 1,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_X: 2,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_Y: 3,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_SELECT: 4,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_START: 5,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_UP: 6,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_DOWN: 7,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_LEFT: 8,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_RIGHT: 9,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_L: 4,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_R: 5,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_SELECT: 6,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_START: 7,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_UP: 8,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_DOWN: 9,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_LEFT: 10,
|
||||
C.RETRO_DEVICE_ID_JOYPAD_RIGHT: 11,
|
||||
}
|
||||
|
||||
type CloudEmulator interface {
|
||||
|
|
|
|||
|
|
@ -213,9 +213,6 @@ func (r *Room) startWebRTCSession(peerconnection *webrtc.WebRTC) {
|
|||
}
|
||||
|
||||
if peerconnection.IsConnected() {
|
||||
// the first 10 bits belong to player 1
|
||||
// the next 10 belongs to player 2 ...
|
||||
// We standardize and put it to inputChannel (20 bits)
|
||||
select {
|
||||
case r.inputChannel <- nanoarch.InputEvent{KeyState: input, PlayerIdx: peerconnection.GameMeta.PlayerIndex, ConnID: peerconnection.ID}:
|
||||
default:
|
||||
|
|
|
|||
5
web/js/input/input.js
vendored
5
web/js/input/input.js
vendored
|
|
@ -1,7 +1,7 @@
|
|||
const input = (() => {
|
||||
const INPUT_HZ = 100;
|
||||
const INPUT_STATE_PACKET = 1;
|
||||
const KEY_BITS = [KEY.A, KEY.B, KEY.X, KEY.Y, KEY.SELECT, KEY.START, KEY.UP, KEY.DOWN, KEY.LEFT, KEY.RIGHT];
|
||||
const KEY_BITS = [KEY.A, KEY.B, KEY.X, KEY.Y, KEY.L, KEY.R, KEY.SELECT, KEY.START, KEY.UP, KEY.DOWN, KEY.LEFT, KEY.RIGHT];
|
||||
|
||||
let gameInputTimer = null;
|
||||
let unchangePacket = 0;
|
||||
|
|
@ -13,6 +13,8 @@ const input = (() => {
|
|||
[KEY.B]: false,
|
||||
[KEY.X]: false,
|
||||
[KEY.Y]: false,
|
||||
[KEY.L]: false,
|
||||
[KEY.R]: false,
|
||||
[KEY.START]: false,
|
||||
[KEY.SELECT]: false,
|
||||
// dpad
|
||||
|
|
@ -55,6 +57,7 @@ const input = (() => {
|
|||
let arrBuf = new Uint8Array(2);
|
||||
arrBuf[0] = data & ((1 << 8) - 1);
|
||||
arrBuf[1] = data >> 8;
|
||||
log.info(arrBuf)
|
||||
event.pub(KEY_STATE_UPDATED, arrBuf);
|
||||
|
||||
unchangePacket--;
|
||||
|
|
|
|||
6
web/js/input/keyboard.js
vendored
6
web/js/input/keyboard.js
vendored
|
|
@ -14,13 +14,15 @@ const keyboard = (() => {
|
|||
88: KEY.B, // x
|
||||
67: KEY.X, // c
|
||||
86: KEY.Y, // v
|
||||
65: KEY.L, // a
|
||||
83: KEY.R, // s
|
||||
13: KEY.START, // enter
|
||||
16: KEY.SELECT, // shift
|
||||
// non-game
|
||||
81: KEY.QUIT, // q
|
||||
83: KEY.SAVE, // s
|
||||
87: KEY.JOIN, // w
|
||||
65: KEY.LOAD, // a
|
||||
75: KEY.SAVE, // k
|
||||
76: KEY.LOAD, // l
|
||||
49: KEY.PAD1, // 1
|
||||
50: KEY.PAD2, // 2
|
||||
51: KEY.PAD3, // 3
|
||||
|
|
|
|||
4
web/js/input/keys.js
vendored
4
web/js/input/keys.js
vendored
|
|
@ -4,6 +4,10 @@ const KEY = (() => {
|
|||
B: 'b',
|
||||
X: 'x',
|
||||
Y: 'y',
|
||||
L: 'l',
|
||||
R: 'r',
|
||||
L: 'l',
|
||||
R: 'r',
|
||||
START: 'start',
|
||||
SELECT: 'select',
|
||||
LOAD: 'load',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue