AlexTT 489 Posted August 2, 2019 (edited) I finally had it figured out! Today my Arduino (AGAIN!?🤣) came in. Had to be the pro micro because of the USB compatible driver. Bought it for 2 bucks incl. Shipping on aliexpress. Bought me a box, momentary switches i already had tons of, and 2 rotary encoders. So, this afternoon Alex was soldering and tinkering again. I just threw some stickers on it, for show🤣 where you see buttonboxes for PS4 for 100's of dollars, mine cost: 15 euro's total. When connecting on PS Pro you need to check all USB ports. Mine had the arduino compatibility on the back port, but could be different on others. Also works on Xbox one (X) with this coding. Here you see how buttons now are adressed. No more extra controller! runs together with my F1 wheel. BOOM! I'm STOKED! Up to next project: Rebuilding my t3pa's to 2 pedal construction with better load cell pedal, F1 style and no more plastic casing. Edited August 2, 2019 by AlexTT 4 Share this post Link to post Share on other sites
AlexTT 489 Posted August 2, 2019 And yes... when my buttonbox worked, i did the moonwalk through my livingroom. OFFCOURSE! 🤪 1 Share this post Link to post Share on other sites
jrod22145 98 Posted August 2, 2019 Any chance this would work with a regular PS4? Saving up for PC components so not really looking to buy a new PS4 but would be nice to have for right now. Share this post Link to post Share on other sites
AlexTT 489 Posted August 2, 2019 Keyboard and thrustmaster t300😍😍😍 Share this post Link to post Share on other sites
AlexTT 489 Posted August 2, 2019 3 minutes ago, jrod22145 said: Any chance this would work with a regular PS4? Saving up for PC components so not really looking to buy a new PS4 but would be nice to have for right now. Should work. Do you have a regular keyboard with usb? Plug it in. If you see a keyboard icon appearing where you login with controller and stuff, it should be compatible. Better even, my buttonbox is connected through a usb hub so even that works. Share this post Link to post Share on other sites
TomAAA 447 Posted August 2, 2019 You can also just get a USB Numpad for 5 bucks does the same thing, put some stickers over the numbers to designate function 1 Share this post Link to post Share on other sites
AlexTT 489 Posted August 2, 2019 54 minutes ago, TomAAA said: You can also just get a USB Numpad for 5 bucks does the same thing, put some stickers over the numbers to designate function Tried 4 different ones, didn't work. Ps doesn't accept all those things. Plus now I can expand it how i want for example rotary encoders, or 2 way toggle switches. I can programm how long a button is pressed or and action when i release a button. Endless possibilities. Can you do that also with a numpad? Or does a numpad have encoders? When you want to adjust brake bias or diff, I'd prefer to find a rotary blind and know where to turn. With a keypad you have to look where the button is, which can result in collisions. Yes you learn to do blind, but with encoders you don't need to learn where they are, they're there and just turn em. so for 10 bucks more, i have 1001 more capabilities en possibilies than a numpad, and can programm it tailormade. easy choice. Share this post Link to post Share on other sites
AlexTT 489 Posted August 2, 2019 Oh plus i wear gloves when racing, because my grips have a new coating which in combination with gloves is exxelent. So then those tiny keypad buttons are not so easy as a custom buttonbox built for those purposes. Nothing beats custom😎 1 Share this post Link to post Share on other sites
SIMRACER123 355 Posted August 2, 2019 (edited) 9 minutes ago, AlexTT said: Oh plus i wear gloves when racing, because my grips have a new coating which in combination with gloves is exxelent. So then those tiny keypad buttons are not so easy as a custom buttonbox built for those purposes. Nothing beats custom😎 Racing boots and a helmet too i imagine! Edited August 2, 2019 by SIMRACER123 1 Share this post Link to post Share on other sites
AlexTT 489 Posted August 2, 2019 15 minutes ago, SIMRACER123 said: Racing boots and a helmet too i imagine! omg he's actually trying to be funny! Try harder. Gloves are for grip and to not wear off the coating on the grips einstein. Sweat and other dirt from your hands is terrible for grips. why do you think manufacters who use alcantara grips advise gloves? Unless you want to have your steeringwheel look like trash in a year. Share this post Link to post Share on other sites
SIMRACER123 355 Posted August 2, 2019 2 minutes ago, AlexTT said: omg he's actually trying to be funny! You mean she. Someone is a little assumptious isn't one. Share this post Link to post Share on other sites
AlexTT 489 Posted August 2, 2019 31 minutes ago, SIMRACER123 said: You mean she. Someone is a little assumptious isn't one. oooeh, do i put my impressed face on? Can you stop bothering me and/or my topics. thank you go look for attention somewhere else instead of following and reacting to my every post. stalker. Share this post Link to post Share on other sites
SIMRACER123 355 Posted August 2, 2019 36 minutes ago, AlexTT said: oooeh, do i put my impressed face on? Can you stop bothering me and/or my topics. thank you go look for attention somewhere else instead of following and reacting to my every post. stalker. Alex i assume you are unfamiliar with what a forum is. A forum is "medium where ideas and views on a particular issue can be exchanged." Therefore if you post and i wish to reply i will do so. A forum is not for you to post your view and only people who agree with you can respond. Share this post Link to post Share on other sites
AlexTT 489 Posted August 4, 2019 2 hours ago, Jajb said: @AlexTT How did you get the rotary encoders to work with the console? With them being incremental and changeable direction. Is this something to do with how you program the Arduino Correct. For the buttons I used a 3x3 buttonmatrix and the encoders have their own coding which makes them send one letter clockwise and another counterclockwise no matter how mich you turn them. Share this post Link to post Share on other sites
AlexTT 489 Posted August 4, 2019 1 hour ago, Jajb said: @AlexTT Any chance you have the coding for the rotary encoders? Im useless at coding lol i'll give you the whole coding. It's also not mine, but free to use. Encoders are connected to TX and RX / 2 and 3/ and so on. There are 4 encoders programmed. the other pins are used in a 5x5 button matrix. Remember that you must use an Arduino LEONARDO or Pro MICRO. These have the special USB HID controller chip which makes it work on PS4/Xbox. //BUTTON BOX //USE w ProMicro //Tested in WIN10 + Assetto Corsa //AMSTUDIO //20.8.17 //Modified by Dave Pike on Wed 19 June 2019 to add support for Xbox / PS4 using keyboard.h //Tested on Xbox One X with Project Cars 2 #include <Keypad.h> #include <Keyboard.h> #define ENABLE_PULLUPS #define NUMROTARIES 4 #define NUMBUTTONS 24 #define NUMROWS 5 #define NUMCOLS 5 char keys[NUMROWS][NUMCOLS] = { {'1','2','3','4','5'}, {'6','7','8','9','0'}, {'a','b','c','d','e'}, {'f','g','h','i','j'}, {'k','l','m','n','o'}, }; struct rotarykeysdef { byte pin1; byte pin2; char ccwchar; char cwchar; volatile unsigned char state; }; rotarykeysdef rotarykeys[NUMROTARIES] { {0,1,'p','q',0}, {2,3,'r','s',0}, {4,5,'t','u',0}, {6,7,'v','w',0}, }; #define DIR_CCW 0x10 #define DIR_CW 0x20 #define R_START 0x0 #ifdef HALF_STEP #define R_CCW_BEGIN 0x1 #define R_CW_BEGIN 0x2 #define R_START_M 0x3 #define R_CW_BEGIN_M 0x4 #define R_CCW_BEGIN_M 0x5 const unsigned char ttable[6][4] = { // R_START (00) {R_START_M, R_CW_BEGIN, R_CCW_BEGIN, R_START}, // R_CCW_BEGIN {R_START_M | DIR_CCW, R_START, R_CCW_BEGIN, R_START}, // R_CW_BEGIN {R_START_M | DIR_CW, R_CW_BEGIN, R_START, R_START}, // R_START_M (11) {R_START_M, R_CCW_BEGIN_M, R_CW_BEGIN_M, R_START}, // R_CW_BEGIN_M {R_START_M, R_START_M, R_CW_BEGIN_M, R_START | DIR_CW}, // R_CCW_BEGIN_M {R_START_M, R_CCW_BEGIN_M, R_START_M, R_START | DIR_CCW}, }; #else #define R_CW_FINAL 0x1 #define R_CW_BEGIN 0x2 #define R_CW_NEXT 0x3 #define R_CCW_BEGIN 0x4 #define R_CCW_FINAL 0x5 #define R_CCW_NEXT 0x6 const unsigned char ttable[7][4] = { // R_START {R_START, R_CW_BEGIN, R_CCW_BEGIN, R_START}, // R_CW_FINAL {R_CW_NEXT, R_START, R_CW_FINAL, R_START | DIR_CW}, // R_CW_BEGIN {R_CW_NEXT, R_CW_BEGIN, R_START, R_START}, // R_CW_NEXT {R_CW_NEXT, R_CW_BEGIN, R_CW_FINAL, R_START}, // R_CCW_BEGIN {R_CCW_NEXT, R_START, R_CCW_BEGIN, R_START}, // R_CCW_FINAL {R_CCW_NEXT, R_CCW_FINAL, R_START, R_START | DIR_CCW}, // R_CCW_NEXT {R_CCW_NEXT, R_CCW_FINAL, R_CCW_BEGIN, R_START}, }; #endif byte rowPins[NUMROWS] = {21,20,19,18,15}; byte colPins[NUMCOLS] = {14,16,10,9,8}; Keypad buttbx = Keypad( makeKeymap(keys), rowPins, colPins, NUMROWS, NUMCOLS); void setup() { rotary_init(); } void loop() { CheckAllEncoders(); CheckAllButtons(); } void CheckAllButtons(void) { if (buttbx.getKeys()) { for (int i=0; i<LIST_MAX; i++) { if ( buttbx.key[i].stateChanged ) { switch (buttbx.key[i].kstate) { case PRESSED: Keyboard.press(buttbx.key[i].kchar); break; case HOLD: break; case RELEASED: Keyboard.release(buttbx.key[i].kchar); break; case IDLE: break; } } } } } void rotary_init() { for (int i=0;i<NUMROTARIES;i++) { pinMode(rotarykeys[i].pin1, INPUT); pinMode(rotarykeys[i].pin2, INPUT); #ifdef ENABLE_PULLUPS digitalWrite(rotarykeys[i].pin1, HIGH); digitalWrite(rotarykeys[i].pin2, HIGH); #endif } } unsigned char rotary_process(int _i) { unsigned char pinstate = (digitalRead(rotarykeys[_i].pin2) << 1) | digitalRead(rotarykeys[_i].pin1); rotarykeys[_i].state = ttable[rotarykeys[_i].state & 0xf][pinstate]; return (rotarykeys[_i].state & 0x30); } void CheckAllEncoders(void) { for (int i=0;i<NUMROTARIES;i++) { unsigned char result = rotary_process(i); if (result == DIR_CCW) { Keyboard.press(rotarykeys[i].ccwchar); delay(50); Keyboard.release(rotarykeys[i].ccwchar); }; if (result == DIR_CW) { Keyboard.press(rotarykeys[i].cwchar); delay(50); Keyboard.release(rotarykeys[i].cwchar); }; } } Share this post Link to post Share on other sites
Cptorres 0 Posted May 30 On 8/4/2019 at 9:33 AM, AlexTT said: i'll give you the whole coding. It's also not mine, but free to use. Encoders are connected to TX and RX / 2 and 3/ and so on. There are 4 encoders programmed. the other pins are used in a 5x5 button matrix. Remember that you must use an Arduino LEONARDO or Pro MICRO. These have the special USB HID controller chip which makes it work on PS4/Xbox. //BUTTON BOX //USE w ProMicro //Tested in WIN10 + Assetto Corsa //AMSTUDIO //20.8.17 //Modified by Dave Pike on Wed 19 June 2019 to add support for Xbox / PS4 using keyboard.h //Tested on Xbox One X with Project Cars 2 #include <Keypad.h> #include <Keyboard.h> #define ENABLE_PULLUPS #define NUMROTARIES 4 #define NUMBUTTONS 24 #define NUMROWS 5 #define NUMCOLS 5 char keys[NUMROWS][NUMCOLS] = { {'1','2','3','4','5'}, {'6','7','8','9','0'}, {'a','b','c','d','e'}, {'f','g','h','i','j'}, {'k','l','m','n','o'}, }; struct rotarykeysdef { byte pin1; byte pin2; char ccwchar; char cwchar; volatile unsigned char state; }; rotarykeysdef rotarykeys[NUMROTARIES] { {0,1,'p','q',0}, {2,3,'r','s',0}, {4,5,'t','u',0}, {6,7,'v','w',0}, }; #define DIR_CCW 0x10 #define DIR_CW 0x20 #define R_START 0x0 #ifdef HALF_STEP #define R_CCW_BEGIN 0x1 #define R_CW_BEGIN 0x2 #define R_START_M 0x3 #define R_CW_BEGIN_M 0x4 #define R_CCW_BEGIN_M 0x5 const unsigned char ttable[6][4] = { // R_START (00) {R_START_M, R_CW_BEGIN, R_CCW_BEGIN, R_START}, // R_CCW_BEGIN {R_START_M | DIR_CCW, R_START, R_CCW_BEGIN, R_START}, // R_CW_BEGIN {R_START_M | DIR_CW, R_CW_BEGIN, R_START, R_START}, // R_START_M (11) {R_START_M, R_CCW_BEGIN_M, R_CW_BEGIN_M, R_START}, // R_CW_BEGIN_M {R_START_M, R_START_M, R_CW_BEGIN_M, R_START | DIR_CW}, // R_CCW_BEGIN_M {R_START_M, R_CCW_BEGIN_M, R_START_M, R_START | DIR_CCW}, }; #else #define R_CW_FINAL 0x1 #define R_CW_BEGIN 0x2 #define R_CW_NEXT 0x3 #define R_CCW_BEGIN 0x4 #define R_CCW_FINAL 0x5 #define R_CCW_NEXT 0x6 const unsigned char ttable[7][4] = { // R_START {R_START, R_CW_BEGIN, R_CCW_BEGIN, R_START}, // R_CW_FINAL {R_CW_NEXT, R_START, R_CW_FINAL, R_START | DIR_CW}, // R_CW_BEGIN {R_CW_NEXT, R_CW_BEGIN, R_START, R_START}, // R_CW_NEXT {R_CW_NEXT, R_CW_BEGIN, R_CW_FINAL, R_START}, // R_CCW_BEGIN {R_CCW_NEXT, R_START, R_CCW_BEGIN, R_START}, // R_CCW_FINAL {R_CCW_NEXT, R_CCW_FINAL, R_START, R_START | DIR_CCW}, // R_CCW_NEXT {R_CCW_NEXT, R_CCW_FINAL, R_CCW_BEGIN, R_START}, }; #endif byte rowPins[NUMROWS] = {21,20,19,18,15}; byte colPins[NUMCOLS] = {14,16,10,9,8}; Keypad buttbx = Keypad( makeKeymap(keys), rowPins, colPins, NUMROWS, NUMCOLS); void setup() { rotary_init(); } void loop() { CheckAllEncoders(); CheckAllButtons(); } void CheckAllButtons(void) { if (buttbx.getKeys()) { for (int i=0; i<LIST_MAX; i++) { if ( buttbx.key[i].stateChanged ) { switch (buttbx.key[i].kstate) { case PRESSED: Keyboard.press(buttbx.key[i].kchar); break; case HOLD: break; case RELEASED: Keyboard.release(buttbx.key[i].kchar); break; case IDLE: break; } } } } } void rotary_init() { for (int i=0;i<NUMROTARIES;i++) { pinMode(rotarykeys[i].pin1, INPUT); pinMode(rotarykeys[i].pin2, INPUT); #ifdef ENABLE_PULLUPS digitalWrite(rotarykeys[i].pin1, HIGH); digitalWrite(rotarykeys[i].pin2, HIGH); #endif } } unsigned char rotary_process(int _i) { unsigned char pinstate = (digitalRead(rotarykeys[_i].pin2) << 1) | digitalRead(rotarykeys[_i].pin1); rotarykeys[_i].state = ttable[rotarykeys[_i].state & 0xf][pinstate]; return (rotarykeys[_i].state & 0x30); } void CheckAllEncoders(void) { for (int i=0;i<NUMROTARIES;i++) { unsigned char result = rotary_process(i); if (result == DIR_CCW) { Keyboard.press(rotarykeys[i].ccwchar); delay(50); Keyboard.release(rotarykeys[i].ccwchar); }; if (result == DIR_CW) { Keyboard.press(rotarykeys[i].cwchar); delay(50); Keyboard.release(rotarykeys[i].cwchar); }; } } Tried using your modified code for use on XBOX one could not get it to work. Trying to use it with the amstudio diy 32 function button box. Everything shows that it's working under testing in Windows. Possibly wrong board selected during set-up? I choose Arduino micro board since pro micro was not a selectable option. Any help would be greatly appreciated! Share this post Link to post Share on other sites
Cptorres 0 Posted May 30 Nevermind it all boiled down to having the wrong board selected. Didn't know that I had to add different board types under the manage board tab. Blame it on ignorance as this was my first Arduino project ever. Works flawlessly now, thank you for sharing the code btw!!! Share this post Link to post Share on other sites
KennyOneFive 0 Posted July 30 I'm struggling with this I've built the AMSTUDIO box. I used his code and works with PC But I want to use on PS4 so I've copied the above code and changed the board to Leonardo compiled and uploaded. The PS4 recognizes the Arduino as a keyboard comes up on screen. But I can't assign buttons in Project cars 2. Please help Thanks Share this post Link to post Share on other sites