How to design class and hide detail code?

I tried to design a class base on c source, I hope all detail code hide in class, but I am not sure how to design the class, does anyone give me some suggestion?
Code as below does work, but I don't think its a good idea to use *rc, how can I hide it or arrow user uses any variable of class RemoteControl?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
extern int remote_control_handler(unsigned int etype, unsigned int key);

class RemoteControl {
private:
    unsigned int lr_key;

public:
    RemoteControl() {
        lr_set_handler(remote_control_handler);
    }
    ~RemoteControl() {}
    const void key(unsigned int key) {
        this->lr_key = key;
    }
    unsigned int key() const {
        return lr_key;
    }
};

RemoteControl *rc;

int remote_control_handler(unsigned int etype, unsigned int key) {
    if (etype == LREVT_KEYON) {
        switch(key) {
            case LRKEY_STOP:
            case LRKEY_BEEP:
            case LRKEY_A1:
            case LRKEY_A2:
            case LRKEY_B1:
            case LRKEY_B2:
            case LRKEY_C1:
            case LRKEY_C2:
                rc->key(key);
                break;
				
            default:
                rc->key(0);
                break;
        }
     }
     return 0;
}

wakeup_t remote_control_pressed_key(wakeup_t data) {
    return rc->key() == data || (lnp_rcx_message == data && data >= 1 && data <= 3);
}

wakeup_t remote_control_pressed(wakeup_t data) {
    return rc->key() != 0 || (lnp_rcx_message >= 1 && lnp_rcx_message <= 3);
}

int main(int argc, char **argv) {
    rc = new RemoteControl();
	
    while (!shutdown_requested()) {
        rc->key(0);
        clear_msg();
		
        wait_event(&remote_control_pressed, 0);
		
        if (rc->key() == LRKEY_STOP) {
            program_stop(1);
        }
        else if (lnp_rcx_message == 1) {
            Sound::beep();
        }
        else if (lnp_rcx_message == 2) {
            Sound::up();
        }
        else if (lnp_rcx_message == 3) {
            Sound::down();
        }
		
        msleep(25);
    }
}
Topic archived. No new replies allowed.