-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d3998fb
commit 6fb6f78
Showing
29 changed files
with
1,968 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# | ||
# Copyright (C) 2021 HandsomeMod Project | ||
# | ||
# GC (Gadget Controller) is free software; you can redistribute it and/or | ||
# modify it under the terms of the GNU Lesser General Public | ||
# License as published by the Free Software Foundation; either | ||
# version 2.1 of the License, or (at your option) any later version. | ||
# | ||
cmake_minimum_required(VERSION 3.10) | ||
project(GC C) | ||
|
||
set(CMAKE_C_STANDARD 11)#C11 | ||
set(CMAKE_CXX_STANDARD 17)#C17 | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_INSTALL_PREFIX /usr) | ||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) | ||
#file(GLOB_RECURSE INCLUDES "gc_*.h") | ||
file(GLOB_RECURSE SOURCES "main.c" "gc_*.c") | ||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) | ||
|
||
|
||
# Core Dependency | ||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(LIBUSBGX REQUIRED libusbgx) | ||
list(APPEND EXTRA_LIBS ${LIBUSBGX_LIBRARIES}) | ||
list(APPEND EXTRA_INCLUDES ${LIBUSBGX_INCLUDE_DIRS}) | ||
|
||
# generated headers | ||
configure_file ( | ||
"gc_config.h.in" | ||
"${PROJECT_SOURCE_DIR}/gc_config.h" | ||
) | ||
|
||
include_directories(${EXTRA_INCLUDES} ${INCLUDES}) | ||
add_executable(gc ${SOURCES}) | ||
target_link_libraries(gc PRIVATE ${EXTRA_LIBS}) | ||
install(FILES ${PROJECT_SOURCE_DIR}/bin/gc DESTINATION bin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Copyright (C) 2021-2022 HandsomeMod Project | ||
* | ||
* Handsomeyingyan <[email protected]> | ||
* | ||
* GC(Gadget Controller) is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
*/ | ||
|
||
#include "gc_acm.h" | ||
|
||
int gc_acm_create(int argc,char *argv[],gc_generic_info info) | ||
{ | ||
usbg_gadget *gadget = gc_init(info); | ||
|
||
if(gadget == NULL) | ||
return GC_FAILED; | ||
|
||
usbg_function *f_acm; | ||
int usbg_ret; | ||
|
||
char *id = gc_generate_id(USBG_F_ACM); | ||
|
||
if(id == NULL) | ||
return GC_FAILED; | ||
|
||
usbg_ret = usbg_create_function(gadget,USBG_F_ACM,id,NULL,&f_acm); | ||
if(usbg_ret != USBG_SUCCESS){ | ||
fprintf(stderr,"failed to create acm function! (maybe kernel module not loaded?) \n"); | ||
gc_clean(); | ||
return GC_FAILED; | ||
} | ||
|
||
/* for now we only create one config file */ | ||
usbg_config *config = gc_get_config(gadget); | ||
|
||
usbg_ret = usbg_add_config_function(config,id,f_acm); | ||
if(usbg_ret != USBG_SUCCESS){ | ||
fprintf(stderr,"failed to bind ecm config to function! \n"); | ||
gc_clean(); | ||
return GC_FAILED; | ||
} | ||
|
||
usbg_ret = usbg_enable_gadget(gadget, DEFAULT_UDC); | ||
if(usbg_ret != USBG_SUCCESS){ | ||
fprintf(stderr,"failed to enable gadget! \n"); | ||
gc_clean(); | ||
return GC_FAILED; | ||
} | ||
|
||
gc_clean(); | ||
return GC_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Copyright (C) 2021-2022 HandsomeMod Project | ||
* | ||
* Handsomeyingyan <[email protected]> | ||
* | ||
* GC(Gadget Controller) is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
*/ | ||
|
||
#ifndef GC_ACM_H | ||
#define GC_ACM_H | ||
|
||
#include "gc_generic.h" | ||
|
||
int gc_acm_create(int argc,char *argv[],gc_generic_info info); | ||
|
||
#endif //GC_ACM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Copyright (C) 2021-2022 HandsomeMod Project | ||
* | ||
* Handsomeyingyan <[email protected]> | ||
* | ||
* GC(Gadget Controller) is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
*/ | ||
|
||
#ifndef GC_CONFIG_H | ||
#define GC_CONFIG_H | ||
|
||
/* #undef SERIAL_NUMBER */ | ||
/* #undef MANUFACTURER */ | ||
/* #undef PRODUCT */ | ||
/* #undef ID_VENDOR */ | ||
/* #undef ID_PRODUCT */ | ||
|
||
#ifndef SERIAL_NUMBER | ||
#define SERIAL_NUMBER "0123456789" | ||
#endif | ||
|
||
#ifndef MANUFACTURER | ||
#define MANUFACTURER "HandsomeTech" | ||
#endif | ||
|
||
#ifndef PRODUCT | ||
#define PRODUCT "HandsomeMod Device" | ||
#endif | ||
|
||
#ifndef ID_VENDOR | ||
#define ID_VENDOR "0x18d1" | ||
#endif | ||
|
||
#ifndef ID_PRODUCT | ||
#define ID_PRODUCT "0xd001" | ||
#endif | ||
|
||
#endif //GC_CONFIG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Copyright (C) 2021-2022 HandsomeMod Project | ||
* | ||
* Handsomeyingyan <[email protected]> | ||
* | ||
* GC(Gadget Controller) is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
*/ | ||
|
||
#ifndef GC_CONFIG_H | ||
#define GC_CONFIG_H | ||
|
||
#cmakedefine SERIAL_NUMBER @SERIAL_NUMBER@ | ||
#cmakedefine MANUFACTURER @MANUFACTURER@ | ||
#cmakedefine PRODUCT @PRODUCT@ | ||
#cmakedefine ID_VENDOR @ID_VENDOR@ | ||
#cmakedefine ID_PRODUCT @ID_PRODUCT@ | ||
|
||
#ifndef SERIAL_NUMBER | ||
#define SERIAL_NUMBER "0123456789" | ||
#endif | ||
|
||
#ifndef MANUFACTURER | ||
#define MANUFACTURER "HandsomeTech" | ||
#endif | ||
|
||
#ifndef PRODUCT | ||
#define PRODUCT "HandsomeMod Device" | ||
#endif | ||
|
||
#ifndef ID_VENDOR | ||
#define ID_VENDOR "0x18d1" | ||
#endif | ||
|
||
#ifndef ID_PRODUCT | ||
#define ID_PRODUCT "0xd001" | ||
#endif | ||
|
||
#endif //GC_CONFIG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Copyright (C) 2021-2022 HandsomeMod Project | ||
* | ||
* Handsomeyingyan <[email protected]> | ||
* | ||
* GC(Gadget Controller) is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
*/ | ||
|
||
#include "gc_ecm.h" | ||
|
||
int gc_ecm_create(int argc,char *argv[],gc_generic_info info) | ||
{ | ||
usbg_gadget *gadget = gc_init(info); | ||
|
||
if(gadget == NULL) | ||
return GC_FAILED; | ||
|
||
usbg_function *f_ecm; | ||
int usbg_ret; | ||
|
||
char *id = gc_generate_id(USBG_F_ECM); | ||
|
||
if(id == NULL) | ||
return GC_FAILED; | ||
|
||
usbg_ret = usbg_create_function(gadget,USBG_F_ECM,id,NULL,&f_ecm); | ||
if(usbg_ret != USBG_SUCCESS){ | ||
fprintf(stderr,"failed to create ecm function! (maybe kernel module not loaded?) \n"); | ||
gc_clean(); | ||
return GC_FAILED; | ||
} | ||
|
||
/* for now we only create one config file */ | ||
usbg_config *config = gc_get_config(gadget); | ||
|
||
usbg_ret = usbg_add_config_function(config,id,f_ecm); | ||
if(usbg_ret != USBG_SUCCESS){ | ||
fprintf(stderr,"failed to bind ecm config to function! \n"); | ||
gc_clean(); | ||
return GC_FAILED; | ||
} | ||
|
||
usbg_ret = usbg_enable_gadget(gadget, DEFAULT_UDC); | ||
if(usbg_ret != USBG_SUCCESS){ | ||
fprintf(stderr,"failed to enable gadget! \n"); | ||
gc_clean(); | ||
return GC_FAILED; | ||
} | ||
|
||
gc_clean(); | ||
return GC_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Copyright (C) 2021-2022 HandsomeMod Project | ||
* | ||
* Handsomeyingyan <[email protected]> | ||
* | ||
* GC(Gadget Controller) is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
*/ | ||
|
||
#ifndef GC_ECM_H | ||
#define GC_ECM_H | ||
|
||
#include "gc_generic.h" | ||
|
||
int gc_ecm_create(int argc,char *argv[],gc_generic_info info); | ||
|
||
#endif //GC_ECM_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Copyright (C) 2021-2022 HandsomeMod Project | ||
* | ||
* Handsomeyingyan <[email protected]> | ||
* | ||
* GC(Gadget Controller) is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
*/ | ||
|
||
|
||
#include "gc_ffs.h" | ||
|
||
int gc_ffs_create(int argc,char *argv[],gc_generic_info info) | ||
{ | ||
usbg_gadget *gadget = gc_init(info); | ||
|
||
if(gadget == NULL) | ||
return GC_FAILED; | ||
|
||
usbg_function *f_ffs; | ||
int usbg_ret; | ||
|
||
char *id = gc_generate_id(USBG_F_FFS); | ||
|
||
if(id == NULL) | ||
return GC_FAILED; | ||
|
||
usbg_ret = usbg_create_function(gadget,USBG_F_FFS,id,NULL,&f_ffs); | ||
if(usbg_ret != USBG_SUCCESS){ | ||
fprintf(stderr,"failed to create ffs function! (maybe kernel module not loaded?) \n"); | ||
gc_clean(); | ||
return GC_FAILED; | ||
} | ||
|
||
/* for now we only create one config file */ | ||
usbg_config *config = gc_get_config(gadget); | ||
|
||
|
||
usbg_ret = usbg_add_config_function(config,id,f_ffs); | ||
if(usbg_ret != USBG_SUCCESS){ | ||
fprintf(stderr,"failed to bind ffs config to function! \n"); | ||
gc_clean(); | ||
return GC_FAILED; | ||
} | ||
|
||
usbg_ret = usbg_enable_gadget(gadget, DEFAULT_UDC); | ||
if(usbg_ret != USBG_SUCCESS){ | ||
fprintf(stderr,"failed to enable gadget! \n"); | ||
gc_clean(); | ||
return GC_FAILED; | ||
} | ||
|
||
gc_clean(); | ||
return GC_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* Copyright (C) 2021-2022 HandsomeMod Project | ||
* | ||
* Handsomeyingyan <[email protected]> | ||
* | ||
* GC(Gadget Controller) is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* | ||
*/ | ||
|
||
|
||
#ifndef GC_FFS_H | ||
#define GC_FFS_H | ||
|
||
#include "gc_generic.h" | ||
|
||
int gc_ffs_create(int argc,char *argv[],gc_generic_info info); | ||
|
||
#endif //GC_FFS_H |
Oops, something went wrong.