USB Host Shield 2.0
xboxEnums.h
Go to the documentation of this file.
1 /* Copyright (C) 2012 Kristian Lauszus, TKJ Electronics. All rights reserved.
2 
3  This software may be distributed and modified under the terms of the GNU
4  General Public License version 2 (GPL2) as published by the Free Software
5  Foundation and appearing in the file GPL2.TXT included in the packaging of
6  this file. Please note that GPL2 Section 2[b] requires that all works based
7  on this software must also be made publicly available under the terms of
8  the GPL2 ("Copyleft").
9 
10  Contact information
11  -------------------
12 
13  Kristian Lauszus, TKJ Electronics
14  Web : http://www.tkjelectronics.com
15  e-mail : kristianl@tkjelectronics.com
16  */
17 
18 #ifndef _xboxenums_h
19 #define _xboxenums_h
20 
21 #include "controllerEnums.h"
22 
25  ROTATING = 0x0A,
26  FASTBLINK = 0x0B,
27  SLOWBLINK = 0x0C,
28  ALTERNATING = 0x0D,
29 };
30 
32 const uint8_t XBOX_LEDS[] PROGMEM = {
33  0x00, // OFF
34  0x02, // LED1
35  0x03, // LED2
36  0x04, // LED3
37  0x05, // LED4
38  0x01, // ALL - Used to blink all LEDs
39 };
41 const uint16_t XBOX_BUTTONS[] PROGMEM = {
42  0x0100, // UP
43  0x0800, // RIGHT
44  0x0200, // DOWN
45  0x0400, // LEFT
46 
47  0x2000, // BACK
48  0x1000, // START
49  0x4000, // L3
50  0x8000, // R3
51 
52  0, 0, // Skip L2 and R2 as these are analog buttons
53  0x0001, // L1
54  0x0002, // R1
55 
56  0x0020, // B
57  0x0010, // A
58  0x0040, // X
59  0x0080, // Y
60 
61  0x0004, // XBOX
62  0x0008, // SYNC
63 };
64 
65 inline int8_t getButtonIndexXbox(ButtonEnum b) {
66  const int8_t index = ButtonIndex(b);
67  if ((uint8_t) index >= (sizeof(XBOX_BUTTONS) / sizeof(XBOX_BUTTONS[0]))) return -1;
68  return index;
69 }
70 
71 #endif
XBOX_BUTTONS
const uint16_t XBOX_BUTTONS[]
Definition: xboxEnums.h:41
ButtonIndex
constexpr int8_t ButtonIndex(ButtonEnum key)
Definition: controllerEnums.h:186
ROTATING
@ ROTATING
Definition: xboxEnums.h:25
controllerEnums.h
ALTERNATING
@ ALTERNATING
Definition: xboxEnums.h:28
SLOWBLINK
@ SLOWBLINK
Definition: xboxEnums.h:27
getButtonIndexXbox
int8_t getButtonIndexXbox(ButtonEnum b)
Definition: xboxEnums.h:65
LEDModeEnum
LEDModeEnum
Definition: xboxEnums.h:24
FASTBLINK
@ FASTBLINK
Definition: xboxEnums.h:26
XBOX_LEDS
const uint8_t XBOX_LEDS[]
Definition: xboxEnums.h:32
ButtonEnum
ButtonEnum
Definition: controllerEnums.h:78