Это вот ты для кого это сейчас? Про это я и так знал, в спецификации то предусмотрены, а в эмуляторах - НЕТ. Мало того там ещё предусмотрен второй цифровай крестик и ещё несколько аналогов:-\
Добавлено позже:Chronoman, А че там собирать то?
Во первых не собрал, а разработал. Во вторых, - Ну ну, чё-то кроме меня никто не сделал, сам не сделаешь никто не сделает, зато ууууумных потом, чё собирать... нечего там делать... фи как просто... я бы и сам, только занят был... хлеб на масло намазывал...
Упс... походу переборщил... :-)
Добавлено позже:Вот вом кусочек листинга программы для на затравочку
#include <avr/pgmspace.h>
#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <string.h>
#include <avr/sleep.h>
#include "MapleDevices.h"
unsigned long PeripheralFunction=0;
//Mouse
/*
const uint8_t DeviceInformation[] EEMEM={
//Device ID
0x00,0x00,0x02,0x00,
0x00,0x0E,0x07,0x00,
0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
//Country specification
0xFF,
//Connection method
0x00,
//Model name 30 BYTES
'D','r','e','a','m','c','a','s','t',' ',
'M','o','u','s','e',' ',' ',' ',' ',' ',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
//License 60 BYTES
'P','r','o','d','u','c','e','d',' ','B',
'y',' ','o','r',' ','U','n','d','e','r',
' ','L','i','c','v','e','n','s','e',' ',
'F','r','o','m',' ','S','E','G','A',' ',
'E','N','T','E','R','P','R','I','S','E',
'S',',','L','T','D','.',' ',' ',' ',' ',
//Standby current consumption - 43 ma
0x01,0x90,
//Maximum current consumption - 50 ma
0x01,0xF4
};
*/
/*
//Keyboard
const uint8_t DeviceInformation[] EEMEM={
//Device ID
0x00,0x00,0x00,0x40,
0x0E,0x04,0x00,0x80,
0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
//Country specification
0xFF,
//Connection method
0x00,
//Model name 30 BYTES
'1','0','2','k','e','y',' ','K','e','y',
'b','o','a','r','d',' ','f','o','r',' ',
'E','U','R',' ',' ',' ',' ',' ',' ',' ',
//License 60 BYTES
'P','r','o','d','u','c','e','d',' ','B',
'y',' ','o','r',' ','U','n','d','e','r',
' ','L','i','c','v','e','n','s','e',' ',
'F','r','o','m',' ','S','E','G','A',' ',
'E','N','T','E','R','P','R','I','S','E',
'S',',','L','T','D','.',' ',' ',' ',' ',
//Standby current consumption - 43 ma
0x01,0xAE,
//Maximum current consumption - 50 ma
0x01,0xF4
};
//Free device status is exported from controller
*/
const uint8_t DeviceInformation[] EEMEM ={
//Device ID
0x00,0x00,0x00,0x01,
0x00,0x00,0x04,0xFE,
//0x00,0x0F,0x06,0xFE,
0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,
//Country specification
0xFF,
//Connection method
0x00,
//Model name 30 BYTES
'D','r','e','a','m','c','a','s','t',' ',
'C','o','n','t','r','o','l','l','e','r',
' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',
//License 60 BYTES
'N','o','t',' ','P','r','o','d','u','c',
'e','d',' ','B','y',' ','o','r',' ','U',
'n','d','e','r',' ','L','i','c','e','n',
's','e',' ','F','r','o','m',' ','S','E',
'G','A',' ','E','N','T','E','R','P','R',
'I','S','E','S',',','L','T','D','.',' ',
//Standby current consumption - 43 ma
0x01,0xAE,
//Maximum current consumption - 50 ma
0x01,0xF4
};
const uint8_t DeviceRevisionInfo[] EEMEM ={
'V','e','r','s','i','o','n',' ','1','.',
'0','0','0',',','2','0','0','7','/','0',
'2','/','1','2',',','A','T','M','E','G',
'A','8','5','1','5','-','6','1','2','5',
'-','A','B',',','N','e','s',' ','T','O',
' ','D','C',' ','M','o','d','u','l','e',
',','l','o','g','i','c',' ','v','e','r',
' ','1','.','0','0','0',' ',' ',' ',' '
};
//Our device address
extern unsigned char DeviceAddress;
//Number of Transmits again
extern unsigned char NumbersOfTramsmits;
//Last Sended command
extern unsigned char PreviousCommand;
//Last Sended Data Size
extern unsigned char PreviousDataSize;
void ProcessDeviceFrame(LPMAPLEFRAME MPFrame)
{
/*
#define DeviceStatus 0x05
#define DeviceAllStatus 0x06
#define DeviceReply 0x07
#define DataTransfer 0x08
#define FunctionTypeUnknown 0xFE//Controller
#define CommandUnknown 0xFD//Controller
#define FileError 0xFB
#define LCDError 0xFA
#define ARError 0xF9
#define TransmitAgain 0xFC//Host, Controller
*/
//We receive our device address
if(DeviceAddress==0)
DeviceAddress=MapleFrame.DestAP;
//Is our maple perefirial address?
if(MapleFrame.DestAP!=DeviceAddress || DeviceAddress==0)
return;
MPFrame->DestAP=MPFrame->OriginAP;
MPFrame->OriginAP=MakeOurDeviceAddress(DeviceAddress);
switch(MPFrame->Command)
{
case DeviceRequest: //0x01
MPFrame->Command=DeviceStatus;
MPFrame->DataSize=sizeof(DeviceInformation)/4;
eeprom_read_block(MPFrame->DataLine,DeviceInformation
,sizeof(DeviceInformation));
// memcpy_P(MPFrame->DataLine,DeviceInformation,sizeof(DeviceInformation));
MapleSend(MPFrame);
break;
case AllStatusRequest: //0x02
MPFrame->Command=DeviceAllStatus;
MPFrame->DataSize=(sizeof(DeviceInformation)+sizeof(DeviceRevisionInfo))/4;
eeprom_read_block(MPFrame->DataLine,DeviceInformation,
(sizeof(DeviceInformation)+sizeof(DeviceRevisionInfo)));
// memcpy_P(MPFrame->DataLine,DeviceInformation,sizeof(DeviceInformation)+sizeof(DeviceRevisionInfo));
MapleSend(MPFrame);
break;
case DeviceReset: //0x03
MPFrame->Command=DeviceReply;
MPFrame->DataSize=0;
MapleSend(MPFrame);
//Hire we must processing "Peripheral is initialized".
break;
case DeviceKill: //0x04
//Reply for this command
MPFrame->Command=DeviceReply;
MPFrame->DataSize=0;
MapleSend(MPFrame);
//Stop interrupt processing
cli();
//And halt
sleep_enable();
sleep_cpu();
case GetCondition: //0x09
//Hire we get device status
//Hire we copy our device condition
MPFrame->Command=DataTransfer;
if(!(MPFrame->DataSize=GetDeviceCondition((LPDEVICEINFORMATION)(MPFrame->DataLine))))
MPFrame->Command=FunctionTypeUnknown;
MapleSend(MPFrame);
break;
case TransmitAgain: //0xFC
if(NumbersOfTramsmits!=0)
{
MPFrame->Command=PreviousCommand;
MPFrame->DataSize=PreviousDataSize;
MapleSend(MPFrame);
NumbersOfTramsmits--;
}
return;
case GetMediaInfo: //0x0A
case BlockRead: //0x0B
case BlockWrite: //0x0C
case SetCondition: //0x0E
case FT4Control: //0x0F
case ARControl: //0x10
case GetLastError: //0x0D
default:
MPFrame->Command=CommandUnknown;
MPFrame->DataSize=0;
MapleSend(MPFrame);
break;
}
NumbersOfTramsmits=3;
PreviousCommand=MPFrame->Command;
PreviousDataSize=MPFrame->DataSize;
}
/*
+0004 Function type 00h The function type specifies
+0005 00h the controller.
+0006 00h
+0007 01h
+0008 Read format FFh According to the controller format,
+0009 FFh the controller's data is stored. The
+000a 00h blocks to be used have been
+000b 00h declared already by the device ID.
+000c 80h
+000d 80h
+000e 80h
+000f 80h
*/
unsigned char GetDeviceCondition(LPDEVICEINFORMATION DeviceCond)
{
//be shure what host is needed data from Controller, not other device!
//==0x00000100 - Vibration pack... and others
switch(DeviceCond->FT0&PeripheralFunction)
{
case CONTROLLER:
return GetControllerCondition((LPCONTROLLERCONDITION)DeviceCond);
case KEYBOARD:
return GetKeyboardCondition((LPKEYBOARDCONDITION)DeviceCond);
case MOUSE:
return GetMouseCondition((LPMOUSECONDITION)DeviceCond);
case GUN:
break;
default:
break;
}
return 0;
}
//Hire we process controller buttons/hooks/d-pad/analog
unsigned char GetMouseCondition(LPMOUSECONDITION MouseCond)
{
//press = '0', release = '1'.
MouseCond->BTN=DEF_BUTTON|
MW_BUTTON|
MA_BUTTON|
MB_BUTTON; //Operating button data
//no overflow=0
//AOV0
//AOV1
//AOV2
MouseCond->AOV=0x0000; //Analog coordinate overflow
//
MouseCond->AC1=0x0000; //X-axis analog coordinate region
MouseCond->AC2=0x0000; //Y-axis analog coordinate region
MouseCond->AC3=0x0000; //Z-axis analog coordinate region (wheel)
MouseCond->AC4=ST_CONSTANT; //Constant (00h-02h, fixed)
MouseCond->AC5=ST_CONSTANT; //Constant (00h-02h, fixed)
MouseCond->AC6=ST_CONSTANT; //Constant (00h-02h, fixed)
MouseCond->AC7=ST_CONSTANT; //Constant (00h-02h, fixed)
MouseCond->AC8=ST_CONSTANT; //Constant (00h-02h, fixed)
return sizeof(MOUSECONDITION)/4;
}
//Hire we process controller buttons/hooks/d-pad/analog
unsigned char GetKeyboardCondition(LPKEYBOARDCONDITION KeybCond)
{
KeybCond->ChangeKeyBit=0x00;
KeybCond->LEDInformation=0x00;
memset(KeybCond->KeyScanCodeArray,0x00,0x06);
return sizeof(KEYBOARDCONDITION)/4;
}
//Hire we process controller buttons/hooks/d-pad/analog
/*
***********CONTROLLER***********
0x00 0x0F 0x06 0xFE
0b00000000 0b00001111 0b00000110 0b11111110
16,17,18,19 X,Y Ra,La,Da,Ua,St,A,B
Bit 7 6 5 4 3 2 1 0
1st Data 0 0 0 0 0 0 0 0
2nd Data 0 0 RB21RB20RB19RB18RB17RB16
3rd Data RB15RB14RB13RB12RB11RB10RB9 RB8
4th Data RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0
bit 7 6 5 4 3 2 1 0
1st Data RB7 RB6 RB5 RB4 RB3 RB2 RB1 RB0
2nd Data RB15RB14RB13RB12RB11RB10RB9 RB8
3rd Data -------------RB16--------------
4th Data -------------RB17--------------
5th Data -------------RB18--------------
6th Data -------------RB19--------------
7th Data -------------RB20--------------
8th Data -------------RB21--------------
bit 7 6 5 4 3 2 1 0
1st Data Ra La Da Ua St A B C
2nd Data Rb Lb Db Ub D X Y Z
3rd Data A17 A16 A15 A14 A13 A12 A11 A10
4th Data A27 A26 A25 A24 A23 A22 A21 A20
5th Data A37 A36 A35 A34 A33 A32 A31 A30
6th Data A47 A46 A45 A44 A43 A42 A41 A40
7th Data A57 A56 A55 A54 A53 A52 A51 A50
8th Data A67 A66 A65 A64 A63 A62 A61 A60
***********GUN***********
0x00 0x00 0x00 0xFE
0b00000000 0b00000000 0b00000000 0b11111110
Ra,La,Da,Ua,St,A,B
*/
unsigned char GetControllerCondition(LPCONTROLLERCONDITION ContCond)
{
// X Ra,La,Da,Ua,St,A,B
//0b00000000 0b00000000 0b00000100 0b11111110
ContCond->ButtonsLO=0xFF;
ContCond->ButtonsHI=0xFF;
ContCond->AR_axis=0x00;//Left Lever not pushed
ContCond->AL_axis=0x00;//Left Lever not pushed
ContCond->Xa_axis=0x80;//center
ContCond->Ya_axis=0x80;//center
ContCond->Not_used_A=0x80;
ContCond->Not_used_B=0x80;
ReadNesController(ContCond);
return sizeof(CONTROLLERCONDITION)/4;
}
//Acks all expansions slots for any devices connected
unsigned char MakeOurDeviceAddress(unsigned char DeviceAddress)
{
unsigned char ExpDevices=0;
//Hire We read Expansion devices from slots
//ExpDevices = FindExpDevices();
return ExpDevices|DeviceAddress;
}
void GetPeripheralFunctionType(void)
{
eeprom_read_block(&PeripheralFunction
,(const char *)DeviceInformation,sizeof(PeripheralFunction));
}
Добавлено позже:Есть ещё мыслищи, так что тема ещё не раскрыта.