-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
GamepadUnplugged.c
63 lines (55 loc) · 2.06 KB
/
GamepadUnplugged.c
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
// Filename: GamepadUnplugged.c
// Contains code for the functions that are specific to the "Gamepad Unplugged" screen.
//
// Project Codename: GameB
// TODO: Come up with a better name later.
// 2020 Joseph Ryan Ries <ryanries09@gmail.com>
// My YouTube series where we program an entire video game from scratch in C.
// Watch it on YouTube: https://www.youtube.com/watch?v=3zFFrBSdBvA
// Follow along on GitHub: https://github.com/ryanries/GameB
// Find me on Twitter @JosephRyanRies
// # License
// ----------
// The source code in this project is licensed under the MIT license.
// The media assets such as artwork, custom fonts, music and sound effects are licensed under a separate license.
// A copy of that license can be found in the 'Assets' directory.
// stb_vorbis by Sean Barrett is public domain and a copy of its license can be found in the stb_vorbis.c file.
#include "CommonMain.h"
#include "Platform.h"
#include "GamepadUnplugged.h"
void DrawGamepadUnplugged(void)
{
memset(gBackBuffer.Memory, 0, GAME_DRAWING_AREA_MEMORY_SIZE);
BlitStringEx(
GAMEPADUNPLUGGEDSTRING1,
&g6x7Font,
(GAME_RES_WIDTH / 2) - (((int)strlen(GAMEPADUNPLUGGEDSTRING1) * 6) / 2),
100,
255,
255,
255,
0,
BLIT_FLAG_ALPHABLEND | BLIT_FLAG_TEXT_SHADOW);
BlitStringEx(
GAMEPADUNPLUGGEDSTRING2,
&g6x7Font,
(GAME_RES_WIDTH / 2) - (((int)strlen(GAMEPADUNPLUGGEDSTRING2) * 6) / 2),
115,
255,
255,
255,
0,
BLIT_FLAG_ALPHABLEND | BLIT_FLAG_TEXT_SHADOW);
}
void PPI_GamepadUnplugged(void)
{
if (gGamepadID > -1 || (gGameInput.EscapeKeyIsDown && !gGameInput.EscapeKeyWasDown))
{
gCurrentGameState = gPreviousGameState;
gPreviousGameState = GAMESTATE_GAMEPADUNPLUGGED;
LogMessageA(LL_INFO, "[%s] Transitioning from game state %d to %d. Either a gamepad was reconnected or the player chose to continue without one.",
__FUNCTION__,
gPreviousGameState,
gCurrentGameState);
}
}