Lay the foundation for actions, layers, modules, and slots.

This commit is contained in:
László Monda
2016-03-15 01:17:33 +01:00
parent 51de538b4a
commit 9788050568
5 changed files with 138 additions and 0 deletions

39
right/action.h Normal file
View File

@@ -0,0 +1,39 @@
#ifndef __ACTION_H__
#define __ACTION_H__
// Macros:
// The value of action ID can be any valid HID_KEYBOARD_SC_* scancode constants of LUFA.
// Hence, ACTION_ID_* values must not conflict with any of the HID_KEYBOARD_SC_* constants.
#define ACTION_ID_NONE 0xFF
#define ACTION_ID_SWITCH_LAYER 0xFE
#define ACTION_ID_MOUSE 0xFD
#define ACTION_ID_SWITCH_KEYMAP 0xFC
#define ACTION_ID_PLAY_MACRO 0xFB
#define ACTION_ARG_NONE 0
#define ACTION_ARG_SWITCH_LAYER_MOD 0
#define ACTION_ARG_SWITCH_LAYER_FN 1
#define ACTION_ARG_SWITCH_LAYER_MOUSE 2
#define ACTION_ARG_MOUSE_MOVE_UP 0
#define ACTION_ARG_MOUSE_MOVE_DOWN 1
#define ACTION_ARG_MOUSE_MOVE_LEFT 3
#define ACTION_ARG_MOUSE_MOVE_RIGHT 4
#define ACTION_ARG_MOUSE_CLICK_LEFT 5
#define ACTION_ARG_MOUSE_CLICK_MIDDLE 6
#define ACTION_ARG_MOUSE_CLICK_RIGHT 7
#define ACTION_ARG_MOUSE_WHEEL_UP 8
#define ACTION_ARG_MOUSE_WHEEL_DOWN 9
#define ACTION_ARG_MOUSE_WHEEL_LEFT 10
#define ACTION_ARG_MOUSE_WHEEL_RIGHT 11
// Typedefs:
typedef struct {
uint8_t id;
uint8_t arg;
} action_t;
#endif

View File

@@ -190,11 +190,21 @@
<type>1</type>
<locationURI>$%7BPARENT-3-PROJECT_LOC%7D/lib/KSDK_2.0_FRDM-K22F/middleware/usb_1.0.0/osa/usb_osa_bm.h</locationURI>
</link>
<link>
<name>sources/action.h</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/action.h</locationURI>
</link>
<link>
<name>sources/i2c.h</name>
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/include/i2c.h</locationURI>
</link>
<link>
<name>sources/layer.h</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/layer.h</locationURI>
</link>
<link>
<name>sources/main.c</name>
<type>1</type>
@@ -205,6 +215,16 @@
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/main.h</locationURI>
</link>
<link>
<name>sources/module.h</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/module.h</locationURI>
</link>
<link>
<name>sources/slot.h</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/slot.h</locationURI>
</link>
<link>
<name>sources/usb_api.h</name>
<type>1</type>

13
right/layer.h Normal file
View File

@@ -0,0 +1,13 @@
#ifndef __LAYER_H__
#define __LAYER_H__
// Macros:
#define LAYER_ID_BASE 0
#define LAYER_ID_MOD 1
#define LAYER_ID_FN 2
#define LAYER_ID_MOUSE 3
#define LAYER_COUNT 4
#endif

39
right/module.h Normal file
View File

@@ -0,0 +1,39 @@
#ifndef __MODULE_H__
#define __MODULE_H__
// Includes:
#include "action.h"
#include "layer.h"
#include "slot.h"
// Macros:
#define MODULE_ID_LEFT_KEYBOARD_HALF 0
#define MODULE_ID_KEY_CLUSTER_LEFT 1
#define MODULE_ID_TRACKBALL_RIGHT 2
#define MODULE_ID_TRACKPOINT_RIGHT 3
#define MODULE_ID_TOUCHPAD 4
#define MODULE_REQUEST_GET_PROTOCOL_VERSION 0
#define MODULE_REQUEST_GET_MODULE_ID 1
#define MODULE_REQUEST_GET_FEATURES 2
#define MODULE_REQUEST_GET_STATE 3
#define MAX_KEY_COUNT_PER_MODULE 64
// Typedefs:
typedef struct {
uint8_t moduleId;
uint8_t pointerCount;
uint8_t keyCount;
uint8_t keyStates[MAX_KEY_COUNT_PER_MODULE];
key_action_t keyActions[LAYER_COUNT][MAX_KEY_COUNT_PER_MODULE];
} module_t;
// Variables:
extern module_t AttachedModules[SLOT_COUNT];
#endif

27
right/slot.h Normal file
View File

@@ -0,0 +1,27 @@
#ifndef __SLOT_H__
#define __SLOT_H__
// Slots provide a way to avoid I2C address collision of modules as only a single module can
// allocate a given slot.
// Macros:
#define SLOT_ID_RIGHT_KEYBOARD_HALF 0
#define SLOT_ID_LEFT_KEYBOARD_HALF 1
#define SLOT_ID_LEFT_MODULE 2
#define SLOT_ID_RIGHT_MODULE 3
#define SLOT_ID_BOTH_SIDED_MODULE 4
// The 7-bit I2C addresses below 0x08 are reserved.
#define SLOT_I2C_ADDRESS_LEFT_KEYBOARD_HALF 0x08
#define SLOT_I2C_ADDRESS_LEFT_MODULE 0x09
#define SLOT_I2C_ADDRESS_RIGHT_MODULE 0x0A
#define SLOT_I2C_ADDRESS_BOTH_SIDED_MODULE 0x0B
#define SLOT_I2C_ADDRESS_LEFT_KEYBOARD_HALF 0x0C
#define SLOT_I2C_ADDRESS_MIN 0x08
#define SLOT_I2C_ADDRESS_MAX 0x0C
#define SLOT_COUNT 5
#endif