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

ps2: keyboard+mouse passthru support #171

Merged
merged 1 commit into from
Jul 19, 2024
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
2 changes: 1 addition & 1 deletion hid/pico/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ endef
.tinyusb:
$(call libdep,tinyusb,hathach/tinyusb,d713571cd44f05d2fc72efc09c670787b74106e0)
.ps2x2pico:
$(call libdep,ps2x2pico,No0ne/ps2x2pico,823260af57dcc55cf7cb96241346f51c065126de)
$(call libdep,ps2x2pico,No0ne/ps2x2pico,27c9bcede3370f0d4fdefea9c86a0eeb6170cf77)
deps: .pico-sdk .tinyusb .ps2x2pico


Expand Down
6 changes: 4 additions & 2 deletions hid/pico/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ target_sources(${target_name} PRIVATE
ph_com_uart.c
ph_debug.c

${PS2_PATH}/ps2phy.c
${PS2_PATH}/ps2out.c
${PS2_PATH}/ps2in.c
${PS2_PATH}/ps2kb.c
${PS2_PATH}/ps2ms.c
${PS2_PATH}/scancodesets.c
Expand All @@ -24,7 +25,8 @@ target_link_options(${target_name} PRIVATE -Xlinker --print-memory-usage)
target_compile_options(${target_name} PRIVATE -Wall -Wextra)
target_include_directories(${target_name} PRIVATE ${CMAKE_CURRENT_LIST_DIR} ${PS2_PATH})

pico_generate_pio_header(${target_name} ${PS2_PATH}/ps2phy.pio)
pico_generate_pio_header(${target_name} ${PS2_PATH}/ps2out.pio)
pico_generate_pio_header(${target_name} ${PS2_PATH}/ps2in.pio)

target_link_libraries(${target_name} PRIVATE
pico_stdlib
Expand Down
6 changes: 4 additions & 2 deletions hid/pico/src/ph_ps2.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#define _KBD_DATA_PIN 11 // CLK == 12
#define _MOUSE_DATA_PIN 14 // CLK == 15

#define _KBD_IN_DATA_PIN 26 // passthru, CLK == 27
#define _MOUSE_IN_DATA_PIN 16 // passthru, CLK == 17

u8 ph_g_ps2_kbd_leds = 0;
bool ph_g_ps2_kbd_online = 0;
Expand All @@ -57,13 +59,13 @@ void ph_ps2_init(void) {
}

if (PH_O_IS_KBD_PS2) {
kb_init(_KBD_DATA_PIN);
kb_init(_KBD_DATA_PIN, _KBD_IN_DATA_PIN);
} else {
INIT_STUB(_KBD_DATA_PIN);
}

if (PH_O_IS_MOUSE_PS2) {
ms_init(_MOUSE_DATA_PIN);
ms_init(_MOUSE_DATA_PIN, _MOUSE_IN_DATA_PIN);
} else {
INIT_STUB(_MOUSE_DATA_PIN);
}
Expand Down
4 changes: 2 additions & 2 deletions hid/pico/src/ph_ps2.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ void ph_ps2_init(void);
void ph_ps2_task(void);

void tuh_kb_set_leds(u8 leds);
void kb_init(u8 gpio);
void kb_init(u8 gpio_out, u8 gpio_in);
bool kb_task();
void kb_send_key(u8 key, bool state, u8 modifiers);
void ph_ps2_kbd_send_key(u8 key, bool state);

void ms_init(u8 gpio);
void ms_init(u8 gpio_out, u8 gpio_in);
bool ms_task();
void ms_send_movement(u8 buttons, s8 x, s8 y, s8 z);
void ph_ps2_mouse_send_button(u8 button, bool state);
Expand Down