Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static byte enter_config[]={0x01,0x43,0x00,0x01,0x00};
- static byte set_mode[]={0x01,0x44,0x00,0x01,0x03,0x00,0x00,0x00,0x00};
- static byte set_bytes_large[]={0x01,0x4F,0x00,0xFF,0xFF,0x03,0x00,0x00,0x00};
- static byte exit_config[]={0x01,0x43,0x00,0x00,0x5A,0x5A,0x5A,0x5A,0x5A};
- static byte enable_rumble[]={0x01,0x4D,0x00,0x00,0x01};
- static byte type_read[]={0x01,0x45,0x00,0x5A,0x5A,0x5A,0x5A,0x5A,0x5A};
- unsigned char PS2X::_gamepad_shiftinout (char byte) {
- unsigned char tmp = 0;
- for(unsigned char i=0;i<8;i++) {
- if(CHK(byte,i)) CMD_SET();
- else CMD_CLR();
- CLK_CLR();
- delayMicroseconds(CTRL_CLK);
- //if(DAT_CHK()) SET(tmp,i);
- if(DAT_CHK()) bitSet(tmp,i);
- CLK_SET();
- #if CTRL_CLK_HIGH
- delayMicroseconds(CTRL_CLK_HIGH);
- #endif
- }
- CMD_SET();
- delayMicroseconds(CTRL_BYTE_DELAY);
- return tmp;
- }
- void PS2X::sendCommandString(byte string[], byte len) {
- #ifdef PS2X_COM_DEBUG
- byte temp[len];
- ATT_CLR(); // low enable joystick
- delayMicroseconds(CTRL_BYTE_DELAY);
- for (int y=0; y < len; y++)
- temp[y] = _gamepad_shiftinout(string[y]);
- ATT_SET(); //high disable joystick
- delay(read_delay); //wait a few
- Serial.println("OUT:IN Configure");
- for(int i=0; i<len; i++) {
- Serial.print(string[i], HEX);
- Serial.print(":");
- Serial.print(temp[i], HEX);
- Serial.print(" ");
- }
- Serial.println("");
- #else
- ATT_CLR(); // low enable joystick
- for (int y=0; y < len; y++)
- _gamepad_shiftinout(string[y]);
- ATT_SET(); //high disable joystick
- delay(read_delay); //wait a few
- #endif
- }
- void PS2X::reconfig_gamepad(){
- sendCommandString(enter_config, sizeof(enter_config));
- sendCommandString(set_mode, sizeof(set_mode));
- if (en_Rumble)
- sendCommandString(enable_rumble, sizeof(enable_rumble));
- if (en_Pressures)
- sendCommandString(set_bytes_large, sizeof(set_bytes_large));
- sendCommandString(exit_config, sizeof(exit_config));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement