2013-11-09 : Version 1.2
- Dreamcast keyboard support (Tested: HKT-7600 and HKT-4000) - Increased poll rate for better responsiveness - Display an image on the LCD if present. (Static image. Not usable by emulators)
This commit is contained in:
parent
c4acc4b111
commit
2449b650cf
|
@ -1,6 +1,8 @@
|
||||||
2013-11-03 : Version 1.2
|
2013-11-09 : Version 1.2
|
||||||
- Dreamcast keyboard support (Tested: HKT-7600)
|
- Dreamcast keyboard support (Tested: HKT-7600 and HKT-4000)
|
||||||
- Increased poll rate for better responsiveness
|
- Increased poll rate for better responsiveness
|
||||||
|
- Display an image on the LCD if present.
|
||||||
|
(Static image. Not usable by emulators)
|
||||||
|
|
||||||
2013-11-02 : Version 1.1.1
|
2013-11-02 : Version 1.1.1
|
||||||
- Longer timeout waiting for an answer.
|
- Longer timeout waiting for an answer.
|
||||||
|
|
35
checksize
35
checksize
|
@ -1,35 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
# Name: checksize
|
|
||||||
# Project: AVR-USB
|
|
||||||
# Author: Christian Starkjohann
|
|
||||||
# Creation Date: 2004-12-29
|
|
||||||
# Tabsize: 4
|
|
||||||
# Copyright: (c) 2005 OBJECTIVE DEVELOPMENT Software GmbH.
|
|
||||||
# Revision: $Id: checksize,v 1.1 2013-10-13 21:01:08 cvs Exp $
|
|
||||||
|
|
||||||
error=0
|
|
||||||
codelimit=8192
|
|
||||||
datalimit=960 # leave 64 bytes for stack
|
|
||||||
|
|
||||||
if [ $# -gt 1 ]; then
|
|
||||||
codelimit="$2"
|
|
||||||
fi
|
|
||||||
if [ $# -gt 2 ]; then
|
|
||||||
datalimit="$3"
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -- `avr-size -d "$1" | awk '/[0-9]/ {print $1 + $2, $2 + $3, $2}'`
|
|
||||||
if [ $1 -gt $codelimit ]; then
|
|
||||||
echo "*** code size $1 exceeds limit of $codelimit"
|
|
||||||
error=1
|
|
||||||
else
|
|
||||||
echo "ROM: $1 bytes (data=$3)"
|
|
||||||
fi
|
|
||||||
if [ $2 -gt $datalimit ]; then
|
|
||||||
echo "*** data size $2 exceeds limit of $datalimit"
|
|
||||||
error=1
|
|
||||||
else
|
|
||||||
echo "RAM: $2 bytes"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit $error
|
|
89
dc_pad.c
89
dc_pad.c
|
@ -19,8 +19,9 @@
|
||||||
*/
|
*/
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <util/delay.h>
|
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "usbdrv.h"
|
#include "usbdrv.h"
|
||||||
#include "gamepad.h"
|
#include "gamepad.h"
|
||||||
|
@ -281,18 +282,68 @@ static void dcInit(void)
|
||||||
#define STATE_READ_PAD 2
|
#define STATE_READ_PAD 2
|
||||||
#define STATE_READ_MOUSE 3
|
#define STATE_READ_MOUSE 3
|
||||||
#define STATE_READ_KEYBOARD 4
|
#define STATE_READ_KEYBOARD 4
|
||||||
|
#define STATE_LCD_DETECT 5
|
||||||
|
#define STATE_NULL 6
|
||||||
|
static unsigned char state = STATE_RESET_DEVICE;
|
||||||
|
|
||||||
|
const char lcd_data[200] PROGMEM = {
|
||||||
|
0x00, 0x00, 0x00, 0x04,
|
||||||
|
0x00, 0x00, 0x00, 0x00,
|
||||||
|
#include "raphnet.c"
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint8_t lcd_addr = 0;
|
||||||
|
|
||||||
|
static void updateLcd(void)
|
||||||
|
{
|
||||||
|
unsigned char tmp[30];
|
||||||
|
|
||||||
|
if (lcd_addr) {
|
||||||
|
maple_sendFrame_P(MAPLE_CMD_BLOCK_WRITE,
|
||||||
|
lcd_addr,
|
||||||
|
MAPLE_DC_ADDR | MAPLE_ADDR_PORTB,
|
||||||
|
200, lcd_data);
|
||||||
|
maple_receiveFrame(tmp, 30);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pollSubs(void)
|
||||||
|
{
|
||||||
|
int i, v;
|
||||||
|
unsigned char tmp[30];
|
||||||
|
|
||||||
|
for (i=0; i<5; i++) {
|
||||||
|
maple_sendFrame(MAPLE_CMD_RQ_DEV_INFO,
|
||||||
|
MAPLE_ADDR_SUB(i) | MAPLE_ADDR_PORTB,
|
||||||
|
MAPLE_DC_ADDR | MAPLE_ADDR_PORTB,
|
||||||
|
0, NULL);
|
||||||
|
v = maple_receiveFrame(tmp, 30);
|
||||||
|
if (v==-2) {
|
||||||
|
_delay_ms(2);
|
||||||
|
uint16_t func = tmp[4] | tmp[5]<<8;
|
||||||
|
|
||||||
|
if (func & MAPLE_FUNC_LCD) {
|
||||||
|
lcd_addr = MAPLE_ADDR_SUB(i) | MAPLE_ADDR_PORTB;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void dcReadPad(void)
|
static void dcReadPad(void)
|
||||||
{
|
{
|
||||||
static unsigned char state = STATE_RESET_DEVICE;
|
|
||||||
static unsigned char err_count = 0;
|
static unsigned char err_count = 0;
|
||||||
unsigned char tmp[30];
|
unsigned char tmp[30];
|
||||||
static unsigned char func_data[4];
|
static unsigned char func_data[4];
|
||||||
|
static int lcd_detect_count = 0;
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
|
case STATE_NULL:
|
||||||
|
{
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case STATE_RESET_DEVICE:
|
case STATE_RESET_DEVICE:
|
||||||
{
|
{
|
||||||
maple_sendFrame(MAPLE_CMD_RESET_DEVICE,
|
maple_sendFrame(MAPLE_CMD_RESET_DEVICE,
|
||||||
|
@ -311,7 +362,7 @@ static void dcReadPad(void)
|
||||||
|
|
||||||
v = maple_receiveFrame(tmp, 30);
|
v = maple_receiveFrame(tmp, 30);
|
||||||
|
|
||||||
// Too many data arrives and we stop listening before the controller stop transmitting. The delay
|
// Too much data arrives and we stop listening before the controller stop transmitting. The delay
|
||||||
// here is to wait until the bus is idle again before continuing.
|
// here is to wait until the bus is idle again before continuing.
|
||||||
_delay_ms(2);
|
_delay_ms(2);
|
||||||
if (v==-2) {
|
if (v==-2) {
|
||||||
|
@ -324,8 +375,9 @@ static void dcReadPad(void)
|
||||||
func = tmp[4] | tmp[5]<<8;
|
func = tmp[4] | tmp[5]<<8;
|
||||||
|
|
||||||
if (func & MAPLE_FUNC_CONTROLLER) {
|
if (func & MAPLE_FUNC_CONTROLLER) {
|
||||||
state = STATE_READ_PAD;
|
|
||||||
setConnectedDevice(MAPLE_FUNC_CONTROLLER);
|
setConnectedDevice(MAPLE_FUNC_CONTROLLER);
|
||||||
|
state = STATE_LCD_DETECT;
|
||||||
|
lcd_detect_count = 0;
|
||||||
} else if (func & MAPLE_FUNC_MOUSE) {
|
} else if (func & MAPLE_FUNC_MOUSE) {
|
||||||
state = STATE_READ_MOUSE;
|
state = STATE_READ_MOUSE;
|
||||||
memcpy(func_data, tmp + 5, 4);
|
memcpy(func_data, tmp + 5, 4);
|
||||||
|
@ -340,6 +392,31 @@ static void dcReadPad(void)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Try for 2 seconds to find the address of the LCD.
|
||||||
|
//
|
||||||
|
// After 2 seconds of trying, if found, send the
|
||||||
|
// image.
|
||||||
|
//
|
||||||
|
// Sending the image right away after detection does not
|
||||||
|
// seem to work. This delay works around this.
|
||||||
|
case STATE_LCD_DETECT:
|
||||||
|
{
|
||||||
|
if (!lcd_addr)
|
||||||
|
{
|
||||||
|
pollSubs();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lcd_detect_count > 120) {
|
||||||
|
if (lcd_addr) {
|
||||||
|
updateLcd();
|
||||||
|
}
|
||||||
|
state = STATE_READ_PAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
lcd_detect_count++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case STATE_READ_MOUSE:
|
case STATE_READ_MOUSE:
|
||||||
{
|
{
|
||||||
int16_t rel_x, rel_y;
|
int16_t rel_x, rel_y;
|
||||||
|
@ -418,7 +495,7 @@ static void dcReadPad(void)
|
||||||
MAPLE_FUNC_CONTROLLER);
|
MAPLE_FUNC_CONTROLLER);
|
||||||
|
|
||||||
v = maple_receiveFrame(tmp, 30);
|
v = maple_receiveFrame(tmp, 30);
|
||||||
|
|
||||||
if (v<=0) {
|
if (v<=0) {
|
||||||
err_count++;
|
err_count++;
|
||||||
if (err_count > MAX_ERRORS) {
|
if (err_count > MAX_ERRORS) {
|
||||||
|
@ -427,7 +504,7 @@ static void dcReadPad(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
err_count = 0;
|
err_count = 0;
|
||||||
|
|
||||||
if (v < 16)
|
if (v < 16)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue