all repos — mgba @ daaa2fa5236df5e8976e7e0ba7ac39e0d9233422

mGBA Game Boy Advance Emulator

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#ifndef QGBA_MULTIPLAYER_CONTROLLER
 7#define QGBA_MULTIPLAYER_CONTROLLER
 8
 9#include <QMutex>
10#include <QList>
11#include <QObject>
12
13extern "C" {
14#include "core/lockstep.h"
15#ifdef M_CORE_GBA
16#include "gba/sio/lockstep.h"
17#endif
18#ifdef M_CORE_GB
19#include "gb/sio/lockstep.h"
20#endif
21}
22
23namespace QGBA {
24
25class GameController;
26
27class MultiplayerController : public QObject {
28Q_OBJECT
29
30public:
31	MultiplayerController();
32
33	bool attachGame(GameController*);
34	void detachGame(GameController*);
35
36	int attached();
37	int playerId(GameController*);
38
39signals:
40	void gameAttached();
41	void gameDetached();
42
43private:
44	struct Player {
45		GameController* 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}
66#endif