FreeJoy-Team / FreeJoy

STM32F103 USB HID game device controller with flexible configuration
GNU General Public License v3.0
726 stars 135 forks source link

4-directional Stick Switch + Encoder + Center-push button #34

Closed 0xcore closed 4 years ago

0xcore commented 4 years ago

Hi,

Does anyone know if it is possible to use with Freejoy ?

imagen imagen

https://tech.alpsalpine.com/prod/e/html/multicontrol/switch/rkjxt/rkjxt1f42001.html

I have seen that it is possible with Arduino & Teensy but I suppose it would need some modification to work with FreeJoy.

Arduino https://github.com/darjusp/test

Teensy https://www.xsimulator.net/community/threads/teensy-lc-arduino-scripts.9681

Thanks!

vostrenkov commented 4 years ago

Hi, I don't see a reason it should not work here. You dont even need external pulling resistors, bluepill provides internal pull-ups and pull-downs. Just connect terminals as ordinary buttons (Button VCC or Button GND) and set encoder inputs as Encoder A and B, buttons inputs as Button Normal or whatever you need

jieweiyang commented 4 years ago

It work as 5 buttons + 1 encoder, nothing special.

0xcore commented 4 years ago

I'm going to try it.

Thanks!

0xcore commented 4 years ago

Hi,

I don't know what happens but when I press the 4 directions stick in any of the four directions (A, B, C, D) the central push button (5) is also pressed. Pressing only the central push button (5) works as expected.

I have made the following connections:

I have made the following connections:

A, B, C, D -> Button_VCC - POV Up, Down, Right, Left 5 -> Button_VCC - Normal Button 7,8 -> Button_VCC - Encoder A, Encoder B 6,9 -> +5V 10 -> GND

vostrenkov commented 4 years ago

This is exactly what logic table from datasheet says: image

Sorry i didnt mentioned this earlier. I will add POV_Center option for buttons settings for handling this state

vostrenkov commented 4 years ago

Please check v1.6.2. POV_Center added to buttons options for support this hardware

0xfgarcia commented 4 years ago

Work like a charm. Good Job!

AndyPeacock commented 3 years ago

Hi, I'm about to try and use the same switch and its great to hear that it should work. I have some quick questions about connections though, hopefully someone can help. I'm planning to use a 4021 shift register to connect this up as I have done for all other connections. So far if I understand it correctly I have been connecting my switches between input to the shift register and ground (using these boards). So am I right in thinking that A,B,C,D, EncoderA, EncoderB and Com would all be connected to their own pin on the 4021, and Push and Encoder Com would go to one of the ground connections on the 2x8 connector?

Sorry if this isn't the right place to post this.

Thanks

vostrenkov commented 3 years ago

Right, both Com pins should be connected to system ground and signal pins to shift register's input

geologic commented 3 years ago

Sorry to hijack this post, but how about connecting 2 of these switch? At "Button Config" tab i can see Pov1 to Pov4, but only one Encoder_A and Encoder_B

AndyPeacock commented 3 years ago

I think the encoders work differently. If you just set one of your encoder hardware pins to EncoderA and the other to EncoderB for each of your switches I think that will work. I don't have my switches hooked up yet, but this is how it works for standard rotary encoders for me. So you'll endup with mapping like:

1 Pov1_U 2 Pov1_D 3 Pov1_L 4 Pov1_R 5 Pov1_C 6 EncoderA 7 EncoderB 8 Pov2_U 9 Pov2_D 10 Pov2_L 11 Pov2_R 12 Pov2_C 13 EncoderA 14 EncoderB

Once you have that setup the encoders tab seems to recognise the pairs and show them correctly.

geologic commented 3 years ago

Thanks @AndyPeacock, i'll try that