mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Reworked PRReset() logic with respect to switch rules.
This commit is contained in:
@@ -247,7 +247,8 @@ PR_EXPORT int PRGetEvents(PRHandle handle, PREvent *eventsOut, int maxEvents);
|
|||||||
#define kPRSwitchPhysicalLast (223) /**< Switch number of the last physical switch. */
|
#define kPRSwitchPhysicalLast (223) /**< Switch number of the last physical switch. */
|
||||||
#define kPRSwitchVirtualFirst (224) /**< Switch number of the first virtual switch. */
|
#define kPRSwitchVirtualFirst (224) /**< Switch number of the first virtual switch. */
|
||||||
#define kPRSwitchVirtualLast (255) /**< Switch number of the last virtual switch. */
|
#define kPRSwitchVirtualLast (255) /**< Switch number of the last virtual switch. */
|
||||||
#define kPRSwitchRulesCount ((kPRSwitchVirtualLast + 1) << 2) /**< Total number of available switch rules. */
|
#define kPRSwitchCount (256)
|
||||||
|
#define kPRSwitchRulesCount (kPRSwitchCount << 2) /**< Total number of available switch rules. */
|
||||||
|
|
||||||
typedef struct PRSwitchConfig {
|
typedef struct PRSwitchConfig {
|
||||||
bool_t clear; // Drive the clear output
|
bool_t clear; // Drive the clear output
|
||||||
|
|||||||
@@ -82,23 +82,13 @@ PRResult PRDevice::Reset(uint32_t resetFlags)
|
|||||||
group->polarity = defaultPolarity;
|
group->polarity = defaultPolarity;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create empty switch rule for clearing the rules in the device.
|
freeSwitchRuleIndexes.empty();
|
||||||
PRSwitchRule emptySwitchRule;
|
|
||||||
memset(&emptySwitchRule, 0x00, sizeof(PRSwitchRule));
|
|
||||||
|
|
||||||
for (i = 0; i < kPRSwitchRulesCount; i++)
|
for (i = 0; i < kPRSwitchRulesCount; i++)
|
||||||
{
|
{
|
||||||
PRSwitchRuleInternal *switchRule = &switchRules[i];
|
PRSwitchRuleInternal *switchRule = &switchRules[i];
|
||||||
memset(switchRule, 0x00, sizeof(PRSwitchRule));
|
memset(switchRule, 0x00, sizeof(PRSwitchRule));
|
||||||
|
|
||||||
// Send blank rule for each event type to Device if necessary
|
|
||||||
if ((resetFlags & kPRResetFlagUpdateDevice) && i <= kPRSwitchPhysicalLast) {
|
|
||||||
SwitchUpdateRule(i, kPREventTypeSwitchOpenDebounced, &emptySwitchRule, NULL, 0);
|
|
||||||
SwitchUpdateRule(i, kPREventTypeSwitchClosedDebounced, &emptySwitchRule, NULL, 0);
|
|
||||||
SwitchUpdateRule(i, kPREventTypeSwitchOpenNondebounced, &emptySwitchRule, NULL, 0);
|
|
||||||
SwitchUpdateRule(i, kPREventTypeSwitchClosedNondebounced, &emptySwitchRule, NULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ruleIndex = i;
|
uint16_t ruleIndex = i;
|
||||||
ParseSwitchRuleIndex(ruleIndex, &switchRule->switchNum, &switchRule->eventType);
|
ParseSwitchRuleIndex(ruleIndex, &switchRule->switchNum, &switchRule->eventType);
|
||||||
switchRule->driver.polarity = defaultPolarity;
|
switchRule->driver.polarity = defaultPolarity;
|
||||||
@@ -106,6 +96,22 @@ PRResult PRDevice::Reset(uint32_t resetFlags)
|
|||||||
freeSwitchRuleIndexes.push(ruleIndex);
|
freeSwitchRuleIndexes.push(ruleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create empty switch rule for clearing the rules in the device.
|
||||||
|
PRSwitchRule emptySwitchRule;
|
||||||
|
memset(&emptySwitchRule, 0x00, sizeof(PRSwitchRule));
|
||||||
|
|
||||||
|
for (i = 0; i < kPRSwitchCount; i++)
|
||||||
|
{
|
||||||
|
// Send blank rule for each event type to Device if necessary
|
||||||
|
if ((resetFlags & kPRResetFlagUpdateDevice) && i <= kPRSwitchPhysicalLast)
|
||||||
|
{
|
||||||
|
SwitchUpdateRule(i, kPREventTypeSwitchOpenDebounced, &emptySwitchRule, NULL, 0);
|
||||||
|
SwitchUpdateRule(i, kPREventTypeSwitchClosedDebounced, &emptySwitchRule, NULL, 0);
|
||||||
|
SwitchUpdateRule(i, kPREventTypeSwitchOpenNondebounced, &emptySwitchRule, NULL, 0);
|
||||||
|
SwitchUpdateRule(i, kPREventTypeSwitchClosedNondebounced, &emptySwitchRule, NULL, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unrequestedDataQueue.empty();
|
unrequestedDataQueue.empty();
|
||||||
requestedDataQueue.empty();
|
requestedDataQueue.empty();
|
||||||
num_collected_bytes = 0;
|
num_collected_bytes = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user