#NEWLINE# def __prepare_raw_data( self ) : #NEWLINE# #INDENT# 'Format internal __raw_data storage according to usages setting' #NEWLINE# if ( not self . __hid_object . ptr_preparsed_data ) : #NEWLINE# #INDENT# raise HIDError ( 'HID object close or unable to request pre parsed report data' ) #NEWLINE# #UNINDENT# self . __alloc_raw_data ( ) #NEWLINE# try : #NEWLINE# #INDENT# HidStatus ( hid_dll . HidP_InitializeReportForID ( self . __report_kind , self . __report_id , self . __hid_object . ptr_preparsed_data , byref ( self . __raw_data ) , self . __raw_report_size ) ) #NEWLINE# #UNINDENT# except HIDError : #NEWLINE# #INDENT# self . __raw_data [ 0 ] = self . __report_id #NEWLINE# #UNINDENT# if ( not self . __usage_data_list ) : #NEWLINE# #INDENT# max_items = hid_dll . HidP_MaxDataListLength ( self . __report_kind , self . __hid_object . ptr_preparsed_data ) #NEWLINE# if ( not max_items ) : #NEWLINE# #INDENT# raise HIDError ( 'Internal error while requesting usage length' ) #NEWLINE# #UNINDENT# data_list_type = ( winapi . HIDP_DATA * max_items ) #NEWLINE# self . __usage_data_list = data_list_type ( ) #NEWLINE# #UNINDENT# data_list = self . __usage_data_list #NEWLINE# n_total_usages = 0 #NEWLINE# single_usage = USAGE ( ) #NEWLINE# single_usage_len = c_ulong ( ) #NEWLINE# for ( data_index , report_item ) in self . __idx_items . items ( ) : #NEWLINE# #INDENT# if ( ( not report_item . is_value_array ( ) ) and ( report_item . value != None ) ) : #NEWLINE# #INDENT# if ( report_item . is_button ( ) and report_item . value ) : #NEWLINE# #INDENT# single_usage . value = report_item . usage_id #NEWLINE# single_usage_len . value = 1 #NEWLINE# HidStatus ( hid_dll . HidP_SetUsages ( self . __report_kind , report_item . page_id , 0 , byref ( single_usage ) , byref ( single_usage_len ) , self . __hid_object . ptr_preparsed_data , byref ( self . __raw_data ) , self . __raw_report_size ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( report_item . is_value ( ) and ( not report_item . is_value_array ( ) ) ) : #NEWLINE# #INDENT# data_list [ n_total_usages ] . value . raw_value = report_item . value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# data_list [ n_total_usages ] . reserved = 0 #NEWLINE# data_list [ n_total_usages ] . data_index = data_index #NEWLINE# n_total_usages += 1 #NEWLINE# #UNINDENT# #UNINDENT# if n_total_usages : #NEWLINE# #INDENT# usage_len = c_ulong ( n_total_usages ) #NEWLINE# HidStatus ( hid_dll . HidP_SetData ( self . __report_kind , byref ( data_list ) , byref ( usage_len ) , self . __hid_object . ptr_preparsed_data , byref ( self . __raw_data ) , self . __raw_report_size ) ) #NEWLINE# #UNINDENT# for report_item in self . __value_array_items : #NEWLINE# #INDENT# HidStatus ( hid_dll . HidP_SetUsageValueArray ( self . __report_kind , report_item . page_id , 0 , report_item . usage_id , byref ( report_item . value_array ) , len ( report_item . value_array ) , self . __hid_object . ptr_preparsed_data , byref ( self . __raw_data ) , len ( self . __raw_data ) ) )