mirror of
https://github.com/mist-devel/mist-firmware.git
synced 2026-05-03 14:59:36 +00:00
Second USB joystick fire button support for SMS core
This commit is contained in:
9
fpga.c
9
fpga.c
@@ -255,13 +255,14 @@ RAMFUNC unsigned char ConfigureFpga(char *name)
|
||||
ptr = sector_buffer;
|
||||
|
||||
/* Drive a transition of 0 to 1 to NCONFIG to indicate start of configuration */
|
||||
*AT91C_PIOA_CODR = ALTERA_NCONFIG;
|
||||
*AT91C_PIOA_CODR = ALTERA_NCONFIG; // must be low for at least 500ns
|
||||
for(i=0;i<10;i++)
|
||||
*AT91C_PIOA_CODR = ALTERA_NCONFIG; // must be low for at least 500ns
|
||||
|
||||
*AT91C_PIOA_SODR = ALTERA_NCONFIG;
|
||||
|
||||
// now wait for NSTATUS to go high
|
||||
// specs: max 800us
|
||||
i = 100000;
|
||||
i = 1000000;
|
||||
while (!(*AT91C_PIOA_PDSR & ALTERA_NSTATUS))
|
||||
{
|
||||
if (--i == 0)
|
||||
@@ -789,7 +790,7 @@ void fpga_init(char *name) {
|
||||
iprintf("FPGA configured in %lu ms\r", time >> 20);
|
||||
} else {
|
||||
iprintf("FPGA configuration failed\r");
|
||||
FatalError(3);
|
||||
FatalError(8); // 3
|
||||
}
|
||||
|
||||
WaitTimer(100); // let's wait some time till reset is inactive so we can get a valid keycode
|
||||
|
||||
4
menu.c
4
menu.c
@@ -135,7 +135,9 @@ void SelectFile(char* pFileExt, unsigned char Options, unsigned char MenuSelect,
|
||||
|
||||
{ int i;
|
||||
for(i=0;i<nDirEntries;i++) {
|
||||
if(strncmp(DirEntry[i].Name, s, 11) == 0)
|
||||
// iprintf("cmp %11s %11s\n", DirEntry[i].Name, s);
|
||||
|
||||
if(strncasecmp(DirEntry[i].Name, s, 11) == 0)
|
||||
ChangeDirectory(DirEntry[i].StartCluster + (fat32 ? (DirEntry[i].HighCluster & 0x0FFF) << 16 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
19
usb/hid.c
19
usb/hid.c
@@ -8,12 +8,6 @@
|
||||
#include "../user_io.h"
|
||||
#include "../hardware.h"
|
||||
|
||||
// joystick todo:
|
||||
// + renumber on unplug
|
||||
// + shift legacy joysticks up
|
||||
// + emulate extra joysticks (at printerport, ...)
|
||||
// - second fire button (no known system uses it, but OSD may have a use ...)
|
||||
|
||||
static unsigned char kbd_led_state = 0; // default: all leds off
|
||||
static unsigned char joysticks = 0; // number of detected usb joysticks
|
||||
|
||||
@@ -379,11 +373,12 @@ static uint8_t usb_hid_poll(usb_device_t *dev) {
|
||||
if(ax < 64) jmap |= JOY_UP;
|
||||
if(ax > 192) jmap |= JOY_DOWN;
|
||||
|
||||
// ... and one button
|
||||
if(buf[conf->joystick.button_byte_offset] &
|
||||
conf->joystick.button0_bitmask)
|
||||
jmap |= JOY_BTN1;
|
||||
|
||||
// ... and buttons
|
||||
if(buf[conf->joystick.button_byte_offset] &
|
||||
conf->joystick.button_bitmask[0]) jmap |= JOY_BTN1;
|
||||
if(buf[conf->joystick.button_byte_offset] &
|
||||
conf->joystick.button_bitmask[1]) jmap |= JOY_BTN2;
|
||||
|
||||
// swap joystick 0 and 1 since 1 is the one
|
||||
// used primarily on most systems
|
||||
ax = iface->jindex;
|
||||
@@ -392,7 +387,7 @@ static uint8_t usb_hid_poll(usb_device_t *dev) {
|
||||
|
||||
// check if joystick state has changed
|
||||
if(jmap != iface->jmap) {
|
||||
// iprintf("jmap changed to %x\n", jmap);
|
||||
// iprintf("jmap %d changed to %x\n", ax, jmap);
|
||||
|
||||
// and feed into joystick input system
|
||||
user_io_joystick(ax, jmap);
|
||||
|
||||
@@ -143,7 +143,12 @@ bool parse_report_descriptor(uint8_t *rep, uint16_t rep_size) {
|
||||
bit_count, bit_count/8, 1 << (bit_count%8));
|
||||
if(hid_conf[config_idx].type == CONFIG_TYPE_JOYSTICK) {
|
||||
hid_conf[config_idx].joystick.button_byte_offset = bit_count/8;
|
||||
hid_conf[config_idx].joystick.button0_bitmask = 1 << (bit_count%8);
|
||||
hid_conf[config_idx].joystick.button_bitmask[0] = 1 << (bit_count%8);
|
||||
|
||||
// second button present?
|
||||
if(report_count > 1)
|
||||
hid_conf[config_idx].joystick.button_bitmask[1] = 1 << ((bit_count+1)%8);
|
||||
|
||||
setup_complete |= JOYSTICK_REQ_BTN_0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ typedef struct {
|
||||
struct {
|
||||
uint8_t axis_byte_offset[2]; // x and y axis
|
||||
uint8_t button_byte_offset;
|
||||
uint8_t button0_bitmask;
|
||||
uint8_t button_bitmask[2];
|
||||
} joystick;
|
||||
};
|
||||
} hid_config_t;
|
||||
|
||||
28
user_io.c
28
user_io.c
@@ -345,6 +345,7 @@ void user_io_file_tx(fileTYPE *file) {
|
||||
SPI(0xff);
|
||||
DisableFpga();
|
||||
|
||||
#if 1
|
||||
while(bytes2send) {
|
||||
iprintf(".");
|
||||
|
||||
@@ -367,6 +368,30 @@ void user_io_file_tx(fileTYPE *file) {
|
||||
if(bytes2send)
|
||||
FileNextSector(file);
|
||||
}
|
||||
#else
|
||||
{
|
||||
int i, j;
|
||||
EnableFpga();
|
||||
SPI(UIO_FILE_TX_DAT);
|
||||
|
||||
// zx spectrum video:
|
||||
// 256*192 pixels = 6144 bytes
|
||||
// _"_ = 768 attribute bytes
|
||||
|
||||
for(j=0;j<8;j++)
|
||||
for(i=0;i<32*8;i++) SPI(0xf0);
|
||||
|
||||
for(j=0;j<8;j++)
|
||||
for(i=0;i<32*8;i++) SPI(0xcc);
|
||||
|
||||
for(j=0;j<8;j++)
|
||||
for(i=0;i<32*8;i++) SPI(0x55);
|
||||
|
||||
for(i=0;i<768;i++) SPI(i/3);
|
||||
|
||||
DisableFpga();
|
||||
}
|
||||
#endif
|
||||
|
||||
// signal end of transmission
|
||||
EnableFpga();
|
||||
@@ -740,7 +765,7 @@ static unsigned char is_emu_key(unsigned char c) {
|
||||
}
|
||||
|
||||
#define EMU_BTN1 0 // left control
|
||||
#define EMU_BTN2 4 // right control
|
||||
#define EMU_BTN2 1 // left shift
|
||||
|
||||
unsigned short keycode(unsigned char in) {
|
||||
if(core_type == CORE_TYPE_MINIMIG)
|
||||
@@ -775,7 +800,6 @@ unsigned short modifier_keycode(unsigned char index) {
|
||||
{ 0x63, 0x60, 0x64, 0x66, 0x63, 0x61, 0x65, 0x67 };
|
||||
return amiga_modifier[index];
|
||||
}
|
||||
|
||||
if(core_type == CORE_TYPE_MIST) {
|
||||
static const unsigned short atari_modifier[] =
|
||||
{ 0x1d, 0x2a, 0x38, MISS, 0x1d, 0x36, 0x38, MISS };
|
||||
|
||||
Reference in New Issue
Block a user