windows.gaming.input.idl 16.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * Copyright 2021 Rémi Bernon for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#ifdef __WIDL__
#pragma winrt ns_prefix
#endif

import "inspectable.idl";
24 25 26
import "asyncinfo.idl";
import "eventtoken.idl";
import "windowscontracts.idl";
27
import "windows.foundation.idl";
28 29
import "windows.gaming.input.forcefeedback.idl";
import "windows.system.idl";
30 31 32 33 34

namespace Windows {
    namespace Gaming {
        namespace Input {
            typedef enum GamepadButtons GamepadButtons;
35 36 37
            typedef enum GameControllerButtonLabel GameControllerButtonLabel;
            typedef enum GameControllerSwitchKind GameControllerSwitchKind;
            typedef enum GameControllerSwitchPosition GameControllerSwitchPosition;
38 39 40 41 42 43 44 45
            typedef struct GamepadReading GamepadReading;
            typedef struct GamepadVibration GamepadVibration;
            interface IGameController;
            interface IGameControllerBatteryInfo;
            interface IGamepad;
            interface IGamepad2;
            interface IGamepadStatics;
            interface IGamepadStatics2;
46 47
            interface IRawGameController;
            interface IRawGameController2;
48
            runtimeclass Gamepad;
49 50
            runtimeclass Headset;
            runtimeclass RawGameController;
51 52 53 54 55 56 57 58 59
        }
    }
}

namespace Windows {
    namespace Gaming {
        namespace Input {
            declare {
                interface Windows.Foundation.EventHandler<Windows.Gaming.Input.Gamepad*>;
60 61 62
                interface Windows.Foundation.EventHandler<Windows.Gaming.Input.RawGameController*>;
                interface Windows.Foundation.TypedEventHandler<Windows.Gaming.Input.IGameController*, Windows.Gaming.Input.Headset*>;
                interface Windows.Foundation.TypedEventHandler<Windows.Gaming.Input.IGameController*, Windows.System.UserChangedEventArgs*>;
63
                interface Windows.Foundation.Collections.IVectorView<Gamepad*>;
64
                interface Windows.Foundation.Collections.IVectorView<Windows.Gaming.Input.RawGameController*>;
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
            }
        }
    }
}

namespace Windows {
    namespace Gaming {
        namespace Input {
            [
                contract(Windows.Foundation.UniversalApiContract, 1.0),
                flags
            ]
            enum GamepadButtons
            {
                None = 0x0,
                Menu = 0x1,
                View = 0x2,
                A = 0x4,
                B = 0x8,
                X = 0x10,
                Y = 0x20,
                DPadUp = 0x40,
                DPadDown = 0x80,
                DPadLeft = 0x100,
                DPadRight = 0x200,
                LeftShoulder = 0x400,
                RightShoulder = 0x800,
                LeftThumbstick = 0x1000,
                RightThumbstick = 0x2000,
                [contract(Windows.Foundation.UniversalApiContract, 3.0)]
                Paddle1 = 0x4000,
                [contract(Windows.Foundation.UniversalApiContract, 3.0)]
                Paddle2 = 0x8000,
                [contract(Windows.Foundation.UniversalApiContract, 3.0)]
                Paddle3 = 0x10000,
                [contract(Windows.Foundation.UniversalApiContract, 3.0)]
                Paddle4 = 0x20000
            };

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
            [contract(Windows.Foundation.UniversalApiContract, 3.0)]
            enum GameControllerButtonLabel
            {
                None                 = 0,
                XboxBack             = 1,
                XboxStart            = 2,
                XboxMenu             = 3,
                XboxView             = 4,
                XboxUp               = 5,
                XboxDown             = 6,
                XboxLeft             = 7,
                XboxRight            = 8,
                XboxA                = 9,
                XboxB                = 10,
                XboxX                = 11,
                XboxY                = 12,
                XboxLeftBumper       = 13,
                XboxLeftTrigger      = 14,
                XboxLeftStickButton  = 15,
                XboxRightBumper      = 16,
                XboxRightTrigger     = 17,
                XboxRightStickButton = 18,
                XboxPaddle1          = 19,
                XboxPaddle2          = 20,
                XboxPaddle3          = 21,
                XboxPaddle4          = 22,
                Mode                 = 23,
                Select               = 24,
                Menu                 = 25,
                View                 = 26,
                Back                 = 27,
                Start                = 28,
                Options              = 29,
                Share                = 30,
                Up                   = 31,
                Down                 = 32,
                Left                 = 33,
                Right                = 34,
                LetterA              = 35,
                LetterB              = 36,
                LetterC              = 37,
                LetterL              = 38,
                LetterR              = 39,
                LetterX              = 40,
                LetterY              = 41,
                LetterZ              = 42,
                Cross                = 43,
                Circle               = 44,
                Square               = 45,
                Triangle             = 46,
                LeftBumper           = 47,
                LeftTrigger          = 48,
                LeftStickButton      = 49,
                Left1                = 50,
                Left2                = 51,
                Left3                = 52,
                RightBumper          = 53,
                RightTrigger         = 54,
                RightStickButton     = 55,
                Right1               = 56,
                Right2               = 57,
                Right3               = 58,
                Paddle1              = 59,
                Paddle2              = 60,
                Paddle3              = 61,
                Paddle4              = 62,
                Plus                 = 63,
                Minus                = 64,
                DownLeftArrow        = 65,
                DialLeft             = 66,
                DialRight            = 67,
                Suspension           = 68
            };

            [contract(Windows.Foundation.UniversalApiContract, 4.0)]
            enum GameControllerSwitchKind
            {
                TwoWay   = 0,
                FourWay  = 1,
                EightWay = 2
            };

            [contract(Windows.Foundation.UniversalApiContract, 4.0)]
            enum GameControllerSwitchPosition
            {
                Center    = 0,
                Up        = 1,
                UpRight   = 2,
                Right     = 3,
                DownRight = 4,
                Down      = 5,
                DownLeft  = 6,
                Left      = 7,
                UpLeft    = 8
            };

200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
            [contract(Windows.Foundation.UniversalApiContract, 1.0)]
            struct GamepadReading
            {
                UINT64 Timestamp;
                Windows.Gaming.Input.GamepadButtons Buttons;
                DOUBLE LeftTrigger;
                DOUBLE RightTrigger;
                DOUBLE LeftThumbstickX;
                DOUBLE LeftThumbstickY;
                DOUBLE RightThumbstickX;
                DOUBLE RightThumbstickY;
            };

            [contract(Windows.Foundation.UniversalApiContract, 1.0)]
            struct GamepadVibration
            {
                DOUBLE LeftMotor;
                DOUBLE RightMotor;
                DOUBLE LeftTrigger;
                DOUBLE RightTrigger;
            };

222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
            [
                contract(Windows.Foundation.UniversalApiContract, 1.0),
                uuid(1baf6522-5f64-42c5-8267-b9fe2215bfbd)
            ]
            interface IGameController : IInspectable
            {
                [eventadd] HRESULT HeadsetConnected([in] Windows.Foundation.TypedEventHandler<Windows.Gaming.Input.IGameController*, Windows.Gaming.Input.Headset*>* handler,
                                                    [out, retval] EventRegistrationToken* token);
                [eventremove] HRESULT HeadsetConnected([in] EventRegistrationToken token);
                [eventadd] HRESULT HeadsetDisconnected([in] Windows.Foundation.TypedEventHandler<Windows.Gaming.Input.IGameController*, Windows.Gaming.Input.Headset*>* handler,
                                                       [out, retval] EventRegistrationToken* token);
                [eventremove] HRESULT HeadsetDisconnected([in] EventRegistrationToken token);
                [eventadd] HRESULT UserChanged([in] Windows.Foundation.TypedEventHandler<Windows.Gaming.Input.IGameController*, Windows.System.UserChangedEventArgs*>* handler,
                                               [out, retval] EventRegistrationToken* token);
                [eventremove] HRESULT UserChanged([in] EventRegistrationToken token);
                [propget] HRESULT Headset([out, retval] Windows.Gaming.Input.Headset** value);
                [propget] HRESULT IsWireless([out, retval] boolean* value);
                [propget] HRESULT User([out, retval] Windows.System.User** value);
            }

242 243 244 245 246 247 248 249 250 251 252 253 254
            [
                contract(Windows.Foundation.UniversalApiContract, 1.0),
                exclusiveto(Windows.Gaming.Input.Gamepad),
                uuid(bc7bb43c-0a69-3903-9e9d-a50f86a45de5)
            ]
            interface IGamepad : IInspectable
                requires Windows.Gaming.Input.IGameController
            {
                [propget] HRESULT Vibration([out, retval] Windows.Gaming.Input.GamepadVibration* value);
                [propput] HRESULT Vibration([in] Windows.Gaming.Input.GamepadVibration value);
                HRESULT GetCurrentReading([out, retval] Windows.Gaming.Input.GamepadReading* value);
            }

255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
            [
                contract(Windows.Foundation.UniversalApiContract, 4.0),
                exclusiveto(Windows.Gaming.Input.RawGameController),
                uuid(7cad6d91-a7e1-4f71-9a78-33e9c5dfea62)
            ]
            interface IRawGameController : IInspectable
                requires Windows.Gaming.Input.IGameController
            {
                [propget] HRESULT AxisCount([out, retval] INT32* value);
                [propget] HRESULT ButtonCount([out, retval] INT32* value);
                [propget] HRESULT ForceFeedbackMotors([out, retval] Windows.Foundation.Collections.IVectorView<Windows.Gaming.Input.ForceFeedback.ForceFeedbackMotor*>** value);
                [propget] HRESULT HardwareProductId([out, retval] UINT16* value);
                [propget] HRESULT HardwareVendorId([out, retval] UINT16* value);
                [propget] HRESULT SwitchCount([out, retval] INT32* value);
                HRESULT GetButtonLabel([in] INT32 index, [out, retval] Windows.Gaming.Input.GameControllerButtonLabel* value);
                HRESULT GetCurrentReading([in] UINT32 buttons_size, [out, size_is(buttons_size)] boolean* buttons,
                                          [in] UINT32 switches_size, [out, size_is(switches_size)] Windows.Gaming.Input.GameControllerSwitchPosition* switches,
                                          [in] UINT32 axes_size, [out, size_is(axes_size)] DOUBLE* axes,
                                          [out, retval] UINT64* timestamp);
                HRESULT GetSwitchKind([in] INT32 index, [out, retval] Windows.Gaming.Input.GameControllerSwitchKind* value);
            }

277 278 279 280 281 282 283 284 285 286 287 288 289
            [
                object,
                uuid(8bbce529-d49c-39e9-9560-e47dde96b7c8)
            ]
            interface IGamepadStatics : IInspectable
            {
                [eventadd] HRESULT GamepadAdded([in] Windows.Foundation.EventHandler<Gamepad*> *value, [out, retval] EventRegistrationToken* token);
                [eventremove] HRESULT GamepadAdded([in] EventRegistrationToken token);
                [eventadd] HRESULT GamepadRemoved([in] Windows.Foundation.EventHandler<Gamepad*> *value, [out, retval] EventRegistrationToken* token);
                [eventremove] HRESULT GamepadRemoved([in] EventRegistrationToken token);
                [propget] HRESULT Gamepads([out, retval] Windows.Foundation.Collections.IVectorView<Gamepad*> **value);
            }

290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
            [
                contract(Windows.Foundation.UniversalApiContract, 1.0),
                exclusiveto(Windows.Gaming.Input.Headset),
                uuid(3fd156ef-6925-3fa8-9181-029c5223ae3b)
            ]
            interface IHeadset : IInspectable
            {
                [propget] HRESULT CaptureDeviceId([out, retval] HSTRING* value);
                [propget] HRESULT RenderDeviceId([out, retval] HSTRING* value);
            }

            [
                object,
                uuid(eb8d0792-e95a-4b19-afc7-0a59f8bf759e)
            ]
            interface IRawGameControllerStatics : IInspectable
            {
                [eventadd] HRESULT RawGameControllerAdded([in] Windows.Foundation.EventHandler<Windows.Gaming.Input.RawGameController*> *handler,
                                                          [out, retval] EventRegistrationToken* token);
                [eventremove] HRESULT RawGameControllerAdded([in] EventRegistrationToken token);
                [eventadd] HRESULT RawGameControllerRemoved([in] Windows.Foundation.EventHandler<Windows.Gaming.Input.RawGameController*> *handler,
                                                            [out, retval] EventRegistrationToken* token);
                [eventremove] HRESULT RawGameControllerRemoved([in] EventRegistrationToken token);
                [propget] HRESULT RawGameControllers([out, retval] Windows.Foundation.Collections.IVectorView<Windows.Gaming.Input.RawGameController*> **value);
                HRESULT FromGameController([in] Windows.Gaming.Input.IGameController *game_controller, [out, retval] Windows.Gaming.Input.RawGameController **value);
            }

317 318 319 320 321 322 323 324 325 326 327 328 329 330
            [
                contract(Windows.Foundation.UniversalApiContract, 1.0),
                marshaling_behavior(agile),
                static(Windows.Gaming.Input.IGamepadStatics, Windows.Foundation.UniversalApiContract, 1.0),
                static(Windows.Gaming.Input.IGamepadStatics2, Windows.Foundation.UniversalApiContract, 4.0),
                threading(both)
            ]
            runtimeclass Gamepad
            {
                [default] interface Windows.Gaming.Input.IGamepad;
                interface Windows.Gaming.Input.IGameController;
                [contract(Windows.Foundation.UniversalApiContract, 3.0)] interface Windows.Gaming.Input.IGamepad2;
                [contract(Windows.Foundation.UniversalApiContract, 4.0)] interface Windows.Gaming.Input.IGameControllerBatteryInfo;
            }
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355

            [
                contract(Windows.Foundation.UniversalApiContract, 1.0),
                marshaling_behavior(agile),
                threading(both)
            ]
            runtimeclass Headset
            {
                [default] interface Windows.Gaming.Input.IHeadset;
                [contract(Windows.Foundation.UniversalApiContract, 4.0)] interface Windows.Gaming.Input.IGameControllerBatteryInfo;
            }

            [
                contract(Windows.Foundation.UniversalApiContract, 4.0),
                marshaling_behavior(agile),
                static(Windows.Gaming.Input.IRawGameControllerStatics, Windows.Foundation.UniversalApiContract, 4.0),
                threading(both)
            ]
            runtimeclass RawGameController
            {
                [default] interface Windows.Gaming.Input.IRawGameController;
                interface Windows.Gaming.Input.IGameController;
                interface Windows.Gaming.Input.IGameControllerBatteryInfo;
                [contract(Windows.Foundation.UniversalApiContract, 5.0)] interface Windows.Gaming.Input.IRawGameController2;
            }
356 357 358
        }
    }
}