Rework HID data processing.

Move port handling up into XUA_Buffer_lite2() to take advantage of its select operator.  Add functions to initialise and set the HID data.
This commit is contained in:
Michael Banther
2019-10-01 17:04:13 +01:00
parent 2fb0bdfcc2
commit 17317093d5
3 changed files with 23 additions and 14 deletions

View File

@@ -883,7 +883,7 @@ void XUA_Buffer_Ep(register chanend c_aud_out,
case XUD_SetData_Select(c_hid, ep_hid, result):
{
g_hidData[0]=0;
UserReadHIDData(p_int, g_hidData);
UserReadHIDData(g_hidData);
XUD_SetReady_In(ep_hid, g_hidData, 1);
}
break;

View File

@@ -30,11 +30,12 @@
#endif
#if( 0 < HID_SIMULATE_INTERRUPTS )
#define HID_DEASSERT_COUNT 10000000
#define HID_DEASSERT_COUNT 10000
#define HID_INTERRUPT_COUNT 1000000000
#endif
void UserInitHIDData(void);
void UserReadHIDData(unsigned char hidData[ HID_DATA_SIZE ]);
void UserSetHIDData(const unsigned hidData);
#endif /* ( 0 < HID_CONTROLS ) */
void UserReadHIDData(in port p_int, unsigned char hidData[HID_DATA_SIZE]);

View File

@@ -8,20 +8,28 @@
#define HID_REPORT_INTERRUPT_ASSERTED 0x01
#define HID_REPORT_INTERRUPT_DEASSERTED 0x00
void UserReadHIDData( in port p_int, unsigned char hidData[ HID_DATA_SIZE ])
static unsigned char s_hidData;
void UserInitHIDData( void )
{
unsigned curr_val;
s_hidData = HID_REPORT_INTERRUPT_DEASSERTED;
}
p_int :> curr_val;
void UserReadHIDData( unsigned char hidData[ HID_DATA_SIZE ])
{
hidData[ 0 ] = s_hidData;
if( curr_val == NDP10X_ASSERT_LEVEL ) {
hidData[ 0 ] = HID_REPORT_INTERRUPT_ASSERTED;
} else {
hidData[ 0 ] = HID_REPORT_INTERRUPT_DEASSERTED;
for( unsigned i = 1; i < HID_DATA_SIZE; ++i ) {
hidData[ i ] = 0U;
}
}
for( unsigned idx = 1; idx < HID_DATA_SIZE; ++idx ) {
hidData[ idx ] = 0U;
void UserSetHIDData( const unsigned hidData )
{
if( hidData == NDP10X_ASSERT_LEVEL ) {
s_hidData = HID_REPORT_INTERRUPT_ASSERTED;
} else {
s_hidData = HID_REPORT_INTERRUPT_DEASSERTED;
}
}