66 lines
1.6 KiB
C
66 lines
1.6 KiB
C
/*
|
|
* Copyright (c) 2019-2021, yzrh <yzrh@noema.org>
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#define GPIO_LOW 0x00
|
|
#define GPIO_HIGH 0x01
|
|
|
|
#ifdef __FreeBSD__
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/gpio.h>
|
|
|
|
#define GPIO_IN GPIO_PIN_INPUT
|
|
#define GPIO_OUT GPIO_PIN_OUTPUT
|
|
#define GPIO_INT GPIO_INTR_EDGE_FALLING
|
|
|
|
#elif __linux__
|
|
|
|
#define GPIO_IN 0x00
|
|
#define GPIO_OUT 0x01
|
|
/*
|
|
* 0: falling
|
|
* 1: rising
|
|
*/
|
|
#define GPIO_INT 0
|
|
|
|
#endif /* __FreeBSD__ */
|
|
|
|
/* Raspberry Pi 3 */
|
|
#define GPIO_PIN_IN0 4 /* 7: DPAD_LEFT */
|
|
#define GPIO_PIN_IN1 14 /* 8: DPAD_UP */
|
|
#define GPIO_PIN_IN2 15 /* 10: DPAD_DOWN */
|
|
#define GPIO_PIN_IN3 17 /* 11: DPAD_RIGHT */
|
|
|
|
#define GPIO_PIN_IN4 18 /* 12: BACK */
|
|
#define GPIO_PIN_IN5 27 /* 13: GUIDE */
|
|
#define GPIO_PIN_IN6 22 /* 15: START */
|
|
|
|
#define GPIO_PIN_IN7 23 /* 16: A */
|
|
#define GPIO_PIN_IN8 24 /* 18: B */
|
|
#define GPIO_PIN_IN9 10 /* 19: X */
|
|
#define GPIO_PIN_IN10 9 /* 21: Y */
|
|
|
|
#define GPIO_PIN_IN11 25 /* 22: LEFTSHOULDER */
|
|
#define GPIO_PIN_IN12 11 /* 23: RIGHTSHOULDER */
|
|
|
|
#define GPIO_PIN_IN13 8 /* 24: LEFTSTICK */
|
|
#define GPIO_PIN_IN14 7 /* 26: RIGHTSTICK */
|
|
|
|
/* Second controller */
|
|
#define GPIO_PIN_IN15 0 /* 27: DPAD_LEFT */
|
|
#define GPIO_PIN_IN16 1 /* 28: DPAD_UP */
|
|
#define GPIO_PIN_IN17 5 /* 29: DPAD_DOWN */
|
|
#define GPIO_PIN_IN18 6 /* 31: DPAD_RIGHT */
|
|
|
|
/* Unused */
|
|
#define GPIO_PIN_IN19 12 /* 32: NULL */
|
|
#define GPIO_PIN_IN20 13 /* 33: NULL */
|
|
#define GPIO_PIN_IN21 19 /* 35: NULL */
|
|
#define GPIO_PIN_IN22 16 /* 36: NULL */
|
|
#define GPIO_PIN_IN23 26 /* 37: NULL */
|
|
#define GPIO_PIN_IN24 20 /* 38: NULL */
|
|
#define GPIO_PIN_IN25 21 /* 40: NULL */
|