NAME
XGetDeviceKeyMapping, XChangeDeviceKeyMapping - query or change device key mappings
SYNTAX
iinntt XXCChhaannggeeDDeevviicceeKKeeyyMMaappppiinngg((DDiissppllaayy **_d_i_s_p_l_a_y,, XXDDeevviiccee
**_d_e_v_i_c_e,, iinntt _f_i_r_s_t___k_e_y_c_o_d_e,, iinntt _k_e_y_s_y_m_s___p_e_r___k_e_y_c_o_d_e,,
KKeeyySSyymm **_k_e_y_s_y_m_s,, iinntt _k_e_y_c_o_d_e___c_o_u_n_t));;
KKeeyySSyymm **XXGGeettDDeevviicceeKKeeyyMMaappppiinngg((DDiissppllaayy **_d_i_s_p_l_a_y,, XXDDeevviiccee
**_d_e_v_i_c_e,, KKeeyyCCooddee _f_i_r_s_t___k_e_y_c_o_d_e,, iinntt _k_e_y_c_o_d_e___c_o_u_n_t,, iinntt
**_k_e_y_s_y_m_s___p_e_r___k_e_y_c_o_d_e___r_e_t_u_r_n));;
_<_h_3 _i_d_=_"_A_R_G_U_M_E_N_T_S_"_> _A_R_G_U_M_E_N_T_S _<_/_h_3_>
_<_d_l _c_o_m_p_a_c_t_>
_<_d_t_>
_<_i_>_d_i_s_p_l_a_y_<_/_i_>
_<_d_d_>
_S_p_e_c_i_f_i_e_s _t_h_e _c_o_n_n_e_c_t_i_o_n _t_o _t_h_e _X _s_e_r_v_e_r_.
_<_d_t_>
_<_i_>_d_e_v_i_c_e_<_/_i_>
_<_d_d_>
_S_p_e_c_i_f_i_e_s _t_h_e _d_e_v_i_c_e _w_h_o_s_e _k_e_y _m_a_p_p_i_n_g _i_s _t_o _b_e _q_u_e_r_i_e_d _o_r _m_o_d_i_f_i_e_d_.
_<_d_t_>
_<_i_>_f_i_r_s_t___k_e_y_c_o_d_e_<_/_i_>
_<_d_d_>
_S_p_e_c_i_f_i_e_s _t_h_e _f_i_r_s_t _K_e_y_C_o_d_e _t_o _b_e _r_e_t_u_r_n_e_d_.
_<_d_t_>
_<_i_>_k_e_y_c_o_d_e___c_o_u_n_t_<_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