Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Core] Rework PS/2 driver selection #17892

Merged
merged 8 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions builddefs/common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -805,31 +805,25 @@ ifeq ($(strip $(PS2_MOUSE_ENABLE)), yes)
OPT_DEFS += -DMOUSE_ENABLE
endif

ifeq ($(strip $(PS2_USE_BUSYWAIT)), yes)
PS2_ENABLE := yes
SRC += ps2_busywait.c
SRC += ps2_io.c
OPT_DEFS += -DPS2_USE_BUSYWAIT
endif
VALID_PS2_DRIVER_TYPES := busywait interrupt usart vendor

ifeq ($(strip $(PS2_USE_INT)), yes)
PS2_ENABLE := yes
SRC += ps2_interrupt.c
SRC += ps2_io.c
OPT_DEFS += -DPS2_USE_INT
endif
PS2_DRIVER ?= busywait
ifeq ($(strip $(PS2_ENABLE)), yes)
ifeq ($(filter $(PS2_DRIVER),$(VALID_PS2_DRIVER_TYPES)),)
$(call CATASTROPHIC_ERROR,Invalid PS2_DRIVER,PS2_DRIVER="$(PS2_DRIVER)" is not a valid PS/2 driver)
endif

ifeq ($(strip $(PS2_USE_USART)), yes)
PS2_ENABLE := yes
SRC += ps2_usart.c
SRC += ps2_io.c
OPT_DEFS += -DPS2_USE_USART
endif
OPT_DEFS += -DPS2_DRIVER_$(strip $(shell echo $(PS2_DRIVER) | tr '[:lower:]' '[:upper:]'))

ifeq ($(strip $(PS2_ENABLE)), yes)
COMMON_VPATH += $(DRIVER_PATH)/ps2
COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/ps2
OPT_DEFS += -DPS2_ENABLE

ifneq ($(strip $(PS2_DRIVER)), vendor)
SRC += ps2_io.c
endif

SRC += ps2_$(strip $(PS2_DRIVER)).c
endif

JOYSTICK_ENABLE ?= no
Expand Down
2 changes: 2 additions & 0 deletions builddefs/show_options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ OTHER_OPTION_NAMES = \
KEYLOGGER_ENABLE \
LCD_BACKLIGHT_ENABLE \
MACROS_ENABLED \
PS2_ENABLE \
PS2_MOUSE_ENABLE \
PS2_DRIVER \
RAW_ENABLE \
SWAP_HANDS_ENABLE \
RING_BUFFERED_6KRO_REPORT_ENABLE \
Expand Down
2 changes: 2 additions & 0 deletions data/mappings/info_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
"ONESHOT_TAP_TOGGLE": {"info_key": "oneshot.tap_toggle", "value_type": "int"},
"PERMISSIVE_HOLD": {"info_key": "tapping.permissive_hold", "value_type": "bool"},
"PERMISSIVE_HOLD_PER_KEY": {"info_key": "tapping.permissive_hold_per_key", "value_type": "bool"},
"PS2_CLOCK_PIN": {"info_key": "ps2.clock_pin"},
"PS2_DATA_PIN": {"info_key": "ps2.data_pin"},
"RETRO_TAPPING": {"info_key": "tapping.retro", "value_type": "bool"},
"RETRO_TAPPING_PER_KEY": {"info_key": "tapping.retro_per_key", "value_type": "bool"},
"RGB_DI_PIN": {"info_key": "rgblight.pin"},
Expand Down
3 changes: 3 additions & 0 deletions data/mappings/info_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
"WAIT_FOR_USB": {"info_key": "usb.wait_for", "value_type": "bool"},
"STENO_ENABLE": {"info_key": "stenography.enabled", "value_type": "bool"},
"STENO_PROTOCOL": {"info_key": "stenography.protocol"},
"PS2_ENABLE": {"info_key": "ps2.enabled", "value_type": "bool"},
"PS2_MOUSE_ENABLE": {"info_key": "ps2.mouse_enabled", "value_type": "bool"},
"PS2_DRIVER": {"info_key": "ps2.driver"},

# Items we want flagged in lint
"CTPC": {"info_key": "_deprecated.ctpc", "deprecated": true, "replace_with": "CONVERT_TO=proton_c"},
Expand Down
14 changes: 14 additions & 0 deletions data/schemas/keyboard.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,20 @@
}
}
},
"ps2": {
"type": "object",
"additionalProperties": false,
"properties": {
"enabled": {"type": "boolean"},
"mouse_enabled": {"type": "boolean"},
"clock_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
"data_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"},
"driver": {
"type": "string",
"enum": ["busywait", "interrupt", "usart", "vendor"]
}
}
},
"split": {
"type": "object",
"additionalProperties": false,
Expand Down
18 changes: 11 additions & 7 deletions docs/feature_ps2_mouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ In rules.mk:

```make
PS2_MOUSE_ENABLE = yes
PS2_USE_BUSYWAIT = yes
PS2_ENABLE = yes
PS2_DRIVER = busywait
```

In your keyboard config.h:

```c
#ifdef PS2_USE_BUSYWAIT
#ifdef PS2_DRIVER_BUSYWAIT
# define PS2_CLOCK_PIN D1
# define PS2_DATA_PIN D2
#endif
Expand All @@ -52,13 +53,14 @@ In rules.mk:

```make
PS2_MOUSE_ENABLE = yes
PS2_USE_INT = yes
PS2_ENABLE = yes
PS2_DRIVER = interrupt
```

In your keyboard config.h:

```c
#ifdef PS2_USE_INT
#ifdef PS2_DRIVER_INTERRUPT
#define PS2_CLOCK_PIN D2
#define PS2_DATA_PIN D5

Expand All @@ -84,7 +86,8 @@ In rules.mk:

```
PS2_MOUSE_ENABLE = yes
PS2_USE_INT = yes
PS2_ENABLE = yes
PS2_DRIVER = interrupt
```

In your keyboard config.h:
Expand All @@ -108,13 +111,14 @@ In rules.mk:

```make
PS2_MOUSE_ENABLE = yes
PS2_USE_USART = yes
PS2_ENABLE = yes
PS2_DRIVER = usart
```

In your keyboard config.h:

```c
#ifdef PS2_USE_USART
#ifdef PS2_DRIVER_USART
#define PS2_CLOCK_PIN D5
#define PS2_DATA_PIN D2

Expand Down
16 changes: 9 additions & 7 deletions docs/ja/feature_ps2_mouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ rules.mk で:

```makefile
PS2_MOUSE_ENABLE = yes
PS2_USE_BUSYWAIT = yes
PS2_ENABLE = yes
PS2_DRIVER = busywait
```

キーボードの config.h で:

```c
#ifdef PS2_USE_BUSYWAIT
#ifdef PS2_DRIVER_BUSYWAIT
# define PS2_CLOCK_PIN D1
# define PS2_DATA_PIN D2
#endif
Expand All @@ -56,13 +57,14 @@ rules.mk で:

```makefile
PS2_MOUSE_ENABLE = yes
PS2_USE_INT = yes
PS2_ENABLE = yes
PS2_DRIVER = interrupt
```

キーボードの config.h で:

```c
#ifdef PS2_USE_INT
#ifdef PS2_DRIVER_INTERRUPT
#define PS2_CLOCK_PIN D2
#define PS2_DATA_PIN D5

Expand All @@ -88,14 +90,14 @@ rules.mk で:

```makefile
PS2_MOUSE_ENABLE = yes
PS2_USE_USART = yes
PS2_ENABLE = yes
PS2_DRIVER = usart
```

キーボードの config.h で:

```c
#ifdef PS2_USE_USART
#ifdef PS2_USE_USART
#ifdef PS2_DRIVER_USART
#define PS2_CLOCK_PIN D5
#define PS2_DATA_PIN D2

Expand Down
2 changes: 1 addition & 1 deletion keyboards/buzzard/rev1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#define SPLIT_OLED_ENABLE
#endif

#ifdef PS2_USE_INT
#ifdef PS2_DRIVER_INTERRUPT
#define PS2_CLOCK_PIN E6
#define PS2_DATA_PIN D7

Expand Down
3 changes: 2 additions & 1 deletion keyboards/buzzard/rev1/rules.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
OLED_DRIVER = SSD1306

PS2_USE_INT = yes
PS2_ENABLE = yes
PS2_DRIVER = interrupt
6 changes: 3 additions & 3 deletions keyboards/converter/ibm_terminal/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/*
* PS/2 USART configuration for ATMega32U4
*/
#ifdef PS2_USE_USART
#ifdef PS2_DRIVER_USART
/* XCK for clock line */
#define PS2_CLOCK_PIN D5
#define PS2_DATA_PIN D2
Expand Down Expand Up @@ -77,7 +77,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/*
* PS/2 Interrupt configuration
*/
#ifdef PS2_USE_INT
#ifdef PS2_DRIVER_INTERRUPT
/* uses INT1 for clock line(ATMega32U4) */
#define PS2_CLOCK_PIN D1
#define PS2_DATA_PIN D0
Expand All @@ -99,7 +99,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/*
* PS/2 Busywait configuration
*/
#ifdef PS2_USE_BUSYWAIT
#ifdef PS2_DRIVER_BUSYWAIT
#define PS2_CLOCK_PIN D1
#define PS2_DATA_PIN D0
#endif
3 changes: 2 additions & 1 deletion keyboards/converter/ibm_terminal/keymaps/default/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ NKRO_ENABLE = yes
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
AUDIO_ENABLE = no # Audio output
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
PS2_USE_USART = yes
PS2_ENABLE = yes
PS2_DRIVER = usart
7 changes: 4 additions & 3 deletions keyboards/converter/ibm_terminal/keymaps/priyadi/rules.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build Options
# change to "no" to disable the options, or define them in the Makefile in
# change to "no" to disable the options, or define them in the Makefile in
# the appropriate keymap folder that will get included automatically
#
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite
Expand All @@ -14,8 +14,9 @@ AUDIO_ENABLE = no # Audio output on port C6
UNICODE_ENABLE = no # Unicode
UNICODEMAP_ENABLE = yes
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
PS2_USE_USART = yes
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
PS2_ENABLE = yes
PS2_DRIVER = usart

# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
3 changes: 2 additions & 1 deletion keyboards/converter/ibm_terminal/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ NKRO_ENABLE = yes # Enable N-Key Rollover
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
AUDIO_ENABLE = no # Audio output
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
PS2_USE_USART = yes
PS2_ENABLE = yes
PS2_DRIVER = usart
CUSTOM_MATRIX = yes

SRC = matrix.c led.c
4 changes: 2 additions & 2 deletions keyboards/evyd13/gh80_3700/keymaps/ps2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#ifdef PS2_USE_USART
#ifdef PS2_DRIVER_USART
#define PS2_CLOCK_PIN D5
#define PS2_DATA_PIN D2

Expand Down Expand Up @@ -51,7 +51,7 @@
#define PS2_USART_ERROR (UCSR1A & ((1<<FE1) | (1<<DOR1) | (1<<UPE1)))
#define PS2_USART_RX_VECT USART1_RX_vect
#define PS2_MOUSE_ENABLE_SCROLLING
#define PS2_MOUSE_INIT_DELAY 1000
#define PS2_MOUSE_INIT_DELAY 1000
#define PS2_MOUSE_BTN_LEFT 0
#define PS2_MOUSE_BTN_RIGHT 1
#define PS2_MOUSE_BTN_MIDDLE 2
Expand Down
3 changes: 2 additions & 1 deletion keyboards/evyd13/gh80_3700/keymaps/ps2/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
# change yes to no to disable
#
PS2_MOUSE_ENABLE = yes
PS2_USE_USART = yes
PS2_ENABLE = yes
PS2_DRIVER = usart
2 changes: 1 addition & 1 deletion keyboards/handwired/108key_trackpoint/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define MATRIX_ROWS 8
#define MATRIX_COLS 23

#ifdef PS2_USE_USART
#ifdef PS2_DRIVER_USART
#define PS2_CLOCK_PIN D5
#define PS2_DATA_PIN D2

Expand Down
3 changes: 2 additions & 1 deletion keyboards/handwired/108key_trackpoint/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow
AUDIO_ENABLE = no # Audio output
PS2_MOUSE_ENABLE = yes
PS2_USE_USART = yes
PS2_ENABLE = yes
PS2_DRIVER = usart
6 changes: 3 additions & 3 deletions keyboards/handwired/promethium/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ enum led_sequence {
#endif

/* PS/2 mouse */
#ifdef PS2_USE_BUSYWAIT
#ifdef PS2_DRIVER_BUSYWAIT
# define PS2_CLOCK_PIN D3
# define PS2_DATA_PIN D2
#endif

/* PS/2 mouse interrupt version */
#ifdef PS2_USE_INT
#ifdef PS2_DRIVER_INTERRUPT
/* uses INT1 for clock line(ATMega32U4) */
# define PS2_CLOCK_PIN D3
# define PS2_DATA_PIN D2
Expand All @@ -237,7 +237,7 @@ enum led_sequence {
#endif

/* PS/2 mouse USART version */
#ifdef PS2_USE_USART
#ifdef PS2_DRIVER_USART
/* XCK for clock line and RXD for data line */
#define PS2_CLOCK_PIN D5
#define PS2_DATA_PIN D2
Expand Down
3 changes: 2 additions & 1 deletion keyboards/handwired/promethium/keymaps/default/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ AUDIO_ENABLE = no # Audio output
UNICODEMAP_ENABLE = yes
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
PS2_MOUSE_ENABLE = yes
PS2_USE_INT = yes
PS2_ENABLE = yes
PS2_DRIVER = interrupt
3 changes: 2 additions & 1 deletion keyboards/handwired/promethium/keymaps/priyadi/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ UNICODE_ENABLE = no # Unicode
UNICODEMAP_ENABLE = yes
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
PS2_MOUSE_ENABLE = yes
PS2_USE_INT = yes
PS2_ENABLE = yes
PS2_DRIVER = interrupt

# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
3 changes: 2 additions & 1 deletion keyboards/handwired/promethium/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
AUDIO_ENABLE = no # Audio output
RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
PS2_MOUSE_ENABLE = yes
PS2_USE_INT = yes
PS2_ENABLE = yes
PS2_DRIVER = interrupt
CUSTOM_MATRIX = yes
BLUETOOTH_ENABLE = yes
BLUETOOTH_DRIVER = BluefruitLE
Expand Down
2 changes: 1 addition & 1 deletion keyboards/handwired/trackpoint/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define MATRIX_ROWS 1
#define MATRIX_COLS 3

#ifdef PS2_USE_USART
#ifdef PS2_DRIVER_USART
#define PS2_CLOCK_PIN D5
#define PS2_DATA_PIN D2

Expand Down
3 changes: 2 additions & 1 deletion keyboards/handwired/trackpoint/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
AUDIO_ENABLE = no # Audio output

PS2_MOUSE_ENABLE = yes
PS2_USE_USART = yes
PS2_ENABLE = yes
PS2_DRIVER = usart
Loading