Skip to content

Commit

Permalink
Fixed offset calculation for wide keys
Browse files Browse the repository at this point in the history
  • Loading branch information
univrsal committed Sep 5, 2018
1 parent 45a5885 commit df054d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion sources/input-history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ obs_properties_t * get_properties_for_history(void * data)
obs_property_list_add_int(mode_list, T_OVERLAY_MODE_TEXT, 0);
obs_property_list_add_int(mode_list, T_OVERLAY_MODE_ICON, 1);
obs_property_set_modified_callback(mode_list, mode_changed);
blog(LOG_INFO, "ADDED HISTORY MODE LIST");

// Key name file
std::string filter_img = util_file_filter(T_FILTER_IMAGE_FILES, "*.jpg *.png *.bmp");
std::string filter_text = util_file_filter(T_FILTER_TEXT_FILES, "*.ini");
Expand Down
14 changes: 10 additions & 4 deletions sources/input-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ inline void InputSource::Render(gs_effect_t *effect)
y = m_layout.m_btn_h * k->row + (m_layout.m_key_space_v * k->row);
draw_key(effect, k, x, y);
}


}
else if (m_layout.m_type == TYPE_MOUSE)
{
Expand Down Expand Up @@ -291,8 +293,8 @@ void InputSource::load_layout()
k.texture_v = (uint16_t) (v_cord - 1);
tempw = util_read_int(key_width);
temph = util_read_int(key_height);
k.w = tempw * m_layout.m_btn_w;
k.h = temph * m_layout.m_btn_h;
k.w = tempw * m_layout.m_btn_w + m_layout.m_key_space_h * (tempw - 1);
k.h = temph * m_layout.m_btn_h + m_layout.m_key_space_v * (temph - 1);
k.m_key_code = util_read_hex(key_order);
k.m_pressed = false;
k.row = util_read_int(key_row);
Expand All @@ -302,6 +304,7 @@ void InputSource::load_layout()
{
k.x_offset = (uint16_t)
((k.w + m_layout.m_key_space_h * (tempw - 1)) / 2 - k.w / 2);
k.w -= k.x_offset;
index += tempw;
}
else
Expand All @@ -311,12 +314,12 @@ void InputSource::load_layout()
}

m_layout.m_keys.emplace_back(k);
u_cord += k.w + 3;
u_cord += tempw * m_layout.m_btn_w + (tempw * 3);
}

m_layout.m_h = m_layout.m_rows * m_layout.m_btn_h + m_layout.m_key_space_v * m_layout.m_rows;
m_layout.m_w = (m_layout.m_cols * m_layout.m_btn_w + m_layout.m_key_space_h *
(m_layout.m_cols - 1));
(m_layout.m_cols - 1));
}
else if (m_layout.m_type == TYPE_MOUSE)
{
Expand Down Expand Up @@ -536,7 +539,10 @@ void InputSource::load_layout()
m_layout.m_is_loaded = false;
}
}

#ifndef _DEBUG
if (cfg->get_bool("debug"))
#endif
{
blog(LOG_INFO, "------ input-overlay DEBUG");
cfg->dump_structure();
Expand Down

0 comments on commit df054d3

Please sign in to comment.