xsm3.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. xsm3.h - part of libxsm3
  3. Copyright (C) 2022 InvoxiPlayGames
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with this library; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  15. */
  16. #ifndef XSM3_H_
  17. #define XSM3_H_
  18. #include <stdint.h>
  19. #include <stddef.h>
  20. #include <stdbool.h>
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. // Identification data taken from an official wired controller. (Serial number is static.)
  25. extern uint8_t xsm3_id_data_ms_controller[0x1D];
  26. // The response data from the previously completed challenge.
  27. extern uint8_t xsm3_challenge_response[0x30];
  28. // The console ID fetched from the console after request 0x82.
  29. extern uint8_t xsm3_console_id[0x8];
  30. // Clears the state of the XSM3 internal variables.
  31. void xsm3_initialise_state();
  32. // Sets the identification data to use.
  33. void xsm3_set_identification_data(const uint8_t id_data[0x1D]);
  34. // Initialises the XSM3 state using information from the challenge init packet (0x82) and places a response in xsm3_challenge_response.
  35. void xsm3_do_challenge_init(uint8_t challenge_packet[0x22]);
  36. // Completes a verify challenge passed from request 0x87 and places the response data in xsm3_challenge_response.
  37. void xsm3_do_challenge_verify(uint8_t challenge_packet[0x16]);
  38. void xsm3_set_vid_pid(const uint8_t serial[0x0C], uint16_t vid, uint16_t pid);
  39. #ifdef __cplusplus
  40. }
  41. #endif
  42. #endif // XSM3_H_