Skip to content

Commit

Permalink
add gpio default io map
Browse files Browse the repository at this point in the history
Signed-off-by: Ju, Gyeong-min <[email protected]>
  • Loading branch information
amos42 committed Jun 17, 2022
1 parent 555c442 commit 6622af8
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 40 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ Once the preliminary work has been completed, the installation work begins in ea
#### When using wget

```shell
wget https://github.com/amos42/am_joyin/releases/download/v0.3.2/am_joyin-0.3.2.deb
sudo dpkg -i am_joyin-0.3.2.deb
wget https://github.com/amos42/am_joyin/releases/download/v0.3.3/am_joyin-0.3.3.deb
sudo dpkg -i am_joyin-0.3.3.deb
```

#### When using git
Expand All @@ -160,8 +160,8 @@ git clone https://github.com/amos42/am_joyin.git

```shell
cd am_joyin
./utils/makepackage.sh 0.3.2
sudo dpkg -i build/am_joyin-0.3.2.deb
./utils/makepackage.sh 0.3.3
sudo dpkg -i build/am_joyin-0.3.3.deb
```

If you go through this process, the driver installation is primarily completed.
Expand Down Expand Up @@ -508,8 +508,8 @@ The default pinmap is compatible with mk_arcade_joystick_rpi.
* Endpoint parameters
> 1. config type - button setting type
> - default : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {gpio1, button1, value1}, {gpio2, button2, value2}, ...
> - default (default1/default2/default3) : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {gpio1, button1, value1}, {gpio2, button2, value2}, ...
- Set the primary key for 1 person

Expand Down Expand Up @@ -583,8 +583,8 @@ They are LD, CK, DT in that order.
* Endpoint parameters
> 1. config type - button setting type
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
practical use case

Expand Down Expand Up @@ -627,8 +627,8 @@ Since it is an I2C device, it needs to know the address to access it. In the cas
* Endpoint parameters
> 1. config type - button setting type
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
practical use case

Expand Down Expand Up @@ -660,8 +660,8 @@ Since it communicates with the SPI interface, in general, only two can be connec
* Endpoint parameters
> 1. config type - button setting type
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
practical use case

Expand Down Expand Up @@ -706,8 +706,8 @@ The GPIO numbers corresponding to these 5 pins must be passed as parameters resp
* Endpoint parameters
> 1. config type - button setting type
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
If you want to support more than 2p, use two 16-bit MUXs to make it 32-bit, and one of the following three methods to access each chip in turn.

Expand Down Expand Up @@ -770,8 +770,8 @@ In order to wire the analog stick to the Raspberry Pi through the actual MCP3008
* Endpoint parameters
> 1. config type - button setting type
> - default : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {adc channel1, button1, min_value1, max_value1, adc_min_value1, adc_max_value1, adc_mid_value1}, ...
> - default : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {adc channel1, button1, min_value1, max_value1, adc_min_value1, adc_max_value1, adc_mid_value1}, ...
practical use case

Expand Down Expand Up @@ -839,8 +839,8 @@ ADS1115/ADS1015 does not have a separate pin for receiving the reference voltage
* Endpoint parameters
> 1. config type - button setting type
> - default : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {adc channel1, button1, min_value1, max_value1, adc_min_value1, adc_max_value1, adc_mid_value1}, ...
> - default : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {adc channel1, button1, min_value1, max_value1, adc_min_value1, adc_max_value1, adc_mid_value1}, ...
practical use case

Expand Down Expand Up @@ -923,8 +923,8 @@ When setting the driver, carefully set the P/R of the Rotary Encoder and the DPI
* Endpoint parameters
> 1. config type - button setting type
> - default : pin_count, button_start_index, mouse_dpi (default 1000dpi)
> - custom : mouse_dpi, code_mode (0: keycode, 1:index), {button1, value1}, ...
> - default : pin_count, button_start_index, mouse_dpi (default 1000dpi)
> - custom : mouse_dpi, code_mode (0: keycode, 1:index), {button1, value1}, ...
practical use case

Expand Down
40 changes: 20 additions & 20 deletions README_kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ sudo raspi-config
#### wget 사용시

```shell
wget https://github.com/amos42/am_joyin/releases/download/v0.3.2/am_joyin-0.3.2.deb
sudo dpkg -i am_joyin-0.3.2.deb
wget https://github.com/amos42/am_joyin/releases/download/v0.3.3/am_joyin-0.3.3.deb
sudo dpkg -i am_joyin-0.3.3.deb
```

#### git 사용시
Expand All @@ -160,8 +160,8 @@ git clone https://github.com/amos42/am_joyin.git

```shell
cd am_joyin
./utils/makepackage.sh 0.3.2
sudo dpkg -i build/am_joyin-0.3.2.deb
./utils/makepackage.sh 0.3.3
sudo dpkg -i build/am_joyin-0.3.3.deb
```

이 과정까지 거치면 드라이버 설치가 1차적으로 완료된다.
Expand Down Expand Up @@ -509,8 +509,8 @@ device1="74hc165;16,20,21,24;0,default,12;1,default,12"
* 엔드포인트 파라미터
> 1. config type - 버튼 설정 타입
> - default : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {gpio1, button1, value1}, {gpio2, button2, value2}, ...
> - default (default1/default2/default3) : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {gpio1, button1, value1}, {gpio2, button2, value2}, ...
- 1인용 기본 키 설정

Expand Down Expand Up @@ -583,8 +583,8 @@ sudo modprobe am_joyin device1="gpio;;0,default1,12;0,custom,,{11,0x13C,1}"
* 엔드포인트 파라미터
> 1. config type - 버튼 설정 타입
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
실제 사용 예

Expand Down Expand Up @@ -627,8 +627,8 @@ I2C 장치이기 때문에 액세스를 위해서는 주소를 알아야 한다.
* 엔드포인트 파라미터
> 1. config type - 버튼 설정 타입
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
실제 사용 예

Expand Down Expand Up @@ -660,8 +660,8 @@ SPI 인터페이스로 통신하기에, Raspberry Pi에선 일반적으로 2개
* 엔드포인트 파라미터
> 1. config type - 버튼 설정 타입
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
실제 사용 예

Expand Down Expand Up @@ -706,8 +706,8 @@ MUX 모듈은 다음과 같은 형태로 주로 판매되고 있다.
* 엔드포인트 파라미터
> 1. config type - 버튼 설정 타입
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
> - default : pin_count, button_start_index, io_skip_count
> - custom : io_skip_count, code_mode (0: keycode, 1:index), {button1, value1}, {button2, value2}, ...
만약 2p 이상을 지원하게 하려면 16-bit MUX 2개를 사용하여 32비트로 만들고, 다음의 3가지 중 하나로 각 칩들을 차례로 액세스 하도록 하면 된다.

Expand Down Expand Up @@ -770,8 +770,8 @@ MCP3008의 Pinout은 다음과 같다.
* 엔드포인트 파라미터
> 1. config type - 버튼 설정 타입
> - default : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {adc채널1, button1, min_value1, max_value1, adc_min_value1, adc_max_value1, adc_mid_value1}, ...
> - default : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {adc채널1, button1, min_value1, max_value1, adc_min_value1, adc_max_value1, adc_mid_value1}, ...
실제 사용 예

Expand Down Expand Up @@ -839,8 +839,8 @@ ADS1115/ADS1015는 Reference 전압을 입력 받는 핀이 따로 존재하지
* 엔드포인트 파라미터
> 1. config type - 버튼 설정 타입
> - default : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {adc채널1, button1, min_value1, max_value1, adc_min_value1, adc_max_value1, adc_mid_value1}, ...
> - default : pin_count, button_start_index
> - custom : code_mode (0: keycode, 1:index), {adc채널1, button1, min_value1, max_value1, adc_min_value1, adc_max_value1, adc_mid_value1}, ...
실제 사용 예

Expand Down Expand Up @@ -923,8 +923,8 @@ Rotary Encoder의 A, B 핀은 보드의 GPIO 2번과 3번 핀에 각각 연결
* 엔드포인트 파라미터
> 1. config type - 버튼 설정 타입
> - default : pin_count, button_start_index, mouse_dpi (기본 1000dpi)
> - custom : mouse_dpi, code_mode (0: keycode, 1:index), {button1, value1}, ...
> - default : pin_count, button_start_index, mouse_dpi (기본 1000dpi)
> - custom : mouse_dpi, code_mode (0: keycode, 1:index), {button1, value1}, ...
실제 사용 예

Expand Down
25 changes: 25 additions & 0 deletions device_gpio_rpi2.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,25 @@ static const device_gpio_index_table_t default_input2_gpio_config = {
0
};

static const device_gpio_index_table_t default_input3_gpio_config = {
{
{4, ABS_Y, -DEFAULT_INPUT_ABS_MAX_VALUE},
{14, ABS_Y, DEFAULT_INPUT_ABS_MAX_VALUE},
{15, ABS_X, -DEFAULT_INPUT_ABS_MAX_VALUE},
{17, ABS_X, DEFAULT_INPUT_ABS_MAX_VALUE},
{18, BTN_START, 1},
{27, BTN_SELECT, 1},
{22, BTN_A, 1},
{23, BTN_B, 1},
{24, BTN_X, 1},
{10, BTN_Y, 1},
{9, BTN_TL, 1},
{25, BTN_TR, 1},
{11, BTN_MODE, 1},
},
INPUT_GPIO_DEFAULT_KEYCODE_TABLE_ITEM_COUNT,
0
};

// device 파라미터 파싱
static int __parse_device_param_for_gpio(device_gpio_data_t* user_data, char* device_config_str)
Expand Down Expand Up @@ -144,6 +163,12 @@ static int __parse_endpoint_param_for_gpio(device_gpio_data_t* user_data, char*
src = (device_gpio_index_table_t *)&default_input2_gpio_config;
code_mode = INPUT_CODE_TYPE_KEYCODE;

pin_count = parse_number(&pText, ",", 10, src->pin_count);
button_start_index = parse_number(&pText, ",", 10, 0);
} else if (strcmp(cfgtype_p, "default3") == 0){
src = (device_gpio_index_table_t *)&default_input3_gpio_config;
code_mode = INPUT_CODE_TYPE_KEYCODE;

pin_count = parse_number(&pText, ",", 10, src->pin_count);
button_start_index = parse_number(&pText, ",", 10, 0);
} else if (strcmp(cfgtype_p, "custom") == 0){
Expand Down

0 comments on commit 6622af8

Please sign in to comment.