Skip to content
This repository was archived by the owner on Mar 30, 2019. It is now read-only.

Commit 727269c

Browse files
committed
Correctly map XInput GamepadButtonFlags.
1 parent f60c34e commit 727269c

2 files changed

Lines changed: 47 additions & 4 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
using System;
21+
22+
namespace SharpDX.XInput
23+
{
24+
[Flags]
25+
public enum GamepadButtonFlags : ushort
26+
{
27+
None = 0,
28+
DPadUp = 0x0001,
29+
DPadDown = 0x0002,
30+
DPadLeft = 0x0004,
31+
DPadRight = 0x0008,
32+
Start = 0x0010,
33+
Back = 0x0020,
34+
LeftThumb = 0x0040,
35+
RightThumb = 0x0080,
36+
LeftShoulder = 0x0100,
37+
RightShoulder = 0x0200,
38+
A = 0x1000,
39+
B = 0x2000,
40+
X = 0x4000,
41+
Y = 0x8000
42+
}
43+
}
44+

Source/SharpDX.XInput/Mapping.xml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
<context>sharpdx-xinput-ext</context>
4545
<context>xinput</context>
4646

47+
<define enum="SharpDX.XInput.GamepadButtonFlags" sizeof="2" underlying="System.UInt16" />
48+
4749
<create-cpp enum="BATTERY_DEVTYPE" macro="BATTERY_DEVTYPE_.*"/>
4850
<create-cpp enum="BATTERY_TYPE" macro="BATTERY_TYPE_.*"/>
4951
<create-cpp enum="BATTERY_LEVEL" macro="BATTERY_LEVEL_.*"/>
@@ -65,6 +67,7 @@
6567
</extension>
6668

6769
<bindings>
70+
<bind from="XINPUT_GAMEPAD_BUTTON_FLAGS" to="SharpDX.XInput.GamepadButtonFlags" />
6871
</bindings>
6972

7073
<mapping>
@@ -94,10 +97,6 @@
9497
<map enum="XINPUT_CAPS_FLAGS" name="CapabilityFlags" type="short"/>
9598
<map enum-item="XINPUT_CAPS_(.*)" name-tmp="$1"/>
9699

97-
<map enum="XINPUT_GAMEPAD_BUTTON_FLAGS" name="GamepadButtonFlags" flags="true" none="true" type="short"/>
98-
<map enum-item="XINPUT_GAMEPAD_(.*)" name-tmp="$1"/>
99-
<map enum-item="XINPUT_GAMEPAD_DPAD_(.*)" name-tmp="D_PAD_$1"/>
100-
101100
<map enum="XINPUT_GAMEPAD_KEY_CODE" name="GamepadKeyCode" flags="true" none="true" type="short"/>
102101
<map enum-item="VK_PAD_(.*)" name-tmp="$1"/>
103102
<map enum-item="VK_PAD_LTHUMB_(.*)" name-tmp="LEFT_THUMB_$1"/>

0 commit comments

Comments
 (0)