src/platform/qt/MultiplayerController.h (view raw)
1/* Copyright (c) 2013-2015 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#pragma once
7
8#include <QMutex>
9#include <QList>
10#include <QObject>
11
12#include <mgba/core/lockstep.h>
13#ifdef M_CORE_GBA
14#include <mgba/internal/gba/sio/lockstep.h>
15#endif
16#ifdef M_CORE_GB
17#include <mgba/internal/gb/sio/lockstep.h>
18#endif
19
20struct GBSIOLockstepNode;
21struct GBASIOLockstepNode;
22
23namespace QGBA {
24
25class CoreController;
26
27class MultiplayerController : public QObject {
28Q_OBJECT
29
30public:
31 MultiplayerController();
32
33 bool attachGame(CoreController*);
34 void detachGame(CoreController*);
35
36 int attached();
37 int playerId(CoreController*);
38
39signals:
40 void gameAttached();
41 void gameDetached();
42
43private:
44 struct Player {
45 CoreController* controller;
46 GBSIOLockstepNode* gbNode;
47 GBASIOLockstepNode* gbaNode;
48 int awake;
49 int32_t cyclesPosted;
50 unsigned waitMask;
51 };
52 union {
53 mLockstep m_lockstep;
54#ifdef M_CORE_GB
55 GBSIOLockstep m_gbLockstep;
56#endif
57#ifdef M_CORE_GBA
58 GBASIOLockstep m_gbaLockstep;
59#endif
60 };
61 QList<Player> m_players;
62 QMutex m_lock;
63};
64
65}