diff options
Diffstat (limited to 'xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp')
| -rw-r--r-- | xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp | 178 |
1 files changed, 81 insertions, 97 deletions
diff --git a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp index 4423cb4..f01180b 100644 --- a/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp +++ b/xbmc/addons/kodi-addon-dev-kit/include/kodi/kodi_peripheral_utils.hpp | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | 21 | ||
| 22 | #include "kodi_peripheral_types.h" | 22 | #include "kodi_peripheral_types.h" |
| 23 | 23 | ||
| 24 | #include <array> // Requires c++11 | ||
| 24 | #include <cstring> | 25 | #include <cstring> |
| 25 | #include <map> | 26 | #include <map> |
| 26 | #include <string> | 27 | #include <string> |
| @@ -204,6 +205,7 @@ namespace ADDON | |||
| 204 | JOYSTICK_STATE_BUTTON ButtonState(void) const { return m_event.driver_button_state; } | 205 | JOYSTICK_STATE_BUTTON ButtonState(void) const { return m_event.driver_button_state; } |
| 205 | JOYSTICK_STATE_HAT HatState(void) const { return m_event.driver_hat_state; } | 206 | JOYSTICK_STATE_HAT HatState(void) const { return m_event.driver_hat_state; } |
| 206 | JOYSTICK_STATE_AXIS AxisState(void) const { return m_event.driver_axis_state; } | 207 | JOYSTICK_STATE_AXIS AxisState(void) const { return m_event.driver_axis_state; } |
| 208 | JOYSTICK_STATE_MOTOR MotorState(void) const { return m_event.motor_state; } | ||
| 207 | 209 | ||
| 208 | void SetType(PERIPHERAL_EVENT_TYPE type) { m_event.type = type; } | 210 | void SetType(PERIPHERAL_EVENT_TYPE type) { m_event.type = type; } |
| 209 | void SetPeripheralIndex(unsigned int index) { m_event.peripheral_index = index; } | 211 | void SetPeripheralIndex(unsigned int index) { m_event.peripheral_index = index; } |
| @@ -211,6 +213,7 @@ namespace ADDON | |||
| 211 | void SetButtonState(JOYSTICK_STATE_BUTTON state) { m_event.driver_button_state = state; } | 213 | void SetButtonState(JOYSTICK_STATE_BUTTON state) { m_event.driver_button_state = state; } |
| 212 | void SetHatState(JOYSTICK_STATE_HAT state) { m_event.driver_hat_state = state; } | 214 | void SetHatState(JOYSTICK_STATE_HAT state) { m_event.driver_hat_state = state; } |
| 213 | void SetAxisState(JOYSTICK_STATE_AXIS state) { m_event.driver_axis_state = state; } | 215 | void SetAxisState(JOYSTICK_STATE_AXIS state) { m_event.driver_axis_state = state; } |
| 216 | void SetMotorState(JOYSTICK_STATE_MOTOR state) { m_event.motor_state = state; } | ||
| 214 | 217 | ||
| 215 | void ToStruct(PERIPHERAL_EVENT& event) const | 218 | void ToStruct(PERIPHERAL_EVENT& event) const |
| 216 | { | 219 | { |
| @@ -243,7 +246,9 @@ namespace ADDON | |||
| 243 | m_requestedPort(NO_PORT_REQUESTED), | 246 | m_requestedPort(NO_PORT_REQUESTED), |
| 244 | m_buttonCount(0), | 247 | m_buttonCount(0), |
| 245 | m_hatCount(0), | 248 | m_hatCount(0), |
| 246 | m_axisCount(0) | 249 | m_axisCount(0), |
| 250 | m_motorCount(0), | ||
| 251 | m_supportsPowerOff(false) | ||
| 247 | { | 252 | { |
| 248 | } | 253 | } |
| 249 | 254 | ||
| @@ -258,7 +263,9 @@ namespace ADDON | |||
| 258 | m_requestedPort(info.requested_port), | 263 | m_requestedPort(info.requested_port), |
| 259 | m_buttonCount(info.button_count), | 264 | m_buttonCount(info.button_count), |
| 260 | m_hatCount(info.hat_count), | 265 | m_hatCount(info.hat_count), |
| 261 | m_axisCount(info.axis_count) | 266 | m_axisCount(info.axis_count), |
| 267 | m_motorCount(info.motor_count), | ||
| 268 | m_supportsPowerOff(info.supports_poweroff) | ||
| 262 | { | 269 | { |
| 263 | } | 270 | } |
| 264 | 271 | ||
| @@ -275,6 +282,8 @@ namespace ADDON | |||
| 275 | m_buttonCount = rhs.m_buttonCount; | 282 | m_buttonCount = rhs.m_buttonCount; |
| 276 | m_hatCount = rhs.m_hatCount; | 283 | m_hatCount = rhs.m_hatCount; |
| 277 | m_axisCount = rhs.m_axisCount; | 284 | m_axisCount = rhs.m_axisCount; |
| 285 | m_motorCount = rhs.m_motorCount; | ||
| 286 | m_supportsPowerOff = rhs.m_supportsPowerOff; | ||
| 278 | } | 287 | } |
| 279 | return *this; | 288 | return *this; |
| 280 | } | 289 | } |
| @@ -284,6 +293,8 @@ namespace ADDON | |||
| 284 | unsigned int ButtonCount(void) const { return m_buttonCount; } | 293 | unsigned int ButtonCount(void) const { return m_buttonCount; } |
| 285 | unsigned int HatCount(void) const { return m_hatCount; } | 294 | unsigned int HatCount(void) const { return m_hatCount; } |
| 286 | unsigned int AxisCount(void) const { return m_axisCount; } | 295 | unsigned int AxisCount(void) const { return m_axisCount; } |
| 296 | unsigned int MotorCount(void) const { return m_motorCount; } | ||
| 297 | bool SupportsPowerOff(void) const { return m_supportsPowerOff; } | ||
| 287 | 298 | ||
| 288 | // Derived property: Counts are unknown if all are zero | 299 | // Derived property: Counts are unknown if all are zero |
| 289 | bool AreElementCountsKnown(void) const { return m_buttonCount != 0 || m_hatCount != 0 || m_axisCount != 0; } | 300 | bool AreElementCountsKnown(void) const { return m_buttonCount != 0 || m_hatCount != 0 || m_axisCount != 0; } |
| @@ -293,6 +304,8 @@ namespace ADDON | |||
| 293 | void SetButtonCount(unsigned int buttonCount) { m_buttonCount = buttonCount; } | 304 | void SetButtonCount(unsigned int buttonCount) { m_buttonCount = buttonCount; } |
| 294 | void SetHatCount(unsigned int hatCount) { m_hatCount = hatCount; } | 305 | void SetHatCount(unsigned int hatCount) { m_hatCount = hatCount; } |
| 295 | void SetAxisCount(unsigned int axisCount) { m_axisCount = axisCount; } | 306 | void SetAxisCount(unsigned int axisCount) { m_axisCount = axisCount; } |
| 307 | void SetMotorCount(unsigned int motorCount) { m_motorCount = motorCount; } | ||
| 308 | void SetSupportsPowerOff(bool supportsPowerOff) { m_supportsPowerOff = supportsPowerOff; } | ||
| 296 | 309 | ||
| 297 | void ToStruct(JOYSTICK_INFO& info) const | 310 | void ToStruct(JOYSTICK_INFO& info) const |
| 298 | { | 311 | { |
| @@ -303,6 +316,8 @@ namespace ADDON | |||
| 303 | info.button_count = m_buttonCount; | 316 | info.button_count = m_buttonCount; |
| 304 | info.hat_count = m_hatCount; | 317 | info.hat_count = m_hatCount; |
| 305 | info.axis_count = m_axisCount; | 318 | info.axis_count = m_axisCount; |
| 319 | info.motor_count = m_motorCount; | ||
| 320 | info.supports_poweroff = m_supportsPowerOff; | ||
| 306 | 321 | ||
| 307 | std::strcpy(info.provider, m_provider.c_str()); | 322 | std::strcpy(info.provider, m_provider.c_str()); |
| 308 | } | 323 | } |
| @@ -320,6 +335,8 @@ namespace ADDON | |||
| 320 | unsigned int m_buttonCount; | 335 | unsigned int m_buttonCount; |
| 321 | unsigned int m_hatCount; | 336 | unsigned int m_hatCount; |
| 322 | unsigned int m_axisCount; | 337 | unsigned int m_axisCount; |
| 338 | unsigned int m_motorCount; | ||
| 339 | bool m_supportsPowerOff; | ||
| 323 | }; | 340 | }; |
| 324 | 341 | ||
| 325 | typedef PeripheralVector<Joystick, JOYSTICK_INFO> Joysticks; | 342 | typedef PeripheralVector<Joystick, JOYSTICK_INFO> Joysticks; |
| @@ -332,6 +349,7 @@ namespace ADDON | |||
| 332 | * 1) a button | 349 | * 1) a button |
| 333 | * 2) a hat direction | 350 | * 2) a hat direction |
| 334 | * 3) a semiaxis (either the positive or negative half of an axis) | 351 | * 3) a semiaxis (either the positive or negative half of an axis) |
| 352 | * 4) a motor | ||
| 335 | * | 353 | * |
| 336 | * The type determines the fields in use: | 354 | * The type determines the fields in use: |
| 337 | * | 355 | * |
| @@ -345,9 +363,24 @@ namespace ADDON | |||
| 345 | * Semiaxis: | 363 | * Semiaxis: |
| 346 | * - driver index | 364 | * - driver index |
| 347 | * - semiaxis direction | 365 | * - semiaxis direction |
| 366 | * | ||
| 367 | * Motor: | ||
| 368 | * - driver index | ||
| 348 | */ | 369 | */ |
| 349 | class DriverPrimitive | 370 | struct DriverPrimitive |
| 350 | { | 371 | { |
| 372 | protected: | ||
| 373 | /*! | ||
| 374 | * \brief Construct a driver primitive of the specified type | ||
| 375 | */ | ||
| 376 | DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE type, unsigned int driverIndex) : | ||
| 377 | m_type(type), | ||
| 378 | m_driverIndex(driverIndex), | ||
| 379 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), | ||
| 380 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN) | ||
| 381 | { | ||
| 382 | } | ||
| 383 | |||
| 351 | public: | 384 | public: |
| 352 | /*! | 385 | /*! |
| 353 | * \brief Construct an invalid driver primitive | 386 | * \brief Construct an invalid driver primitive |
| @@ -363,12 +396,9 @@ namespace ADDON | |||
| 363 | /*! | 396 | /*! |
| 364 | * \brief Construct a driver primitive representing a button | 397 | * \brief Construct a driver primitive representing a button |
| 365 | */ | 398 | */ |
| 366 | DriverPrimitive(unsigned int buttonIndex) : | 399 | static DriverPrimitive CreateButton(unsigned int buttonIndex) |
| 367 | m_type(JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON), | ||
| 368 | m_driverIndex(buttonIndex), | ||
| 369 | m_hatDirection(JOYSTICK_DRIVER_HAT_UNKNOWN), | ||
| 370 | m_semiAxisDirection(JOYSTICK_DRIVER_SEMIAXIS_UNKNOWN) | ||
| 371 | { | 400 | { |
| 401 | return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON, buttonIndex); | ||
| 372 | } | 402 | } |
| 373 | 403 | ||
| 374 | /*! | 404 | /*! |
| @@ -395,6 +425,14 @@ namespace ADDON | |||
| 395 | { | 425 | { |
| 396 | } | 426 | } |
| 397 | 427 | ||
| 428 | /*! | ||
| 429 | * \brief Construct a driver primitive representing a motor | ||
| 430 | */ | ||
| 431 | static DriverPrimitive CreateMotor(unsigned int motorIndex) | ||
| 432 | { | ||
| 433 | return DriverPrimitive(JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR, motorIndex); | ||
| 434 | } | ||
| 435 | |||
| 398 | DriverPrimitive(const JOYSTICK_DRIVER_PRIMITIVE& primitive) : | 436 | DriverPrimitive(const JOYSTICK_DRIVER_PRIMITIVE& primitive) : |
| 399 | m_type(primitive.type), | 437 | m_type(primitive.type), |
| 400 | m_driverIndex(0), | 438 | m_driverIndex(0), |
| @@ -420,6 +458,11 @@ namespace ADDON | |||
| 420 | m_semiAxisDirection = primitive.semiaxis.direction; | 458 | m_semiAxisDirection = primitive.semiaxis.direction; |
| 421 | break; | 459 | break; |
| 422 | } | 460 | } |
| 461 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: | ||
| 462 | { | ||
| 463 | m_driverIndex = primitive.motor.index; | ||
| 464 | break; | ||
| 465 | } | ||
| 423 | default: | 466 | default: |
| 424 | break; | 467 | break; |
| 425 | } | 468 | } |
| @@ -437,6 +480,7 @@ namespace ADDON | |||
| 437 | switch (m_type) | 480 | switch (m_type) |
| 438 | { | 481 | { |
| 439 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: | 482 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_BUTTON: |
| 483 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: | ||
| 440 | { | 484 | { |
| 441 | return m_driverIndex == other.m_driverIndex; | 485 | return m_driverIndex == other.m_driverIndex; |
| 442 | } | 486 | } |
| @@ -479,11 +523,21 @@ namespace ADDON | |||
| 479 | driver_primitive.semiaxis.direction = m_semiAxisDirection; | 523 | driver_primitive.semiaxis.direction = m_semiAxisDirection; |
| 480 | break; | 524 | break; |
| 481 | } | 525 | } |
| 526 | case JOYSTICK_DRIVER_PRIMITIVE_TYPE_MOTOR: | ||
| 527 | { | ||
| 528 | driver_primitive.motor.index = m_driverIndex; | ||
| 529 | break; | ||
| 530 | } | ||
| 482 | default: | 531 | default: |
| 483 | break; | 532 | break; |
| 484 | } | 533 | } |
| 485 | } | 534 | } |
| 486 | 535 | ||
| 536 | static void FreeStruct(JOYSTICK_DRIVER_PRIMITIVE& primitive) | ||
| 537 | { | ||
| 538 | (void)primitive; | ||
| 539 | } | ||
| 540 | |||
| 487 | private: | 541 | private: |
| 488 | JOYSTICK_DRIVER_PRIMITIVE_TYPE m_type; | 542 | JOYSTICK_DRIVER_PRIMITIVE_TYPE m_type; |
| 489 | unsigned int m_driverIndex; | 543 | unsigned int m_driverIndex; |
| @@ -491,6 +545,8 @@ namespace ADDON | |||
| 491 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection; | 545 | JOYSTICK_DRIVER_SEMIAXIS_DIRECTION m_semiAxisDirection; |
| 492 | }; | 546 | }; |
| 493 | 547 | ||
| 548 | typedef PeripheralVector<DriverPrimitive, JOYSTICK_DRIVER_PRIMITIVE> DriverPrimitives; | ||
| 549 | |||
| 494 | /*! | 550 | /*! |
| 495 | * ADDON::JoystickFeature | 551 | * ADDON::JoystickFeature |
| 496 | * | 552 | * |
| @@ -499,44 +555,20 @@ namespace ADDON | |||
| 499 | * 1) scalar[1] | 555 | * 1) scalar[1] |
| 500 | * 2) analog stick | 556 | * 2) analog stick |
| 501 | * 3) accelerometer | 557 | * 3) accelerometer |
| 558 | * 4) motor | ||
| 502 | * | 559 | * |
| 503 | * [1] All three driver primitives (buttons, hats and axes) have a state that | 560 | * [1] All three driver primitives (buttons, hats and axes) have a state that |
| 504 | * can be represented using a single scalar value. For this reason, | 561 | * can be represented using a single scalar value. For this reason, |
| 505 | * features that map to a single primitive are called "scalar features". | 562 | * features that map to a single primitive are called "scalar features". |
| 506 | * | ||
| 507 | * Features can be mapped to a variable number of driver primitives. The names | ||
| 508 | * of the primitives for each feature are: | ||
| 509 | * | ||
| 510 | * Scalar feature: | ||
| 511 | * - primitive | ||
| 512 | * | ||
| 513 | * Analog stick: | ||
| 514 | * - up | ||
| 515 | * - down | ||
| 516 | * - right | ||
| 517 | * - left | ||
| 518 | * | ||
| 519 | * Accelerometer: | ||
| 520 | * - positive X | ||
| 521 | * - positive Y | ||
| 522 | * - positive Z | ||
| 523 | */ | 563 | */ |
| 524 | class JoystickFeature | 564 | class JoystickFeature |
| 525 | { | 565 | { |
| 526 | public: | 566 | public: |
| 527 | const unsigned int MAX_PRIMITIVES = 4; | 567 | JoystickFeature(const std::string& name = "", JOYSTICK_FEATURE_TYPE type = JOYSTICK_FEATURE_TYPE_UNKNOWN) : |
| 528 | |||
| 529 | JoystickFeature(void) : | ||
| 530 | m_type(JOYSTICK_FEATURE_TYPE_UNKNOWN) | ||
| 531 | { | ||
| 532 | m_primitives.resize(MAX_PRIMITIVES); | ||
| 533 | } | ||
| 534 | |||
| 535 | JoystickFeature(const std::string& name, JOYSTICK_FEATURE_TYPE type) : | ||
| 536 | m_name(name), | 568 | m_name(name), |
| 537 | m_type(type) | 569 | m_type(type), |
| 570 | m_primitives() | ||
| 538 | { | 571 | { |
| 539 | m_primitives.resize(MAX_PRIMITIVES); | ||
| 540 | } | 572 | } |
| 541 | 573 | ||
| 542 | JoystickFeature(const JoystickFeature& other) | 574 | JoystickFeature(const JoystickFeature& other) |
| @@ -548,26 +580,8 @@ namespace ADDON | |||
| 548 | m_name(feature.name ? feature.name : ""), | 580 | m_name(feature.name ? feature.name : ""), |
| 549 | m_type(feature.type) | 581 | m_type(feature.type) |
| 550 | { | 582 | { |
| 551 | m_primitives.resize(MAX_PRIMITIVES); | 583 | for (unsigned int i = 0; i < JOYSTICK_PRIMITIVE_MAX; i++) |
| 552 | switch (m_type) | 584 | m_primitives[i] = feature.primitives[i]; |
| 553 | { | ||
| 554 | case JOYSTICK_FEATURE_TYPE_SCALAR: | ||
| 555 | SetPrimitive(feature.scalar.primitive); | ||
| 556 | break; | ||
| 557 | case JOYSTICK_FEATURE_TYPE_ANALOG_STICK: | ||
| 558 | SetUp(feature.analog_stick.up); | ||
| 559 | SetDown(feature.analog_stick.down); | ||
| 560 | SetRight(feature.analog_stick.right); | ||
| 561 | SetLeft(feature.analog_stick.left); | ||
| 562 | break; | ||
| 563 | case JOYSTICK_FEATURE_TYPE_ACCELEROMETER: | ||
| 564 | SetPositiveX(feature.accelerometer.positive_x); | ||
| 565 | SetPositiveY(feature.accelerometer.positive_y); | ||
| 566 | SetPositiveZ(feature.accelerometer.positive_z); | ||
| 567 | break; | ||
| 568 | default: | ||
| 569 | break; | ||
| 570 | } | ||
| 571 | } | 585 | } |
| 572 | 586 | ||
| 573 | JoystickFeature& operator=(const JoystickFeature& rhs) | 587 | JoystickFeature& operator=(const JoystickFeature& rhs) |
| @@ -590,55 +604,25 @@ namespace ADDON | |||
| 590 | 604 | ||
| 591 | const std::string& Name(void) const { return m_name; } | 605 | const std::string& Name(void) const { return m_name; } |
| 592 | JOYSTICK_FEATURE_TYPE Type(void) const { return m_type; } | 606 | JOYSTICK_FEATURE_TYPE Type(void) const { return m_type; } |
| 607 | bool IsValid() const { return m_type != JOYSTICK_FEATURE_TYPE_UNKNOWN; } | ||
| 593 | 608 | ||
| 594 | void SetName(const std::string& name) { m_name = name; } | 609 | void SetName(const std::string& name) { m_name = name; } |
| 595 | void SetType(JOYSTICK_FEATURE_TYPE type) { m_type = type; } | 610 | void SetType(JOYSTICK_FEATURE_TYPE type) { m_type = type; } |
| 611 | void SetInvalid(void) { m_type = JOYSTICK_FEATURE_TYPE_UNKNOWN; } | ||
| 612 | |||
| 613 | const DriverPrimitive& Primitive(JOYSTICK_FEATURE_PRIMITIVE which) const { return m_primitives[which]; } | ||
| 614 | void SetPrimitive(JOYSTICK_FEATURE_PRIMITIVE which, const DriverPrimitive& primitive) { m_primitives[which] = primitive; } | ||
| 596 | 615 | ||
| 597 | // Scalar methods | 616 | std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX>& Primitives() { return m_primitives; } |
| 598 | const DriverPrimitive& Primitive(void) const { return m_primitives[0]; } | 617 | const std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX>& Primitives() const { return m_primitives; } |
| 599 | void SetPrimitive(const DriverPrimitive& primitive) { m_primitives[0] = primitive; } | ||
| 600 | |||
| 601 | // Analog stick methods | ||
| 602 | const DriverPrimitive& Up(void) const { return m_primitives[0]; } | ||
| 603 | const DriverPrimitive& Down(void) const { return m_primitives[1]; } | ||
| 604 | const DriverPrimitive& Right(void) const { return m_primitives[2]; } | ||
| 605 | const DriverPrimitive& Left(void) const { return m_primitives[3]; } | ||
| 606 | void SetUp(const DriverPrimitive& primitive) { m_primitives[0] = primitive; } | ||
| 607 | void SetDown(const DriverPrimitive& primitive) { m_primitives[1] = primitive; } | ||
| 608 | void SetRight(const DriverPrimitive& primitive) { m_primitives[2] = primitive; } | ||
| 609 | void SetLeft(const DriverPrimitive& primitive) { m_primitives[3] = primitive; } | ||
| 610 | |||
| 611 | // Accelerometer methods | ||
| 612 | const DriverPrimitive& PositiveX(void) const { return m_primitives[0]; } | ||
| 613 | const DriverPrimitive& PositiveY(void) const { return m_primitives[1]; } | ||
| 614 | const DriverPrimitive& PositiveZ(void) const { return m_primitives[2]; } | ||
| 615 | void SetPositiveX(const DriverPrimitive& primitive) { m_primitives[0] = primitive; } | ||
| 616 | void SetPositiveY(const DriverPrimitive& primitive) { m_primitives[1] = primitive; } | ||
| 617 | void SetPositiveZ(const DriverPrimitive& primitive) { m_primitives[2] = primitive; } | ||
| 618 | 618 | ||
| 619 | void ToStruct(JOYSTICK_FEATURE& feature) const | 619 | void ToStruct(JOYSTICK_FEATURE& feature) const |
| 620 | { | 620 | { |
| 621 | feature.name = new char[m_name.length() + 1]; | 621 | feature.name = new char[m_name.length() + 1]; |
| 622 | feature.type = m_type; | 622 | feature.type = m_type; |
| 623 | switch (m_type) | 623 | for (unsigned int i = 0; i < JOYSTICK_PRIMITIVE_MAX; i++) |
| 624 | { | 624 | m_primitives[i].ToStruct(feature.primitives[i]); |
| 625 | case JOYSTICK_FEATURE_TYPE_SCALAR: | 625 | |
| 626 | Primitive().ToStruct(feature.scalar.primitive); | ||
| 627 | break; | ||
| 628 | case JOYSTICK_FEATURE_TYPE_ANALOG_STICK: | ||
| 629 | Up().ToStruct(feature.analog_stick.up); | ||
| 630 | Down().ToStruct(feature.analog_stick.down); | ||
| 631 | Right().ToStruct(feature.analog_stick.right); | ||
| 632 | Left().ToStruct(feature.analog_stick.left); | ||
| 633 | break; | ||
| 634 | case JOYSTICK_FEATURE_TYPE_ACCELEROMETER: | ||
| 635 | PositiveX().ToStruct(feature.accelerometer.positive_x); | ||
| 636 | PositiveY().ToStruct(feature.accelerometer.positive_y); | ||
| 637 | PositiveZ().ToStruct(feature.accelerometer.positive_z); | ||
| 638 | break; | ||
| 639 | default: | ||
| 640 | break; | ||
| 641 | } | ||
| 642 | std::strcpy(feature.name, m_name.c_str()); | 626 | std::strcpy(feature.name, m_name.c_str()); |
| 643 | } | 627 | } |
| 644 | 628 | ||
| @@ -650,7 +634,7 @@ namespace ADDON | |||
| 650 | private: | 634 | private: |
| 651 | std::string m_name; | 635 | std::string m_name; |
| 652 | JOYSTICK_FEATURE_TYPE m_type; | 636 | JOYSTICK_FEATURE_TYPE m_type; |
| 653 | std::vector<DriverPrimitive> m_primitives; | 637 | std::array<DriverPrimitive, JOYSTICK_PRIMITIVE_MAX> m_primitives; |
| 654 | }; | 638 | }; |
| 655 | 639 | ||
| 656 | typedef PeripheralVector<JoystickFeature, JOYSTICK_FEATURE> JoystickFeatures; | 640 | typedef PeripheralVector<JoystickFeature, JOYSTICK_FEATURE> JoystickFeatures; |
