Close
0%
0%

F.P.S: Foot Presto Switch

Pedal Switch for playing FPS games

Similar projects worth following
This project provides an USB keyboard emulator to be activated by feet either individually or simultaneously.
It is based on a DigisPark board with updated DigiKeyboard.h library.

DigiKeyboard_6keys.h

Digikeyboard.h modified to allow up to 6 simultaneous keypresses and renamed

x-chdr - 19.10 kB - 05/25/2019 at 01:19

Download

  • Building a Single-Switch spinoff version

    danjovic03/23/2016 at 02:51 0 comments

    As mentioned in previous log I have built a spinoff version of the project. Here are the details:

    Only 3 components were used to built the unit (besides the footswitch itself as well as the USB cable).

    • A Digispark Clone
    • A P10 jack
    • A small box

    The plastic flanges were trimmed and a hole was made for the P10 jack

    Then another hole was made on the opposite side of the box for the USB connector. The board was attached to the bottom cover of the box using two threaded screws.

    The plastic spacers were trimmed to match the height of the board with the window for the USB connector.

    The Jack was then wired to the board. Since the switch is Normally Closed a bridge wire was used to keep the wires short circuited when the plug is not inserted.

    The firmware was then uploaded and the pedal was tested using a web application from Microsoft from a page about keyboard ghosting (very interesting by the way).

    A short video is shown here

  • Using NC switches

    danjovic03/23/2016 at 02:07 0 comments

    While developing a spinoff version using an electric keyboard footswitch I found that such footswitch is normaly closed, and opens when you step over it.

    No problem. it is simply a matter of changing a compare value.

      if ((digitalRead(_Pin_Left_footswitch) == 0))   footkeys |= (1 << _Pin_Left_footswitch);
      if ((digitalRead(_Pin_Middle_footswitch) == 0)) footkeys |= (1 << _Pin_Middle_footswitch);
      if ((digitalRead(_Pin_Right_footswitch) == 1))  footkeys |= (1 << _Pin_Right_footswitch); // use a NC contact

  • Running in Digispark

    danjovic03/23/2016 at 00:41 0 comments

    The first tests have been performed using the #SILSpark board which has no pulldowns or pullups in pin 1 (PB1), but when using digispark it is necessary to change the pin connections:

    #define _Pin_Left_footswitch    5
    #define _Pin_Middle_footswitch  2
    #define _Pin_Right_footswitch   0

    Then the connections shall be like this:

  • Simultaneous Keystrokes

    danjovic03/22/2016 at 05:32 1 comment

    Spent some time trying to figure out how to allow simultaneous keypresses using DigiKeyboard Library.

    Both the problem and the solution were right in front of me but took some time until I figure out that the report size of only one keystroke was hardcoded in Digikeyboard.h file.

    First step was to find the Digikeyboard.h file:

    In Windows it is located in the following folder

    c:\Users\username\AppData\Roaming\Arduino15\packages\digistump\hardware\avr\1.6.5\libraries\DigisparkKeyboard\

    In Linux the file is on a hidden folder

    /home/username/.arduino15/packages/digistump/hardware/avr/1.6.7/libraries/DigisparkKeyboard/

    const PROGMEM char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = { /* USB report descriptor */
      0x05, 0x01,  // USAGE_PAGE (Generic Desktop) 
      0x09, 0x06,  // USAGE (Keyboard) 
      0xa1, 0x01,  // COLLECTION (Application) 
      0x05, 0x07,  //   USAGE_PAGE (Keyboard) 
      0x19, 0xe0,  //   USAGE_MINIMUM (Keyboard LeftControl) 
      0x29, 0xe7,  //   USAGE_MAXIMUM (Keyboard Right GUI) 
      0x15, 0x00,  //   LOGICAL_MINIMUM (0) 
      0x25, 0x01,  //   LOGICAL_MAXIMUM (1) 
      0x75, 0x01,  //   REPORT_SIZE (1) 
      0x95, 0x08,  //   REPORT_COUNT (8) 
      0x81, 0x02,  //   INPUT (Data,Var,Abs) 
      0x95, 0x06,  //   REPORT_COUNT (6 simultaneous keystrokes) 
      0x75, 0x08,  //   REPORT_SIZE (8) 
      0x25, 0x65,  //   LOGICAL_MAXIMUM (101) 
      0x19, 0x00,  // (Reserved (no event indicated)) 
      0x29, 0xE7,  //   USAGE_MAXIMUM (Right GUI) 
      0x81, 0x00,  //   INPUT (Data,Ary,Abs) 
      0xc0         // END_COLLECTION 
    };

    The 2nd parameter in the 12th line was changed to 0x06, to allow up to 6 simultaneous key presses.

    0x95, 0x06,  //   REPORT_COUNT (6 simultaneous keystrokes) 

    The Buffer size was also updated to allow up to 6 keys (plus a modifier)

      //private: TODO: Make friend?
     // maximum 6 keystrokes, defined in HID report
      uchar    reportBuffer[7];    // buffer for HID reports [ 1 modifier byte + (len-1) key strokes]
      using Print::write;

View all 4 project logs

  • 1
    Install Digispark libraries

    If you have already installed digispark libraries you can skip this step, otherwise follow the tutorial   "Connecting and Programming your Digispark"

    Link: https://digistump.com/wiki/digispark/tutorials/connecting

  • 2
    Install the modified Digikeyboard library

    Download the modified library "DigiKeyboard_6keys.h" and copy it to the following folder/directory:

    Under Windows

    c:\Users\username\AppData\Roaming\Arduino15\packages\digistump\hardware\avr\1.6.5\libraries\DigisparkKeyboard\

    Under Linux
    /home/username/.arduino15/packages/digistump/hardware/avr/1.6.7/libraries/DigisparkKeyboard/

  • 3
    Include the modified library in your project

    Whenever is necessary to use the modified version with 6 simultaneous keys, include the following library

    #include "DigiKeyboard_6keys.h" 

    Then you can send simultaneous keys by adding keystrokes to output buffer

    // clear buffer by default
    memset( DigiKeyboard.reportBuffer , 0, sizeof( DigiKeyboard.reportBuffer));
    
    // Now add up to 6 keys to report
    DigiKeyboard.reportBuffer[i++] = _Key_A;
    DigiKeyboard.reportBuffer[i++] = _Key_B;
    DigiKeyboard.reportBuffer[i++] = _Key_C;
    DigiKeyboard.reportBuffer[i++] = _Key_D;
    DigiKeyboard.reportBuffer[i++] = _Key_E;
    DigiKeyboard.reportBuffer[i++] = _Key_F;
    
    // Now set to send the keystrokes in the next USB interrupt
    usbSetInterrupt( DigiKeyboard.reportBuffer, sizeof(DigiKeyboard.reportBuffer));
      while (!usbInterruptIsReady()) {
        usbPoll();
        _delay_ms(5);
      }

    To release all the keys, simply send a clear buffer

View all 3 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates