-
Notifications
You must be signed in to change notification settings - Fork 1
/
platform_core.h
88 lines (79 loc) · 2.08 KB
/
platform_core.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef PLATFORM_CORE_H
#define PLATFORM_CORE_H 1
// Button definitions
const int P1_Left = 0;
const int P1_Top = 1;
const int P1_Right = 2;
const int P1_Bottom = 3;
const int P2_Right = 4;
const int P2_Bottom = 5;
const int P2_Left = 6;
const int P2_Top = 7;
#ifdef _WIN32
#include <iostream>
#include <chrono>
#include <thread>
#include <ctime>
#include <Windows.h>
#include <cwchar>
#include <stdint.h>
#include <math.h> // Added for GCC
#define localtime_r(_Time, _Tm) localtime_s(_Tm, _Time)
#elif __linux
#include <iostream>
#include <chrono>
#include <thread>
#include <ctime>
#include <cwchar>
#include <stdint.h>
#include <string.h>
#include <math.h>
//typedef uint32_t DWORD; // DWORD = unsigned 32 bit value
//typedef uint16_t WORD; // WORD = unsigned 16 bit value
typedef uint8_t byte; // BYTE = unsigned 8 bit value
#elif ESP32
#include <Arduino.h> // for type definitions
#elif __EMSCRIPTEN__
#include <emscripten.h>
#include <cstdlib>
#include <stdio.h>
typedef int byte;
#include <iostream>
#include <chrono>
#include <thread>
#include <ctime>
#include <cwchar>
#include <stdint.h>
#include <string.h>
#include <math.h>
#endif
unsigned long getTimeInMillis();
static double getBatteryVoltage();
void gameSleep(int);
struct PlayerKeys {
bool up = false;
bool down = false;
bool right = false;
bool left = false;
bool a = false;
bool b = false;
bool start = false;
bool select = false;
int debounceDelay = 300;
bool debouncedInput = true;
unsigned long debounceTimeout = 0;
};
const char *getDevicePlatform();
bool startBLEKeyboard();
bool processBLEKeyboard(PlayerKeys keys);
bool stopBLEKeyboard();
bool initBLEDevice();
bool deinitBLEDevice();
void printBLEDeviceAddress(char* bd_addr);
static unsigned long frameTime = getTimeInMillis();
static unsigned long startTime = getTimeInMillis();
static unsigned long currentTime = getTimeInMillis();
static unsigned long fpsTimer1 = getTimeInMillis();
static unsigned long fpsTimer2 = getTimeInMillis();
static unsigned int timeDiff = 0;
#endif