Skip to content

Commit

Permalink
Combine USB joy/mouse into common handler
Browse files Browse the repository at this point in the history
  • Loading branch information
polpo committed Jul 6, 2024
1 parent 7a0b3c4 commit 8b0c34e
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
url = https://github.com/hathach/tinyusb
[submodule "sw/tusb_xinput"]
path = sw/tusb_xinput
url = https://github.com/RobertDaleSmith/tusb_xinput
url = https://github.com/Ryzee119/tusb_xinput
29 changes: 14 additions & 15 deletions sw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,17 @@ function(config_target TARGET_NAME MULTIFW)
# USB stack common stuff
target_link_libraries(${TARGET_NAME} tinyusb_host)
target_compile_definitions(${TARGET_NAME} PRIVATE USB_STACK=1)
target_sources(${TARGET_NAME} PRIVATE usb_hid/hid_app.c)
endif()
if(USB_JOYSTICK)
# Joystick stuff
target_sources(${TARGET_NAME} PRIVATE joy_hid/joy_hid.c)
target_link_libraries(${TARGET_NAME} hardware_pwm)
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/joy_hid)
target_link_libraries(${TARGET_NAME} xinput_host_app_driver)
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/usb_hid)
target_link_libraries(${TARGET_NAME} xinput_host)
target_compile_definitions(${TARGET_NAME} PRIVATE USB_JOYSTICK=1)
endif()
if (USB_MOUSE)
# USB Mouse stuff
target_sources(${TARGET_NAME} PRIVATE mouse/mouse_hid.c)
target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/mouse)
target_compile_definitions(${TARGET_NAME} PRIVATE USB_MOUSE=1)
endif()
Expand Down Expand Up @@ -143,7 +142,7 @@ add_subdirectory(opl)
################################################################################
# Build GUS firmware
function(build_gus TARGET_NAME MULTIFW)
set(USB_JOYSTICK 1)
set(USB_JOYSTICK TRUE)
config_target(${TARGET_NAME} ${MULTIFW})
pico_set_program_name(${TARGET_NAME} "picogus-gus")
target_sources(${TARGET_NAME} PRIVATE gusplay.cpp pico_pic.c isa_dma.c)
Expand Down Expand Up @@ -177,7 +176,7 @@ endfunction()
################################################################################
# Build SB firmware
function(build_sb TARGET_NAME MULTIFW)
set(USB_JOYSTICK 1)
set(USB_JOYSTICK TRUE)
config_target(${TARGET_NAME} ${MULTIFW})
pico_set_program_name(${TARGET_NAME} "picogus-sb")
target_sources(${TARGET_NAME} PRIVATE sbdsp.cpp sbplay.cpp pico_pic.c isa_dma.c)
Expand All @@ -200,8 +199,8 @@ endfunction()
################################################################################
# Build AdLib firmware
function(build_adlib TARGET_NAME MULTIFW)
set(USB_JOYSTICK 1)
set(USB_MOUSE 1)
set(USB_JOYSTICK TRUE)
set(USB_MOUSE TRUE)
config_target(${TARGET_NAME} ${MULTIFW})
pico_set_program_name(${TARGET_NAME} "picogus-sb")
target_sources(${TARGET_NAME} PRIVATE sbplay.cpp)
Expand All @@ -221,7 +220,7 @@ endfunction()
################################################################################
# Build MPU firmware
function(build_mpu TARGET_NAME MULTIFW)
set(USB_JOYSTICK 1)
set(USB_JOYSTICK TRUE)
config_target(${TARGET_NAME} ${MULTIFW})
pico_set_program_name(${TARGET_NAME} "picogus-mpu401")
target_compile_definitions(${TARGET_NAME} PRIVATE
Expand All @@ -246,8 +245,8 @@ endfunction()
################################################################################
# Build Tandy firmware
function(build_tandy TARGET_NAME MULTIFW)
set(USB_JOYSTICK 1)
set(USB_MOUSE 1)
set(USB_JOYSTICK TRUE)
set(USB_MOUSE TRUE)
config_target(${TARGET_NAME} ${MULTIFW})
pico_set_program_name(${TARGET_NAME} "picogus-tandy")
target_compile_definitions(${TARGET_NAME} PRIVATE
Expand All @@ -267,8 +266,8 @@ endfunction()
################################################################################
# Build CMS firmware
function(build_cms TARGET_NAME MULTIFW)
set(USB_JOYSTICK 1)
set(USB_MOUSE 1)
set(USB_JOYSTICK TRUE)
set(USB_MOUSE TRUE)
config_target(${TARGET_NAME} ${MULTIFW})
pico_set_program_name(${TARGET_NAME} "picogus-cms")
target_compile_definitions(${TARGET_NAME} PRIVATE
Expand All @@ -287,8 +286,8 @@ endfunction()
################################################################################
# Build USB-only firmware (joystick + mouse support)
function(build_usb TARGET_NAME MULTIFW)
set(USB_JOYSTICK 1)
set(USB_MOUSE 1)
set(USB_JOYSTICK TRUE)
set(USB_MOUSE TRUE)
config_target(${TARGET_NAME} ${MULTIFW})
pico_set_program_name(${TARGET_NAME} "picogus-usb")
target_compile_definitions(${TARGET_NAME} PRIVATE
Expand Down
178 changes: 0 additions & 178 deletions sw/mouse/mouse_hid.c

This file was deleted.

2 changes: 1 addition & 1 deletion sw/picogus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ cms_buffer_t cms_buffer = { {0}, 0, 0 };
#endif

#ifdef USB_JOYSTICK
#include "joy_hid/joy.h"
#include "usb_hid/joy.h"
extern "C" joystate_struct_t joystate_struct;
uint8_t joystate_bin;
#include "hardware/pwm.h"
Expand Down
Loading

0 comments on commit 8b0c34e

Please sign in to comment.