-
Notifications
You must be signed in to change notification settings - Fork 6
/
joystick.h
56 lines (48 loc) · 1.18 KB
/
joystick.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
// --------------------------------------------------------------------------
//
// C Kong
// Copyright (C) 2018 Jeff Panici
// All rights reserved.
//
// This software source file is licensed according to the
// MIT License. Refer to the LICENSE file distributed along
// with this source file to learn more.
//
// --------------------------------------------------------------------------
#pragma once
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include "fwd.h"
typedef enum {
button_invalid = -1,
button_a,
button_b,
button_x,
button_y,
button_back,
button_guide,
button_start,
button_left_stick,
button_right_stick,
button_left_shoulder,
button_right_shoulder,
button_dpad_up,
button_dpad_down,
button_dpad_left,
button_dpad_right,
} joystick_button_t;
typedef struct {
int32_t index;
const char* name;
const char* mapping;
struct _SDL_GameController* controller;
} joystick_t;
bool joystick_button(
joystick_t* joy,
joystick_button_t button);
bool joystick_button_pressed(
joystick_t* joy,
joystick_button_t button);
joystick_t* joystick_open();
void joystick_close(joystick_t* joy);