Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 65 additions & 65 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wooting-analog-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ wooting-analog-common = { path = "../wooting-analog-common"}
wooting-analog-plugin-dev = { path = "../wooting-analog-plugin-dev"}

[dev-dependencies]
shared_memory = "^0.8"
shared_memory = "^0.12"

[build-dependencies]
cmake = "0.1"
Expand Down
34 changes: 8 additions & 26 deletions wooting-analog-sdk/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,7 @@ pub extern "C" fn wooting_analog_read_full_buffer_device(
mod tests {
use super::*;
use crate::keycode::hid_to_code;
use shared_memory::{
ReadLockGuard, ReadLockable, SharedMem, SharedMemCast, WriteLockGuard, WriteLockable,
};
use shared_memory::ShmemConf;

use std::sync::{Arc, MutexGuard};
use std::time::Duration;
Expand All @@ -379,8 +377,6 @@ mod tests {
pub analog_values: [u8; 0xFF],
}

unsafe impl SharedMemCast for SharedState {}

pub fn get_sdk() -> MutexGuard<'static, AnalogSDK> {
ANALOG_SDK.lock().unwrap()
}
Expand Down Expand Up @@ -409,20 +405,6 @@ mod tests {
info!("Got {:?} after {} attempts", connected, n);
}

fn get_wlock(shmem: &mut SharedMem) -> WriteLockGuard<SharedState> {
match shmem.wlock::<SharedState>(0) {
Ok(v) => v,
Err(_) => panic!("Failed to acquire write lock !"),
}
}

fn get_rlock(shmem: &mut SharedMem) -> ReadLockGuard<SharedState> {
match shmem.rlock::<SharedState>(0) {
Ok(v) => v,
Err(_) => panic!("Failed to acquire write lock !"),
}
}

fn shared_init() {
env_logger::try_init_from_env(env_logger::Env::from("trace"))
.map_err(|e| println!("ERROR: Could not initialise env_logger. '{:?}'", e));
Expand Down Expand Up @@ -455,11 +437,11 @@ mod tests {
//Wait a slight bit to ensure that the test-plugin worker thread has initialised the shared mem
::std::thread::sleep(Duration::from_millis(500));

let mut shmem = match SharedMem::open_linked(
let mut shmem = match ShmemConf::new().size(4096).flink(
std::env::temp_dir()
.join("wooting-test-plugin.link")
.as_os_str(),
) {
).open() {
Ok(v) => v,
Err(e) => {
println!("Error : {}", e);
Expand All @@ -474,7 +456,7 @@ mod tests {
//Check the connected cb is called
{
{
let mut shared_state = get_wlock(&mut shmem);
let shared_state = unsafe { &mut *(shmem.as_ptr() as *mut u8 as *mut SharedState) };
shared_state.device_connected = true;
}
wait_for_connected(5, true);
Expand Down Expand Up @@ -506,7 +488,7 @@ mod tests {
//Check the cb is called with disconnected
{
{
let mut shared_state = get_wlock(&mut shmem);
let shared_state = unsafe { &mut *(shmem.as_ptr() as *mut u8 as *mut SharedState) };
shared_state.device_connected = false;
}
wait_for_connected(5, false);
Expand All @@ -529,7 +511,7 @@ mod tests {
let analog_key = 5;
//Connect the device again, set a keycode to a val
let device_id = {
let mut shared_state = get_wlock(&mut shmem);
let shared_state = unsafe { &mut *(shmem.as_ptr() as *mut u8 as *mut SharedState) };
shared_state.analog_values[analog_key] = analog_val;
shared_state.device_connected = true;
1
Expand Down Expand Up @@ -632,7 +614,7 @@ mod tests {
wooting_analog_set_keycode_mode(mode.clone() as u32);

{
let mut shared_state = get_wlock(&mut shmem);
let shared_state = unsafe { &mut *(shmem.as_ptr() as *mut u8 as *mut SharedState) };
shared_state.analog_values[analog_key] = 0;
}
::std::thread::sleep(Duration::from_secs(1));
Expand Down Expand Up @@ -668,7 +650,7 @@ mod tests {
WootingAnalogResult::Ok
);
{
let mut shared_state = get_wlock(&mut shmem);
let shared_state = unsafe { &mut *(shmem.as_ptr() as *mut u8 as *mut SharedState) };
shared_state.device_connected = false;
}
::std::thread::sleep(Duration::from_secs(1));
Expand Down
1 change: 0 additions & 1 deletion wooting-analog-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ extern crate wooting_analog_common;
extern crate wooting_analog_plugin_dev;

#[cfg(test)]
#[macro_use]
extern crate shared_memory;

//library modules
Expand Down
Loading
Loading