Browse Source

Show the firmware version in testgamecontroller

Sam Lantinga 3 years ago
parent
commit
30cf26e089
1 changed files with 8 additions and 0 deletions
  1. 8 0
      test/testgamecontroller.c

+ 8 - 0
test/testgamecontroller.c

@@ -133,6 +133,7 @@ static void AddController(int device_index, SDL_bool verbose)
     SDL_JoystickID controller_id = SDL_JoystickGetDeviceInstanceID(device_index);
     SDL_JoystickID controller_id = SDL_JoystickGetDeviceInstanceID(device_index);
     SDL_GameController *controller;
     SDL_GameController *controller;
     SDL_GameController **controllers;
     SDL_GameController **controllers;
+    Uint16 firmware_version;
 
 
     controller_id = SDL_JoystickGetDeviceInstanceID(device_index);
     controller_id = SDL_JoystickGetDeviceInstanceID(device_index);
     if (controller_id < 0) {
     if (controller_id < 0) {
@@ -168,6 +169,13 @@ static void AddController(int device_index, SDL_bool verbose)
         SDL_Log("Opened game controller %s%s%s\n", name, path ? ", " : "", path ? path : "");
         SDL_Log("Opened game controller %s%s%s\n", name, path ? ", " : "", path ? path : "");
     }
     }
 
 
+    firmware_version = SDL_GameControllerGetFirmwareVersion(gamecontroller);
+    if (firmware_version) {
+        if (verbose) {
+            SDL_Log("Firmware version: 0x%x (%d)\n", firmware_version, firmware_version);
+        }
+    }
+
     if (SDL_GameControllerHasSensor(gamecontroller, SDL_SENSOR_ACCEL)) {
     if (SDL_GameControllerHasSensor(gamecontroller, SDL_SENSOR_ACCEL)) {
         if (verbose) {
         if (verbose) {
             SDL_Log("Enabling accelerometer at %.2f Hz\n", SDL_GameControllerGetSensorDataRate(gamecontroller, SDL_SENSOR_ACCEL));
             SDL_Log("Enabling accelerometer at %.2f Hz\n", SDL_GameControllerGetSensorDataRate(gamecontroller, SDL_SENSOR_ACCEL));