Willy-JL 1 rok temu
rodzic
commit
67af85443f

+ 8 - 13
mtp/application.fam

@@ -6,20 +6,15 @@ App(
     name="MTP",  # Displayed in UI
     apptype=FlipperAppType.EXTERNAL,
     entry_point="entrypoint",
-    stack_size=2 * 1024, # size of memory stack it will allocate
-    
+    stack_size=2 * 1024,  # size of memory stack it will allocate
     # source code settings
-    sources=[            # Due to limitation of the fbt,
-      "src/*.c*",        # you need to specify nested directories
-      "src/*/*.c*",      # manually since it doesn't support
-      "src/*/*/*.c*"     # recurse globbing such as "src/**/*.c*"
-    ], 
-
-    # Dependencies
-    requires=[
-
+    sources=[  # Due to limitation of the fbt,
+        "src/*.c*",  # you need to specify nested directories
+        "src/*/*.c*",  # manually since it doesn't support
+        "src/*/*/*.c*",  # recurse globbing such as "src/**/*.c*"
     ],
-
+    # Dependencies
+    requires=[],
     # FAP Settings
     fap_category="USB",
     fap_description="Use Flipper Zero as a MTP device.",
@@ -28,5 +23,5 @@ App(
     fap_author="Alex4386",
     fap_weburl="https://github.com/Alex4386/f0-mtp",
     fap_icon_assets="icons",  # Image assets to compile for this application
-                              # available as {appid}_icons.h in the source code
+    # available as {appid}_icons.h in the source code
 )

+ 1 - 1
mtp/src/scenes/mtp/mtp.c

@@ -1244,4 +1244,4 @@ bool DeleteObject(AppMTP* mtp, uint32_t handle) {
     }
 
     return false;
-}
+}

+ 50 - 50
mtp/src/scenes/mtp/mtp.h

@@ -1,83 +1,83 @@
 #pragma once
 
 // MTP Device Serial
-#define MTP_DEVICE_SERIAL "HakureiReimu"
+#define MTP_DEVICE_SERIAL  "HakureiReimu"
 #define MTP_DEVICE_VERSION "1.0"
 
-#define MTP_STANDARD_VERSION 100
-#define MTP_VENDOR_EXTENSION_ID 0x6
+#define MTP_STANDARD_VERSION         100
+#define MTP_VENDOR_EXTENSION_ID      0x6
 #define MTP_VENDOR_EXTENSION_VERSION 100
-#define MTP_FUNCTIONAL_MODE 0x0
+#define MTP_FUNCTIONAL_MODE          0x0
 
-#define MTP_TYPE_COMMAND 0x1
-#define MTP_TYPE_DATA 0x2
+#define MTP_TYPE_COMMAND  0x1
+#define MTP_TYPE_DATA     0x2
 #define MTP_TYPE_RESPONSE 0x3
 
-#define MTP_REQ_CANCEL 0x64
+#define MTP_REQ_CANCEL             0x64
 #define MTP_REQ_GET_EXT_EVENT_DATA 0x65
-#define MTP_REQ_RESET 0x66
-#define MTP_REQ_GET_DEVICE_STATUS 0x67
+#define MTP_REQ_RESET              0x66
+#define MTP_REQ_GET_DEVICE_STATUS  0x67
 
 // MTP Operation Codes
-#define MTP_OP_GET_DEVICE_INFO 0x1001
-#define MTP_OP_OPEN_SESSION 0x1002
-#define MTP_OP_CLOSE_SESSION 0x1003
-#define MTP_OP_GET_STORAGE_IDS 0x1004
-#define MTP_OP_GET_STORAGE_INFO 0x1005
-#define MTP_OP_GET_NUM_OBJECTS 0x1006
+#define MTP_OP_GET_DEVICE_INFO    0x1001
+#define MTP_OP_OPEN_SESSION       0x1002
+#define MTP_OP_CLOSE_SESSION      0x1003
+#define MTP_OP_GET_STORAGE_IDS    0x1004
+#define MTP_OP_GET_STORAGE_INFO   0x1005
+#define MTP_OP_GET_NUM_OBJECTS    0x1006
 #define MTP_OP_GET_OBJECT_HANDLES 0x1007
-#define MTP_OP_GET_OBJECT_INFO 0x1008
-#define MTP_OP_GET_OBJECT 0x1009
+#define MTP_OP_GET_OBJECT_INFO    0x1008
+#define MTP_OP_GET_OBJECT         0x1009
 
-#define MTP_OP_DELETE_OBJECT 0x100B
-#define MTP_OP_SEND_OBJECT_INFO 0x100C
-#define MTP_OP_SEND_OBJECT 0x100D
-#define MTP_OP_GET_DEVICE_PROP_DESC 0x1014
+#define MTP_OP_DELETE_OBJECT         0x100B
+#define MTP_OP_SEND_OBJECT_INFO      0x100C
+#define MTP_OP_SEND_OBJECT           0x100D
+#define MTP_OP_GET_DEVICE_PROP_DESC  0x1014
 #define MTP_OP_GET_DEVICE_PROP_VALUE 0x1015
 
 #define MTP_OP_GET_OBJECT_PROPS_SUPPORTED 0x9801
-#define MTP_OP_GET_OBJECT_PROP_DESC 0x9802
-#define MTP_OP_GET_OBJECT_PROP_VALUE 0x9803
-#define MTP_OP_SET_OBJECT_PROP_VALUE 0x9804
+#define MTP_OP_GET_OBJECT_PROP_DESC       0x9802
+#define MTP_OP_GET_OBJECT_PROP_VALUE      0x9803
+#define MTP_OP_SET_OBJECT_PROP_VALUE      0x9804
 
 // MTP Object Props
-#define MTP_PROP_STORAGE_ID 0xDC01
-#define MTP_PROP_OBJECT_FORMAT 0xDC02
+#define MTP_PROP_STORAGE_ID       0xDC01
+#define MTP_PROP_OBJECT_FORMAT    0xDC02
 #define MTP_PROP_OBJECT_FILE_NAME 0xDC07
 
 // MTP Response Codes
-#define MTP_RESP_UNKNOWN 0x2000
-#define MTP_RESP_OK 0x2001
-#define MTP_RESP_GENERAL_ERROR 0x2002
-#define MTP_RESP_SESSION_NOT_OPEN 0x2003
-#define MTP_RESP_INVALID_TRANSACTION_ID 0x2004
-#define MTP_RESP_OPERATION_NOT_SUPPORTED 0x2005
-#define MTP_RESP_PARAMETER_NOT_SUPPORTED 0x2006
-#define MTP_RESP_INCOMPLETE_TRANSFER 0x2007
-#define MTP_RESP_INVALID_STORAGE_ID 0x2008
-#define MTP_RESP_INVALID_OBJECT_HANDLE 0x2009
-#define MTP_RESP_DEVICE_PROP_NOT_SUPPORTED 0x200A
-#define MTP_RESP_STORE_FULL 0x200C
-#define MTP_RESP_OBJECT_WRITE_PROTECTED 0x200D
-#define MTP_RESP_STORE_READ_ONLY 0x200E
-#define MTP_RESP_ACCESS_DENIED 0x200F
-#define MTP_RESP_NO_THUMBNAIL_PRESENT 0x2010
-#define MTP_RESP_SELF_TEST_FAILED 0x2011
-#define MTP_RESP_PARTIAL_DELETION 0x2012
-#define MTP_RESP_STORE_NOT_AVAILABLE 0x2013
+#define MTP_RESP_UNKNOWN                    0x2000
+#define MTP_RESP_OK                         0x2001
+#define MTP_RESP_GENERAL_ERROR              0x2002
+#define MTP_RESP_SESSION_NOT_OPEN           0x2003
+#define MTP_RESP_INVALID_TRANSACTION_ID     0x2004
+#define MTP_RESP_OPERATION_NOT_SUPPORTED    0x2005
+#define MTP_RESP_PARAMETER_NOT_SUPPORTED    0x2006
+#define MTP_RESP_INCOMPLETE_TRANSFER        0x2007
+#define MTP_RESP_INVALID_STORAGE_ID         0x2008
+#define MTP_RESP_INVALID_OBJECT_HANDLE      0x2009
+#define MTP_RESP_DEVICE_PROP_NOT_SUPPORTED  0x200A
+#define MTP_RESP_STORE_FULL                 0x200C
+#define MTP_RESP_OBJECT_WRITE_PROTECTED     0x200D
+#define MTP_RESP_STORE_READ_ONLY            0x200E
+#define MTP_RESP_ACCESS_DENIED              0x200F
+#define MTP_RESP_NO_THUMBNAIL_PRESENT       0x2010
+#define MTP_RESP_SELF_TEST_FAILED           0x2011
+#define MTP_RESP_PARTIAL_DELETION           0x2012
+#define MTP_RESP_STORE_NOT_AVAILABLE        0x2013
 #define MTP_RESP_SPEC_BY_FORMAT_UNSUPPORTED 0x2014
-#define MTP_RESP_NO_VALID_OBJECT_INFO 0x2015
-#define MTP_RESP_INVALID_CODE_FORMAT 0x2016
-#define MTP_RESP_UNKNOWN_VENDOR_CODE 0x2017
+#define MTP_RESP_NO_VALID_OBJECT_INFO       0x2015
+#define MTP_RESP_INVALID_CODE_FORMAT        0x2016
+#define MTP_RESP_UNKNOWN_VENDOR_CODE        0x2017
 #define MTP_RESP_CAPTURE_ALREADY_TERMINATED 0x2018
-#define MTP_RESP_DEVICE_BUSY 0x2019
+#define MTP_RESP_DEVICE_BUSY                0x2019
 
 // Storage IDs
 #define INTERNAL_STORAGE_ID 0x00010001
 #define EXTERNAL_STORAGE_ID 0x00020001
 
 // MTP Playback formats
-#define MTP_FORMAT_UNDEFINED 0x3000
+#define MTP_FORMAT_UNDEFINED   0x3000
 #define MTP_FORMAT_ASSOCIATION 0x3001
 
 typedef struct {

+ 1 - 1
mtp/src/scenes/mtp/usb.h

@@ -18,4 +18,4 @@ enum UsbDevDescStr {
 void usb_mtp_init(usbd_device* dev, FuriHalUsbInterface* intf, void* ctx);
 void usb_mtp_deinit(usbd_device* dev);
 void usb_mtp_wakeup(usbd_device* dev);
-void usb_mtp_suspend(usbd_device* dev);
+void usb_mtp_suspend(usbd_device* dev);

+ 7 - 7
mtp/src/scenes/mtp/usb_desc.h

@@ -4,21 +4,21 @@
 #include <furi_hal_usb.h>
 
 #define USB_MANUFACTURER_STRING "Flipper Devices Inc."
-#define USB_PRODUCT_STRING "Flipper Zero Virtual MTP Device"
-#define USB_DEVICE_MODEL "Flipper Zero"
+#define USB_PRODUCT_STRING      "Flipper Zero Virtual MTP Device"
+#define USB_DEVICE_MODEL        "Flipper Zero"
 
 #define USB_SUBCLASS_MTP 0x01
-#define USB_PROTO_MTP 0x01
+#define USB_PROTO_MTP    0x01
 #define USB_CONF_VAL_MTP 1
 
 // Endpoint Addresses
-#define MTP_EP_IN_ADDR 0x81
-#define MTP_EP_OUT_ADDR 0x02
+#define MTP_EP_IN_ADDR     0x81
+#define MTP_EP_OUT_ADDR    0x02
 #define MTP_EP_INT_IN_ADDR 0x03
 
-#define MTP_MAX_PACKET_SIZE 64
+#define MTP_MAX_PACKET_SIZE    64
 #define USB_MAX_INTERRUPT_SIZE 28
-#define BCD_VERSION VERSION_BCD(1, 0, 0)
+#define BCD_VERSION            VERSION_BCD(1, 0, 0)
 
 struct MtpDescriptor {
     struct usb_config_descriptor config;