all repos — mgba @ 3f61f68f22bd5545d4d65ad7f78b7426fe1e8c34

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
13#include <mgba/core/lockstep.h>
14#ifdef M_CORE_GBA
15#include <mgba/internal/gba/sio/lockstep.h>
16#endif
17#ifdef M_CORE_GB
18#include <mgba/internal/gb/sio/lockstep.h>
19#endif
20
21namespace QGBA {
22
23class GameController;
24
25class MultiplayerController : public QObject {
26Q_OBJECT
27
28public:
29	MultiplayerController();
30
31	bool attachGame(GameController*);
32	void detachGame(GameController*);
33
34	int attached();
35	int playerId(GameController*);
36
37signals:
38	void gameAttached();
39	void gameDetached();
40
41private:
42	struct Player {
43		GameController* controller;
44		GBSIOLockstepNode* gbNode;
45		GBASIOLockstepNode* gbaNode;
46		int awake;
47		int32_t cyclesPosted;
48		unsigned waitMask;
49	};
50	union {
51		mLockstep m_lockstep;
52#ifdef M_CORE_GB
53		GBSIOLockstep m_gbLockstep;
54#endif
55#ifdef M_CORE_GBA
56		GBASIOLockstep m_gbaLockstep;
57#endif
58	};
59	QList<Player> m_players;
60	QMutex m_lock;
61};
62
63}
64#endif