src/core/interface.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 CORE_INTERFACE_H
7#define CORE_INTERFACE_H
8
9#include "util/common.h"
10
11struct mCore;
12
13#ifdef COLOR_16_BIT
14typedef uint16_t color_t;
15#define BYTES_PER_PIXEL 2
16#else
17typedef uint32_t color_t;
18#define BYTES_PER_PIXEL 4
19#endif
20
21struct blip_t;
22
23struct mCoreCallbacks {
24 void* context;
25 void (*videoFrameStarted)(void* context);
26 void (*videoFrameEnded)(void* context);
27 void (*coreCrashed)(void* context);
28};
29
30struct mAVStream {
31 void (*videoDimensionsChanged)(struct mAVStream*, unsigned width, unsigned height);
32 void (*postVideoFrame)(struct mAVStream*, const color_t* buffer, size_t stride);
33 void (*postAudioFrame)(struct mAVStream*, int16_t left, int16_t right);
34 void (*postAudioBuffer)(struct mAVStream*, struct blip_t* left, struct blip_t* right);
35};
36
37struct mKeyCallback {
38 uint16_t (*readKeys)(struct mKeyCallback*);
39};
40
41struct mStopCallback {
42 void (*stop)(struct mStopCallback*);
43};
44
45struct mRotationSource {
46 void (*sample)(struct mRotationSource*);
47
48 int32_t (*readTiltX)(struct mRotationSource*);
49 int32_t (*readTiltY)(struct mRotationSource*);
50
51 int32_t (*readGyroZ)(struct mRotationSource*);
52};
53
54struct mRTCSource {
55 void (*sample)(struct mRTCSource*);
56
57 time_t (*unixTime)(struct mRTCSource*);
58};
59
60enum mRTCGenericType {
61 RTC_NO_OVERRIDE,
62 RTC_FIXED,
63 RTC_FAKE_EPOCH
64};
65
66struct mRTCGenericSource {
67 struct mRTCSource d;
68 struct mCore* p;
69 enum mRTCGenericType override;
70 int64_t value;
71};
72
73void mRTCGenericSourceInit(struct mRTCGenericSource* rtc, struct mCore* core);
74
75struct mRumble {
76 void (*setRumble)(struct mRumble*, int enable);
77};
78
79#endif