void Joystick::set_key() { static t_key key = {0, 0, 0, 0}; static t_key key2 = {0, 0, 0, 0}; // key for p2 (keyboard) static t_key key3 = {0, 0, 0, 0}; static t_key key4 = {0, 0, 0, 0}; static t_key key5 = {0, 0, 0, 0}; static t_key ckey = {0, 0, 0, 0}; static t_key ckey2 = {0, 0, 0, 0}; // key for p2 (controller) static t_key ckey3 = {0, 0, 0, 0}; static t_key ckey4 = {0, 0, 0, 0}; static t_key ckey5 = {0, 0, 0, 0}; this->arr_key_keyboard[0] = &key; this->arr_key_keyboard[1] = &key2; this->arr_key_keyboard[2] = &key3; this->arr_key_keyboard[3] = &key4; this->arr_key_keyboard[4] = &key5; this->arr_key_controller[0] = &ckey; this->arr_key_controller[1] = &ckey2; this->arr_key_controller[2] = &ckey3; this->arr_key_controller[3] = &ckey4; this->arr_key_controller[4] = &ckey5; set_key_config(); }
void Joystick::save_config( void ) { FILE *stream; char buf[128] = {0}; if ((stream = fopen(CONFIG_FILE, "w")) == NULL) return ; sprintf(buf, "%d,%d,%d,%d,%d", this->config[0], this->config[1], this->config[2], this->config[3], this->config[4]); fputs(buf, stream); fclose(stream); set_key_config(); }
bool set_config_zone (int fd) { bool result = false; if (lca_is_config_locked (fd)) return true; enum config_slots slots[CONFIG_SLOTS_NUM_SLOTS] = {slot0, slot2, slot4, slot6, slot8, slot10, slot12, slot14}; struct slot_config ** configs = build_slot_configs(); int x = 0; const uint8_t I2C_ADDR_OTP_MODE_SELECTOR_MODE [] = { 0xC0, 0x00, 0xAA, 0x00 }; const uint8_t I2C_ADDR_ETC_WORD = 0x04; uint32_t to_send = 0; memcpy (&to_send, &I2C_ADDR_OTP_MODE_SELECTOR_MODE, sizeof (to_send)); result = write4 (fd, CONFIG_ZONE, I2C_ADDR_ETC_WORD,to_send); for (x=0; x < CONFIG_SLOTS_NUM_SLOTS && result; x++) { int slot = 2 * x; result = write_slot_configs (fd, slots[x], configs[slot], configs[slot+1]); } free_slot_configs (configs); /* Set the Slot Locked and Temperature offset */ if (result) { if ((result = set_slot_locked_and_temp (fd))) { LCA_LOG (DEBUG, "slot lock config passed"); result = set_key_config (fd); } } return result; }