Just put 2 items of the same type, and it will combine them in a new item of lower quality.
Not too sure about what governs the quality of the new item. Could be player's stat, mathemathical median value, luck, I am not sure.
Actually I had a look at the code and it seems that the combined quality value of the new items should be at least 4 point lower than the best quality item put in,