Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.7 KiB

  1. //===== Copyright 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose: Access to the cuter features of the PS3
  4. // devkit, like the front LEDs.
  5. //
  6. // $NoKeywords: $
  7. //
  8. //===========================================================================//
  9. #ifndef PS3_FRONTPANELLED_H
  10. #define PS3_FRONTPANELLED_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. /// encapsulates the DECR-1000's front panel LEDs, dip switches, and foot pedal
  15. /// the system only lets you set a subset of the LEDs; there are FOUR LIGHTS.
  16. /// (really. you can set LEDs 0..3)
  17. namespace CPS3FrontPanelLED
  18. {
  19. // sets the on/off state of the LEDs on the front panel.
  20. // you simply specify them as a bitmask -- ie, LED0 | LED 2 would light the zeroth and twoth LED and darken the other two.
  21. inline bool SetLEDs( uint64 lights );
  22. // you can use this to eg set LED1 while leaving the rest undisturbed. a 1 bit in the mask means the corresponding
  23. // bit in value will be written to the hardware.
  24. inline bool SetLEDsMasked( uint64 mask, uint64 lights );
  25. // gets the on/off state of the LEDs on the front panel
  26. inline uint64 GetLEDs();
  27. // gets the on/off state of the switches on the front panel
  28. inline uint64 GetSwitches();
  29. // you will notice there is no function to set the state of the DIP switches from software.
  30. // you don't actually need to use these, but just to be obvious:
  31. enum eLEDIndex_t
  32. {
  33. kPS3LED0 = 1,
  34. kPS3LED1 = 2,
  35. kPS3LED2 = 4,
  36. kPS3LED3 = 8
  37. };
  38. enum eSwitchIndex_t
  39. {
  40. kPS3SWITCH0 = 1,
  41. kPS3SWITCH1 = 2,
  42. kPS3SWITCH2 = 4,
  43. kPS3SWITCH3 = 8
  44. };
  45. };
  46. #if !defined(_PS3)
  47. inline bool CPS3FrontPanelLED::SetLEDs( uint64 lights ) {return false;}
  48. inline bool CPS3FrontPanelLED::SetLEDsMasked( uint64 mask, uint64 lights ) {return false;}
  49. inline uint64 CPS3FrontPanelLED::GetLEDs() {return 0;}
  50. inline uint64 CPS3FrontPanelLED::GetSwitches() {return 0;}
  51. #else
  52. #include <sys/gpio.h>
  53. inline bool CPS3FrontPanelLED::SetLEDs( uint64 lights )
  54. {
  55. return sys_gpio_set( SYS_GPIO_LED_DEVICE_ID, SYS_GPIO_LED_USER_AVAILABLE_BITS, lights ) == CELL_OK;
  56. }
  57. inline bool CPS3FrontPanelLED::SetLEDsMasked( uint64 mask, uint64 lights )
  58. {
  59. return sys_gpio_set( SYS_GPIO_LED_DEVICE_ID, SYS_GPIO_LED_USER_AVAILABLE_BITS & mask, SYS_GPIO_LED_USER_AVAILABLE_BITS & lights ) == CELL_OK;
  60. }
  61. inline uint64 CPS3FrontPanelLED::GetLEDs()
  62. {
  63. uint64 val;
  64. if ( sys_gpio_get( SYS_GPIO_LED_DEVICE_ID, &val ) == CELL_OK )
  65. {
  66. return val & SYS_GPIO_LED_USER_AVAILABLE_BITS;
  67. }
  68. else
  69. {
  70. return 0;
  71. }
  72. }
  73. inline uint64 CPS3FrontPanelLED::GetSwitches()
  74. {
  75. uint64 val;
  76. if ( sys_gpio_get( SYS_GPIO_DIP_SWITCH_DEVICE_ID, &val ) == CELL_OK )
  77. {
  78. return val & SYS_GPIO_DIP_SWITCH_USER_AVAILABLE_BITS;
  79. }
  80. else
  81. {
  82. return 0;
  83. }
  84. }
  85. #endif
  86. #endif // PS3_FRONTPANELLED_H