-
-
Notifications
You must be signed in to change notification settings - Fork 40.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expand digitizer feature. #15917
Closed
Closed
Expand digitizer feature. #15917
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#pragma once | ||
|
||
#include "config_common.h" | ||
|
||
/* USB Device descriptor parameter */ | ||
#define VENDOR_ID 0xFEED | ||
#define PRODUCT_ID 0xD1D0 | ||
#define DEVICE_VER 0x0001 | ||
#define MANUFACTURER QMK | ||
#define PRODUCT DigitizerDemo | ||
|
||
/* key matrix size */ | ||
#define MATRIX_ROWS 2 | ||
#define MATRIX_COLS 5 | ||
|
||
/* | ||
* Keyboard Matrix Assignments | ||
* | ||
* Change this to how you wired your keyboard | ||
* COLS: AVR pins used for columns, left to right | ||
* ROWS: AVR pins used for rows, top to bottom | ||
* DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode) | ||
* ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode) | ||
* | ||
*/ | ||
#define MATRIX_ROW_PINS { D1, D0 } | ||
#define MATRIX_COL_PINS { D4, C6, D7, E6, B4 } | ||
#define UNUSED_PINS | ||
|
||
/* COL2ROW, ROW2COL */ | ||
#define DIODE_DIRECTION COL2ROW | ||
|
||
/* | ||
* Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN. | ||
*/ | ||
#define SOFT_SERIAL_PIN F4 // or D1, D2, D3, E6 | ||
|
||
/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ | ||
#define DEBOUNCE 5 | ||
|
||
/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ | ||
#define LOCKING_SUPPORT_ENABLE | ||
/* Locking resynchronize hack */ | ||
#define LOCKING_RESYNC_ENABLE | ||
|
||
/* disable these deprecated features by default */ | ||
#define NO_ACTION_MACRO | ||
#define NO_ACTION_FUNCTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#pragma once | ||
|
||
#include "quantum.h" | ||
|
||
|
||
#define LAYOUT( \ | ||
k00, k01, k02, k03, k04, \ | ||
k10, k11, k12, k13, k14 \ | ||
) { \ | ||
{ k00, k01, k02, k03, k04 }, \ | ||
{ k10, k11, k12, k13, k14 }, \ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* Identify this digitizer as a less generic device */ | ||
#define DIGITIZER_USAGE_ID DIG_TOUCH_SCREEN | ||
|
||
/* Set x/y resolution to match desired screen aspect ratio */ | ||
#define DIGITIZER_MAX_X 2560 | ||
#define DIGITIZER_MAX_Y 1440 | ||
|
||
/* Jitter x/y to simulate more realistic touch events for the OS */ | ||
#define DIGITIZER_FUZZ |
47 changes: 47 additions & 0 deletions
47
keyboards/handwired/digitizer_demo/keymaps/default/keymap.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include QMK_KEYBOARD_H | ||
#include "digitizer.h" | ||
#include "math.h" | ||
|
||
|
||
enum my_layers { | ||
_BASE | ||
}; | ||
|
||
|
||
enum my_keycodes { | ||
MY_FUZZ = SAFE_RANGE | ||
}; | ||
|
||
|
||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
[_BASE] = LAYOUT( | ||
RESET, DZ_TIP1, DZ_BAR1, DZ_BAR2, MY_FUZZ, | ||
DZ_P_C, DZ_P_U0, DZ_P_U1, DZ_P_U2, DZ_P_U3 | ||
), | ||
}; | ||
|
||
|
||
bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
digitizer_t digitizer; | ||
switch (keycode) { | ||
case MY_FUZZ: | ||
if (record->event.pressed) { | ||
// Set mouse to the top of the screen, 50% of the way across | ||
digitizer = digitizer_fuzz_xy(DIG_REL2ABS_X(0.5), 0); | ||
// Press the tip switch (usually treated as left mouse button) | ||
digitizer.buttons |= DIG_TIP_PRIMARY; | ||
digitizer.inrange = true; | ||
digitizer_set_report(digitizer); | ||
return false; | ||
} else { | ||
// Release the tip switch | ||
digitizer = digitizer_get_report(); | ||
digitizer.buttons &= ~DIG_TIP_PRIMARY; | ||
digitizer.inrange = true; | ||
digitizer_set_report(digitizer); | ||
return false; | ||
} | ||
default: | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DIGITIZER_ENABLE = yes | ||
POINTING_DEVICE_ENABLE = yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# MCU name | ||
MCU = atmega32u4 | ||
|
||
# Bootloader selection | ||
BOOTLOADER = caterina | ||
|
||
# Build Options | ||
# change yes to no to disable | ||
# | ||
BOOTMAGIC_ENABLE = no # Enable Bootmagic Lite | ||
MOUSEKEY_ENABLE = no # Mouse keys | ||
EXTRAKEY_ENABLE = no # Audio control and System control | ||
CONSOLE_ENABLE = no # Console for debug | ||
COMMAND_ENABLE = no # Commands for debug and configuration | ||
NKRO_ENABLE = no # Enable N-Key Rollover | ||
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality | ||
RGBLIGHT_ENABLE = no # Enable keyboard RGB underglow | ||
AUDIO_ENABLE = no # Audio output | ||
ENCODER_ENABLE = no # Encoder support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a license header.
But also, this may be better as a keymap for
handwired/onekey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, good call. I just wired up a promicro onekey board to test with, so I can make this suggested change.