Final SonyNEWS commit before sending device back
This commit is contained in:
		
							parent
							
								
									d85c8b56eb
								
							
						
					
					
						commit
						e3fc873cba
					
				
					 5 changed files with 38 additions and 32 deletions
				
			
		| 
						 | 
				
			
			@ -54,6 +54,7 @@ static uint8_t Bootloader_ConditionSequence[] = {1,16,6,11};
 | 
			
		|||
 | 
			
		||||
inline void macro_finishedWithBuffer(void)
 | 
			
		||||
{
 | 
			
		||||
	/* BudKeypad
 | 
			
		||||
	// Boot loader sequence state handler
 | 
			
		||||
	switch ( KeyIndex_BufferUsed )
 | 
			
		||||
	{
 | 
			
		||||
| 
						 | 
				
			
			@ -72,6 +73,7 @@ inline void macro_finishedWithBuffer(void)
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	Bootloader_KeyDetected = 0;
 | 
			
		||||
	*/
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void jumpToBootloader(void)
 | 
			
		||||
| 
						 | 
				
			
			@ -213,6 +215,7 @@ int scancodeMacro( uint8_t scanCode )
 | 
			
		|||
	}
 | 
			
		||||
	return 1;
 | 
			
		||||
	*/
 | 
			
		||||
	/* BudKeypad
 | 
			
		||||
	// Is this a bootloader sequence key?
 | 
			
		||||
	if ( !Bootloader_KeyDetected
 | 
			
		||||
	   && Bootloader_NextPositionReady
 | 
			
		||||
| 
						 | 
				
			
			@ -226,8 +229,8 @@ int scancodeMacro( uint8_t scanCode )
 | 
			
		|||
	{
 | 
			
		||||
		Bootloader_KeyDetected = 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return 1;
 | 
			
		||||
	*/
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t sendCode = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -346,7 +349,7 @@ inline void process_macros(void)
 | 
			
		|||
	keyPressBufferRead( MODIFIER_MASK, sizeof(MODIFIER_MASK), KEYINDEX_MASK );
 | 
			
		||||
 | 
			
		||||
	// Check for bootloader condition
 | 
			
		||||
	if ( Bootloader_ConditionState == sizeof( Bootloader_ConditionSequence ) )
 | 
			
		||||
		jumpToBootloader();
 | 
			
		||||
	//if ( Bootloader_ConditionState == sizeof( Bootloader_ConditionSequence ) )
 | 
			
		||||
	//	jumpToBootloader();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,9 +38,14 @@
 | 
			
		|||
// ----- Defines -----
 | 
			
		||||
 | 
			
		||||
// Pinout Defines
 | 
			
		||||
#define RESET_PORT PORTB
 | 
			
		||||
#define RESET_DDR   DDRD
 | 
			
		||||
#define RESET_PIN      0
 | 
			
		||||
#define SPKR_PORT PORTD
 | 
			
		||||
#define SPKR_DDR   DDRD
 | 
			
		||||
#define SPKR_POS      1
 | 
			
		||||
 | 
			
		||||
#define POWR_PORT PORTC
 | 
			
		||||
#define POWR_DDR   DDRC
 | 
			
		||||
#define POWR_POS      7
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// ----- Macros -----
 | 
			
		||||
| 
						 | 
				
			
			@ -50,9 +55,6 @@
 | 
			
		|||
		if ( KeyIndex_BufferUsed < KEYBOARD_BUFFER ) \
 | 
			
		||||
			KeyIndex_Buffer[KeyIndex_BufferUsed++] = byte
 | 
			
		||||
 | 
			
		||||
#define UNSET_RESET()   RESET_DDR &= ~(1 << RESET_PIN)
 | 
			
		||||
#define   SET_RESET()   RESET_DDR |=  (1 << RESET_PIN)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// ----- Variables -----
 | 
			
		||||
| 
						 | 
				
			
			@ -89,11 +91,20 @@ inline void scan_setup()
 | 
			
		|||
	// Asynchrounous USART mode
 | 
			
		||||
	UCSR1C = 0x06;
 | 
			
		||||
 | 
			
		||||
	// Set Speaker Pin to Pull-Up gives a low-volume click (XXX no other setting does, why?)
 | 
			
		||||
	SPKR_DDR  &= ~(1 << SPKR_POS);
 | 
			
		||||
	SPKR_PORT |= (1 << SPKR_POS);
 | 
			
		||||
 | 
			
		||||
	// Set Power Pin (I've traced this back to the "Power On" Switch, but I don't really know what it's for)
 | 
			
		||||
	// Configured as a Pull-up Input - This pin "can" be read as well, it will go to GND when the "Power On" switch is pressed, and will read ~5V otherwise
 | 
			
		||||
	// XXX Currently not used by the controller
 | 
			
		||||
	POWR_DDR  &= ~(1 << POWR_POS);
 | 
			
		||||
	POWR_PORT |= (1 << POWR_POS); 
 | 
			
		||||
 | 
			
		||||
	// Reset the keyboard before scanning, we might be in a wierd state
 | 
			
		||||
	scan_resetKeyboard();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Main Detection Loop
 | 
			
		||||
// Not needed for the Sony NEWS, this is just a busy loop
 | 
			
		||||
inline uint8_t scan_loop()
 | 
			
		||||
| 
						 | 
				
			
			@ -140,7 +151,7 @@ void processKeyValue( uint8_t keyValue )
 | 
			
		|||
			erro_dPrint( "Could not find key to release: ", tmpStr );
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	// Press or Repeat Rate
 | 
			
		||||
	// Press or Repeated Key
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
		// Make sure the key isn't already in the buffer
 | 
			
		||||
| 
						 | 
				
			
			@ -178,20 +189,12 @@ ISR(USART1_RX_vect)
 | 
			
		|||
 | 
			
		||||
	// Process the scancode
 | 
			
		||||
	if ( keyValue != 0x00 )
 | 
			
		||||
	processKeyValue( keyValue );
 | 
			
		||||
		processKeyValue( keyValue );
 | 
			
		||||
 | 
			
		||||
	sei(); // Re-enable Interrupts
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Send data TODO
 | 
			
		||||
//
 | 
			
		||||
// Keyboard Input Guide for Micro Switch 8304
 | 
			
		||||
// 0xBX is for LED F1,F2,Over Type,Lock
 | 
			
		||||
// 0xAX is for LED F3,F8,F9,F10
 | 
			
		||||
// 0x92 resets keyboard (LED off, echo scancode mode off)
 | 
			
		||||
// 0x9E sets echo scancode mode from (0x81 to 0xFF; translates to 0x01 to 0x7F)
 | 
			
		||||
// Other echos: 0x15~0x19 send 0x15~0x19, 0x40 sends 0x40 (as well as 0x44,0x45, 0x80)
 | 
			
		||||
// 0x8C Acks the keyboard and gets 0x70 sent back (delayed)
 | 
			
		||||
// Send data to keyboard
 | 
			
		||||
uint8_t scan_sendData( uint8_t dataPayload )
 | 
			
		||||
{
 | 
			
		||||
	// Debug
 | 
			
		||||
| 
						 | 
				
			
			@ -212,24 +215,23 @@ void scan_finishedWithBuffer( void )
 | 
			
		|||
 | 
			
		||||
// Reset/Hold keyboard TODO
 | 
			
		||||
// Warning! This will cause the keyboard to not send any data, so you can't disable with a keypress
 | 
			
		||||
// The Micro Switch 8304 has a dedicated reset line
 | 
			
		||||
void scan_lockKeyboard( void )
 | 
			
		||||
{
 | 
			
		||||
	//UNSET_RESET();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void scan_unlockKeyboard( void )
 | 
			
		||||
{
 | 
			
		||||
	//SET_RESET();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Reset Keyboard TODO
 | 
			
		||||
// Reset Keyboard
 | 
			
		||||
void scan_resetKeyboard( void )
 | 
			
		||||
{
 | 
			
		||||
	// Reset command for the 8304
 | 
			
		||||
	//scan_sendData( 0x92 );
 | 
			
		||||
 | 
			
		||||
	// Empty buffer, now that keyboard has been reset
 | 
			
		||||
	KeyIndex_BufferUsed = 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void scan_finishedWithUSBBuffer( void )
 | 
			
		||||
{
 | 
			
		||||
	return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,6 +55,7 @@ uint8_t scan_loop( void );
 | 
			
		|||
// Functions available to macro.c
 | 
			
		||||
uint8_t scan_sendData( uint8_t dataPayload );
 | 
			
		||||
 | 
			
		||||
void scan_finishedWithUSBBuffer( void );
 | 
			
		||||
void scan_finishedWithBuffer( void );
 | 
			
		||||
void scan_lockKeyboard( void );
 | 
			
		||||
void scan_unlockKeyboard( void );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -42,7 +42,7 @@ add_definitions( -I${HEAD_DIR}/Keymap )
 | 
			
		|||
#| Keymap Settings
 | 
			
		||||
add_definitions(
 | 
			
		||||
	-DMODIFIER_MASK=sonynews_ModifierMask
 | 
			
		||||
	-DKEYINDEX_MASK=sonynews_ColemakMap
 | 
			
		||||
	#-DKEYINDEX_MASK=sonynews_DefaultMap
 | 
			
		||||
	#-DKEYINDEX_MASK=sonynews_ColemakMap
 | 
			
		||||
	-DKEYINDEX_MASK=sonynews_DefaultMap
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,7 +20,7 @@
 | 
			
		|||
#| Please the {Scan,Macro,USB,Debug}/module.txt for information on the modules and how to create new ones
 | 
			
		||||
 | 
			
		||||
##| Deals with acquiring the keypress information and turning it into a key index
 | 
			
		||||
set(  ScanModule  "BudKeypad" )
 | 
			
		||||
set(  ScanModule  "SonyNEWS" )
 | 
			
		||||
 | 
			
		||||
##| Uses the key index and potentially applies special conditions to it, mapping it to a usb key code
 | 
			
		||||
set( MacroModule  "buffer"  )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue