Revision 378
Added by markw over 10 years ago
| firmware/a800/joystick.c | ||
|---|---|---|
|
#endif
|
||
|
|
||
|
unsigned char porta = *atari_porta;
|
||
|
porta = (porta>>4) & (porta);
|
||
|
|
||
|
int controls = get_controls();
|
||
|
|
||
|
status->y_ = !(porta&0x2) -((unsigned int)!(porta&0x1));
|
||
|
status->x_ = !(porta&0x8) -((unsigned int)!(porta&0x4));
|
||
|
status->fire_ = !(1&*atari_trig0);
|
||
|
status->fire_ = !(1&*atari_trig0&*atari_trig1);
|
||
|
|
||
|
if (controls!=0)
|
||
|
{
|
||
| firmware/a800/mainmenu.c | ||
|---|---|---|
|
#include "usb.h"
|
||
|
#endif
|
||
|
|
||
|
#undef USBSETTINGS
|
||
|
|
||
|
void loadosrom()
|
||
|
{
|
||
|
if (file_size(files[5]) == 0x4000)
|
||
| ... | ... | |
|
}*/
|
||
|
}
|
||
|
|
||
|
#ifdef USBSETTINGS
|
||
|
void usb_settings()
|
||
|
{
|
||
|
struct joystick_status joy;
|
||
|
joy.x_ = joy.y_ = joy.fire_ = joy.escape_ = 0;
|
||
|
|
||
|
int row = 0;
|
||
|
|
||
|
int done = 0;
|
||
|
for (;!done;)
|
||
|
{
|
||
|
// Render
|
||
|
clearscreen();
|
||
|
debug_pos = 0;
|
||
|
debug_adjust = 0;
|
||
|
printf("USB Se");
|
||
|
debug_adjust = 128;
|
||
|
printf("ttings");
|
||
|
debug_pos = 80;
|
||
|
debug_adjust = row==0 ? 128 : 0;
|
||
|
printf("Hello world");
|
||
|
|
||
|
debug_pos = 200;
|
||
|
debug_adjust = row==1 ? 128 : 0;
|
||
|
printf("Exit");
|
||
|
|
||
|
// Slow it down a bit
|
||
|
wait_us(100000);
|
||
|
|
||
|
// move
|
||
|
joystick_wait(&joy,WAIT_QUIET);
|
||
|
joystick_wait(&joy,WAIT_EITHER);
|
||
|
if (joy.escape_) break;
|
||
|
|
||
|
row+=joy.y_;
|
||
|
if (row<0) row = 0;
|
||
|
if (row>1) row = 1;
|
||
|
switch (row)
|
||
|
{
|
||
|
case 0:
|
||
|
{
|
||
|
}
|
||
|
break;
|
||
|
case 1:
|
||
|
if (joy.fire_)
|
||
|
{
|
||
|
done = 1;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
int settings()
|
||
|
{
|
||
|
struct joystick_status joy;
|
||
| ... | ... | |
|
debug_adjust = row==10 ? 128 : 0;
|
||
|
printf("Save memory (for debugging)");
|
||
|
|
||
|
|
||
|
#ifdef USBSETTINGS
|
||
|
debug_pos = 640;
|
||
|
debug_adjust = row==11 ? 128 : 0;
|
||
|
printf("USB");
|
||
|
|
||
|
debug_pos = 720;
|
||
|
debug_adjust = row==12 ? 128 : 0;
|
||
|
printf("Exit");
|
||
|
#else
|
||
|
debug_pos = 640;
|
||
|
debug_adjust = row==11 ? 128 : 0;
|
||
|
printf("Exit");
|
||
|
#endif
|
||
|
|
||
|
// Slow it down a bit
|
||
|
wait_us(100000);
|
||
| ... | ... | |
|
|
||
|
row+=joy.y_;
|
||
|
if (row<0) row = 0;
|
||
|
#ifdef USB
|
||
|
if (row>12) row = 12;
|
||
|
#else
|
||
|
if (row>11) row = 11;
|
||
|
#endif
|
||
|
switch (row)
|
||
|
{
|
||
|
case 0:
|
||
| ... | ... | |
|
}
|
||
|
}
|
||
|
break;
|
||
|
#ifdef USBSETTINGS
|
||
|
case 11:
|
||
|
if (joy.fire_)
|
||
|
{
|
||
|
usb_settings();
|
||
|
}
|
||
|
break;
|
||
|
case 12:
|
||
|
if (joy.fire_)
|
||
|
{
|
||
|
done = 1;
|
||
|
}
|
||
|
break;
|
||
|
#else
|
||
|
case 11:
|
||
|
if (joy.fire_)
|
||
|
{
|
||
|
done = 1;
|
||
|
}
|
||
|
break;
|
||
|
#endif
|
||
|
}
|
||
|
}
|
||
|
|
||
| firmware/regs.h | ||
|---|---|---|
|
#define atari_porta ((unsigned char volatile *)(0xd300 + atari_regbase))
|
||
|
#define atari_portb ((unsigned char volatile *)(0xd301 + atari_regbase))
|
||
|
#define atari_trig0 ((unsigned char volatile *)(0xd010 + atari_regbase))
|
||
|
#define atari_trig1 ((unsigned char volatile *)(0xd011 + atari_regbase))
|
||
|
#define atari_chbase ((unsigned char volatile *)(0xd409 + atari_regbase))
|
||
|
#define atari_chactl ((unsigned char volatile *)(0xd401 + atari_regbase))
|
||
|
#define atari_dmactl ((unsigned char volatile *)(0xd400 + atari_regbase))
|
||
| firmware/usb/hid.c | ||
|---|---|---|
|
uint8_t c_jindex = info->iface[i].jindex;
|
||
|
hid_debugf("releasing joystick #%d, renumbering", c_jindex);
|
||
|
|
||
|
event_digital_joystick(c_jindex, 0);
|
||
|
event_analog_joystick(c_jindex, 0,0);
|
||
|
|
||
|
// walk through all devices and search for sticks with a higher id
|
||
|
|
||
|
// search for all joystick interfaces on all hid devices
|
||
| ... | ... | |
|
if(dev[j].hid_info.iface[k].jindex > c_jindex) {
|
||
|
hid_debugf("decreasing jindex of dev #%d from %d to %d", j,
|
||
|
dev[j].hid_info.iface[k].jindex, dev[j].hid_info.iface[k].jindex-1);
|
||
|
|
||
|
dev[j].hid_info.iface[k].jindex--;
|
||
|
}
|
||
|
}
|
||
| firmware/usb/usb.c | ||
|---|---|---|
|
|
||
|
int i;
|
||
|
for(i=0; i<USB_NUMDEVICES; i++) {
|
||
|
if(devices[i].bAddress && devices[i].parent == parent && devices[i].port == port) {
|
||
|
if(devices[i].bAddress && devices[i].parent == parent && devices[i].port == port && devices[i].host_addr == usbhostslave) {
|
||
|
iprintf(" -> device with address %x\n", dev[i].bAddress);
|
||
|
|
||
|
// check if this is a hub (parent of some other device)
|
||
|
// and release its kids first
|
||
|
uint8_t j;
|
||
|
for(j=0; j<USB_NUMDEVICES; j++) {
|
||
|
if(devices[j].parent == devices[i].bAddress)
|
||
|
usb_release_device(devices[i].bAddress, devices[j].port);
|
||
|
if(devices[j].parent == devices[i].bAddress && devices[j].host_addr == devices[i].host_addr)
|
||
|
usb_release_device(devices[j].parent, devices[j].port);
|
||
|
}
|
||
|
|
||
|
uint8_t rcode = 0;
|
||
Allow 2nd joystick to control menu. Some small USB fixes.