More buttons ? -> Custom DS4 snap-on device
Posted: Sun Jul 23, 2017 7:34 pm
Hi,
* Update : Added all files for printing, sourcecode and instructions to thingiverse
I always wanted some more buttons on the DS4 controller to use them to trigger special actions in scripts (combos/adjustments/..). Finding out about the teensy boards by another users post I got an idea how to do it.
Finally, here is a first fully working version of my very own snap-on device for the DS4 controller of the PS4.
It features a teensy 3.2 board with a 0.96" oled (i2c) display and 15 additional buttons,
3 around each analog-stick and 4 on the backside to be triggers by flexing/stretching the middle finger (I only use the index fingers for the front buttons L1/L2 R1/R2) and 5 around the oled display.
I've created this design in blender to test the my ideas and produce the needed file for the 3d printer.
I have printed most of the parts with petg and 50% infill (purple). The button caps are printed with pla and 50% infill (black), only the top rear buttons are petg at the moment because I was to lazy to change the material.
I would have used black petg for the buttons but I had none around.
Everything works at the moment, but I will have to use it for some time to be sure the design is stable enough.
ToDo:
- Adding bluetooth support when the T2 bluetooth module is available
- Output of variables/infos by scripts on the screen
Here is a short video with information and the added oled screen:
I can now easily switch between profiles (currently 4, can add a lot more) and edit them:
Changing to output a button as any controller button or key press without having to restart or connect it to a pc.
The profiles and configuration are stored on the teensy's permanent storage.
Here are some screenshots/photos:
Blender3d :
Photos of the attached device:
Here is the T2 code I have used to test if everything works and get recognized correctly be the Titan Two, I was almost shocked that this works like a charm. Meaning the Titan Two is more awesome than I already thought ;-)
* Update : Added all files for printing, sourcecode and instructions to thingiverse
I always wanted some more buttons on the DS4 controller to use them to trigger special actions in scripts (combos/adjustments/..). Finding out about the teensy boards by another users post I got an idea how to do it.
Finally, here is a first fully working version of my very own snap-on device for the DS4 controller of the PS4.
It features a teensy 3.2 board with a 0.96" oled (i2c) display and 15 additional buttons,
3 around each analog-stick and 4 on the backside to be triggers by flexing/stretching the middle finger (I only use the index fingers for the front buttons L1/L2 R1/R2) and 5 around the oled display.
I've created this design in blender to test the my ideas and produce the needed file for the 3d printer.
I have printed most of the parts with petg and 50% infill (purple). The button caps are printed with pla and 50% infill (black), only the top rear buttons are petg at the moment because I was to lazy to change the material.
I would have used black petg for the buttons but I had none around.
Everything works at the moment, but I will have to use it for some time to be sure the design is stable enough.
ToDo:
- Adding bluetooth support when the T2 bluetooth module is available
- Output of variables/infos by scripts on the screen
Here is a short video with information and the added oled screen:
I can now easily switch between profiles (currently 4, can add a lot more) and edit them:
Changing to output a button as any controller button or key press without having to restart or connect it to a pc.
The profiles and configuration are stored on the teensy's permanent storage.
Here are some screenshots/photos:
Blender3d :
Photos of the attached device:
Here is the T2 code I have used to test if everything works and get recognized correctly be the Titan Two, I was almost shocked that this works like a charm. Meaning the Titan Two is more awesome than I already thought ;-)
- Code: Select all
#pragma METAINFO("Snap On - Test", 1, 0, "Scachi")
#include <keyboard.gph>
#define KEYS_TO_MONITOR 15
const uint8 keys_to_monitor[KEYS_TO_MONITOR] = {
KEY_A, KEY_B, KEY_C, KEY_D, KEY_E,
KEY_F, KEY_G, KEY_H, KEY_I, KEY_J,
KEY_K, KEY_L, KEY_M, KEY_N, KEY_O,
};
bool monitor_previous[KEYS_TO_MONITOR];
uint32 monitor_time_active[KEYS_TO_MONITOR];
uint32 monitor_time_release[KEYS_TO_MONITOR];
int k;
main {
for(k = 0; k < KEYS_TO_MONITOR; ++k) {
if(key_status(keys_to_monitor[k]) != monitor_previous[k]) {
if(monitor_previous[k]) {
monitor_time_release[k] = system_time();
printf("key event release : %d : KEY_%C",keys_to_monitor[k],keys_to_monitor[k]+61);
} else {
monitor_time_active[k] = system_time();
printf("key event active : %d : KEY_%C",keys_to_monitor[k],keys_to_monitor[k]+61);
}
}
}
btn_events();
for(k = 0; k < KEYS_TO_MONITOR; ++k) {
monitor_previous[k] = key_status(keys_to_monitor[k]);
}
}
void btn_events() {
uint8 i;
for(i=BUTTON_1; i<=BUTTON_21; ++i) {
if ( event_active(i) ) mprintf("btn event active : BUTTON_%d",i+1);
if ( event_release(i) ) mprintf("btn event release : BUTTON_%d",i+1);
}
}
uint8 key_idx(uint8 key) {
for(k = 0; k < KEYS_TO_MONITOR; ++k) {
if(keys_to_monitor[k] == key) {
return(k);
}
}
return(0);
}
#define key_is_active(k) key_status(k)
#define key_is_release(k) (!key_status(k))
uint32 key_time_active(uint8 key) {
return(system_time() - monitor_time_active[key_idx(key)]);
}
uint32 key_time_release(uint8 key) {
return(system_time() - monitor_time_release[key_idx(key)]);
}
bool key_event_active(uint8 key) {
return(key_status(key) && !monitor_previous[key_idx(key)]);
}
bool key_event_release(uint8 key) {
return(!key_status(key) && monitor_previous[key_idx(key)]);
}
bool key_check_active(uint8 key, uint32 ms) {
return(key_status(key) && key_time_active(key) >= ms);
}
bool key_check_release(uint8 key, uint32 ms) {
return(!key_status(key) && key_time_release(key) >= ms);
}
void mprintf(char *text,uint8 Btn) {
static uint32 last = 0;
if ( last < system_time() ) {
printf(text,Btn);
last = system_time() + 200;
}
}