Changeset 0ca7286 in mainline for uspace/srv/hid/input/generic/gsp.c
- Timestamp:
- 2012-07-21T11:19:27Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2732c94
- Parents:
- 1c1da4b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/generic/gsp.c
r1c1da4b r0ca7286 54 54 #include <stdio.h> 55 55 56 #define TRANS_TABLE_CHAINS 25657 58 56 /* 59 57 * Hash table operations for the transition function. 60 58 */ 61 59 62 static hash_index_t trans_op_hash(unsigned long key[]); 63 static int trans_op_compare(unsigned long key[], hash_count_t keys, 64 link_t *item); 65 static void trans_op_remove_callback(link_t *item); 66 67 static hash_table_operations_t trans_ops = { 60 static size_t trans_op_hash(const link_t *item); 61 static size_t trans_op_key_hash(unsigned long key[]); 62 static bool trans_op_match(unsigned long key[], size_t keys, const link_t *item); 63 64 static hash_table_ops_t trans_ops = { 68 65 .hash = trans_op_hash, 69 .compare = trans_op_compare, 70 .remove_callback = trans_op_remove_callback 66 .key_hash = trans_op_key_hash, 67 .match = trans_op_match, 68 .equal = 0, 69 .remove_callback = 0 71 70 }; 72 71 … … 75 74 static gsp_trans_t *trans_new(void); 76 75 77 /** Initiali se scancode parser. */76 /** Initialize scancode parser. */ 78 77 void gsp_init(gsp_t *p) 79 78 { 80 79 p->states = 1; 81 hash_table_create(&p->trans, TRANS_TABLE_CHAINS, 2, &trans_ops);80 hash_table_create(&p->trans, 0, 2, &trans_ops); 82 81 } 83 82 … … 242 241 static void trans_insert(gsp_t *p, gsp_trans_t *t) 243 242 { 244 unsigned long key[2]; 245 246 key[0] = t->old_state; 247 key[1] = t->input; 248 249 hash_table_insert(&p->trans, key, &t->link); 243 hash_table_insert(&p->trans, &t->link); 250 244 } 251 245 … … 268 262 */ 269 263 270 static hash_index_t trans_op_hash(unsigned long key[]) 271 { 272 return (key[0] * 17 + key[1]) % TRANS_TABLE_CHAINS; 273 } 274 275 static int trans_op_compare(unsigned long key[], hash_count_t keys, 276 link_t *item) 277 { 278 gsp_trans_t *t; 279 280 t = hash_table_get_instance(item, gsp_trans_t, link); 264 static size_t trans_op_key_hash(unsigned long key[]) 265 { 266 return (key[0] * 17 + key[1]); 267 } 268 269 static size_t trans_op_hash(const link_t *item) 270 { 271 gsp_trans_t *t = hash_table_get_instance(item, gsp_trans_t, link); 272 unsigned long key[] = { 273 t->old_state, 274 t->input 275 }; 276 277 return trans_op_key_hash(key); 278 } 279 280 static bool trans_op_match(unsigned long key[], size_t keys, const link_t *item) 281 { 282 gsp_trans_t *t = hash_table_get_instance(item, gsp_trans_t, link); 281 283 return ((key[0] == (unsigned long) t->old_state) 282 284 && (key[1] == (unsigned long) t->input)); 283 }284 285 static void trans_op_remove_callback(link_t *item)286 {287 285 } 288 286
Note:
See TracChangeset
for help on using the changeset viewer.